Skip to content

Fixed outer enum issue on jaxrs-resteasy and jaxrs-resteasy-eap#10533

Open
GabriRuflex wants to merge 2 commits into
swagger-api:masterfrom
GabriRuflex:issue-3856
Open

Fixed outer enum issue on jaxrs-resteasy and jaxrs-resteasy-eap#10533
GabriRuflex wants to merge 2 commits into
swagger-api:masterfrom
GabriRuflex:issue-3856

Conversation

@GabriRuflex

@GabriRuflex GabriRuflex commented Oct 31, 2020

Copy link
Copy Markdown

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
  • Filed the PR against the correct branch: 3.0.0 branch for changes related to OpenAPI spec 3.0. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

Ping

@HugoMario

@GabriRuflex

Copy link
Copy Markdown
Author

@HugoMario Hi Hugo, could you please take a look on this? Thanks a lot!

@ellyxc

ellyxc commented Jul 11, 2022

Copy link
Copy Markdown

Hi there, what is the status of this PR? i think this PR open for about 2 years already

@GabriRuflex
GabriRuflex force-pushed the issue-3856 branch 2 times, most recently from e181bab to 413088e Compare July 19, 2026 13:30
@GabriRuflex

GabriRuflex commented Jul 19, 2026

Copy link
Copy Markdown
Author

Hi maintainers 👋

This PR has now been open for almost 6 years (since October 2020), so here's a fresh status update:

The bug is evident, trivially reproducible and blocking. Any Swagger spec that defines a top-level (outer) enum currently produces broken code with these generators — you can reproduce it with a three-line definition:

OrderStatus:
  type: string
  enum: [placed, approved, delivered]
  • jaxrs-resteasy: the generated enum does not even compile — the template renders the raw allowableValues map, producing something like public enum OrderStatus { {values=[placed, approved, delivered], enumVars=[...]} }. This is the same class of bug that was fixed for jaxrs-spec in [JAXRS-SPEC] Enum values are generating """, "&#3D;", imports are being written inside class declaration #3856.
  • jaxrs-resteasy-eap: the enum compiles but loses the spec values — no value field and no @JsonValue, so Jackson serializes the Java constant name (PLACED) instead of the wire value (placed), breaking round-tripping with any conforming client.

The fix is the missing half of code that is already on master. Interestingly, JavaResteasyServerCodegen and JavaResteasyEapServerCodegen already contain the postProcessModelsEnum logic that adds the com.fasterxml.jackson.annotation.JsonValue import for outer enum models — but the templates were never updated to use it. This PR provides exactly that missing template side.

Current state of the PR:

  • ✅ Rebased on the current master, no conflicts, mergeable
  • ✅ Now includes regression tests (JavaResteasyOuterEnumTest, parametrized over both generators) that generate from a spec with a top-level enum and verify the emitted code — the tests fail on master and pass with this PR

Given that the change is two mustache templates plus tests, aligns these generators with what jaxrs-spec has done since 2019, and is now covered by regression tests, it would be great to finally get this reviewed and merged. Happy to address any feedback quickly. Thanks! 🙏

cc @ewaostrowska

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants