datamodel-code-generator
datamodel-code-generator copied to clipboard
Resolve patternProperties
Is your feature request related to a problem? Please describe. I recently attempted to ingest a json schema containing patternProperties and they were completely ignored (generated model and silently left out these fields).
Describe the solution you'd like
Per https://github.com/samuelcolvin/pydantic/issues/329, I think that patternProperties should generate a
var_name: typing.Dict[constr(regex=r'<regex_pattern>'), <patternProperty_object_type>] = {}
Describe alternatives you've considered I would also appreciate if it didn't leave out the fields silently, but I assume this would be the case if I used a verbose option.
Additional context I love your work so far! Just doing my best to help by providing feedback.
@zthatch Thank you for suggesting this idea. OK, I will implement it.
@zthatch
I have released a new version 0.11.12
This version supports patternProperties
https://github.com/koxudaxi/datamodel-code-generator/blob/55eab4fb418555a2088f49346a4b0f212a823bb4/tests/data/expected/main/main_pattern_properties/output.py#L16-L17