-
-
Notifications
You must be signed in to change notification settings - Fork 7k
[BUG] invalid allVars for allOf and properties at the same level #18340
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
Comments
there's already a normalizer rule for that: REFACTOR_ALLOF_WITH_PROPERTIES_ONLY |
I don't think it works if REF_AS_PARENT_IN_ALLOF is enabled. I meant a new normalizer that runs ** before ** REFACTOR_ALLOF_WITH_PROPERTIES_ONLY |
I did a test and Cat seems correctly extending Pet
and allVars contains both name and petType
command: java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java -i /tmp/allof.yaml -o /tmp/alloftest/ --openapi-normalizer REFACTOR_ALLOF_WITH_PROPERTIES_ONLY=true,REF_AS_PARENT_IN_ALLOF=true Did you get something similar in your end? |
It seems the code on master has not the issue anymore. |
I reproduce on master using this test in DefaultCodegenTest using the same contract:
|
Additional info. Moving the properties to the list of allOf fixes the issue:
allVars = petType,name (IMHO a much better order) Using this contract and the DefaultCodegen (ie without supportInheriance)
allVars = name,petType (IMHO not a good order. See #17542) So I would "fix" REFACTOR_ALLOF_WITH_PROPERTIES_ONLY (or create another normalizer) to migrate to first version to the second version |
@wing328 Sorry my mistake, in testAllVars_issue_18340() I made a stupid typo with an extra space for " true".
Sorry that the typo is now on master |
@jpfinne that's ok. please fix it later in another PR |
Uh oh!
There was an error while loading. Please reload this page.
Bug Report Checklist
Description
allVars does not contain the properties when the properties are on the same level as the allOf
Simlar to Object3 in issue_16797.yaml
openapi-generator version
7.4
OpenAPI declaration file content or url
Ps: the issue also exists if there is no discriminator
Generation Details
Spring generator (probably all generators that support inheritance)
Steps to reproduce
use this templates/pojo.mustache for demonstration
openapi-generator-cli generate -g spring -i allvarSample.yaml -o out -t templates
Cat.java has an invalid allVars. It should contain name.
Related issues/PRs
Suggest a fix
Add a normalizer that transforms the model into
The text was updated successfully, but these errors were encountered: