From 6859e03fc6cf80b32162fec8e1a6032f529d811a Mon Sep 17 00:00:00 2001 From: Yegor Kutuzov Date: Mon, 25 Mar 2024 19:40:00 +0300 Subject: [PATCH] chore: openapi url disabled if debug mode is false --- app/api/routers.py | 4 +++- app/main.py | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/api/routers.py b/app/api/routers.py index ef7298a..5c93e13 100644 --- a/app/api/routers.py +++ b/app/api/routers.py @@ -4,10 +4,12 @@ from app.api.endpoints.botx import router as bot_router from app.api.endpoints.healthcheck import router as healthcheck_router from app.api.endpoints.swagger_rpc_execute import router as swagger_rpc_execute_router +from app.settings import settings router = APIRouter(include_in_schema=False) router.include_router(healthcheck_router) router.include_router(bot_router) -router.include_router(swagger_rpc_execute_router) +if settings.DEBUG: + router.include_router(swagger_rpc_execute_router) diff --git a/app/main.py b/app/main.py index 2f08967..a5d73ae 100644 --- a/app/main.py +++ b/app/main.py @@ -49,7 +49,10 @@ def get_application( bot = get_bot(callback_repo) - application = FastAPI() + application = FastAPI( + openapi_url="/openapi.json" if settings.DEBUG else None, + ) + application.state.bot = bot application.add_event_handler("startup", partial(startup, bot))