From e6529afa79ab5309fdf1f9a1d514d2a9b80b995d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Thu, 18 Dec 2025 17:21:36 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Auto=20format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fastapi/openapi/docs.py | 57 +++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/fastapi/openapi/docs.py b/fastapi/openapi/docs.py index f7d8b6d50..b71adafee 100644 --- a/fastapi/openapi/docs.py +++ b/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,18 +118,20 @@ 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) - + html = f''' @@ -144,17 +145,17 @@ def get_swagger_ui_html( -''' - +""" + return HTMLResponse(html) @@ -216,20 +217,20 @@ def get_redoc_html( Read more about it in the [FastAPI docs for Custom Docs UI Static Assets (Self-Hosting)](https://fastapi.tiangolo.com/how-to/custom-docs-ui-assets/). """ - - html = f''' + + html = f""" {title} -''' - +""" + if with_google_fonts: - html += ''' -''' - + html += """ +""" + html += f'''