From f5a44424986617c1d0df52a9f3ab72e0f2ddd90a Mon Sep 17 00:00:00 2001 From: Karis N <4590565+karisN@users.noreply.github.com> Date: Wed, 17 Jan 2024 16:04:18 -0600 Subject: [PATCH 1/2] Allow to serve swagger ui as index --- connexion/middleware/swagger_ui.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/connexion/middleware/swagger_ui.py b/connexion/middleware/swagger_ui.py index a9bded0fe..65052b797 100644 --- a/connexion/middleware/swagger_ui.py +++ b/connexion/middleware/swagger_ui.py @@ -151,12 +151,12 @@ async def redirect(request): url += "/" return RedirectResponse(url=url) - self.router.add_route(methods=["GET"], path=console_ui_path, endpoint=redirect) + self.router.add_route(methods=["GET"], path=console_ui_path or "/", endpoint=redirect) # this route will match and get a permission error when trying to # serve index.html, so we add the redirect above. self.router.mount( - path=console_ui_path, + path=console_ui_path or "/", app=StaticFiles(directory=str(self.options.swagger_ui_template_dir)), name="swagger_ui_static", ) From aa72de2b6158561425a10053438d004a0950b574 Mon Sep 17 00:00:00 2001 From: Karis N <4590565+karisN@users.noreply.github.com> Date: Wed, 17 Jan 2024 16:04:52 -0600 Subject: [PATCH 2/2] Update test --- tests/api/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/api/conftest.py b/tests/api/conftest.py index 9249e6126..917f6876f 100644 --- a/tests/api/conftest.py +++ b/tests/api/conftest.py @@ -30,7 +30,7 @@ def swagger_ui_app(app_class): app_class=app_class, spec_file=OPENAPI3_SPEC, validate_responses=True, - swagger_ui_options=SwaggerUIOptions(spec_path="/spec.json"), + swagger_ui_options=SwaggerUIOptions(spec_path="/spec.json", swagger_ui_path="/"), )