Skip to content

OpenAPI 3.1.0 support: "No parameters" with Path parameters and OAS 3.1.0 #8971

@dvitek

Description

@dvitek

Q&A (please complete the following information)

This is a regression in the recent 5.1.0 release. The bug does not exist in 5.0.0.

  • OS: windows
  • Browser: chrome
  • Version: 114.0.5735.110 (Official Build) (64-bit)
  • Method of installation: curl -L https://github.com/swagger-api/swagger-ui/archive/refs/tags/v5.1.0.tar.gz | tar xzf -
  • Swagger-UI version: 5.1.0
  • Swagger/OpenAPI version: OpenAPI 3.1.0

Content & configuration

Example Swagger/OpenAPI definition:

{
    "openapi": "3.1.0",
    "paths": {
        "/pet/{petId}": {
            "parameters": [
                {
                    "name": "petId",
                    "in": "path",
                    "schema": {
                        "type": "integer",
                        "format": "int64"
                    }
                }
            ],
            "get": {
                "summary": "Find pet by ID"
            }
        }
    }
}

Swagger-UI configuration options:

  window.ui = SwaggerUIBundle({
    url: "petstore3.json",
    dom_id: '#swagger-ui',
    deepLinking: true,
    presets: [
      SwaggerUIBundle.presets.apis,
      SwaggerUIStandalonePreset
    ],
    plugins: [
      SwaggerUIBundle.plugins.DownloadUrl
    ],
    layout: "StandaloneLayout"
  });

Describe the bug you're encountering

image

As you can see it says "No parameters" in Swagger UI. However, as you can also see, there is a parameter in the openapi document.

To reproduce...

Steps to reproduce the behavior:

  1. cd to some directory mounted by a web server. I've tried this with two unrelated webservers, so I don't think it matters which one.
  2. rm -fr swagger-ui-5.1.0
  3. curl -L https://github.com/swagger-api/swagger-ui/archive/refs/tags/v5.1.0.tar.gz | tar xzf -
  4. echo '{"openapi":"3.1.0","paths":{"/pet/{petId}":{"parameters":[{"name":"petId","in":"path","schema":{"type":"integer","format":"int64"}}],"get":{"summary":"FindpetbyID"}}}}' > swagger-ui-5.1.0/dist/petstore3.json
  5. sed -i 's|https://petstore.swagger.io/v2/swagger.json|petstore3.json|' swagger-ui-5.1.0/dist/swagger-initializer.js
  6. Navigate to http://...../swagger-ui-5.1.0/dist/ in your web browser
  7. Click the GET /pet/{petId} Operation
  8. Witness that it says "No parameters"

Expected behavior

image

I expect to see the petId parameter.

Additional context or thoughts

My openapi document differs from the vanilla petstore sample in that I have hoisted "parameters" from the GET Operation into its parent Path.

I have discovered 4 different workarounds:

  • Refresh the web browser once the address bar ends with #/default/get_pet__petId_. Suddenly there are parameters!
    • Delete the fragment from the address bar to return to the broken behavior.
  • Change "openapi" to "3.0.2". Suddenly there are parameters!
  • Move the parameter into the GET Operation instead of the Path. Suddenly there are parameters!
    • OAS 3.1.0 still allows parameters to be specified in the Path, which is sensible for path parameters, so I don't think I'm doing anything wrong w.r.t. the standard.
  • Use swagger-ui v5.0.0. Suddenly there are parameters!

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions