-
Notifications
You must be signed in to change notification settings - Fork 149
Closed
Description
While joining the paths together opts.BasePath and opts.Path, path.Join drops the trailing slash.
runtime/middleware/swaggerui.go
Line 68 in 6a17228
| pth := path.Join(opts.BasePath, opts.Path) |
So, a
/example/ui/ becomes /example/ui, and I get the error"/example/ui" not found if I try to access /example/ui/
This is a problem because other languages use the trailing / as a pattern (for example python as here http://thomaxxl.pythonanywhere.com/api/ ), and we have webserver that use swagger in different languages.
There are 2 solutions, in my opinion:
- [Preferred/Easiest] compare apples to apples and submit
r.URL.Pathtopath.Joinas well here:
runtime/middleware/swaggerui.go
Line 76 in 6a17228
if r.URL.Path == pth {
if path.Join(r.URL.Path) == pth { - do not use path.Join to join the
opts.BasePathandopts.Path, just concatenate them
I can submit a PR for option 1 if you agree.
PS. It seems go is planning to have it's own JoinPath() inside net/url, and that could fix the problem in the future:
golang/go#47005
golang/go#52074
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels