2025-06-03 18:58:32 +00:00

38 lines
933 B
Python

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.openapi.utils import get_openapi
from app.api.v1.routes import router as api_router
from app.api.health import router as health_router
app = FastAPI(
title="Generic REST API",
description="A FastAPI REST API with SQLite",
version="0.1.0",
docs_url="/docs",
redoc_url="/redoc",
)
# CORS middleware setup
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Include routers
app.include_router(health_router)
app.include_router(api_router, prefix="/api/v1")
# Custom OpenAPI schema endpoint
@app.get("/openapi.json", include_in_schema=False)
async def get_open_api_endpoint():
return get_openapi(
title=app.title,
version=app.version,
description=app.description,
routes=app.routes,
)