swagger-api / swagger-api/swagger-ui

Global parameters not visible when referenced through other definition.

Open
#5,667 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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)
Content & configuration

Example Swagger/OpenAPI definition:

file: /openapi/openapi.yaml

openapi: "3.0.0"
info:
  version: 1.0.0
  title: Swagger Petstore
  license:
    name: MIT

paths:
  /pets/{petId}:
    $ref: ./petstore.yaml#/paths/~1pets~1{petid}

file: /openapi/petstore.yaml

openapi: "3.0.0"
info:
  version: 1.0.0
  title: Swagger Petstore
  license:
    name: MIT

paths:
  /pets/{petId}:
    parameters:
      - $ref: '#/components/parameters/PetIdPathParam'
    get:
      summary: Info for a specific pet
      operationId: showPetById
      tags:
        - pets
      parameters:
        - $ref: '#/components/parameter/PetIdPathParam'
      responses:
        '200':
          description: ok
    options:
      summary: show problem with parameter not displayed
      operationId: showPetById
      tags:
        - pets
      responses:
        '200':
          description: ok
          
components:
  parameters:
    PetIdPathParam:
      - in: path
        name: petId
        required: true
        description: The id of the pet to retrieve
        schema:
          type: string

Swagger-UI configuration options:
file: /openapi/swagger-ui-config.json

{
  "urls": [
  {
    "name": "petstore.yaml",
    "url": "/openapi/petstore.yaml"
  },
  {
    "name": "openapi.yaml",
    "url": "/openapi/openapi.yaml"
  }
  ],
  "urls.primaryName": "openapi.yaml"
}
?configUrl=/openapi/swagger-ui-config.json
Describe the bug you're encountering

I have one openapi.yaml from which I'm referencing paths from other files. When remote path has global parameter (see PetIdPathParam definition in petstore.yaml) this parameter is not visible through referenced url (e.g. when looking at openapi.yaml from swagger-ui -> in this case OPTIONS does not have param.
When I switch to petstore.yaml parameters are visible in both methods (get and options) even when options doesn't define PetIdPathParam.

To reproduce...

Steps to reproduce the behavior:
use definitions added tho this issue

Expected behavior

if global url parameters are defined, they should be displayed as if they were added directly to method

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

Start by reproducing the behavior with the provided /openapi/openapi.yaml, /openapi/petstore.yaml, and swagger-ui-config.json definitions. Compare the parameter rendering when openapi.yaml references the path with the direct petstore.yaml view; done when the global PetIdPathParam is visible through the referenced definition, including for OPTIONS.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.