88 lines
2.4 KiB
Python
88 lines
2.4 KiB
Python
"""Main router for v1 endpoints."""
|
|
|
|
from fastapi import APIRouter
|
|
from fastapi.responses import HTMLResponse
|
|
|
|
from app.core.logging import get_logger
|
|
from app.schemas.common import HealthResponse
|
|
|
|
router = APIRouter()
|
|
|
|
logger = get_logger(__name__)
|
|
|
|
|
|
@router.get("/health")
|
|
def health() -> HealthResponse:
|
|
"""Health check endpoint."""
|
|
logger.info("Health check endpoint accessed")
|
|
return HealthResponse(status="healthy")
|
|
|
|
|
|
@router.get("/docs/scalar", response_class=HTMLResponse)
|
|
def scalar_docs() -> HTMLResponse:
|
|
"""Serve the API documentation using Scalar."""
|
|
return """
|
|
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<title>API Documentation - Scalar</title>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
</head>
|
|
<body>
|
|
<script
|
|
id="api-reference"
|
|
data-url="http://localhost:8000/api/openapi.json"
|
|
src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>
|
|
</body>
|
|
</html>
|
|
"""
|
|
|
|
|
|
@router.get("/docs/rapidoc", response_class=HTMLResponse)
|
|
async def rapidoc_docs() -> HTMLResponse:
|
|
"""Serve the API documentation using Rapidoc."""
|
|
return """
|
|
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<title>API Documentation - Rapidoc</title>
|
|
<meta charset="utf-8">
|
|
<script type="module" src="https://unpkg.com/rapidoc/dist/rapidoc-min.js"></script>
|
|
</head>
|
|
<body>
|
|
<rapi-doc
|
|
spec-url="http://localhost:8000/api/openapi.json"
|
|
theme="dark"
|
|
render-style="read">
|
|
</rapi-doc>
|
|
</body>
|
|
</html>
|
|
"""
|
|
|
|
|
|
@router.get("/docs/elements", response_class=HTMLResponse)
|
|
async def elements_docs() -> HTMLResponse:
|
|
"""Serve the API documentation using Stoplight Elements."""
|
|
return """
|
|
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta
|
|
name="viewport"
|
|
content="width=device-width, initial-scale=1, shrink-to-fit=no"
|
|
>
|
|
<title>API Documentation - elements</title>
|
|
<script src="https://unpkg.com/@stoplight/elements/web-components.min.js"></script>
|
|
<link rel="stylesheet" href="https://unpkg.com/@stoplight/elements/styles.min.css">
|
|
</head>
|
|
<body>
|
|
<elements-api
|
|
apiDescriptionUrl="http://localhost:8000/api/openapi.json"
|
|
router="hash"
|
|
/>
|
|
</body>
|
|
</html>
|
|
"""
|