An array of arrays gets translated into List[List[T]], even when the second array has contraints, losing these constraints. Minimal working example :
{
"components": {
"schemas": {
"Mod": {
"type": "object",
"properties": {
"prop": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "number",
},
"minItems": 3,
"maxItems": 6
}
}
},
}
}
}
}
I see 2 solutions to that :
1 - Use a conlist to keep the contraints. Albeit compact and easy (only a few lines to add around datamodel-code-generator/types.py L87,L254 and datamodel-code-generator/parser/jsonschema.py L772), it would stand out quite a bit, compared to the rest (the conX objects being alone in their own Item model).
2 - Handle constrained array the same way object is handled: by giving it its own Model, which would allow to store the constraints in Field, as it is done for a single array.
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