-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
📝 Fix docs UI asset paths to respect root_path
in Custom Docs code example
#13825
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
base: master
Are you sure you want to change the base?
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
root_path
in Custom Docs code example
@YuriiMotov: Ahh...I didn't realize there was a test already for I'll move things over to there. |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
I updated I think this is probably in a good spot now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR fixes the code examples in Custom Docs UI Static Assets (Self-Hosting).
Before changes those examples fail if we run server behind the stripping path proxy and specify root_path
as a parameter to FastAPI(root_path="/api")
. In this case app receives requests with path without root_path
prefix (/static/swagger-ui.css
instead of /api/static/swagger-ui.css
) and UI fails to load self-hosted assets.
Updated code examples are in line with the current implementations of default swagger_ui_html
(link) and redoc_html
(link) routes.
Tests look a bit complicated, the idea is explained here.
Checked line highlights - all correct.
Description
Updates docs for https://fastapi.tiangolo.com/how-to/custom-docs-ui-assets/ with better examples for handling
root_path
setups.Updates tests to validate static assets when
root_path
is used in conjunction with self-hosting swagger/redoc assets.