0

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?

Frank
  • 5,741
  • 4
  • 28
  • 49
  • 1
    Related (or duplicate): [Swagger: wildcard path parameters](https://stackoverflow.com/q/42335178/113116), [Swagger: file path in path parameter](https://stackoverflow.com/q/40393667/113116) – Helen Jun 22 '20 at 11:41

1 Answers1

1

This is currently not possible because OpenAPI Specification does not support non-encoded slashes in path parameters. More info here:
https://github.com/OAI/OpenAPI-Specification/issues/892

Helen
  • 87,344
  • 17
  • 243
  • 314