swagger-api / swagger-api/swagger-codegen
[Kotlin] Restricted keyword in package
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
It seems that when using restricted keyworkds in the package, this will not be escaped.
eg. "in" is a keyword in kotlin (as the source code list it as well), and is also the domain of india.
The config.json for my kotlin-client generation looks like:
{
"modelPackage" : "in.test.client.model",
}
and produces "package in.test.client.model", which does not compile.
It would need to be "package in.test.client.model"
This issue might be the same for domains like "is","it" and so on.
Swagger-codegen version
Swagger v.3.0.8
Command line used for generation
using the config as above by using domain which is reserved
-c config.json
Steps to reproduce
Use for example package like described above "in.test.client.model"
Suggest a fix/enhancement
There is already the escapeReservedWord method in AbstractKotlinCodegen and should be used for every package substring, splitted at the delimiter "."
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 AbstractKotlinCodegen and inspect the existing escapeReservedWord method, then trace how modelPackage is split and emitted. Reproduce the issue with the config using in.test.client.model. Done means each dot-separated package component is handled so the generated Kotlin package declaration compiles.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100