OpenAPITools / OpenAPITools/openapi-generator
Unicode chars are ignored as enum values
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Generating java code from spec with enums using non-latin (russian-cyrillic) chars gives invalid output. For example for enum like:
"enum" : ["один", "два", "три"] ...
output (for java) looks like:
public enum ... {
_("один"),
_("два"),
_("три")
...
}
Which gives compile error. Since java supports unicode chars for enum names - corresponding code should be replaced with one which will not trim non-latin chars.
Proposal: replace regexp with Unicode-enabled one
String var = value.replaceAll("\\W+", "_").toUpperCase(Locale.ROOT);
with
String var = value.replaceAll("(?U)\\W+", "_").toUpperCase(Locale.ROOT);
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 in modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java at the enum-name handling around line 1406. Generate Java code from a spec containing Cyrillic enum values and verify the generated enum constants preserve those characters and compile successfully.
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
- 48/100