Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Paths ending with an extension aren't matched #129

Closed
dunglas opened this issue Oct 7, 2019 · 1 comment · Fixed by #210
Closed

Paths ending with an extension aren't matched #129

dunglas opened this issue Oct 7, 2019 · 1 comment · Fixed by #210

Comments

@dunglas
Copy link
Contributor

dunglas commented Oct 7, 2019

When using the router, the following definition is matched properly (the corresponding route is found):

paths:
  '/books/{id}':
    parameters:
      - schema:
          type: integer
        name: id
        in: path
        required: true
    get:
      # ...

But this doesn't:

paths:
    parameters:
      - schema:
          type: integer
        name: id
        in: path
        required: true
  '/books/{id}.json':
    get:
      # ...
@dunglas dunglas changed the title Path ending with an extension aren't matched Paths ending with an extension aren't matched Oct 7, 2019
@fenollp
Copy link
Collaborator

fenollp commented Oct 8, 2019

Looks like the path (.json) like got carried around by mistake?
Looking at

func (servers Servers) MatchURL(parsedURL *url.URL) (*Server, []string, string) {
rawURL := parsedURL.String()
if i := strings.IndexByte(rawURL, '?'); i >= 0 {
rawURL = rawURL[:i]
}
for _, server := range servers {
pathParams, remaining, ok := server.MatchRawURL(rawURL)
if ok {
return server, pathParams, remaining
}
}
return nil, nil, ""
}
I don't see what the issue would be.
Can you present a valid spec maybe along with the code you're using?

@fenollp fenollp mentioned this issue Apr 25, 2020
7 tasks
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants