-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
In patched_get_swagger_ui_html the urls only reference self.app.docs_url. This works fine until the app itself is mounted under another app. When this occurs the mounted app gets the base path passed to it via root_path.
IE:
def create_app() -> FastAPI:
main_app = FastAPI(...)
app = FastAPI(...)
StandaloneDocs(app)
app.include_router(myroute1, prefix='myroute1')
app.include_router(myroute2, prefix='myroute2')
main_app,mount("/myapp1", app)
return main_appIn the above case, the full docs url is probably /myapp1/docs, but it then will try to read its static assets from /docs.
To fix this, patched_get_swagger_ui_html should prefix the passed urls to get_swager_ui_html with the apps current root_path.
Something like:
def patched_get_swagger_ui_html(*args, **kwargs):
return get_swagger_ui_html(
*args,
**kwargs,
swagger_favicon_url=swagger_favicon_url,
swagger_css_url=f"{self.app.root_path}{self.app.docs_url}/swagger-ui.css",
swagger_js_url=f"{self.app.root_path}{self.app.docs_url}/swagger-ui-bundle.js",
)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels