question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Converting "collectionFormat: csv" in OAS2 to OAS3

See original GitHub issue

Checklist

  • Conversion: I have checked my source definition is valid OpenAPI 2.0
  • Conversion: On valid OpenAPI 2.0 input, the conversion looks wrong

Detailed Description

When converting the following endpoint in petstore.yaml from OAS2 to OAS3 using the online converter:

  /pet/findByStatus:
    get:
      tags:
        - pet
      summary: Finds Pets by status
      description: Multiple status values can be provided with comma separated strings
      operationId: findPetsByStatus
      produces:
        - application/xml
        - application/json
      parameters:
        - name: status
          in: query
          description: Status values that need to be considered for filter
          required: true
          type: array
          items:
            type: string
            enum:
              - available
              - pending
              - sold
            default: available
          collectionFormat: csv

I got the following result in OAS3:

  /pet/findByStatus:
    get:
      tags:
        - pet
      summary: Finds Pets by status
      description: Multiple status values can be provided with comma separated strings
      operationId: findPetsByStatus
      parameters:
        - name: status
          in: query
          description: Status values that need to be considered for filter
          required: true
          style: form
          schema:
            type: array
            items:
              type: string
              enum:
                - available
                - pending
                - sold
              default: available

collectionFormat: csv in OAS2 should be converted to the following in OAS3 instead:

          in: query
          description: Status values that need to be considered for filter
          required: true
          style: form
          explode: false

but in the output generated by the online converter, explode: false is missing.

Ref:

Am I understanding OAS3 correctly in terms of how “collectionFormat: csv” (OAS2) should be defined in OAS3?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jminicommented, Jul 5, 2018

@ackintosh did a great job by creating this table: https://github.com/swagger-api/swagger-parser/pull/702#issue-187611442

it provides conversion rules OAS2 <-> OAS3 for parameters.

1reaction
MikeRalphsoncommented, Jul 5, 2018

@wing328 I think you’re right. Will take a look.

Read more comments on GitHub >

github_iconTop Results From Across the Web

OpenAPI Specification - Version 2.0 - Swagger
Describes the type of items in the array. collectionFormat, string, Determines the format of the array if type array is used. Possible values...
Read more >
OpenAPI Specification v3.0.3 | Introduction, Definitions, & More
The OpenAPI Specification (OAS) defines a standard, ... This option replaces collectionFormat with a csv (when explode is false) or multi ...
Read more >
Swagger: cannot set "collectionFormat" - openapi
To address this issue, i found that you could influence this behavior by setting the attribute "collectionFormat" not to multi but to csv....
Read more >
Mermade Swagger 2.0 to OpenAPI 3.0.0 converter
Mermade Swagger 2.0 to OpenAPI 3.0.0 converter · Conversion / Validation engine v5.3.0 · Web frontend version v1.3.17 · Example definitions · Test...
Read more >
Request Handling — Connexion 2.0 documentation
With this option enabled, Connexion firstly converts CamelCase names to ... and collectionFormat: csv , then connexion will set letters = ['d', 'e',...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found