@@ -161,6 +161,13 @@ def get_cast_mapping(self, custom_formatters=None, strict=True):
161161
162162 return defaultdict (lambda : lambda x : x , mapping )
163163
164+ def are_additional_properties_allowed (self , one_of_schema = None ):
165+ return (
166+ (self .additional_properties is not False ) and
167+ (one_of_schema is None or
168+ one_of_schema .additional_properties is not False )
169+ )
170+
164171 def cast (self , value , custom_formatters = None , strict = True ):
165172 """Cast value to schema type"""
166173 if value is None :
@@ -311,12 +318,9 @@ def _unmarshal_properties(self, value, one_of_schema=None,
311318
312319 value_props_names = value .keys ()
313320 extra_props = set (value_props_names ) - set (all_props_names )
314- no_more_properties_allowed = (
315- (self .additional_properties is False ) or
316- (one_of_schema is not None and
317- one_of_schema .additional_properties is False )
318- )
319- if extra_props and no_more_properties_allowed :
321+ extra_props_allowed = self .are_additional_properties_allowed (
322+ one_of_schema )
323+ if extra_props and not extra_props_allowed :
320324 raise UndefinedSchemaProperty (extra_props )
321325
322326 properties = {}
@@ -548,12 +552,9 @@ def _validate_properties(self, value, one_of_schema=None,
548552
549553 value_props_names = value .keys ()
550554 extra_props = set (value_props_names ) - set (all_props_names )
551- no_more_properties_allowed = (
552- (self .additional_properties is False ) or
553- (one_of_schema is not None and
554- one_of_schema .additional_properties is False )
555- )
556- if extra_props and no_more_properties_allowed :
555+ extra_props_allowed = self .are_additional_properties_allowed (
556+ one_of_schema )
557+ if extra_props and not extra_props_allowed :
557558 raise UndefinedSchemaProperty (extra_props )
558559
559560 if self .additional_properties is not True :
0 commit comments