swagger-api / swagger-api/swagger-codegen
[Kotlin-Client] Malfunctioning parameter generation in Kotlin with -last or hasMore
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I do have a problem with kotlin-client code generation (or kotlin in 2.4) in the current master as well as 3.0.3 and 2.4 versions of Swagger Codegen.
Running java -jar swagger-codegen-cli-3.0.3.jar generate -l kotlin-client -i https://esi.evetech.net/latest/swagger.json\?datasource\=tranquility yields many problems of the same type as the following example:
fun postCharactersCharacterIdAssetsLocations(body: kotlin.Array<kotlin.Long>characterId: kotlin.Int, datasource: kotlin.String, token: kotlin.String) : kotlin.Array<kotlin.Any> {
// ...
}
On a closer look one can see that a comma is missing between the first argument and the following arguments. This yields a compiler error, of course.
Swagger-codegen version
Tried with different versions (master included). As stated above.
Swagger declaration file content or url
https://esi.evetech.net/latest/swagger.json?datasource=tranquility
Command line used for generation
java -jar swagger-codegen-cli-3.0.3.jar generate -l kotlin-client -i https://esi.evetech.net/latest/swagger.json\?datasource\=tranquility
on Arch Linux with the following Java runtime:
$ java -version
openjdk version "1.8.0_192"
OpenJDK Runtime Environment (build 1.8.0_192-b26)
OpenJDK 64-Bit Server VM (build 25.192-b26, mixed mode)
Steps to reproduce
Generate the files with the above Swagger config.
Related issues/PRs
Suggest a fix/enhancement
https://github.com/theZorro266/swagger-codegen/commit/73447d10e9d38cf0cadd6bc8c5385b08f67ef7e3
Honestly, hasMore seems to be buggy at the moment. It is false with the first parameter in allParams although there actually are more parameters. Fixing that would solve this one issue, but there is still something wrong with -last directive and the handlebars templating engine. This needs a closer look.
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
Reproduce the Kotlin client with the provided Swagger URL and generation command, then inspect parameter generation around allParams, hasMore, the -last directive, and the Handlebars templating behavior. Done means the generated function parameters include the required commas and compile without errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100