-
-
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] "allOf" does not support inheritance #9756
Comments
I have tried to modify my schema to generate the extends but nothing I am doing is working my latest incarnation looks like: common/base-page.yml
and the class that extends it has:
This generates OrganizationPage.java without an "extends BasePage". For some reason it also isn't including pageType as an attribute in the generated class. Can someone please explain what I am doing incorrectly? |
Can this please be fixed? Because no there is no inheritance. Also check what happens if you have multiple discriminator or multiple allOf |
Any idea when to fix this? |
Refs #5726. I'm also interested in a fix for this issue. |
Any idea for a fix? This is not real inheritance. I cannot use polymorphism using this allOf generation |
Our team needs this fix too :( |
Bug is also present in 6.0.0-beta |
This is a huge issue. This is very important. |
After I got the Pet model working that @marcdejonge provided in #9615 (comment), I figured out a workaround for my own issue. I had separate yaml files for my schema model classes, and by moving them into the same file as the endpoints under this, it worked for me!!!
Note, I also applied this fix to avoid the extra AllOf classes: #3100 (comment) |
Hi all, I've filed #14172 to allow using $ref as parent in allOf with a new option called "openapi-normalizer". Please give it a try as follows:
|
@wing328 Is this code merged with the most up-to-date version? |
the fix has been merged into master. please give latest stable version v6.6.0 a try |
All, this seems to have regressed in Version 7.2.0. The JAXRS generator that used to generate code correctly up until version 7.0.1 no longer does so. |
Description
I am trying to generate Java classes from an openapi schema that contains
this ends up generating a class named OrganizationPage with
but I require
the documentation seems to indicate that it is required that the definition of BasePage be modified to add a discriminator field. I am unable to do that as that file is in a different project that is shared by different projects, some of which use older versions of openapi-generator and do not populate a discriminator field. Furthermore, a discriminator field is never required as the base class is never referenced in the API, only the subclass is, so serialization/deserialization doesn't require a discriminator. However, there are utility methods that operate on the base class so all instances must extend the class.
openapi-generator version
openapi-generator-mave-plugin 5.1.0
OpenAPI declaration file content or url
base-page.yml contains
Generation Details
mvn clean install produces:
[deprecated] inheritance without use of 'discriminator.propertyName' has been deprecated in the 5.x release. Composed schema name: null. Title: null
The above line is emitted a few times during the build but it isn't clear if it is associated with this issue or not since it doesn't identify the file, line, or object it is referencing.
Related issues/PRs
Both #3100 and #3172 have similarities to this issue.
Suggest a fix
The only fix I can think of is to add an attribute to the definition of the object to direct it to use inheritance instead of composition.
The text was updated successfully, but these errors were encountered: