You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Using the openapiNormalizer option REF_AS_PARENT_IN_ALLOF has no effect for child schema that contains only the parent reference in the allOf.
With the example spec below, it is expected that the generated class FirstChild extends FirstParent, and the generate class SecondChild extends SecondParent. What actually happens is that class SecondChild extends SecondParent but class FirstChild only inherits FirstParent's properties, but does not get the inheritance.
openapi-generator version
7.13.0
I've verified behavior using openapi-generator-maven-plugin, openapi-generator-cli, and using spec v3.0.1 and v2.0.
[BUG] REF_AS_PARENT_IN_ALLOF=true no longer works for allOf combined with properties #16389
Suggest a fix
The regression seems to be caused by the changes in #17426. Skipping an "allOf" list with only one item is causing the FirstParent class not to be marked as x-parent: true by the normalizer, even though the FirstChild includes it in its "allOf" list. SecondParent is being marked as x-parent: true because the extra properties constitute a second entry in the "allOf" list. removing the size() == 1 guard does not seem to cause a regression for #17425 (i.e. the tests still pass)
The text was updated successfully, but these errors were encountered:
nlbuescher
changed the title
[BUG] REF_AS_PARENT_IN_ALLOF=true has no effect for simple inheritance without extra properties.
[BUG] REF_AS_PARENT_IN_ALLOF=true has no effect for simple inheritance without extra properties
May 5, 2025
Bug Report Checklist
Description
Using the openapiNormalizer option REF_AS_PARENT_IN_ALLOF has no effect for child schema that contains only the parent reference in the allOf.
With the example spec below, it is expected that the generated class FirstChild extends FirstParent, and the generate class SecondChild extends SecondParent. What actually happens is that class SecondChild extends SecondParent but class FirstChild only inherits FirstParent's properties, but does not get the inheritance.
openapi-generator version
7.13.0
I've verified behavior using openapi-generator-maven-plugin, openapi-generator-cli, and using spec v3.0.1 and v2.0.
The last version that this worke
OpenAPI declaration file content or url
Generation Details
openapi-generator generate -i test.yaml -o out -g java --openapi-normalizer=REF_AS_PARENT_IN_ALLOF=true --global-property models
Steps to reproduce
Related issues/PRs
[BUG] REF_AS_PARENT_IN_ALLOF=true no longer works for allOf combined with properties #16389
Suggest a fix
The regression seems to be caused by the changes in #17426. Skipping an "allOf" list with only one item is causing the FirstParent class not to be marked as
x-parent: true
by the normalizer, even though the FirstChild includes it in its "allOf" list. SecondParent is being marked asx-parent: true
because the extra properties constitute a second entry in the "allOf" list. removing thesize() == 1
guard does not seem to cause a regression for #17425 (i.e. the tests still pass)The text was updated successfully, but these errors were encountered: