from fastapi import APIRouter, Depends from fastapi.openapi.docs import get_swagger_ui_html from fastapi.security import HTTPBasicCredentials from config import conf from auth import verify_user_pwd from typing import TYPE_CHECKING if TYPE_CHECKING: from fastapi.security import HTTPBasicCredentials router = APIRouter() @router.get("", include_in_schema=False) async def custom_swagger_ui_html( credentials: HTTPBasicCredentials = Depends(verify_user_pwd), ): return get_swagger_ui_html( openapi_url=conf.swagger.openapi_url, title=conf.swagger.title, oauth2_redirect_url=conf.swagger.oauth2_redirect_url, swagger_js_url=conf.swagger.swagger_js_url, swagger_css_url=conf.swagger.swagger_css_url, swagger_favicon_url=conf.swagger.swagger_favicon_url, )