From 79932bb5952df4e9404e45d4d2a2c62621fbfa4c Mon Sep 17 00:00:00 2001 From: Vitor Hideyoshi Date: Tue, 19 Aug 2025 20:29:25 -0300 Subject: [PATCH] (feature): Removes _has_meaningful_constraints Removes _has_meaningful_constraints since nowhere in the spec says that a subproperty should have a meaningful value other that its type --- jambo/parser/oneof_type_parser.py | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/jambo/parser/oneof_type_parser.py b/jambo/parser/oneof_type_parser.py index f0a1c88..12b62fe 100644 --- a/jambo/parser/oneof_type_parser.py +++ b/jambo/parser/oneof_type_parser.py @@ -51,6 +51,9 @@ class OneOfTypeParser(GenericTypeParser): def _build_type_one_of_with_discriminator( subfield_types: list[Annotated], discriminator_prop: dict ) -> Annotated: + """ + Build a type with a discriminator. + """ if not isinstance(discriminator_prop, dict): raise ValueError("Discriminator must be a dictionary") @@ -63,8 +66,7 @@ class OneOfTypeParser(GenericTypeParser): @staticmethod def _build_type_one_of_with_func(subfield_types: list[Annotated]) -> Annotated: """ - Build a validation function for the oneOf constraint. - This function will validate that the value matches exactly one of the schemas. + Build a type with a validation function for the oneOf constraint. """ def validate_one_of(value: Any) -> Any: @@ -87,24 +89,3 @@ class OneOfTypeParser(GenericTypeParser): return value return Annotated[Union[(*subfield_types,)], BeforeValidator(validate_one_of)] - - @staticmethod - def _has_meaningful_constraints(field_props): - """ - Check if field properties contain meaningful constraints that require Field wrapping. - Returns False if: - - field_props is None or empty - - field_props only contains {'default': None} - Returns True if: - - field_props contains a non-None default value - - field_props contains other constraint properties (min_length, max_length, pattern, etc.) - """ - if not field_props: - return False - - # If only default is set and it's None, no meaningful constraints - if field_props == {"default": None}: - return False - - # If there are multiple properties or non-None default, that's meaningful - return True