-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG][Java] ApiClient.java: error: no suitable method found for create(byte[],MediaType) #9151
Comments
In 5.0.1 the generated line in
in 5.1.0 it is:
Looks like this change was introduced in #8969 |
Should it be |
I did a test with the latest master and the output compiles without issues. Can you give it another try with the latest master? |
I don't believe so - I'll look at the response, it's intended to be a simple string.
You used the attached YAML and it compiles? On both this sample and the real YAML I distilled it from it continues to not compile for me with the latest Docker image (563bdd246a47).
I'm on Windows with this, I wouldn't imagine this is a platform difference but maybe? |
@wing328 The okhttp3 version needs to be updated to 4.9.0 |
@cb-manideep can you please file a PR with the suggested change? |
Sure! |
@cb-manideep - any luck? If you're no longer intending to tackle this, I'd like to grab it in hopes of making it into the next release. |
@toby-murray-snow-software Please go ahead :) |
@wing328 - OkHTTP 3.13+ (including 4.*) needs Java 8. The current default of the generator is Java 7 and there's a flag to use Java 8. My understanding is 5.* intended to drop Java 7 and default to Java 8. If it's viable to drop Java 7, I can submit a PR doing so. Without that, updating OkHTTP is marginally more complicated: needs to default to a ~2 year old version and only optionally use a modern version. |
My understanding of the version 5 release of OpenAPI generator was that Java 7 support was dropped. Currently the Java client defaults to Java 7, Java 8 can be opted in with the `java8` config option. This removes the conditional logic in `build.gradle` around that config option and defaults to Java 8. This is to support OpenAPITools#9151, up-to-date dependency versions rely on Java 8 and it's easier if that is the default. To be clear, this changes behavior - previous default version was Java 7, this changes it to Java 8.
My understanding of the version 5 release of OpenAPI generator was that Java 7 support was dropped. Currently the Java client defaults to Java 7, Java 8 can be opted in with the `java8` config option. This removes the conditional logic in `build.gradle` around that config option and defaults to Java 8. This is to support #9151, up-to-date dependency versions rely on Java 8 and it's easier if that is the default. To be clear, this changes behavior - previous default version was Java 7, this changes it to Java 8.
In 5.0.1 the generated line in `ApiClient` was: ``` return RequestBody.create(MediaType.parse(contentType), (byte[]) obj); ``` in 5.1.0 it is: ``` return RequestBody.create((byte[]) obj, MediaType.parse(contentType)); ``` Looks like this change was introduced in OpenAPITools#8969, and requires a more recent version of OkHttp to compile in some (all?) circumstances.
The same problem on version 2.7.5 with Maven |
Bug Report Checklist
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
Generation Details
java -jar openapi-generator-cli-5.1.0.jar generate -g java -i service.yaml
Steps to reproduce
./gradlew compileJava
or similarExpected:
It will compile
Actual:
A bunch of:
Related issues/PRs
Suggest a fix
The text was updated successfully, but these errors were encountered: