swagger-api / swagger-api/swagger-codegen
[JAVA] Enum character escaping bug
Open
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Java Enum Codegen escapes both + (plus) and - (minus) with "_". In some cases, it can cause duplicated Enum names that are prohibited by JLS.
Swagger-codegen version
Online Editor
Swagger declaration file content or url
definitions:
BuggedCodeGen:
type: "object"
properties:
timeZone:
type: "string"
enum:
- "Etc/GMT+1"
- "Etc/GMT-1"
Results in:
public enum TestEnum {
GMT_1("Etc/GMT+1"),
GMT_1("Etc/GMT-1");
// ...
}
Suggest a Fix
Replace + with PLUS and - with MINUS
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 tracing the Java enum code generation path for the provided YAML declaration and inspect how plus and minus characters are escaped. Reproduce the duplicate constants GMT_1 and GMT_1, then verify that the generated enum uses distinct names such as PLUS and MINUS and compiles successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100