swagger-api / swagger-api/swagger-codegen
kotlin-client uses $ sign in variable names
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I want to create a kotlin client for youtrack but Jetbrains somehow uses $ in some of their variable names. e.g.
paths:
/activities:
description: This resource provides access to the activities with the possibility to filter them by various parameters.
get:
parameters:
....
- name: fields
in: query
schema:
type: string
example: '$type,added,author($type,id,login,name,ringId),category($type,id),field($type,customField($type,fieldType($type,id),id,localizedName,name),id,name),id,removed,target,targetMember,timestamp'
- name: $skip
in: query
schema:
type: integer
format: int32
- name: $top
in: query
schema:
type: integer
format: int32
These get converted to
fun adminCustomFieldSettingsBundlesBuildGet(fields: kotlin.String? = null, $skip: kotlin.Int? = null, $top: kotlin.Int? = null): kotlin.Array<BuildBundle> {
val localVariableQuery: MultiValueMap = mapOf("fields" to listOf("$fields"), "$skip" to listOf("$$skip"), "$top" to listOf("$$top"))
val localVariableConfig = RequestConfig(
RequestMethod.GET,
"/admin/customFieldSettings/bundles/build", query = localVariableQuery
)
val response = request<kotlin.Array<BuildBundle>>(
localVariableConfig
)
return when (response.responseType) {
ResponseType.Success -> (response as Success<*>).data as kotlin.Array<BuildBundle>
ResponseType.Informational -> TODO()
ResponseType.Redirection -> TODO()
ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error")
ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error")
}
}
which of cause fails to compile in 2 ways
- parameters are not allowed to have
$in their name - String interpolation is used in
"$skip"
Swagger-codegen version
3.0.21
Swagger declaration file content or url
https://youtrack.jetbrains.com/api/openapi.json
Command line used for generation
java -jar swagger-codegen-cli.jar generate -i https://youtrack.jetbrains.com/api/openapi.json -l kotline-client -o kotlin
Steps to reproduce
java -jar swagger-codegen-cli.jar generate -i https://youtrack.jetbrains.com/api/openapi.json -l kotline-client -o kotlin
cd kotline
gradle build
any ideas?
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
No source file is named. Start by reproducing the generation from https://youtrack.jetbrains.com/api/openapi.json with Swagger Codegen 3.0.21, then run the generated Kotlin project with Gradle and trace how the $skip and $top query parameters become Kotlin identifiers and string values. Done means the generated client compiles and preserves those query parameter names.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin, openapi
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100