datamodel-code-generator icon indicating copy to clipboard operation
datamodel-code-generator copied to clipboard

Resolve patternProperties

Open zthatch opened this issue 4 years ago • 2 comments
trafficstars

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 avatar Jul 29 '21 20:07 zthatch

@zthatch Thank you for suggesting this idea. OK, I will implement it.

koxudaxi avatar Jul 31 '21 08:07 koxudaxi

@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

koxudaxi avatar Aug 27 '21 16:08 koxudaxi