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
Is your feature request related to a problem? Please describe.
One of the reasons why I want to use pydantic instead of json-schema (where the source of truth for data models I'm using lie) is because if much easier error codes and information when data doesn't validate. However, when translating a json schema that specifies that one of or any of a set of requirements must be met, it creates a bunch of separate data models and puts them together in a single data model that is a union. This results in error codes that are....not very helpful. It creates a laundry list of all the possible sub models that aren't being met.
classParentModel1(BaseModel):
other_info:....
option_1: Option1option_2: Optional[Option2] =Noneoption_3: Optional[Option3] =NoneclassParentModel2(BaseModel):
other_info:....
option_1: Optional[Option1] =Noneoption_2: Option2option_3: Optional[Option3] =NoneclassParentModel3(BaseModel):
other_info:....
option_1: Optional[Option1] =Noneoption_2: Optional[Option2] =Noneoption_3: Option3classParentModel(
RootModel[
Union[
ParentModel1,
ParentModel2,
ParentModel3, #note that in my case I have a few dozen of these...
]
]
):
root: Annotated[
Union[
ParentModel1,
ParentModel2,
ParentModel3,
],
Field(title='Parent Schema'),
]
Describe the solution you'd like
Translation of a "oneOf" statement (and similar) to a pydantic @rootmodel validator.
Describe alternatives you've considered
After spending a few hours trying to accurately post-process the resulting data models, I currently edit the resulting data models by hand, which isn't traceable or reproducible in a data pipeline.
I also did a search to see if other issues like this had been opened and couldn't immediately find any - which was surprising to me so maybe I missed something?
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
One of the reasons why I want to use pydantic instead of json-schema (where the source of truth for data models I'm using lie) is because if much easier error codes and information when data doesn't validate. However, when translating a json schema that specifies that one of or any of a set of requirements must be met, it creates a bunch of separate data models and puts them together in a single data model that is a union. This results in error codes that are....not very helpful. It creates a laundry list of all the possible sub models that aren't being met.
Describe the solution you'd like
Translation of a "oneOf" statement (and similar) to a pydantic @rootmodel validator.
Describe alternatives you've considered
After spending a few hours trying to accurately post-process the resulting data models, I currently edit the resulting data models by hand, which isn't traceable or reproducible in a data pipeline.
I also did a search to see if other issues like this had been opened and couldn't immediately find any - which was surprising to me so maybe I missed something?
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: