swagger-api / swagger-api/swagger-codegen

[JAVA] Non compilable enums generated with property errorOnUnknownEnum=true

Open Beginner friendly
#11,812 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

Since version 3.0.30, Java enum generated with IllegalArgumentException is not compilable. In commit linked bellow, method parameter was renamed from text to input, but was left as text in the exception message.

Swagger-codegen version

Since version 3.0.30, issue still present in 3.0.34.

Swagger declaration file content or url

Any open api definition containing enum is impacted.

Command line used for generation

Generated using swagger-codegen-maven-plugin.

Steps to reproduce
  1. Create yaml specification containing enum.
  2. Generate Java code using swagger-codegen-maven-plugin with additional property errorOnUnknownEnum=true.
<additionalProperties>
  <additionalProperty>errorOnUnknownEnum=true</additionalProperty>
</additionalProperties>
  1. Check generated Java enums.
Related issues/PRs

Issue introduced in commit: https://github.com/swagger-api/swagger-codegen-generators/pull/978/commits/065a98cddb111015f25782f223eb159569220f68
Line 47: renamed parameter
Line 53: non compilable exception is thrown

Suggest a fix/enhancement

Simply update the thrown exception message with the new parameter name input.

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

Inspect the linked commit, especially lines 47 and 53, and reproduce the problem by generating Java enums with swagger-codegen-maven-plugin and errorOnUnknownEnum=true. Confirm that the generated enums compile and that the exception message uses the renamed parameter input rather than the stale name text.

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
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.