OpenAPITools / OpenAPITools/openapi-generator
[BUG][JAVA] Generator fails to create a working client with Springs HttpStatusCode involved
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?
- [❌: I couldn't build the latest Snapshot due to proxy and corporate restrictions] Have you tested with the latest master to confirm the issue still exists?
- [✅] Have you searched for related issues/PRs?
- [expected: should not result in compile errors] What's the actual output vs expected output?
- [❌] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Using the attached files will result in a non compiling generated client, as seen in the description of Steps to reproduce. This is the minimal example I could create. The actual use-case we have is, to use the attached ApiError class in a ControllerAdvice to react to errors of our services.
openapi-generator version
7.17.0
OpenAPI declaration file content or url
https://gist.github.com/coinzz/24597c69a8877d95e4f10fd681f28ee3
Generation Details
- Apache Maven 3.9.9
- openjdk 17.0.12 2024-07-16 LTS
- also with: openjdk 21.0.4 2024-07-16 LTS
- the rest is configured in the pom.xml
Steps to reproduce
- Put the api-docs.json on the same level as the pom.xml
- run
mvn generate-sources - This will be succesful, but navigate to
generated-sources\client\src\main\java\de\test\client\model\HttpStatus.java - See the Error:
Related issues/PRs
I couldn't find a direct related issue.
Suggest a fix
It seems that sealed classes or inheritance break the generation, but I am not sure if that is the concrete problem.
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 attached api-docs.json and pom.xml, then run mvn generate-sources and inspect generated-sources/client/src/main/java/de/test/client/model/HttpStatus.java. Trace the Java client generation path handling the Spring HttpStatusCode-related model and inheritance. Done means the generated client compiles without errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, spring
- Domain
- backend-api-design, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100