OpenAPITools / OpenAPITools/openapi-generator

[REQ] Don't use @JsonCreator in Java enums

Open
#2,868 4 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

When applied to an enum property, Jackson's @JsonValue automatically provides a two-way translation that is likely to be more efficient than the generated fromValue. The @JsonCreator annotation is unnecessary and should be retired.

Applies to 3.3.4 and 4.0.0-beta3.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the Java enum generation path and locating where @JsonCreator and fromValue are emitted; the issue names no files or tests. Verify how @JsonValue handles enum deserialization, then confirm that generated Java enums omit the unnecessary annotation while retaining the requested two-way translation.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.