swagger-api / swagger-api/swagger-ui
Url parameters not using provided value in Swagger UI
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked minimal Spring Boot reproduction and its custom OpenAPI YAML, then compare the generated URL with the swaggerapi/swagger-ui Docker image behavior. Determine whether a path template containing '=' should substitute the supplied value under the relevant OpenAPI behavior; done means the expected URL behavior is fixed or the limitation is clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100