Skip to content
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

Fixed #398 FastAPI integration fails if docs are disabled. #454

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
25 changes: 14 additions & 11 deletions rollbar/contrib/fastapi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,20 @@ def get_installed_middlewares(app):
return middlewares


def has_bare_routing(app_or_router):
expected_app_routes = 4
expected_router_routes = 0

if (
isinstance(app_or_router, FastAPI)
and expected_app_routes != len(app_or_router.routes)
) or (
isinstance(app_or_router, APIRouter)
and expected_router_routes != len(app_or_router.routes)
):
def has_bare_routing(app_or_router: FastAPI | APIRouter):
if not isinstance(app_or_router, (FastAPI, APIRouter)):
return False

urls = [
getattr(app_or_router, 'openapi_url', None),
getattr(app_or_router, 'docs_url', None),
getattr(app_or_router, 'redoc_url', None),
getattr(app_or_router, 'swagger_ui_oauth2_redirect_url', None),
]

for route in app_or_router.routes:
if route is None or route.path in urls:
continue
return False

return True
Loading