2 Commits

Author SHA1 Message Date
e8bda6bc07 Merge pull request #71 from HideyoshiNakazone/fix/fixes-annotation-definition-anyof
fix: fixes annotation definition in anyof parser
2025-11-28 18:30:38 -03:00
d8fe98639a fix: fixes annotation definition in anyof parser 2025-11-28 18:28:49 -03:00

View File

@@ -42,8 +42,12 @@ class AnyOfTypeParser(GenericTypeParser):
# 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.
# We use Annotated to attach the Field validators to the type.
field_types = [
Annotated[t, Field(**v)] if v is not None else t for t, v in sub_types
]
field_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