openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[BUG][JAVA] Generator fails to create a working client with Springs HttpStatusCode involved

Open coinzz opened this issue 1 month ago • 0 comments

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
  1. Put the api-docs.json on the same level as the pom.xml
  2. run mvn generate-sources
  3. This will be succesful, but navigate to generated-sources\client\src\main\java\de\test\client\model\HttpStatus.java
  4. See the Error: Image
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.

coinzz avatar Nov 26 '25 12:11 coinzz