From c579d14b7f9ecf8db9ab23f7902e2811dc7164c7 Mon Sep 17 00:00:00 2001 From: Akrem Abayed Date: Mon, 22 Jan 2024 15:28:42 +0100 Subject: [PATCH] add tags for openapi --- agenta-backend/agenta_backend/main.py | 39 +++++++++++++++-------- agenta-backend/agenta_backend/open_api.py | 14 ++++++++ 2 files changed, 40 insertions(+), 13 deletions(-) create mode 100644 agenta-backend/agenta_backend/open_api.py diff --git a/agenta-backend/agenta_backend/main.py b/agenta-backend/agenta_backend/main.py index 594703181a..81cb84dae8 100644 --- a/agenta-backend/agenta_backend/main.py +++ b/agenta-backend/agenta_backend/main.py @@ -21,6 +21,7 @@ health_router, ) from agenta_backend.models.db_engine import DBEngine +from agenta_backend.open_api import open_api_tags_metadata if os.environ["FEATURE_FLAG"] in ["cloud", "ee"]: from agenta_backend.commons.services import templates_manager @@ -58,7 +59,7 @@ async def lifespan(application: FastAPI, cache=True): yield -app = FastAPI(lifespan=lifespan) +app = FastAPI(lifespan=lifespan, openapi_tags=open_api_tags_metadata) allow_headers = ["Content-Type"] @@ -82,18 +83,30 @@ async def lifespan(application: FastAPI, cache=True): app.include_router(health_router.router, prefix="/health") app.include_router(user_profile.router, prefix="/profile") -app.include_router(app_router.router, prefix="/apps") -app.include_router(variants_router.router, prefix="/variants") -app.include_router(evaluation_router.router, prefix="/evaluations") -app.include_router(human_evaluation_router.router, prefix="/human-evaluations") -app.include_router(evaluators_router.router, prefix="/evaluators") -app.include_router(testset_router.router, prefix="/testsets") -app.include_router(container_router.router, prefix="/containers") -app.include_router(environment_router.router, prefix="/environments") -app.include_router(observability_router.router, prefix="/observability") -app.include_router(organization_router.router, prefix="/organizations") -app.include_router(bases_router.router, prefix="/bases") -app.include_router(configs_router.router, prefix="/configs") +app.include_router(app_router.router, prefix="/apps", tags=["Apps"]) +app.include_router(variants_router.router, prefix="/variants", tags=["Variants"]) +app.include_router( + evaluation_router.router, prefix="/evaluations", tags=["Evaluations"] +) +app.include_router( + human_evaluation_router.router, + prefix="/human-evaluations", + tags=["Human-Evaluations"], +) +app.include_router(evaluators_router.router, prefix="/evaluators", tags=["Evaluators"]) +app.include_router(testset_router.router, prefix="/testsets", tags=["Testsets"]) +app.include_router(container_router.router, prefix="/containers", tags=["Containers"]) +app.include_router( + environment_router.router, prefix="/environments", tags=["Environments"] +) +app.include_router( + observability_router.router, prefix="/observability", tags=["Observability"] +) +app.include_router( + organization_router.router, prefix="/organizations", tags=["Organizations"] +) +app.include_router(bases_router.router, prefix="/bases", tags=["Bases"]) +app.include_router(configs_router.router, prefix="/configs", tags=["Configs"]) if os.environ["FEATURE_FLAG"] in ["cloud", "ee"]: import agenta_backend.cloud.main as cloud diff --git a/agenta-backend/agenta_backend/open_api.py b/agenta-backend/agenta_backend/open_api.py new file mode 100644 index 0000000000..e71542006c --- /dev/null +++ b/agenta-backend/agenta_backend/open_api.py @@ -0,0 +1,14 @@ +open_api_tags_metadata = [ + {"name": "Variants"}, + {"name": "Evaluations"}, + {"name": "Evaluators"}, + {"name": "Apps"}, + {"name": "Human-Evaluations"}, + {"name": "Testsets"}, + {"name": "Containers"}, + {"name": "Environments"}, + {"name": "Observability"}, + {"name": "Organizations"}, + {"name": "Bases"}, + {"name": "Configs"}, +]