-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
openapi-generator-maven-plugin generates invalid Java code when using "oneOf:" property #12556
Comments
I'm having the same issue with DigitalOceans's API - https://github.com/digitalocean/openapi $openapi-generator --version |
+1 seeing this issue with 6.0.0 as well on one of our internal apis @ adobe. |
The same here with: Command: openapi-generator-cli generate -i SWIFT-API-swift-banking-premium-1.1.2-swagger.yaml -g java -o out YAML: I didn't specify any specific property and I got the code: ... |
+1 seeing this issue with 6.1.0 as well on one of our internal apis |
@wing328 Hi William, please can you prioritize this bug for 6.2.1. I'm trying to read the code and fix it myself but the code base is huge and I still don't get how things work :-) |
It is not only |
We also have this issue with one of our builds running |
In #13897 I provided a potential fix for this problem regarding |
I am experiencing the same problem with Fireblocks API, @StevenArzt it also affects |
Same here with 6.2.1 |
Is there a known workaround for this issue? |
I think a workaround would be to wrap your |
Still facing the same issues, it's latest versions (6., 7.) generating the invalid code like Solution : I found |
Facing the same issue with openapi 6.6.0 |
Facing the same issue with openapi 6.6.0 , and is there any workaround here, wrap as a object may not have the |
It (test spec provided in the issue description) works with okhttp-gson but not jersey2/3. If anyone would like to contribute a PR to sponsor the fix, please reply to let us know. Thank you. |
Description
Maven test target in openapi-generator-maven-plugin will run successfully,
but the generated Java models are not valid Java code and cannot be compiled by Java compiler
and therefore cannot be used as a JavaClient.
Because of the following issues in the generated Java model
Value.java
:Is the generated Java code in the maven test target not validate by a Java compiler?
Note, the same error can be reproduced with the Java Types,
String, Boolean, BigDecimal
Steps to reproduce
When using following modified schema in openapi\modules\openapi-generator-maven-plugin\src\test\resources\petstore-on-classpath.yaml
And the following modified
openapi\modules\openapi-generator-maven-plugin\pom.xml
,the
<library>jersey2</library>
was removed.openapi-generator version
Can be reproduced with the current "Master" version of this repository.
But also the compile error was reproduced on a build server with the openapi-generator-maven-plugin:
Suggest a fix
Maybe there should be a more strict check in this code section,
openapi-generator/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/oneof_model.mustache
Lines 101 to 123 in 69f79fb
It looks like this would generate .validateJsonObject(jsonObject) on every type which is not valid
for type
Array, String, Boolean, BigDecimal
in Java.The text was updated successfully, but these errors were encountered: