swagger-api / swagger-ui

Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
https://swagger.io
Apache License 2.0
26.62k stars 8.96k forks source link

Global parameters not visible when referenced through other definition. #5667

Open bilak opened 5 years ago

bilak commented 5 years ago

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

soupmatt commented 5 years ago

I'm experiencing the same thing with version 3.24.0 using from the swaggerapi/swagger-ui docker image.

alexis-puska commented 4 years ago

Same problem in angular app intégration, i updated this last week to 3.24.3 and global parameter not displayed !

"swagger-ui": "2.2.10" -> "swagger-ui-dist": "3.24.3"

Java back dependencies :

io.springfox springfox-swagger2 2.9.2
SSchwaiger commented 4 years ago

Hey!

Has there already been some investigation on this ticket?