@@ -28,7 +28,8 @@ class Schema(object):
2828 def __init__ (
2929 self , schema_type = None , model = None , properties = None , items = None ,
3030 schema_format = None , required = None , default = None , nullable = False ,
31- enum = None , deprecated = False , all_of = None , one_of = None ):
31+ enum = None , deprecated = False , all_of = None , one_of = None ,
32+ additional_properties = None ):
3233 self .type = schema_type and SchemaType (schema_type )
3334 self .model = model
3435 self .properties = properties and dict (properties ) or {}
@@ -41,6 +42,7 @@ def __init__(
4142 self .deprecated = deprecated
4243 self .all_of = all_of and list (all_of ) or []
4344 self .one_of = one_of and list (one_of ) or []
45+ self .additional_properties = additional_properties
4446
4547 self ._all_required_properties_cache = None
4648 self ._all_optional_properties_cache = None
@@ -183,11 +185,16 @@ def _unmarshal_properties(self, value, one_of_schema=None):
183185
184186 value_props_names = value .keys ()
185187 extra_props = set (value_props_names ) - set (all_props_names )
186- if extra_props :
188+ if extra_props and self . additional_properties is None :
187189 raise UndefinedSchemaProperty (
188190 "Undefined properties in schema: {0}" .format (extra_props ))
189191
190192 properties = {}
193+ for prop_name in extra_props :
194+ prop_value = value [prop_name ]
195+ properties [prop_name ] = self .additional_properties .unmarshal (
196+ prop_value )
197+
191198 for prop_name , prop in iteritems (all_props ):
192199 try :
193200 prop_value = value [prop_name ]
0 commit comments