Task 002: add shared domain contracts

This commit is contained in:
2026-05-21 17:45:00 +03:00
parent d42f0c4392
commit a0ae06adfa
31 changed files with 4043 additions and 27 deletions
+25 -1
View File
@@ -1,10 +1,15 @@
from typing import Any
from fastapi import FastAPI
from fastapi.openapi.utils import get_openapi
from fastapi.responses import JSONResponse
from src.infrastructure.dependencies import check_dependencies
from src.domain.contracts.openapi import inject_contract_schemas
from src.presentation.routes.articles import router as articles_router
app = FastAPI(title="AI Content Pipeline Backend")
app.include_router(articles_router)
@app.get("/health")
@@ -14,6 +19,8 @@ def health() -> dict[str, str]:
@app.get("/health/dependencies")
def dependency_health() -> JSONResponse:
from src.infrastructure.dependencies import check_dependencies
dependencies = check_dependencies()
is_ok = all(status == "ok" for status in dependencies.values())
@@ -25,3 +32,20 @@ def dependency_health() -> JSONResponse:
"dependencies": dependencies,
},
)
def custom_openapi() -> dict[str, Any]:
if app.openapi_schema:
return app.openapi_schema
openapi_schema = get_openapi(
title=app.title,
version=app.version,
routes=app.routes,
)
inject_contract_schemas(openapi_schema)
app.openapi_schema = openapi_schema
return app.openapi_schema
app.openapi = custom_openapi