Unfortunately, it is not doable. Swagger supports neither wildcards in the path, nor optional path segments, nor slashes in path parameter values. If you look at the request that swagger-ui executes for your mapping, you will see something like this:
curl -X GET "http://localhost:8080/category1/**"
The stars are not replaced, they are treated as a normal string, not as a placeholder.
I am afraid your only option is modifying the endpoint or adding a new one, e.g:
@GetMapping("/{category}/test/{document}")
@Parameter(name = "document", in = ParameterIn.PATH)
public DocumentModel fetchTest(HttpServletRequest httpServletRequest, @PathVariable("category") String category) {
return fetch(httpServletRequest, category);
}
@GetMapping("/{category}/**")
public DocumentModel fetch(HttpServletRequest httpServletRequest, @PathVariable("category") String category) {
// ...
}
If you need to, you can hide the original endpoint from the swagger-ui:
@GetMapping("/{category}/**")
@Operation(hidden = true)
public DocumentModel fetch(HttpServletRequest httpServletRequest, @PathVariable("category") String category) {
// ...
}