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.33k stars 8.92k forks source link

v5.17.7 broke path template processing #10078

Open igor-tatarnikov-idt opened 2 months ago

igor-tatarnikov-idt commented 2 months ago

Q&A (please complete the following information)

Content & configuration

Example Swagger/OpenAPI definition:

{
  "openapi": "3.0.1",
  "info": {
    "title": "repro-swagger-issue",
    "version": "1.0"
  },
  "paths": {
    "/hello/name={name}": {
      "get": {
        "tags": [
          ""
        ],
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "style": "simple",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    }
  },
  "components": { }
}

Swagger-UI configuration options:

Ran Swagger UI from Docker images v5.17.7 and v5.17.6 against locally running ASP.NET Core test web app

Describe the bug you're encountering

In v5.17.6 a path parameter gets populated with the value provided in the input. In v5.17.7+ it doesn't, the template {name} is sent in the request URL.

Expected behavior

Input path parameter value gets populated into the request URL

Screenshots

v5.17.7+ image

v5.17.6 image

Additional context or thoughts

I suppose the openapi-path-templating package is used for resolving path values (here in swagger-js). So, I thought maybe the template of type /api/hello/name={name} is no longer recognized as valid - tried to run the following locally:

const templatingEngine = require('openapi-path-templating');

const parseResult = templatingEngine.parse('/hello/name={name}');
console.log(parseResult.result.success);

console.log(templatingEngine.resolve('/hello/name={name}', { name: 'Bob'}));

Got:

true
/hello/name=Bob

So, I feel like the path template is fine. Looking at the v5.17.7 release I can't see anything related to the issue from above.

maksim-sovkov commented 1 month ago

Any updates?

sratz commented 3 weeks ago

We were also hit by the same issue and I did some analysis:

So it looks like this should be fixed in the upcoming swagger-ui version?

praveeng-nair commented 1 week ago

Any updates on this ?