fix: fixes annotation definition in anyof parser #71

Merged
HideyoshiNakazone merged 1 commits from fix/fixes-annotation-definition-anyof into main 2025-11-28 21:30:38 +00:00
Showing only changes of commit d8fe98639a - Show all commits

View File

@@ -42,8 +42,12 @@ class AnyOfTypeParser(GenericTypeParser):
# By defining the type as Union of Annotated type we can use the Field validator # By defining the type as Union of Annotated type we can use the Field validator
# to enforce the constraints of each union type when needed. # to enforce the constraints of each union type when needed.
# We use Annotated to attach the Field validators to the type. # We use Annotated to attach the Field validators to the type.
field_types = [ field_types = []
Annotated[t, Field(**v)] if v is not None else t for t, v in sub_types for subType, subProp in sub_types:
] default_value = subProp.pop("default", None)
if default_value is None:
default_value = ...
field_types.append(Annotated[subType, Field(default_value, **subProp)])
return Union[(*field_types,)], mapped_properties return Union[(*field_types,)], mapped_properties