Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Url parameters not using provided value in Swagger UI #10176

Open
akuchcik opened this issue Oct 21, 2024 · 2 comments
Open

Url parameters not using provided value in Swagger UI #10176

akuchcik opened this issue Oct 21, 2024 · 2 comments

Comments

@akuchcik
Copy link

akuchcik commented Oct 21, 2024

I'm resending conversation and issue report from https://github.com/springdoc/springdoc-openapi :

Any value provided inside the parameter input field is ignored and the resulted url only has {parameter} inside it instead of the actual value.

image

  • What version of spring-boot you are using? 3.3.4
  • What modules and versions of springdoc-openapi are you using? springdoc-openapi-starter-webmvc-ui 2.6.0

Issue occurs when using springdoc-openapi-starter-webmvc-ui with custom yaml file
Using the same file with docker image swaggerapi/swagger-ui doesn't result with this issue and works as expected

I found out that the reason for this is the "=" (equals sign) in the path.
This path works:
/data/logging-status/broker/{broker-identifier}
but this path doesn't work:
/data/logging-status/broker={broker-identifier}

I created a new spring boot application with minimal requirements https://github.com/akuchcik/springdoc-url-parameter-bug :

  • springdoc-openapi-starter-webmvc-ui 2.6.0 dependency
  • custom yaml file (which I mentioned earlier) in class path (in resources folder)
  • and OpenApiConfig class

Custom yaml file (same problem on 3.1.0 version):

openapi: 3.0.2
info:
  title: Swagger Petstore - OpenAPI 3.0
  version: 1.0.19
servers:
- url: /rests
paths:
  /pet/{petId}:
    get:
      tags:
        - pet
      parameters:
        - name: petId
          in: path
          description: ID of pet to return
          required: true
          schema:
            type: string
      responses:
        "200":
          description: successful operation
          content:
            application/xml:
              schema:
                $ref: '#/components/schemas/Pet'
            application/json:
              schema:
                $ref: '#/components/schemas/Pet'
        "400":
          description: Invalid ID supplied
        "404":
          description: Pet not found
  "/data/logging-status/broker={broker-identifier}":
    get:
      tags:
        - logging
      parameters:
        - name: broker-identifier
          in: path
          description: Id of broker
          required: true
          schema:
            type: string
      responses:
        "200":
          description: successful operation
          content:
            application/xml:
              schema:
                $ref: '#/components/schemas/Pet'
            application/json:
              schema:
                $ref: '#/components/schemas/Pet'
        "400":
          description: Invalid ID supplied
        "404":
          description: Pet not found
components:
  schemas:
    Category:
      type: object
      properties:
        id:
          type: integer
          format: int64
          example: 1
        name:
          type: string
          example: Dogs
      xml:
        name: category
    Tag:
      type: object
      properties:
        id:
          type: integer
          format: int64
        name:
          type: string
      xml:
        name: tag
    Pet:
      required:
        - name
        - photoUrls
      type: object
      properties:
        id:
          type: integer
          format: int64
          example: 10
        name:
          type: string
          example: doggie
        category:
          $ref: '#/components/schemas/Category'
        photoUrls:
          type: array
          xml:
            wrapped: true
          items:
            type: string
            xml:
              name: photoUrl
        tags:
          type: array
          xml:
            wrapped: true
          items:
            $ref: '#/components/schemas/Tag'
        status:
          type: string
          description: pet status in the store
          enum:
            - available
            - pending
            - sold
      xml:
        name: pet
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic

Reply from @bnasslahsen :
Your expected behavior is invalid.
You are declaring broker-identifier as path variable, whereas it should be declared as query parameter.

NOTE: OpenAPI defines a unique operation as a combination of a path and an HTTP method:

Answer:
if I define it as query the resulted url looks like this:
"http://localhost:8080/data/logging-status/broker={broker-identifier}?broker-identifier=test"
image

It just adds a query at the end of the url. I am not using a query as I'm not using "?" after the path. I am specifying an entry in a list.
This describing of entries/keys in a list of elements is defined in RESTCONF Protocol - RFC 8040.
When using docker image swaggerapi/swagger-ui it is working as expected.

REPLY:
@akuchcikm,

Is the OpenAPI spec correct ?
If it's the case, then it's not a sprindoc issue.
You should reach the https://github.com/swagger-api/swagger-ui/issues instead.

LINK TO THE ORIGINAL REPORTED ISSUE:
springdoc/springdoc-openapi#2764

@akuchcik
Copy link
Author

When using env variable URL instead of URLS in docker image swaggerapi/swagger-ui I get the same error, but when using springdoc that problem persists in both cases (setting url or urls in custom swagger controller).

@falbert-ptc
Copy link

Looks similar to #9979
It looks like a regression introduced in 5.17.8 and later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants