fastify / fastify-swagger-ui

Serve Swagger-UI for Fastify
MIT License
132 stars 40 forks source link

Path parameters are not shown if parameters are introduced at path level #89

Closed MikaKarjunen closed 11 months ago

MikaKarjunen commented 11 months ago

Prerequisites

Fastify version

4.23.2

Plugin version

1.9.3

Node.js version

18.17.0

Operating system

Windows

Operating system version (i.e. 20.04, 11.3, 10)

11

Description

Hard to say if this is a bug or simply missing feature but in any case path parameters are not shown if parameters are introduced at path level. 😕 If parameters-collection is moved inside operation ui works as expected. 👍 Since the path can contain multiple verbs like "put" in this case we are favouring path level.

"In OpenAPI 3.0, parameters are defined in the parameters section of an operation or path." https://swagger.io/docs/specification/describing-parameters/

This version works fine.

{
    "openapi": "3.1.0",
    "info": {
      "title": "example",
      "version": "1.0",
      "summary": "example-project"
    },
    "paths": {
      "/examples/{example_id}": {
        "get": {
          "responses": {
            "200": {
              "description": "OK",
              "content": {
                "application/json": {
                  "schema": {
                    "$ref": "#/components/schemas/Example"
                  }
                }
              }
            }
          },
          "parameters": [
            {
              "name": "example_id",
              "in": "path",
              "required": true,
              "schema": {
                "type": "string",
                "format": "uuid"
              },
              "description": "Example id"
            }
          ]
        }
      }
    }
}

Steps to Reproduce

OpenApi description to reproduce the issue.

{
    "openapi": "3.1.0",
    "info": {
      "title": "example",
      "version": "1.0",
      "summary": "example-project"
    },
    "paths": {
      "/examples/{example_id}": {
        "parameters": [
          {
            "name": "example_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Example id"
          }
        ],
        "get": {
          "responses": {
            "200": {
              "description": "OK",
              "content": {
                "application/json": {
                  "schema": {
                    "$ref": "#/components/schemas/Example"
                  }
                }
              }
            }
          }
        }
      }
    }
}

Expected Behavior

UI should render exception_id parameter before every operation in path.

mcollina commented 11 months ago

I think this looks like a Swagger UI bug. Why do you think it's relevant to this library?

MikaKarjunen commented 11 months ago

Ah. Very true. This plugin acts as a bridge between the softwares. Thanks. I wasn't thinking it through.