Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lite_bootstrap/helpers/fastapi_helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import pathlib
import typing
import warnings

from lite_bootstrap import import_checker
Expand Down Expand Up @@ -47,10 +46,13 @@ def enable_offline_docs(
redoc_url: str = app.redoc_url or "/redoc"
swagger_ui_oauth2_redirect_url: str = app.swagger_ui_oauth2_redirect_url or "/docs/oauth2-redirect"

replaced_urls = (docs_url, redoc_url, swagger_ui_oauth2_redirect_url)
app.router.routes = [
route
for route in app.router.routes
if typing.cast(Route, route).path not in (docs_url, redoc_url, swagger_ui_oauth2_redirect_url)
# Only the auto-generated docs endpoints are plain ``Route``s with a ``path``; other route
# types (e.g. FastAPI's ``_IncludedRouter``) lack ``.path`` and must be left untouched.
if not (isinstance(route, Route) and route.path in replaced_urls)
]

static_dir_path = pathlib.Path(__file__).parent.parent / "static/fastapi_docs"
Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ free-all = [
"lite-bootstrap[sentry,otl,logging,pyroscope]",
]
fastapi = [
"fastapi",
# FastAPI 0.137 introduced the internal `_IncludedRouter` route type, which
# prometheus-fastapi-instrumentator (<=8.0.0) does not handle (it reads `route.path`
# unconditionally and raises AttributeError). Cap until a fixed instrumentator ships.
# Upstream issue: https://github.com/trallnag/prometheus-fastapi-instrumentator/issues/370
"fastapi<0.137",
]
fastapi-sentry = [
"lite-bootstrap[fastapi,sentry]",
Expand Down
Loading