From 20cc327111eb98c2dc0c9e4c42a9bb2f7e076c84 Mon Sep 17 00:00:00 2001 From: Viraj Kanwade Date: Wed, 23 Oct 2024 14:06:53 -0700 Subject: [PATCH] =?UTF-8?q?Handle=20starlette/templating.py:161:=20Depreca?= =?UTF-8?q?tionWarning:=20The=20`name`=20is=E2=80=A6=20(#1976)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: starlette/templating.py:161: DeprecationWarning: The `name` is not the first parameter anymore. The first parameter should be the `Request` instance. Replace `TemplateResponse(name, {"request": request})` by `TemplateResponse(request, name)`. Changes proposed in this pull request: - - - Co-authored-by: Robbe Sneyders --- connexion/middleware/swagger_ui.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/connexion/middleware/swagger_ui.py b/connexion/middleware/swagger_ui.py index a9bded0fe..3f701bcb0 100644 --- a/connexion/middleware/swagger_ui.py +++ b/connexion/middleware/swagger_ui.py @@ -164,14 +164,15 @@ async def redirect(request): async def _get_swagger_ui_home(self, req): base_path = self._base_path_for_prefix(req) template_variables = { - "request": req, "openapi_spec_url": (base_path + self.options.openapi_spec_path), **self.options.swagger_ui_template_arguments, } if self.options.swagger_ui_config: template_variables["configUrl"] = "swagger-ui-config.json" - return self._templates.TemplateResponse("index.j2", template_variables) + return self._templates.TemplateResponse( + req, name="index.j2", context=template_variables + ) async def _get_swagger_ui_config(self, request): return StarletteResponse(