Open andlbrei opened 1 month ago
can you please file a PR to start with? that would make the code review a lot easier
@wing328 created https://github.com/OpenAPITools/openapi-generator/pull/19905
update: filed https://github.com/OpenAPITools/openapi-generator/pull/19964 to workaround this for the time being
Bug Report Checklist
Description
When trying to generate kotlin files from Open API spec, a data class without any properties is generated. In this case the bug is triggered when trying to generate a class from a definition of items in an array containing an
allOf
. It seems like the mustache template iterates overallVars
to populate the data class, butallVars
is empty, being reset inDefaultCodegen.java:L2637
https://github.com/andlbrei/openapi-generator/blob/2b75a9ccdc1a3819e650546d30b94aeb56e99f04/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java#L2637openapi-generator version
7.8.0 The issue is present in 7.7.0 and 7.6.0 as well.
OpenAPI declaration file content or url
https://github.com/andlbrei/openapi-generator/blob/2b75a9ccdc1a3819e650546d30b94aeb56e99f04/modules/openapi-generator/src/test/resources/3_1/issue_wip.yaml
Generation Details
java -jar openapi-generator-cli.jar generate \ -i issue_wip.yaml \ -g kotlin \ -o .
Steps to reproduce
I made a fork with two tests, and a comment on one line of code that seems to break generation in this case. https://github.com/andlbrei/openapi-generator/commit/d51e3ff806d3906efbb5782b691bb07f3a4c8102
array
withitems
that have anallOf
with more than one subschema. (It appears thatallOf
with only one subschema is treated differently, which makes sense)Related issues/PRs
I have not found a recent issue, though it is hard to be sure with the massive amount of issues that are open here.
Suggest a fix
I have commented on a line of code that impacts generation in this case. When this line is commented out it works. The code in this library is pretty complicated, and I would assume that "fixing" this case would break something else if done like this. If someone can guide me, I could make an attempt at fixing it.