Url parameters not using provided value in Swagger UI
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.
- 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"
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: https://github.com/springdoc/springdoc-openapi/issues/2764
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).
Looks similar to https://github.com/swagger-api/swagger-ui/issues/9979 It looks like a regression introduced in 5.17.8 and later
I am encountering this behavior as well. In my case, Springdoc Swagger sends /teams/name={teamName} instead of the proper value. I see nothing in the OpenAPI spec which would prohibit using = within the URL path.