44import litestar
55from httpx import AsyncClient
66from litestar import openapi , status_codes
7+ from litestar .openapi import spec as litestar_openapi
78from litestar .openapi .plugins import ScalarRenderPlugin
89from litestar .static_files import StaticFilesConfig
910from litestar .testing import AsyncTestClient
@@ -52,7 +53,7 @@ def test_litestar_swagger_bootstrap_online_docs(minimal_swagger_config: SwaggerC
5253 assert "static_files_config" not in bootstrap_result
5354
5455
55- def test_litestar_swagger_bootstrap_with_overriden_render_plugins (minimal_swagger_config : SwaggerConfig ) -> None :
56+ def test_litestar_swagger_bootstrap_with_overridden_render_plugins (minimal_swagger_config : SwaggerConfig ) -> None :
5657 new_render_plugins : typing .Final = [ScalarRenderPlugin ()]
5758 minimal_swagger_config .swagger_extra_params ["render_plugins" ] = new_render_plugins
5859
@@ -64,6 +65,21 @@ def test_litestar_swagger_bootstrap_with_overriden_render_plugins(minimal_swagge
6465 assert bootstrap_result ["openapi_config" ].render_plugins is new_render_plugins
6566
6667
68+ def test_litestar_swagger_bootstrap_extra_params_have_correct_types (minimal_swagger_config : SwaggerConfig ) -> None :
69+ swagger_instrument : typing .Final = LitestarSwaggerInstrument (minimal_swagger_config )
70+ new_components : typing .Final = litestar_openapi .Components (
71+ security_schemes = {"Bearer" : litestar_openapi .SecurityScheme (type = "http" , scheme = "Bearer" )}
72+ )
73+ swagger_instrument .configure_instrument (
74+ minimal_swagger_config .model_copy (update = {"swagger_extra_params" : {"components" : new_components }})
75+ )
76+ bootstrap_result : typing .Final = swagger_instrument .bootstrap_before ()
77+
78+ assert "openapi_config" in bootstrap_result
79+ assert isinstance (bootstrap_result ["openapi_config" ], openapi .OpenAPIConfig )
80+ assert type (bootstrap_result ["openapi_config" ].components ) is litestar_openapi .Components
81+
82+
6783def test_litestar_swagger_bootstrap_offline_docs (minimal_swagger_config : SwaggerConfig ) -> None :
6884 minimal_swagger_config .swagger_offline_docs = True
6985 swagger_instrument : typing .Final = LitestarSwaggerInstrument (minimal_swagger_config )
0 commit comments