I'm creating an API to get file info which can handle paths on dynamic paths with:
@GetMapping("/api/file/info/**")
Retrieving this dynamic part is done with this method
public String getDynamicPartFromRequest(HttpServletRequest request) {
return (new AntPathMatcher()).extractPathWithinPattern(
(String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE),
(String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE));
}
This allows to retrieve these example paths:
- /api/file/info/image.jpg --> image.jpg
- /api/file/info/sub1/sub2/sub3/image.jpg --> sub1/sub2/sub3/image.jpg
So from code point of view, working perfectly as expected!
The problem is how to test/use this in Swagger UI as the "**" part can not be filled in, and the request is always made to
Request URL
https://localhost/api/file/info/**
Is there a way to tell Swagger/OpenAPI to provide an input field for the "**"-part of the URL?