swagger-ui icon indicating copy to clipboard operation
swagger-ui copied to clipboard

Only first path parameter is replaced in "Try it out"

Open afdaniele opened this issue 1 year ago • 2 comments

Q&A (please complete the following information)

  • OS: Linux (Ubuntu 22.04)
  • Browser: Chrome
  • Version: 124.0
  • Method of installation: dist assets
  • Swagger-UI version: 5.17.7
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

Example Swagger/OpenAPI definition:

{
    "openapi": "3.0.3",
    "info": {
        "title": "My API",
        "version": "1.0",
        "description": "My API description"
    },
    "paths": {
      "/api/v1/docker/image/metadata/{registry}/{organization}/{repository}/{tag}/latest/": {
        "get": {
            "operationId": "docker/image/metadata/latest",
            "description": "Get the latest metadata of a docker image",
            "summary": "Get latest Image Metadata",
            "parameters": [
                {
                    "in": "path",
                    "name": "registry",
                    "schema": {
                        "type": "string"
                    },
                    "required": true
                },
                {
                    "in": "path",
                    "name": "organization",
                    "schema": {
                        "type": "string"
                    },
                    "required": true
                },
                {
                    "in": "path",
                    "name": "repository",
                    "schema": {
                        "type": "string"
                    },
                    "required": true
                },
                {
                    "in": "path",
                    "name": "tag",
                    "schema": {
                        "type": "string"
                    },
                    "required": true
                }
            ],
            "tags": [
                "Docker"
            ],
            "responses": {
                "200": {
                    "description": "No response body"
                }
            }
        }
      }
  }
}

Describe the bug you're encountering

The path defines 4 parameters, when the API endpoint is tested using the "Try it out" button, only the first parameter is replaced, the others are left as placeholders (see image below).

To reproduce...

Steps to reproduce the behavior:

  1. Point an instance of swagger-ui (default configuration and options) to the OpenAPI description above;
  2. Click on 'Try it out' for the only endpoint defined;
  3. Populate the 4 parameter values;
  4. Click on "Execute"
  5. See how only the first parameter is replaced with the given value;

Expected behavior

All parameters should be replaced in the endpoint's path.

Screenshots

image

afdaniele avatar May 10 '24 22:05 afdaniele

I can confirm I am seeing this and rolling back to 5.17.6 restores it to working correctly.

dfad1469 avatar May 11 '24 00:05 dfad1469

@dfad1469 Thanks. I confirm that the problem is not present in v5.17.6.

image

afdaniele avatar May 11 '24 02:05 afdaniele

Addressed in https://github.com/swagger-api/swagger-ui/pull/9927 with a swagger-client change: https://github.com/swagger-api/swagger-js/pull/3511

glowcloud avatar May 13 '24 06:05 glowcloud

Released in https://github.com/swagger-api/swagger-ui/releases/tag/v5.17.8

char0n avatar May 13 '24 07:05 char0n