fix #17419 useOneOfInterfaces option for java clients & servers#20832
fix #17419 useOneOfInterfaces option for java clients & servers#20832Nicklas2751 wants to merge 12 commits intoOpenAPITools:masterfrom
Conversation
|
@wing328 Seems like the others don't have any feedback on this 😅 |
martin-mfg
left a comment
There was a problem hiding this comment.
Hi @Nicklas2751, thanks for the PR! I found 2 problems:
- When I run OpenAPI Generator with generator=java, library=okhttp-gson, additionalProperties:useOneOfInterfaces=true on this input spec, the output fails to compile because
org.openapitools.client.model.TestResponse.CustomTypeAdapterFactorydoesn't exist. - Using library=jersey2 with all other settings like above generates a file docs/TestResponse.md with sample code which doesn't compile.
I guess both problems apply to more than just the one mentioned library.
Could you please fix these problems? Thanks!
(I did not review the whole PR. So when the described problems are fixed, further review is necessary.)
|
@martin-mfg I added another test to This is how I started the CLI: tl;dr I had to regenerate the CLI then it generated the Interface as expected and without any compile errors. |
|
@martin-mfg The second problem was in the doc generation of jersey2, jersey3 and native. I fixed it & added an test for it :) |
It seems we get different results, or maybe we're talking about different things. So I extended a unit test to show the problem I get - please see martin-mfg@554bb00. The test fails, as seen in this pipeline. As you said, |
|
@martin-mfg Ah, I see! Added another test for it & fixed it :) |
37198f6 to
e0227b0
Compare
|
@martin-mfg ping 🔔 :) |
13015ec to
50ee5b1
Compare
|
I got the newest changes from master branch and cleaned up the commit history of this branch. @martin-mfg Is there anything I can do to make it easier for you to review this? |
martin-mfg
left a comment
There was a problem hiding this comment.
Hi, Sorry for the delay. I am rather busy at the moment.
I tested the changes with the okhttp-gson library and this input spec. The generated output contains a few problems:
TestObjectimplements neitherMyOperationRequestnorMyOperation200Response- It's unclear how to convert a String array to
MyOperationRequestor how to convertMyOperation200Responseto a number array. - The readme contains example code including this line:
Since
MyOperationRequest myOperationRequest = new MyOperationRequest(); // MyOperationRequest |
MyOperationRequestis an interface,new MyOperationRequest()doesn't work.
I guess these problems apply also to some other libraries in addition to okhttp-gson.
Could you please fix these problems? Thanks!
(I did not review the whole PR. So when the described problems are fixed, further review is necessary.)
@martin-mfg Is there anything I can do to make it easier for you to review this?
Don't feel obligated to get an approval from me specifically. It's totally fine if wing328 approves and merges this PR directly. Or if any other member of the Java technical committee approves this PR.
It might also be helpful if you do more testing of special cases on your own. You could look at some existing OpenAPI files, the OpenAPI documentation or the OpenAPI specification and try if the most relevant features work in combination with your useOneOfInterfaces changes.
Finally, we can also discuss a bit more via Slack.
Invitation link for account creation: https://join.slack.com/t/openapi-generator/shared_invite/zt-36ucx4ybl-jYrN6euoYn6zxXNZdldoZA
Link to my Slack profile: https://openapi-generator.slack.com/team/U051HB9A0FJ
|
+1 |
|
@wing328 any updates on this? I tested this for JavaJaxRS spec, and it works like a charm ;-) Thank you, guys, for your good work! |
|
@tomasfrtala The change for the README which @martin-mfg requested is pretty hard since I don't know in the README template if |
67957b2 to
c3f8e1b
Compare
…for java clients jersey2, jersey3, microprofile, native & okhttp-gson (OpenAPITools#17419)
…eOfInterfaces not generating interfaces for java server helidon, jaxrs, micronaut, microprofile, play and pkmst (OpenAPITools#17419)
…hen using useOneOfInterfaces option
c3f8e1b to
2393ee5
Compare
|
@martin-mfg I created a new issue for the useless interface which is generated for oneOf with array types: #23494 I decided to create a new issue since the main goal of this PR is to support the |
Some java generators generated wrong, not compiling code, when using the option
useOneOfInterfaces.The bug was caused by old/wrong
model.mustachefiles without the part supporting theuseOneOfInterfacesoption.These clients were affected:
as well as the following servers:
This PR fixes all of them 😎
It also fixes a compile error of the java native client generator when using anyOf with generic types.
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)@bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) @lwlee2608 (2019/10) @martin-mfg (2023/08)