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.
Go to the Swagger UI GET /example/{*path} endpoint and click Try it out
Click in the path variable and enter foo/bar
Click the Execute button
Observe that all of the Curl, Request URL & Response body sections show the value {*path} instead of foo/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/bar is 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.
Q&A (please complete the following information)
Content & configuration
Example Swagger/OpenAPI definition:
n/a
Swagger-UI configuration options:
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:To reproduce...
Steps to reproduce the behavior:
GET /example/{*path}
endpoint and clickTry it out
path
variable and enterfoo/bar
Execute
buttonCurl
,Request URL
&Response body
sections show the value{*path}
instead offoo/bar
http://localhost:8454/example/foo/bar
foo/bar
is shown as expectedExpected 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.
Additional Screenshots