@@ -224,6 +224,50 @@ def subresources_of(contents: Schema) -> Iterable[ObjectSchema]:
224
224
return subresources_of
225
225
226
226
227
+ def _subresources_of_with_crazy_aP_items_dependencies (
228
+ in_value : Set [str ] = frozenset (),
229
+ in_subvalues : Set [str ] = frozenset (),
230
+ in_subarray : Set [str ] = frozenset (),
231
+ ):
232
+ """
233
+ Specifically handle even older drafts where there are some funky keywords.
234
+ """
235
+
236
+ def subresources_of (contents : Schema ) -> Iterable [ObjectSchema ]:
237
+ if isinstance (contents , bool ):
238
+ return
239
+ for each in in_value :
240
+ if each in contents :
241
+ yield contents [each ]
242
+ for each in in_subarray :
243
+ if each in contents :
244
+ yield from contents [each ]
245
+ for each in in_subvalues :
246
+ if each in contents :
247
+ yield from contents [each ].values ()
248
+
249
+ items = contents .get ("items" )
250
+ if items is not None :
251
+ if isinstance (items , Sequence ):
252
+ yield from items
253
+ else :
254
+ yield items
255
+ dependencies = contents .get ("dependencies" )
256
+ if dependencies is not None :
257
+ values = iter (dependencies .values ())
258
+ value = next (values , None )
259
+ if isinstance (value , Mapping ):
260
+ yield value
261
+ yield from values
262
+
263
+ for each in "additionalItems" , "additionalProperties" :
264
+ value = contents .get (each )
265
+ if isinstance (value , Mapping ):
266
+ yield value
267
+
268
+ return subresources_of
269
+
270
+
227
271
def _maybe_in_subresource (
228
272
in_value : Set [str ] = frozenset (),
229
273
in_subvalues : Set [str ] = frozenset (),
@@ -468,8 +512,8 @@ def maybe_in_subresource(
468
512
DRAFT4 = Specification (
469
513
name = "draft-04" ,
470
514
id_of = _legacy_id ,
471
- subresources_of = _subresources_of_with_crazy_items_dependencies (
472
- in_value = {"additionalItems" , "additionalProperties" , " not" },
515
+ subresources_of = _subresources_of_with_crazy_aP_items_dependencies (
516
+ in_value = {"not" },
473
517
in_subarray = {"allOf" , "anyOf" , "oneOf" },
474
518
in_subvalues = {"definitions" , "patternProperties" , "properties" },
475
519
),
@@ -484,8 +528,7 @@ def maybe_in_subresource(
484
528
DRAFT3 = Specification (
485
529
name = "draft-03" ,
486
530
id_of = _legacy_id ,
487
- subresources_of = _subresources_of_with_crazy_items_dependencies (
488
- in_value = {"additionalItems" , "additionalProperties" },
531
+ subresources_of = _subresources_of_with_crazy_aP_items_dependencies (
489
532
in_subarray = {"extends" },
490
533
in_subvalues = {"definitions" , "patternProperties" , "properties" },
491
534
),
0 commit comments