Skip to content

[BUG][kotlin] Path params with type: array doesn't work #7199

@nilskuhn

Description

@nilskuhn
Description

If API contains path parameters of type array, generated client function uses toString() method on kotlin.Array which doesn't provide comma separated representation.

Generated code:

fun <function-name-generated-resp-operationId>(<my-array-param>: kotlin.Array<kotlin.String>) : kotlin.Array<MyDtoType> {
        val localVariableBody: kotlin.Any? = null
        val localVariableQuery: MultiValueMap = mutableMapOf()
        val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
        val localVariableConfig = RequestConfig(
            RequestMethod.GET,
            "/path-part-1/{<my-array-param>}/path-part-2".replace("{"+"<my-array-param>"+"}", "$<my-array-param>"),
            query = localVariableQuery,
            headers = localVariableHeaders
        )

The problem is the string templating here ("$<my-array-param>"), which uses objects toString() method.

openapi-generator version

4.3.1

OpenAPI declaration file content or url

Path param of type array:

parameters:
        - name: <my-array-param>
          in: path
          required: true
          style: simple
          explode: false
          schema:
            type: array
            items:
              type: string
Generation Details

We are using openapi-generator-maven-plugin.

Steps to reproduce

Every API with a path parameter of type array should provide the described behaviour.

Suggest a fix

Use joinToString method:

"${<my-array-param>.joinToString(",")}"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions