🐛 Fix support for path parameters in WebSockets#3879
Conversation
917e0a9 to
9987d03
Compare
9987d03 to
47f01da
Compare
adam-tokarski
left a comment
There was a problem hiding this comment.
Care to add some tests for that?
47f01da to
2209807
Compare
Sure, let me know what you think. |
2209807 to
c81c878
Compare
adam-tokarski
left a comment
There was a problem hiding this comment.
Generally LGTM, but personally I'd
- add more tests for not so happy paths, e.g.
"/path/{param::}"or"/path:smth/{param}" - introduce kind of parametrized (if available here), but it would not change too much
c81c878 to
7f1b37d
Compare
Done.
|
6216d8d to
23bf8ee
Compare
|
@adam-tokarski do you think this can be merged? |
If there are not any edge cases for which it could break anything I would say - yes, why not. |
|
I don't see any edge cases. What's the next step to have this PR in? |
|
The only person that can merge is @tiangolo he'll take a look at it soon |
|
@tiangolo do you think this can go in? We are currently monkey-patching the change in Jupyter. |
23bf8ee to
d460d06
Compare
Codecov Report
@@ Coverage Diff @@
## master #3879 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 535 535
Lines 13825 13838 +13
=========================================
+ Hits 13825 13838 +13
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
|
📝 Docs preview for commit 6552462 at: https://628205635239266587b6e591--fastapi.netlify.app |
|
The Jupyter server still needs to monkey-patch FastAPI, is there any chance this change could go in? |
|
What's this for? |
|
Thanks for chiming in @Kludex! @app.websocket("/files/{file_path:path}")
async def websocket_endpoint(websocket: WebSocket, file_path):
... |
|
I'll check later, but if you can answer "why this is not needed on the HTTP methods?" would be helpful. |
|
Also, just to set the expectations... I don't have merge rights. 👀 |
6552462 to
f1afa0d
Compare
No worries, it's already great to have your feedback.
Your question made me revisit the issue, and it turns out that there is a better fix. |
|
📝 Docs preview for commit f1afa0d at: https://630f2f2d4b042e7bbc6f2c70--fastapi.netlify.app |
|
Now it makes more sense. 👍 A test checking that query and path params can be passed as expected might be a good idea. 👀 |
👍 |
|
📝 Docs preview for commit 7c7c76e at: https://630f5c1603e32307504c07f3--fastapi.netlify.app |
|
This makes sense. 👍 Thanks @davidbrochart 🙏 |
|
Awesome, thank you @davidbrochart! 🤓 It's so exciting you are using FastAPI in some part of Jupyter! Also thanks everyone for the help here! 🚀 This will be available in the next release, in some hours (the current is |
Because a path can look like
/files/{file_path:path}, we need to strip the type (e.g.:path) of the parameter.