diff --git a/fastapi/openapi/docs.py b/fastapi/openapi/docs.py index 69473d19c..0880defdd 100644 --- a/fastapi/openapi/docs.py +++ b/fastapi/openapi/docs.py @@ -114,45 +114,49 @@ def get_swagger_ui_html( if swagger_ui_parameters: current_swagger_ui_parameters.update(swagger_ui_parameters) + html_swagger_ui_parameters = "\n ".join( + [ + f"{json.dumps(key)}: {json.dumps(jsonable_encoder(value))}," + for key, value in current_swagger_ui_parameters.items() + ] + ) + html_oauth2_redirect_url = ( + f"oauth2RedirectUrl: window.location.origin + '{oauth2_redirect_url}'," + if oauth2_redirect_url + else "" + ) + init_oauth_html = ( + f"ui.initOAuth({json.dumps(jsonable_encoder(init_oauth))})" + if init_oauth + else "" + ) + html = f""" -
- - -