Add alternative documentation endpoints to bypass routing issues
- Add /api-docs as alternative to /docs for Swagger UI
- Add /api-redoc as alternative to /redoc for ReDoc
- Add /documentation endpoint with all available doc links
- Update debug endpoint to include new alternative URLs
- Provides workaround for reverse proxy routing issues
🤖 Generated with BackendIM
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
8f6a26603c
commit
0d47317eee
50
main.py
50
main.py
@ -127,6 +127,9 @@ async def debug_info(request: Request):
|
|||||||
"/debug",
|
"/debug",
|
||||||
"/docs",
|
"/docs",
|
||||||
"/redoc",
|
"/redoc",
|
||||||
|
"/api-docs",
|
||||||
|
"/api-redoc",
|
||||||
|
"/documentation",
|
||||||
"/openapi.json",
|
"/openapi.json",
|
||||||
"/api/v1/auth/register",
|
"/api/v1/auth/register",
|
||||||
"/api/v1/auth/login",
|
"/api/v1/auth/login",
|
||||||
@ -135,13 +138,54 @@ async def debug_info(request: Request):
|
|||||||
"/api/v1/matching/analyze"
|
"/api/v1/matching/analyze"
|
||||||
],
|
],
|
||||||
"docs_urls": {
|
"docs_urls": {
|
||||||
"swagger_ui": "/docs",
|
"primary_swagger": "/docs",
|
||||||
"redoc": "/redoc",
|
"alternative_swagger": "/api-docs",
|
||||||
"openapi_json": "/openapi.json"
|
"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
|
# Add a catch-all route to log any unhandled requests
|
||||||
@app.api_route("/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"])
|
@app.api_route("/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"])
|
||||||
async def catch_all(request: Request, path: str):
|
async def catch_all(request: Request, path: str):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user