Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Unable to distinguish between ""Path was not found" and "Path doesn't support the HTTP method" in certain cases #308

Open
joshi-mohit opened this issue Feb 26, 2021 · 3 comments

Comments

@joshi-mohit
Copy link

In case the api has path parameters the FindRoute is unable to distinguish between "Path not found" and "Path doesn't support the HTTP method". Seems becasue of the way call "root.Match(method + " " + remainingPath)" and subsequently "swagger.Paths[remainingPath]"
Is this understanding correct ? If so is there any plan of fixing this
.... either the root.Match has to be without "method" and method later validated in pathItem.GetOperation (anyways being done).

@fenollp
Copy link
Collaborator

fenollp commented Feb 28, 2021

Note that I should be dusting off #210 soon but this PR suffers the issue you mention.
I am not aware of cases that make these errors indistinguishable in the current API. Do you have an example spec and requests that would show this? thanks

@joshi-mohit
Copy link
Author

For example in spec if we have an api like "/api/cards" which is only supported for "get" and in case a post is sent curl -X POST http://server-name/api/cards" is sent it reports as "Path doesn't support the HTTP method" but if the api is like "/api/cards/{card-id}" then for the traffic curl -X POST http://server-name/api/cards/10" it gets reported as "route not found"

@fenollp
Copy link
Collaborator

fenollp commented Mar 1, 2021

I understand you'd rather get a badmethod in the second case, correct? So you would prefer a triplet of errors: "bad method", "bad path" and "bad method and path"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants