Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] all languages: not handling array parameters #2125

Open
5 of 6 tasks
jacobweber opened this issue Feb 11, 2019 · 3 comments
Open
5 of 6 tasks

[BUG] all languages: not handling array parameters #2125

jacobweber opened this issue Feb 11, 2019 · 3 comments

Comments

@jacobweber
Copy link
Contributor

jacobweber commented Feb 11, 2019

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.

@auto-labeler
Copy link

auto-labeler bot commented Feb 11, 2019

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@jacobweber
Copy link
Contributor Author

Also happening with -g java -Dlibrary=okhttp-gson.

@jacobweber jacobweber changed the title [BUG] swift4: not handling array parameters [BUG] all languages: not handling array parameters Feb 12, 2019
@jacobweber
Copy link
Contributor Author

objc is even weirder -- it sends something like GET /users/%28%0A%20%20%20%20sample%0A%29, which decodes to:

(
    sample
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant