1

I have an asp.net-core project that acts as a proxy to different other services.

So, a user would send a GET-request to <myproxy>/someservice/foo/bar/baz, where my proxy would send a request to someservice/foo/bar/baz, log the request and result, and return the answer to the end-user. I've implemented this as an endpoint annotated with [Route("{servicename}/{**subPath}")], and it works fine.

However, when my openAPI/swagger-UI page is generated, the subPath-parameter is seen as one parameter, and when I fill in foo/bar/baz in the field for subPath, this is url-encoded by swagger.

So, when I try to send the request <myproxy>/someservice/foo/bar/baz, what swagger actually sends is <myproxy>/someservice/foo%2Fbar%2Fbaz which breaks everything (it does get passed along, but to someservice/foo%2Fbar%2Fbaz giving a 404.

How do I tell swagger to not url-encode this catch-all parameter?

3
  • OpenAPI Specification (and, by extension, OpenAPI-based tools like Swagger UI) currently does not support slashes in path parameters. See Swagger: file path in path parameter and Swagger: wildcard path parameters. Commented May 22 at 9:19
  • 1
    Can't your proxy URL-decode foo%2Fbar%2Fbaz, before it passes the request on? Commented May 22 at 9:55
  • @C3Roe That feels like a hack. It's just the swagger-UI that's not doing what I want, but the proxy itself is behaving exactly as I want it to. I don't want GET myproxy/someservice/foo%2Fbar%2Fbaz to give a result, I just want to be able to send (in the swagger-ui) to send a request GET myproxy/someservice/foo/bar/baz. Also, decoding could lead to problems in the future if one of my services actually expects something like /foo/{id}, and id could include percent-signs Commented May 22 at 11:57

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.