@@ -294,3 +294,42 @@ def test_optional_query_parameter_consistency_with_default_queried_with_other_pa
294294 assert optional_default_client .get ("/optional-default" , params = {"param" : "a" }).json () == {"key" : None }
295295 assert optional_default_client .get ("/optional-annotated-default" , params = {"abc" : "xyz" }).json () == {"key" : None }
296296 assert optional_default_client .get ("/optional-annotated-default" , params = {"param" : "a" }).json () == {"key" : None }
297+
298+
299+ def test_not_included_in_schema_param_as_annotated () -> None :
300+ @get (path = "/" )
301+ def handler (param : Annotated [str , Parameter (include_in_schema = True )]) -> str :
302+ return param
303+
304+ with create_test_client (handler ) as client :
305+ response = client .get ("/" )
306+ assert response .status_code == HTTP_400_BAD_REQUEST
307+
308+ response = client .get ("/?param=a" )
309+ assert response .status_code == HTTP_200_OK
310+ assert response .text == "a"
311+
312+
313+ def test_not_included_in_schema_param_as_default () -> None :
314+ @get (path = "/" )
315+ def handler (param : str = Parameter (include_in_schema = True )) -> str :
316+ return param
317+
318+ with create_test_client (handler ) as client :
319+ response = client .get ("/" )
320+ assert response .status_code == HTTP_400_BAD_REQUEST
321+
322+ response = client .get ("/?param=a" )
323+ assert response .status_code == HTTP_200_OK
324+ assert response .text == "a"
325+
326+
327+ def test_not_included_in_schema_param_with_default_value () -> None :
328+ @get (path = "/" )
329+ def handler (param : str = Parameter (default = "b" , include_in_schema = True )) -> str :
330+ return param
331+
332+ with create_test_client (handler ) as client :
333+ response = client .get ("/" )
334+ assert response .status_code == HTTP_200_OK
335+ assert response .text == "b"
0 commit comments