@@ -3083,6 +3083,18 @@ def test_jsonschema_pattern_properties_field_constraints(output_file: Path) -> N
30833083 )
30843084
30853085
3086+ def test_jsonschema_pattern_properties_use_annotated (output_file : Path ) -> None :
3087+ """Test pattern properties with --use-annotated preserves pattern constraint on dict keys."""
3088+ run_main_and_assert (
3089+ input_path = JSON_SCHEMA_DATA_PATH / "pattern_properties.json" ,
3090+ output_path = output_file ,
3091+ input_file_type = "jsonschema" ,
3092+ assert_func = assert_file_content ,
3093+ expected_file = "pattern_properties_use_annotated.py" ,
3094+ extra_args = ["--output-model-type" , "pydantic_v2.BaseModel" , "--use-annotated" ],
3095+ )
3096+
3097+
30863098@LEGACY_BLACK_SKIP
30873099def test_jsonschema_titles (output_file : Path ) -> None :
30883100 """Test JSON Schema title handling."""
@@ -3892,6 +3904,22 @@ def test_main_jsonschema_property_names_pattern(output_file: Path) -> None:
38923904 )
38933905
38943906
3907+ def test_main_jsonschema_property_names_pattern_field_constraints (output_file : Path ) -> None :
3908+ """Test propertyNames pattern with field_constraints preserves constr key."""
3909+ run_main_and_assert (
3910+ input_path = JSON_SCHEMA_DATA_PATH / "property_names_pattern.json" ,
3911+ output_path = output_file ,
3912+ input_file_type = "jsonschema" ,
3913+ assert_func = assert_file_content ,
3914+ expected_file = "property_names_pattern_field_constraints.py" ,
3915+ extra_args = [
3916+ "--output-model-type" ,
3917+ "pydantic_v2.BaseModel" ,
3918+ "--field-constraints" ,
3919+ ],
3920+ )
3921+
3922+
38953923def test_main_jsonschema_property_names_enum (output_file : Path ) -> None :
38963924 """Test propertyNames with enum constraint generates dict with Literal key."""
38973925 run_main_and_assert (
0 commit comments