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

Query parameter default array values not rendered correctly #1806

Closed
cmeeren opened this issue Nov 26, 2021 · 5 comments · Fixed by #2186
Closed

Query parameter default array values not rendered correctly #1806

cmeeren opened this issue Nov 26, 2021 · 5 comments · Fixed by #2186

Comments

@cmeeren
Copy link

cmeeren commented Nov 26, 2021

Consider the following query parameter definition:

- in: query
  name: "sort"
  description: |
    ...
  explode: false
  schema:
    type: array
    items:
      type: string
      enum:
        - isPending
        - userFullName
        - email
    default:
      - isPending
      - userFullName
      - email
    example:
      - -isPending
      - email
      - userFullName

It is rendered like this:

image

As you can see, the enumeration and the example renders correctly, but not the default value. It should be rendered like the example, with the query parameter name first and comma between the values.

Workaround: Format manually as string:

default: isPending,userFullName,email

Using @next version from npm.

@AlexVarchuk
Copy link
Collaborator

@cmeeren HI, I try to reproduce it but seems I miss something. Can you share additional steps to reproduce? Here is my definition. It works on my side.

openapi: 3.0.0
servers:
  - url: //petstore.swagger.io/v2
    description: Default server
  - url: //petstore.swagger.io/sandbox
    description: Sandbox server
info:
  description: string
  version: 1.0.0
  title: Swagger Petstore
tags:
  - name: url
    description: Everything about your Pets
paths:
  /url:
    parameters:
      - name: Accept-Language
        in: header
        description: "The language you prefer for messages. Supported values are en-AU, en-CA, en-GB, en-US"
        example: en-US
        required: false
        schema:
          type: string
          default: en-AU
      - in: query
        name: "sort"
        description: |
          ...
        explode: false
        schema:
          type: array
          items:
            type: string
            enum:
              - isPending
              - userFullName
              - email
          default:
            - isPending
            - userFullName
            - email
          example:
            - -isPending
            - email
            - userFullName
      - in: query
        name: "sort1"
        description: |
          ...
        explode: false
        schema:
          type: array
          items:
            type: string
            enum:
              - isPending
              - userFullName
              - email
          default:
            - isPending
            - userFullName
            - email
          example:
            - -isPending
            - email
            - userFullName
    get:
      tags:
        - pet
      summary: Find pet by ID
      description: Returns a single pet
      operationId: getPetById
      parameters:
        - name: petId
          in: path
          description: ID of pet to return
          required: true
          deprecated: true
          schema:
            type: integer
            format: int64

@cmeeren
Copy link
Author

cmeeren commented Nov 26, 2021

I am also using enumSkipQuotes.

Without it, it renders like this, which is still a bug and different from example:

image

@AlexVarchuk
Copy link
Collaborator

@cmeeren Why do you need additional - before isPending in your definition?

@cmeeren
Copy link
Author

cmeeren commented Nov 26, 2021

The dash is part of the value. In the JSON:API format, it indicates that the column should be sorted descending. It should be irrelevant here.

@AlexVarchuk
Copy link
Collaborator

@cmeeren We found the problem. We'll fix it. Thank you for your help.

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

Successfully merging a pull request may close this issue.

2 participants