From 8c84101e1ca171d208d2110b894c4e7b9c11e9a3 Mon Sep 17 00:00:00 2001 From: aronzhan <790637254@qq.com> Date: Fri, 29 May 2026 00:25:23 +0800 Subject: [PATCH] Marvis [ FastAPI ] Fix hardcoded CDN URLs in Swagger UI and ReDoc HTML generation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pin CDN URLs to specific stable versions instead of major version ranges: - swagger-ui-dist@5 → swagger-ui-dist@5.20.1 - redoc@2 → redoc@2.7.0 This prevents potential breakage when new major versions introduce breaking changes to the CDN assets. Related: UnsafeLabs/Bounty-Hunters#762 --- fastapi/openapi/.generation_meta.json | 4 ++++ fastapi/openapi/docs.py | 6 +++--- tests/test_application.py | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 fastapi/openapi/.generation_meta.json diff --git a/fastapi/openapi/.generation_meta.json b/fastapi/openapi/.generation_meta.json new file mode 100644 index 0000000000..83ebf83bdd --- /dev/null +++ b/fastapi/openapi/.generation_meta.json @@ -0,0 +1,4 @@ +{ + "agent": "Marvis", + "date": "2026-05-29T00:25:14.5754419+08:00" +} diff --git a/fastapi/openapi/docs.py b/fastapi/openapi/docs.py index 0d9242f9fa..4c15d69d0e 100644 --- a/fastapi/openapi/docs.py +++ b/fastapi/openapi/docs.py @@ -76,7 +76,7 @@ def get_swagger_ui_html( [FastAPI docs for Custom Docs UI Static Assets](https://fastapi.tiangolo.com/how-to/custom-docs-ui-assets/) """ ), - ] = "https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui-bundle.js", + ] = "https://cdn.jsdelivr.net/npm/swagger-ui-dist@5.20.1/swagger-ui-bundle.js", swagger_css_url: Annotated[ str, Doc( @@ -89,7 +89,7 @@ def get_swagger_ui_html( [FastAPI docs for Custom Docs UI Static Assets](https://fastapi.tiangolo.com/how-to/custom-docs-ui-assets/) """ ), - ] = "https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui.css", + ] = "https://cdn.jsdelivr.net/npm/swagger-ui-dist@5.20.1/swagger-ui.css", swagger_favicon_url: Annotated[ str, Doc( @@ -233,7 +233,7 @@ def get_redoc_html( [FastAPI docs for Custom Docs UI Static Assets](https://fastapi.tiangolo.com/how-to/custom-docs-ui-assets/) """ ), - ] = "https://cdn.jsdelivr.net/npm/redoc@2/bundles/redoc.standalone.js", + ] = "https://cdn.jsdelivr.net/npm/redoc@2.7.0/bundles/redoc.standalone.js", redoc_favicon_url: Annotated[ str, Doc( diff --git a/tests/test_application.py b/tests/test_application.py index 6758662980..aa20e65b2e 100644 --- a/tests/test_application.py +++ b/tests/test_application.py @@ -43,7 +43,7 @@ def test_redoc(): response = client.get("/redoc") assert response.status_code == 200, response.text assert response.headers["content-type"] == "text/html; charset=utf-8" - assert "redoc@2" in response.text + assert "redoc@2.7.0" in response.text def test_enum_status_code_response():