-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[Spring][server] oneOf Polymorphism support for spring boot #5661
base: master
Are you sure you want to change the base?
Conversation
added x-is-one-of-interface extension for oneOf interface in mustache template
fixed name of model from UNKNOWN_BASE_TYPE to right one in api: operationId + OneOf Fix OpenAPITools#5381 parcelableModel is not required
removed not needed methods
catch NPE cases in preprocessOpenAPI updated samples
…rator into spring_fix_5381
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey 👋 this mostly looks good, but I left 2 questions and 1 comment in the code to get answered/addressed.
modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/JavaSpring/oneof_interface.mustache
Show resolved
Hide resolved
fixed generation of oneOf Models
addOneOfInterfaceModel only for cases when useOneOfInterfaces is true and for spring
NPE fix
…rator into spring_fix_5381
…rator into spring_fix_5381 � Conflicts: � modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
spring: fixed use of oneOf Models in API
@@ -764,7 +769,7 @@ public void preprocessOpenAPI(OpenAPI openAPI) { | |||
Schema s = e.getValue(); | |||
String nOneOf = toModelName(n + "OneOf"); | |||
if (ModelUtils.isComposedSchema(s)) { | |||
if (e.getKey().contains("/")) { | |||
if (e.getKey().contains("/") || (useOneOfInterfaces && LIBRARY_ONEOF_IMPL.equals(templateDir))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code is specific to the SpringCodegen class and must be written in it???
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the code will be executed only for java spring library, as the specification of this issue require.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If so, move the code in SpringCodegen.java and all if statments with (.... templateDir.equals(LIBRARY_ONEOF_IMPL....) should be in SpringCodegen.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To do it so, i must duplicate almost the whole preprocessOpenAPI method in SpringCodegen, only because of this condition. I wanted to avoid it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Scorpioncik should i do so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to duplicate the whole preprocessOpenAPI, you can extract in a method the piece of code and override it in SpringCodegen.
example:
if (e.getKey().contains("/")) { ====> if (method1()) {
modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
Outdated
Show resolved
Hide resolved
implementing oneOf for spring lib overriding methods with different behavior from default
@Override | ||
protected void addOneOfForComposedSchema(Entry<String, Schema> stringSchemaEntry, String modelName, ComposedSchema composedSchema, | ||
String nOneOf){ | ||
if (useOneOfInterfaces) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useOneOfInterfaces is always true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, you are right useOneOfInterfaces is always true, i will change the code, that there is no if cases anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you mean this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Scorpioncik please review this pull request again.
added x-is-one-of-interface extension for oneOf interface in mustache template
fixed name of model from UNKNOWN_BASE_TYPE to right one in api: operationId + OneOf Fix OpenAPITools#5381 removed not needed methods Fix OpenAPITools#5381 fixed generation of oneOf Models Fix OpenAPITools#5381 addOneOfInterfaceModel only for cases when useOneOfInterfaces is true and for spring Fix OpenAPITools#5381 NPE fix for tests
83ff1ee
to
bfab304
Compare
fixed handing of composed schema with array
fixed NPE in addOneOfInterfaceModel
@alexsuperdev Thanks for you work on this!! I have been monitoring it closely and have been using your fork for testing both
Would you mind running the below OAS with your codebase?
|
fixed generation of oneOf models with descriminator
Thank you @jburgess also for the tip and example with discriminator. |
@alexsuperdev, yes. This seems to have resolved this issue. Thanks! |
Hello @bkabrda @Scorpioncik @jburgess @jimschubert. Can any one of you review this pullrequest? |
Hi @alexsuperdev Thanks for working on this. Do we have an ETA when this fix will be merged? |
I dont know when @bkabrda or @jimschubert have a time to look in this pull request and merge this |
Is there anything new about this? I only mean because 224 PRs are waiting at the moment. So I have little hope to ever see the fix... |
@alexsuperdev Thank you for taking the initiative on implementing this feature - are you still planning on completing this piece of work. It seems that there are maybe people interested in this feature (myself being one of them). |
…rator into spring_fix_5381 � Conflicts: � modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
hello @adzeeman. I will try to fix merge conflicts and possibly junit tests this week |
Us SadaPay engineers are very keen to get this merged ASAP - let us know how we can support. |
It seems that pojo.mustache must be the same as in #8091, it adds "implementats .." to Java class definition public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}}{{^parent}}{{#hateoas}}extends RepresentationModel<{{classname}}> {{/hateoas}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} { --> public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}}{{^parent}}{{#hateoas}}extends RepresentationModel<{{classname}}> {{/hateoas}}{{/parent}} {{#vendorExtensions.x-implements}}{{#-first}}implements {{{.}}}{{/-first}}{{^-first}}, {{{.}}}{{/-first}}{{#-last}} {{/-last}}{{/vendorExtensions.x-implements}} { |
Hello Andreas,
thank you for this message. Yes, its very said, that the the simple merge
could not be done yet. Very useful information about Swagger codegen, maybe
i will switch also to Swagger codegen.
Am Do., 22. Apr. 2021 um 12:16 Uhr schrieb andreas-whc <
***@***.***>:
… Hello Alexei,
thank you for your great work. That's a real shame that the PR was taken
out to make an early hotfix out of a release. Very disappointing release
management. We probably decided to switch back to Swagger codegen soon
because of this :( Real shame.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#5661 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AF4EPWLKHJ4MV6GWPCUI7GTTJ7ZRHANCNFSM4LRH4LRA>
.
|
Hi Any news? This feature is very important for us. |
any news? |
Anything we can help with getting the pull request merged? Is there any open issue in the pull request or are we waiting for the maintainers? |
I also really don't know why this PR will not be merged by maintainers |
looks like there are 2 merge conflicts left, maybe you could fix them to increase the chance for a merge? |
…rator into spring_fix_5381 � Conflicts: � modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java � modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java
Hi @alexsuperdev, |
Its too much changes that need to be manually merged, i don't want to do it, because after it, PR possibly will not be merged by maintainers also. So if someone want to do merge it, you are welcome |
Never contributed to someone else's pull request before. Do I fork your fork and fix it there and do a pull request to your fork? Or how does one go about contributing to someone else's? |
Colleagues, when will this functionality be released? He is sorely missed! |
Is there any chance to get this PR merged any time sooner? |
|
Fix 5381
Implemented OneOf for java spring library(server side).
PR checklist
./bin/
(or Windows batch scripts under.\bin\windows
) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run./bin/{LANG}-petstore.sh
,./bin/openapi3/{LANG}-petstore.sh
if updating the code or mustache templates for a language ({LANG}
) (e.g. php, ruby, python, etc).master
,4.3.x
,5.0.x
. Default:master
.@bbdouglas @sreeshas @jfiala @lukoyanov @cbornet @jeff9finger @karismann @Zomzog @lwlee2608 @bkabrda