[BUG][Java] ApiClient.java: error: no suitable method found for create(byte[],MediaType)
See original GitHub issueBug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- [] What’s the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Using the java generator against a basic spec, the generated project fails to compile.
openapi-generator version
5.1.0 and latest master (docker image 3c6b0382cd49)
Regression from 5.0.1
OpenAPI declaration file content or url
openapi: 3.0.0
info:
version: 1.0.0
title: Api
paths:
/version:
get:
tags:
- version
summary: Gets the system version check
operationId: getVersion
responses:
200:
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/VersionGetResponse'
components:
schemas:
VersionGetResponse:
type: string
description: The version of this service
required:
- status
properties:
status:
type: string
description: OK
Generation Details
java -jar openapi-generator-cli-5.1.0.jar generate -g java -i service.yaml
Steps to reproduce
- Run the generator as described above
- Try to compile the code with
./gradlew compileJava
or similar
Expected:
It will compile
Actual:
A bunch of:
out\java\src\main\java\org\openapitools\client\ApiClient.java:818: error: no suitable method found for create(byte[],MediaType)
return RequestBody.create((byte[]) obj, MediaType.parse(contentType));
^
method RequestBody.create(MediaType,String) is not applicable
(argument mismatch; byte[] cannot be converted to MediaType)
method RequestBody.create(MediaType,ByteString) is not applicable
(argument mismatch; byte[] cannot be converted to MediaType)
method RequestBody.create(MediaType,byte[]) is not applicable
(argument mismatch; byte[] cannot be converted to MediaType)
method RequestBody.create(MediaType,File) is not applicable
(argument mismatch; byte[] cannot be converted to MediaType)
Related issues/PRs
Suggest a fix
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
no suitable method found for add() error - java - Stack Overflow
This question was caused by a typo or a problem that can no longer be ... Error:(20, 59) error: no suitable method found...
Read more >API Client Library for Java - Google Developers
Easily access Google APIs from Java ... The Google API Client Library for Java provides functionality common to all Google APIs, for example...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@toby-murray-snow-software Please go ahead 😃
Sure!