Skip to content

When a path contains special chars, path parameters will not be replaced #10538

@fhurlbrink

Description

@fhurlbrink

Q&A

  • Swagger-UI version: 5.19.0 (current versions, like on editor.swagger.io and editor-next.swagger.io)
  • Swagger/OpenAPI version: OpenAPI 3.1.0

Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.1.0
info:
  title: primes.org
  description: A prime number API
  contact:
    name: Florian Hurlbrink
    url: https://florian.hurlbrink.name
    email: [email protected]
  version: 1.0.0
servers:
  - url: https://primes.org
    description: Generated server url
paths:
  /π/{x}:
    get:
      tags:
        - root-rest-controller
      summary: Prime-counting function
      description: Returns quantity of prime numbers less than or equal a specified number
      operationId: pi
      parameters:
        - name: x
          in: path
          description: Number to be used as upper border. The quantity of prime numbers less or equal to this border will be returned
          required: true
          schema:
            type: number
            format: double
          example: 10.3
      responses:
        '200':
          description: Quantity of prime numbers less than or equal the specified number
          content:
            application/json:
              schema:
                type: integer
                format: int64
              example: 4
        '404':
          description: Specified number exceeds boundaries
  /pi/{x}:
    get:
      tags:
        - root-rest-controller
      summary: Prime-counting function
      description: Returns quantity of prime numbers less than or equal a specified number
      operationId: pi_1
      parameters:
        - name: x
          in: path
          description: Number to be used as upper border. The quantity of prime numbers less or equal to this border will be returned
          required: true
          schema:
            type: number
            format: double
          example: 10.3
      responses:
        '200':
          description: Quantity of prime numbers less than or equal the specified number
          content:
            application/json:
              schema:
                type: integer
                format: int64
              example: 4
        '404':
          description: Specified number exceeds boundaries

Describe the bug you're encountering

When a path contains special chars, path parameters will not be replaced

To reproduce...

Steps to reproduce the behavior:

  1. Load the Example Swagger/OpenAPI definition into editor-next.swagger.io

  2. Open the /pi/{x} method and click on "Try it out"

  3. Type 127 as parameter x

  4. Click "Execute"

  5. The URL https://primes.org/pi/127 will be called. Result 31 appears as intented.

  6. Open the /π/{x} method (which contains the special char π) and click on "Try it out"

  7. Type 127 as parameter x

  8. Click "Execute"

  9. The URL https://primes.org/π/{x} will be called. Result is bad request. (Correct behaviour should be: The URL https://primes.org/π/127 should be called. Result 31 should appear.)

The problem appears not only in the Swagger Editor(s), also in the normal Swagger UI without editor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions