Describe the bug
required
fields declared in an allof
are missing in the generated python code.
If this is not a bug, please let me know if I'm doing something wrong.
To Reproduce
Example schema:
ProjectedPet:
type: object
properties:
id:
type: integer
format: int64
name:
type: string
Pet:
allOf:
- $ref: "#/components/schemas/ProjectedPet"
- type: object
required:
- id
- name
- opts
properties:
tag:
type: string
opts:
type: array
items:
type: string
Used commandline:
datamodel-codegen --input api.yaml --output model.py --input-file-type openapi --use-annotated --collapse-root-models --use-standard-collections --capitalize-enum-members --target-python-version 3.10 --output-model-type pydantic_v2.BaseModel
Actual behavior
class ProjectedPet(BaseModel):
id: Optional[int] = None
name: Optional[str] = None
class Pet(ProjectedPet):
tag: Optional[str] = None
opts: list[str]
Expected behavior
class ProjectedPet(BaseModel):
id: Optional[int] = None
name: Optional[str] = None
class Pet(ProjectedPet):
id: int
name: str
tag: Optional[str] = None
opts: list[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