Describe the bug
--field-constraints
on JSON Schema with nested arrays produces incorrect output for all model typestyping.Any
To Reproduce
Example schema:
{
"type": "object",
"properties": {
"a": {
"type": "array",
"items": {
"type": "array",
"items": {"type": "number"},
"minItems": 2,
"maxItems": 2
}
}
},
"required": ["a"]
}
The following produces correct output, i.e. a
has type List[List[float]]
:
datamodel-codegen --input test.json --input-file-type jsonschema --output-model-type typing.TypedDict --output model.py
datamodel-codegen --input test.json --input-file-type jsonschema --output model.py # This of course doesn't use `pydantic.Field` in model output
The following does not, i.e. a
has type List[AItem]
, where AItem = List[Any]
:
datamodel-codegen --input test.json --input-file-type jsonschema --output-model-type typing.TypedDict --output model.py --field-constraints
datamodel-codegen --input test.json --input-file-type jsonschema --output model.py --field-constraints
Expected behavior
Passing --field-constraints
shouldn't "erase" the type of the nested array items, i.e. we should get AItem = List[float]
instead of AItem = List[Any]
Version:
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too