swagger-api / swagger-api/swagger-ui
Spring WebFlux PathPatternParser syntax in mapping annotation is passed verbatim to the PathVariable
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
Q&A (please complete the following information)
- OS: macOS
- Browser: chrome
- Version: 110.0.5481.177
- Method of installation: maven
- Swagger-UI version: 4.15.5 (via springdoc-openapi-webflux-ui 1.6.14)
- Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
<version>2.7.8</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-webflux-ui</artifactId>
<version>1.6.14</version>
</dependency>
Example Swagger/OpenAPI definition:
n/a
Swagger-UI configuration options:
springdoc.packages-to-scan=com.example.foobar.rest
springdoc.swagger-ui.operationsSorter=alpha
springdoc.swagger-ui.tagsSorter=alpha
springdoc.swagger-ui.doc-expansion=none
springdoc.webjars.prefix=
Describe the bug you're encountering
When using the Spring 5 PathPatternParser multiple segment matching syntax (/{*path}) in a WebFlux app (maybe a regular Spring Web too if configured to use it) with a @GetMapping or @RequestMapping, the literal path variable ({*path}) is sent to the @PathVariable when invoked through Swagger UI. It works as expected from the browser address bar via a simple URL GET.
The path pattern parser syntax is defined here and more examples shown here.
Create a simple @RestController with the following method:
@GetMapping(path = "/{*path}", produces = MediaType.TEXT_PLAIN_VALUE)
public Mono<String> pathMatching(@PathVariable String path) {
return Mono.just("path value: " + path);
}
To reproduce...
Steps to reproduce the behavior:
- Go to the Swagger UI
GET /example/{*path}endpoint and clickTry it out - Click in the
pathvariable and enterfoo/bar - Click the
Executebutton - Observe that all of the
Curl,Request URL&Response bodysections show the value{*path}instead offoo/bar - Open a new browser tab
- Enter the following url (mody as needed for your project):
http://localhost:8454/example/foo/bar - Observe that the value
foo/baris shown as expected
Expected behavior
The value foo/bar should be shown in Swagger UI.
Screenshots


Additional context or thoughts
There is a workaround, of sorts. This workaround seems to point to a problem with the expected variable name.
But it's not 100% because Swagger UI insists on escaping the multiple segment path entered into the path variable, which is undesirable for this style of multiple segment path variable. See screenshots. I would expect it to be substituted verbatim without escaping in this scenario.
Though, in the end, this works because Spring unescapes the value for you, but it looks ugly in Swagger UI.
@GetMapping(path = "/{*path}", produces = MediaType.TEXT_PLAIN_VALUE)
public Mono<String> pathMatching(@Parameter(name = "*path") @PathVariable String path) {
return Mono.just("path value: " + path);
}
Additional Screenshots

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
Reproduce the WebFlux example in Swagger UI with a GET path of /{*path} and the value foo/bar. Trace the UI's path-parameter substitution and request URL generation, then verify that the generated Curl, Request URL, and response use foo/bar rather than the literal {*path} while preserving the expected multi-segment behavior.
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