You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In some projects, I use pydantic.dataclasses to add validation to dataclass models.
This is useful on project that requires dataclasses but still want to use pydantic for validation. All fields and type annotation of pydantic are compatible and can be generated in the same way.
We could easily support this as there is only 2 changes with pydantic.BaseModel:
from pydantic.dataclasses import dataclass
@dataclass
class MyModel:
id: str
Ordering of default value fields :
With dataclasses, default value fields must be written after fields with no default value.
Using BaseModel generation seems to generate fields in definition order without any ordering.
@dataclassclassMyModel:
id: strdescription: str=None# This field needs to be after id field
The text was updated successfully, but these errors were encountered:
AltarBeastiful
changed the title
Support pydantic.dataclasses
Support pydantic.dataclasses as output format
Apr 8, 2024
In some projects, I use pydantic.dataclasses to add validation to dataclass models.
This is useful on project that requires dataclasses but still want to use pydantic for validation. All fields and type annotation of pydantic are compatible and can be generated in the same way.
We could easily support this as there is only 2 changes with pydantic.BaseModel:
to
With dataclasses, default value fields must be written after fields with no default value.
Using BaseModel generation seems to generate fields in definition order without any ordering.
The text was updated successfully, but these errors were encountered: