@@ -1577,6 +1577,38 @@ def test_main_openapi_default_object(output_model: str, expected_output: str, tm
15771577 )
15781578
15791579
1580+ @pytest .mark .parametrize (
1581+ ("output_model" , "expected_output" ),
1582+ [
1583+ (
1584+ "pydantic.BaseModel" ,
1585+ "union_default_object.py" ,
1586+ ),
1587+ (
1588+ "pydantic_v2.BaseModel" ,
1589+ "pydantic_v2_union_default_object.py" ,
1590+ ),
1591+ (
1592+ "msgspec.Struct" ,
1593+ "msgspec_union_default_object.py" ,
1594+ ),
1595+ ],
1596+ )
1597+ @pytest .mark .skipif (
1598+ black .__version__ .split ("." )[0 ] == "19" ,
1599+ reason = "Installed black doesn't support the old style" ,
1600+ )
1601+ def test_main_openapi_union_default_object (output_model : str , expected_output : str , output_file : Path ) -> None :
1602+ """Test OpenAPI generation with Union type default object values."""
1603+ run_main_and_assert (
1604+ input_path = OPEN_API_DATA_PATH / "union_default_object.yaml" ,
1605+ output_path = output_file ,
1606+ expected_file = EXPECTED_OPENAPI_PATH / expected_output ,
1607+ input_file_type = "openapi" ,
1608+ extra_args = ["--output-model" , output_model , "--target-python-version" , "3.9" , "--openapi-scopes" , "schemas" ],
1609+ )
1610+
1611+
15801612def test_main_dataclass (output_file : Path ) -> None :
15811613 """Test OpenAPI generation with dataclass output."""
15821614 run_main_and_assert (
0 commit comments