Skip to content

Commit

Permalink
Handle starlette/templating.py:161: DeprecationWarning: The name is… (
Browse files Browse the repository at this point in the history
#1976)

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 <[email protected]>
  • Loading branch information
virajkanwade and RobbeSneyders authored Oct 23, 2024
1 parent f91b9a3 commit 20cc327
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions connexion/middleware/swagger_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 20cc327

Please sign in to comment.