Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

Add Open API prefix route - correct docs behind reverse proxy#26

Merged
tiangolo merged 11 commits intofastapi:masterfrom
kabirkhan:master
Feb 14, 2019
Merged

Add Open API prefix route - correct docs behind reverse proxy#26
tiangolo merged 11 commits intofastapi:masterfrom
kabirkhan:master

Conversation

@kabirkhan
Copy link

I run a lot of services in Kubernetes usingAmbassador as my API Gateway. Ambassador allows you to configure a route prefix for each one of your services and then it handles ingress and routing to the initial service. This PR enables me to configure the same prefix I use with Ambassador in the Swagger UI API docs.

Example:

prefix='/service1'app=FastAPI(openapi_prefix=prefix)@app.get('/something')=>SwaggerRoute (GET-/service1/something)

NOTE: This is not the same as using the include_router method and adding a prefix.
This is meant only to rewrite the route paths in the Swagger UI.

BTW: Awesome Project! Thanks so much for your work on this, I'm using fastapi a ton these days.

tiangolo, maganaluis, kurianbenoy-aot, nipunsadvilkar, ilhamfp, arjitb, tzirtzi, mrtolkien, anhntt96, waghydjemy, and 15 more reacted with hooray emojiASLamperez, hungaioz, and nvenegas-oliva reacted with heart emoji
@codecov
Copy link

codecovbot commentedFeb 10, 2019
edited
Loading

Codecov Report

Merging#26 intomaster willnot change coverage.
The diff coverage is100%.

Impacted file tree graph

@@          Coverage Diff          @@##           master    #26   +/-   ##=====================================  Coverage     100%   100%           =====================================  Files          95     99    +4       Lines        2484   2582   +98     =====================================+ Hits         2484   2582   +98
Impacted FilesCoverage Δ
fastapi/openapi/utils.py100% <100%> (ø)⬆️
...tutorial/test_sub_applications/test_tutorial001.py100% <100%> (ø)
fastapi/applications.py100% <100%> (ø)⬆️
docs/src/sub_applications/tutorial001.py100% <100%> (ø)
tests/test_jsonable_encoder.py100% <0%> (ø)⬆️
fastapi/encoders.py100% <0%> (ø)⬆️
tests/test_datetime.py
docs/src/sql_databases/tutorial001.py100% <0%> (ø)
tests/test_datetime_custom_encoder.py100% <0%> (ø)
... and2 more

Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last update92c825b...6f7c4cd. Read thecomment docs.

@kabirkhankabirkhan changed the titleAdd Open API prefix routeAdd Open API prefix route - correct docs behind reverse proxyFeb 10, 2019
@kabirkhan
Copy link
Author

Fix for#15

@kabirkhan
Copy link
Author

@tiangolo would you mind taking a look at this?
I'm happy to add documentation once you review the approach.
I'd love to use the official pypi package rather than my own Github version for a production service at work.
Thanks

@tiangolotiangolo merged commit0ea0d0e intofastapi:masterFeb 14, 2019
@tiangolo
Copy link
Member

Great job@kabirkhan ! Thanks a lot. 🎉 🌮

I added tests and docs on top of your work.

for a production service at work

Are you using it at MS? That's very cool!

tiangolo added a commit that referenced this pull requestFeb 14, 2019
@tiangolo
Copy link
Member

I just released0.4.0 including this PR. You should be able to use it now. 🚀

Also, the relevant docs are here:https://fastapi.tiangolo.com/tutorial/sub-applications-proxy/

@kabirkhan
Copy link
Author

@tiangolo yep I'm actually planning to use it for all of my team's ML services at Microsoft. Some of them are getting integrated into the core Windows product and some Office products.

Great job with the documentation too!

tiangolo, cyinwei, monkut, renanaugustom, adyomin, urbanoTF, mwanjajoel, plicatibu, kevlarr, xingheng, and 93 more reacted with thumbs up emojiinex550, bestenevoy, torkashvand, pavloko, its0x08, hdwatts, arunstar, danish-wani, willianantunes, schneiderfelipe, and 15 more reacted with hooray emojicyinwei, adyomin, ThejanW, kevlarr, emr-arvig, ems-ja, ilias-ant, edison12a, DatCanCode, tanaysoni, and 43 more reacted with heart emojitiangolo, lexyurk, PritishSehzpaul, CathalMullan, nkonin, adyomin, Congee, wojtek-fliposports, urbanoTF, okeyokoro, and 47 more reacted with rocket emoji

@tiangolo
Copy link
Member

That's awesome! 🌮 🍰 🚀

May I quote it (that you at MS are using FastAPI)?

Ankur-singh, aurthurm, binbjz, felipe-flex, ALee008, curtwagner1984, nipunsadvilkar, noahabe, miguelms95, dxphilo, and 3 more reacted with thumbs up emojiglarrain, Solid7, edco29, its0x08, tavakoli1020, asaf-kali, wereii, willianantunes, jly36963, binbjz, and 7 more reacted with hooray emoji

@kabirkhan
Copy link
Author

Yeah, go for it!

tiangolo, cesarandreslopez, PritishSehzpaul, rinaldo-rex, renanaugustom, adyomin, keshon, Congee, prostomarkeloff, emr-arvig, and 24 more reacted with thumbs up emojiglarrain, willianantunes, Mitra-Electronics, jly36963, felipe-flex, nipunsadvilkar, hungaioz, and dxphilo reacted with hooray emoji

@sm-Fifteen
Copy link
Contributor

I know this is an old issue/PR, but shouldn'troot_path be used instead of adding a custom parameter to the application?root_path is already the intended mechanism for routing under a mounted subapplication and what Uvicorn and the ASGI spec in general uses to tell the root application what its URL prefix is (it is ignored when routing, but must be taken into account when reconstructing URLs). FastAPIcurrently does not acknowledgeroot_path in its API documentation, onlyopenapi_prefix, which means the routes specified by the API doc and the ones that are actually understood by the application will not match unless the value ofroot_path is also passed asopenapi_prefix when creating the FastAPI application.

Rawk reacted with thumbs up emoji

@luckydonald
Copy link

Huh, sounds about right.@sm-Fifteen you may open a new issue for that.

@tiangolo
Copy link
Member

Yeap@sm-Fifteen, I just merged#1199 addressingroot_path 🚀

binbjz reacted with hooray emoji

@jkoech
Copy link

@tiangolo seems the link to theprefix route docs is broken. Perhaps did the docs move?

I just released0.4.0 including this PR. You should be able to use it now. 🚀

Also, the relevant docs are here:https://fastapi.tiangolo.com/tutorial/sub-applications-proxy/

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@kabirkhan@tiangolo@sm-Fifteen@luckydonald@jkoech

[8]ページ先頭

©2009-2026 Movatter.jp