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
  • #2125
Closed
Open
Issue created Feb 11, 2019 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG] all languages: not handling array parameters

Created by: jacobweber

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

I'm using the swift4 generator, with a Swagger 2 spec, and an array parameter with collectionFormat=csv. The parameter looks like:

          {
            "name": "categories",
            "in": "path",
            "required": true,
            "type": "array",
            "items": {
              "type": "string"
            },
            "collectionFormat": "csv"
          }

It generates code that (correctly) expects an array of strings:

open class func usersGet(categories: [String], completion: @escaping ((_ data: [User]?,_ error: Error?) -> Void)) {

But if I pass an array to it:

DefaultAPI.usersGet(categories: ["sample"] )

it URL-encodes the array literal, rather than using comma-separated values as specified in collectionFormat:

GET /users/%5B%22sample%22%5D

I'm curious if this will be an issue with all generator types.

openapi-generator version

4.0.0-SNAPSHOT

OpenAPI declaration file content or url

https://gist.github.com/jacobweber/2a8b3145952464997545d212772a1b96

Command line used for generation
java -jar /path/to/openapi-generator-cli.jar generate -i /path/to/spec.json -g swift4 -o /path/to/output
Steps to reproduce

See above

Related issues/PRs

None

Suggest a fix

This is not Swift, but swagger-codegen had a fix for one Java client here, and a PR for another one here.

Assignee
Assign to
Time tracking