-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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][SPRING] missing JsonValue import if allOf used as inline-scheme composition #11323
Labels
Comments
kthoms
pushed a commit
to kthoms/openapi-generator
that referenced
this issue
Feb 18, 2022
A CodegenModel's hasEnum property is set in addVars: cm.hasEnums = true; This state was cleared afterwards again. As one of its results the import for @JsonValue was not added for the model class in the Spring code generator, where 'model.hasEnums' was evaluated to false where it should be true.
wing328
pushed a commit
that referenced
this issue
Feb 21, 2022
A CodegenModel's hasEnum property is set in addVars: cm.hasEnums = true; This state was cleared afterwards again. As one of its results the import for @JsonValue was not added for the model class in the Spring code generator, where 'model.hasEnums' was evaluated to false where it should be true.
Does the api spec you provide follow OpenAPI inheritance / polymorphism standard? Although this spec does not provide "unecessary *allOf files", But I don't think this follow the standard. |
6 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
When using allOf as a composition inline-scheme without inheritance/discriminator the import
import com.fasterxml.jackson.annotation.JsonValue
for the Enum method@JsonValue public String getValue()
is not added to the imports of the generated class.This happens when the inline model doesn't have enums, but the parent does.
Also, the syntax that was used is the only workaround that prevents the generation of the redundant additional ParentTitle+AllOf class (see Java generation of 'extra' class with allOf Workaraound):
The result includes the following imports from Jackson,
but not the JsonValue-Import: although the method is generated
openapi-generator version
openapi-generator v. 5.3.1 ( for java spring)
Related issues/PRs
If the generation of the additional unnecessary ParentTitle+AllOf class is fixed then I believe that will fix this problem as well.
Opt-in solution to remove unnecessary model for inline schema composition
Suggest a fix
For the solution, this method postProcessModelProperty (SpringCodegen) might probably be adapted at the point where Jackson imports are added and the model will be checked if it is or has enums or not.
The text was updated successfully, but these errors were encountered: