Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #7199
Closed
Open
Issue created Aug 13, 2020 by Administrator@rootContributor

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

Created by: 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(",")}"
Assignee
Assign to
Time tracking