Browse Source

🎨 Auto format

pull/14568/head
pre-commit-ci-lite[bot] 7 months ago
committed by GitHub
parent
commit
9c592cd195
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 22
      fastapi/openapi/docs.py

22
fastapi/openapi/docs.py

@ -131,24 +131,25 @@ def get_swagger_ui_html(
const ui = SwaggerUIBundle({{ const ui = SwaggerUIBundle({{
url: '{openapi_url}', url: '{openapi_url}',
""" """
for key, value in current_swagger_ui_parameters.items(): for key, value in current_swagger_ui_parameters.items():
encoded_value = jsonable_encoder(value) encoded_value = jsonable_encoder(value)
safe_value = json.dumps(encoded_value) safe_value = json.dumps(encoded_value)
if (
if isinstance(value, str) and safe_value.startswith('"') and safe_value.endswith('"'): isinstance(value, str)
and safe_value.startswith('"')
and safe_value.endswith('"')
):
safe_value = safe_value[1:-1] # Remove aspas externas safe_value = safe_value[1:-1] # Remove aspas externas
html += f" {key}: {safe_value},\n" html += f" {key}: {safe_value},\n"
if oauth2_redirect_url: if oauth2_redirect_url:
html += f"oauth2RedirectUrl: window.location.origin + '{oauth2_redirect_url}',\n" html += (
f"oauth2RedirectUrl: window.location.origin + '{oauth2_redirect_url}',\n"
)
html += """ presets: [ html += """ presets: [
SwaggerUIBundle.presets.apis, SwaggerUIBundle.presets.apis,
SwaggerUIBundle.SwaggerUIStandalonePreset SwaggerUIBundle.SwaggerUIStandalonePreset
@ -156,7 +157,6 @@ def get_swagger_ui_html(
}) })
""" """
if init_oauth: if init_oauth:
init_oauth_json = json.dumps(jsonable_encoder(init_oauth)) init_oauth_json = json.dumps(jsonable_encoder(init_oauth))
html += f""" html += f"""

Loading…
Cancel
Save