swagger-api / swagger-api/swagger-codegen-generators
Java enum classes generation is broken if errorOnUnknownEnum is turned on
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 299
- Forks
- 439
- PR merge metrics
- No merged PRs in 30d
Description
Java enum classes generation is broken if java code is generated to use jackson library to serialize/deserialize json into java objects and errorOnUnknownEnum is turned on.
It affects at least 3.0.36 version.
The generated code looks like:
@JsonCreator
public static EnumName fromValue(String input) {
...
throw new IllegalArgumentException("Unexpected value '" + text + "' for 'EnumName' enum.");
}
the issue is that the method parameter has name input, while exception text uses variable with name text to produce error message.
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 by locating the Java enum generation template or entry point that handles errorOnUnknownEnum, then compare the generated fromValue method with the reported snippet. Correct the inconsistent variable reference in the exception message and verify that generated Java enum code compiles and preserves the expected unknown-value behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100