From 24bb427d6c1f323825c51602ba1569aa59b16279 Mon Sep 17 00:00:00 2001 From: Robert Stein Date: Tue, 19 Nov 2024 20:57:27 +0100 Subject: [PATCH] test: add test for redoc parameters --- fastapi/openapi/docs.py | 2 +- tests/test_local_docs.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/fastapi/openapi/docs.py b/fastapi/openapi/docs.py index 10f52709f..24704f656 100644 --- a/fastapi/openapi/docs.py +++ b/fastapi/openapi/docs.py @@ -229,7 +229,7 @@ def get_redoc_html( config_string = "" if redoc_ui_parameters: for key, value in redoc_ui_parameters.items(): - config_string += f" {key}={value}" + config_string += f" {key}=\"{value}\"" html = f""" diff --git a/tests/test_local_docs.py b/tests/test_local_docs.py index 5f102edf1..1c5f9e8ff 100644 --- a/tests/test_local_docs.py +++ b/tests/test_local_docs.py @@ -65,3 +65,14 @@ def test_google_fonts_in_generated_redoc(): openapi_url="/docs", title="title", with_google_fonts=False ).body.decode() assert "fonts.googleapis.com" not in body_without_google_fonts + + +def test_generated_redoc_with_parameters(): + body_with_parameters = get_redoc_html( + openapi_url="/docs", title="title", with_google_fonts=False, redoc_ui_parameters={"disable-search": "true"} + ).body.decode() + assert "disable-search=\"true\"" in body_with_parameters + body_without_parameters = get_redoc_html( + openapi_url="/docs", title="title", with_google_fonts=False + ).body.decode() + assert "disable-search=\"true\"" not in body_without_parameters