-
-
Notifications
You must be signed in to change notification settings - Fork 302
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
openapi: method with same URL and different path parameters name result in 405 #948
Comments
So as I was investigating further, I found out that the issue #429 was fixed by 78fb112. (change |
So I have an idea that this could be resolved by renaming the path to normalize param names. This would create same entry in the routing table and it could resolve the issue. It could be "injecting" I can look into this on the weekend and send PR to resolve this, but a small guidance would be appreciated. I tried inserting poem/poem-openapi-derive/src/utils.rs Lines 127 to 132 in 658f7de
Then I tried changing this poem/poem-openapi-derive/src/api.rs Lines 278 to 282 in 658f7de
like this let param_name = format!("param{i}"); but that didn't work either. poem/poem-openapi-derive/src/api.rs Lines 351 to 355 in 658f7de
to extract from the param{i} while keeping the openapi param name in meta and the variable name in method signature
|
This commits add automatic renaming of path parameters in route table and param extraction. When having two same routes with different method and different param names, it resulted in one of them returning 405 instead of firing the handler. This fix is somewhat janky, because it checks if the extracted param type is `Path` and then it renames is to `param{i}`. There could be more edge cases down the line, but for now it passess all the tests. Fixes: poem-web#948 Related: poem-web#429 Signed-off-by: Robin Ilyk <[email protected]>
Expected Behavior
Both endpoints should return 200 OK
Actual Behavior
When having two endpoints on the same URL with different path parameters names result in one of them returning 200 OK and the other one 405 Method Not Allowed. It seems that the order of the functions does not matter, the GET method always gets the 405.
This issue is related to #429 but since that issue is closed and I cannot reopen it I'am opening a new one.
Steps to Reproduce the Problem
I have created a minimal reproduction of this issue repository: https://github.com/robko23/poem-openapi-routing-issue/tree/master
Specifications
The text was updated successfully, but these errors were encountered: