Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Closed
dvitek opened this issue Jun 29, 2023 · 5 comments
Closed

Comments

@dvitek
Copy link

dvitek commented Jun 29, 2023

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!
@jrjake
Copy link

jrjake commented Sep 10, 2023

This is still an issue in 5.6.2 unfortunately.

@Pradeep-Singhh
Copy link

Pradeep-Singhh commented Sep 20, 2023

After the 5.4.1 version release the path parameters are not coming up at all even after refreshing the swagger UI with the endpoint selected. There is just a glimpse of path parameters on refresh and after that they vanish.

@char0n char0n changed the title "No parameters" with Path parameters and OAS 3.1.0 OpenAPI 3.1.0 support: "No parameters" with Path parameters and OAS 3.1.0 Nov 13, 2023
@char0n char0n self-assigned this Dec 14, 2023
@char0n
Copy link
Member

char0n commented Dec 14, 2023

Thanks to @jux, this has been addressed in https://github.com/swagger-api/swagger-js/releases/tag/v3.24.6.

@char0n
Copy link
Member

char0n commented Dec 14, 2023

Addressed in #9426

@char0n
Copy link
Member

char0n commented Dec 14, 2023

@char0n char0n closed this as completed Dec 14, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

4 participants