Describe the bug
Items in an array are not generated as Optional
, despite adding the nullable: true
property.
To Reproduce
Example schema:
# test.yml
properties:
list1:
type: array
items:
type: string
nullable: true
required:
- list1
Used commandline:
$ datamodel-codegen --input test.yml --output model.py --strict-nullable
This generates a datamodel in which the list items are not nullable:
class Model(BaseModel):
list1: List[str]
Expected behavior
I would expect Optional array items to be generated:
class Model(BaseModel):
list1: List[Optional[str]]
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