Browse Source

🎨 Auto format

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

25
fastapi/openapi/docs.py

@ -2,7 +2,6 @@ import json
from typing import Annotated, Any, Optional
from annotated_doc import Doc
from fastapi.encoders import jsonable_encoder
from starlette.responses import HTMLResponse
swagger_ui_default_parameters: Annotated[
@ -119,15 +118,17 @@ def get_swagger_ui_html(
"showCommonExtensions": True,
"presets": [
"SwaggerUIBundle.presets.apis",
"SwaggerUIBundle.SwaggerUIStandalonePreset"
]
"SwaggerUIBundle.SwaggerUIStandalonePreset",
],
}
if swagger_ui_parameters:
swagger_config.update(swagger_ui_parameters)
if oauth2_redirect_url:
swagger_config["oauth2RedirectUrl"] = f"window.location.origin + '{oauth2_redirect_url}'"
swagger_config["oauth2RedirectUrl"] = (
f"window.location.origin + '{oauth2_redirect_url}'"
)
config_json = json.dumps(swagger_config, default=str)
@ -147,13 +148,13 @@ const ui = SwaggerUIBundle({config_json});'''
if init_oauth:
init_oauth_json = json.dumps(init_oauth, default=str)
html += f'''
ui.initOAuth({init_oauth_json});'''
html += f"""
ui.initOAuth({init_oauth_json});"""
html += '''
html += """
</script>
</body>
</html>'''
</html>"""
return HTMLResponse(html)
@ -217,18 +218,18 @@ def get_redoc_html(
[FastAPI docs for Custom Docs UI Static Assets (Self-Hosting)](https://fastapi.tiangolo.com/how-to/custom-docs-ui-assets/).
"""
html = f'''<!DOCTYPE html>
html = f"""<!DOCTYPE html>
<html>
<head>
<title>{title}</title>
<!-- needed for adaptive design -->
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
'''
"""
if with_google_fonts:
html += '''<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
'''
html += """<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
"""
html += f'''<link rel="shortcut icon" href="{redoc_favicon_url}">
<!--

Loading…
Cancel
Save