swagger-express-middleware
swagger-express-middleware copied to clipboard
if swagger's basePath is / and endpoint paths start with /, the middleware requires requests be made with two slashes
If swagger's basepath is / and an endpoint is /some/api/endpoint, then one must access the url as //some/api/endpoint otherwise paths won't match.
+1
having the same issue
If your API is served from the root directory, then your basePath
should be empty (unset), not a forward slash. You should only set basePath
if your API is served from a subdirectory, or if all of your API endpoints start with the same path segment(s).
I ported my code from https://github.com/apigee-127/swagger-express, and its project template sets forward slash for basePath
. I eventually found the other issue which describes the solution.
Hmmm... I didn't realize Swagger Express was doing that. It's technically incorrect, per the spec, but I'll add code to Swagger Express Middleware to handle it.
Would a pull request help or are you already working on this issue? And update the swagger-server with a new version of this lib? Some Swagger specifications have this basePath with a forward slash and it would be a nice to have if it worked as is.
A PR would be greatly appreciated. I've got lots of other stuff on my plate right now, so I haven't been able to work on this project in months. :(
Hey guys, any news on this? Is there any way to handle this via middleware options?
Currently the solution is to remove the basePath
option, since it shouldn't be just a /
.