swagger-api / swagger-api/swagger-ui

In Swagger Editor, UI Docs pane display for header parameters is incorrect

Open
#7,741 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cat: try-it-out type: bug
Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Q&A (please complete the following information)
  • OS: [macOS Big Sur 11.6.2]
  • Browser: [Chrome Version 97.0.4692.71]
  • Version: [Online editor]
  • Method of installation: [cloud-based]
  • Swagger-UI version: [most current]
  • Swagger/OpenAPI version: [OpenAPI 3.0]
Content & configuration
  1. Open the Swagger online system.
  2. Create a new copy of the PetStore example and edit it. Ensure that the Editor, Nav, and UI Docs are visible.
  3. Edit the definition of GET /pet/findByStatus.
  4. Add the following query parameter definition to the parameters section. This definition is supposed to describe an optional query parameter that, if used, expands into one or two query entries encoded on the URI:
        - name: userParam
          in: query
          description: Test multiple occurrence of parameter
          required: false
          explode: true
          schema:
            type: array
            items:
              type: string
              enum:
              - creator
              - lastUpdatedBy
            uniqueItems: true

If you set the query parameter status to available the following URIs are valid:

The following URIs are not valid.

Swagger-UI configuration options:
N/A

Describe the bug you're encountering
To reproduce...

Steps to reproduce the behavior:

  1. Open the Swagger online system.
  2. Create a new copy of the PetStore example and edit it. Ensure that the Editor, Nav, and UI Docs panes are visible.
  3. Edit the definition of GET /pet/findByStatus.
  4. Add the query parameter specified in Content & Configuration to the parameters attribute of GET /pet/findByStatus
  5. In the UI Docs pane, expand GET pet/findByStatus.
  6. Look at the options available for userParam.
  7. One of the available options is --.
  8. Click Try it out.
  9. Select status available and userParam --, then click Execute.
  10. The cURL (bash) tab displays the following URI: https://petstore.swagger.io/v2/pet/findByStatus?status=available&userParam=. This is an invalid URI.
Expected behavior

Swagger Editor should not display the -- option in the list of options for userParam. There should be no way to create the URI https://petstore.swagger.io/v2/pet/findByStatus?status=available&userParam=.

Screenshots
Additional context or thoughts

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the PetStore example in the Swagger Editor, focusing on the UI Docs pane's parameter options and the Try it out flow for GET /pet/findByStatus. Inspect how the optional array parameter is represented, then verify that the -- option is absent and execution never generates a URI with an empty userParam value.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, openapi
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.