diff --git a/main.py b/main.py index b355017..36596c3 100644 --- a/main.py +++ b/main.py @@ -127,6 +127,9 @@ async def debug_info(request: Request): "/debug", "/docs", "/redoc", + "/api-docs", + "/api-redoc", + "/documentation", "/openapi.json", "/api/v1/auth/register", "/api/v1/auth/login", @@ -135,13 +138,54 @@ async def debug_info(request: Request): "/api/v1/matching/analyze" ], "docs_urls": { - "swagger_ui": "/docs", - "redoc": "/redoc", - "openapi_json": "/openapi.json" + "primary_swagger": "/docs", + "alternative_swagger": "/api-docs", + "primary_redoc": "/redoc", + "alternative_redoc": "/api-redoc", + "openapi_json": "/openapi.json", + "documentation_links": "/documentation" } } +# Alternative documentation endpoints to bypass routing issues +from fastapi.openapi.docs import get_swagger_ui_html, get_redoc_html +from fastapi.responses import HTMLResponse + +@app.get("/api-docs", response_class=HTMLResponse) +async def custom_swagger_ui(): + """Alternative Swagger UI endpoint""" + return get_swagger_ui_html( + openapi_url="/openapi.json", + title=f"{settings.APP_NAME} - API Documentation" + ) + +@app.get("/api-redoc", response_class=HTMLResponse) +async def custom_redoc(): + """Alternative ReDoc endpoint""" + return get_redoc_html( + openapi_url="/openapi.json", + title=f"{settings.APP_NAME} - API Documentation" + ) + +@app.get("/documentation") +async def documentation_links(): + """Documentation links endpoint""" + return { + "message": "API Documentation Available", + "service": settings.APP_NAME, + "documentation_urls": { + "primary_swagger": "/docs", + "alternative_swagger": "/api-docs", + "primary_redoc": "/redoc", + "alternative_redoc": "/api-redoc", + "openapi_schema": "/openapi.json", + "debug_info": "/debug" + }, + "note": "If /docs doesn't work, try /api-docs for Swagger UI documentation" + } + + # Add a catch-all route to log any unhandled requests @app.api_route("/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"]) async def catch_all(request: Request, path: str):