@@ -101,12 +101,16 @@ def _get_values_for_config(self, config_schema_db, config_db):
101
101
return config
102
102
103
103
@staticmethod
104
- def _get_object_property_schema (object_schema ):
104
+ def _get_object_property_schema (object_schema , init_additional_properties = None ):
105
105
additional_properties = object_schema .get ("additionalProperties" , {})
106
- if isinstance (additional_properties , dict ):
106
+ if additional_properties and isinstance (additional_properties , dict ):
107
107
property_schema = defaultdict (lambda : additional_properties )
108
108
else :
109
109
property_schema = {}
110
+ if init_additional_properties :
111
+ # ensure that these keys are present in the object (vs just defaultdict)
112
+ for key in init_additional_properties :
113
+ property_schema .__missing__ (key )
110
114
property_schema .update (object_schema .get ("properties" , {}))
111
115
return property_schema
112
116
@@ -206,7 +210,14 @@ def _assign_default_values(self, schema, config):
206
210
if not config .get (schema_item_key , None ):
207
211
config [schema_item_key ] = {}
208
212
209
- property_schema = self ._get_object_property_schema (schema_item )
213
+ property_schema = self ._get_object_property_schema (
214
+ schema_item ,
215
+ init_additional_properties = (
216
+ config [schema_item_key ].keys ()
217
+ if has_additional_properties
218
+ else None
219
+ ),
220
+ )
210
221
211
222
self ._assign_default_values (
212
223
schema = property_schema , config = config [schema_item_key ]
0 commit comments