swagger-api / swagger-api/swagger-codegen
[Kotlin] Invalid enum var names
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
When enums name start with a number, the generated code won't compile
Swagger-codegen version
2.4.0-SNAPSHOT
Swagger declaration file content or url
"enum":[
"1name"
]
Command line used for generation
java -jar swagger-codegen-cli.jar generate -i swagger.json -c config.json -l kotlin -o tmp
Steps to reproduce
Add an enum parameter to swagger file; generate and compile.
Related issues/PRs
Suggest a fix/enhancement
The enumeration name can be prefixed by an underscore, it's done like this for the model name.
Another solution is to surround illegals names with backticks, but enum may be tricky to use (Status.1available). And what I understand of kotlin coding convention is backticks are acceptable only for names in tests.
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 reproducing the issue with swagger-codegen-cli.jar, the supplied swagger.json enum value, and the Kotlin generator. Inspect the Kotlin generation templates or entry points responsible for enum names. Done means the generated Kotlin code compiles when an enum value begins with a number, while preserving valid names for other values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100