swagger-api / swagger-api/swagger-codegen
[Kotlin] API Input param with dot cannot be handled in kotlin code generated
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
When generating kotlin client code with v2.3.1, if the api input parameter has a dot ".", the generated kotlin parameter will also contain the dot (e.g. model.paramName), which is an invalid kotlin variable name.
Swagger-codegen version
v2.3.1
Swagger declaration file content or url
Sample swagger spec with the problematic param pattern with dot "MobileDeviceUpdateDTO.Udid"
https://gist.github.com/joecklau/7cc6c168b9fc74ced352effec99b89a4
Command line used for generation
java -jar swagger-codegen-cli-2.3.1.jar generate -i swagger.json -l kotlin
Steps to reproduce
Just run it, and you will see the following java method created:
fun apiAuthLoginForTokenPost(mobileDeviceUpdateDTO.Udid : kotlin.String, _(someMoreParameters...)_ , phoneAreaCode: kotlin.String, phoneNumber: kotlin.String, email: kotlin.String) : JSendResponseLeft_Square_BracketAppTokenModelRight_Square_Bracket {
val localVariableBody: kotlin.Any? = null
val localVariableQuery: MultiValueMap = mapOf("mobileDeviceUpdateDTO.Udid" to listOf("**$mobileDeviceUpdateDTO.Udid**"), _(someMoreParameters...)_ , "phoneAreaCode" to listOf("$phoneAreaCode"), "phoneNumber" to listOf("$phoneNumber"), "email" to listOf("$email"), "password" to listOf("$password"))
val localVariableHeaders: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
_(someMoreCode...)_
in which "mobileDeviceUpdateDTO.Udid : kotlin.String" is invalid
Suggest a fix/enhancement
Skip the "." dot for kotlin param
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
Run the swagger-codegen-cli-2.3.1.jar command with the swagger.json sample from the linked gist and inspect the generated Kotlin method, especially the MobileDeviceUpdateDTO.Udid parameter. Trace the Kotlin generation entry point or template responsible for parameter names. Done means the generated Kotlin parameter is valid without the dot and the generated client no longer contains that invalid declaration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100