OpenAPITools / OpenAPITools/openapi-generator
[BUG] [JAVA] [Gradle] '"additionalProperties": false' leads to failing code generation
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I have recently updated the openapi-generator gradle plugin from 6.6.0 to 7.1.0. Since then I have two problems, seemingly related to the use of "additionalProperties" in my swagger.json file.
- Case 1: If I have a definition with
"additionalProperties": false, no java class will be generated for this defnition. - Case 2: If I have a definition with
"additionalProperties": falseand a property that references the same definition, it will cause aStackOverflowError.
openapi-generator version
openapi-generator gradle plugin 7.1.0
It worked fine with version 6.6.0
OpenAPI declaration file content or url
- Case 1: https://raw.githubusercontent.com/sandra-thieme/openapi-generate-example/main/src/main/resources/swagger-no-generation.json
- Case2: https://github.com/sandra-thieme/openapi-generate-example/blob/main/src/main/resources/swagger-stackoverflow.json
Generation Details
I have created a minimal sample project to illustrate the issue: https://github.com/sandra-thieme/openapi-generate-example/tree/main. There are three swagger.json files in there: one that works, one that shows that nothing is generated (case 1), one that shows the stackoverflow error (case 2).
Steps to reproduce
In the above sample project:
- Call
./gradlew clean openApiGenerate - Build succeeds but no class will have been generated in
build/generated - Change
swagger-no-generation.jsonin build.gradle.kts toswagger-stackoverflow.json - Call
./gradlew clean openApiGenerate - Build fails with
StackOverflowError
Related issues/PRs
Suggest a fix
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked sample project, its build.gradle.kts, and the swagger-no-generation.json and swagger-stackoverflow.json inputs. Run ./gradlew clean openApiGenerate for each case and compare the generated output and failure. Done means the first input generates its Java class and the self-referencing input completes without StackOverflowError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100