@@ -402,28 +402,27 @@ def _get_objects():
402
402
"""
403
403
objects = {}
404
404
for node , path in utils .node_generator (GRAPH_REFERENCE ):
405
+
405
406
if any ([key in path for key in GRAPH_REFERENCE ['defs' ]['metaKeys' ]]):
406
407
continue # objects don't exist under nested meta keys
408
+ if node .get ('role' ) != 'object' :
409
+ continue
410
+ if 'items' in node :
411
+ continue
407
412
408
- # note that arrays are *not* stored in objects! they're arrays!
409
- if node .get ('role' ) == 'object' :
410
- object_name = path [- 1 ]
411
- if node .get ('_isLinkedToArray' ):
412
- object_name = object_name [:- 1 ]
413
-
414
- if object_name not in objects :
415
- objects [object_name ] = {'meta_paths' : [],
416
- 'attribute_paths' : [],
417
- 'additional_attributes' : {}}
418
-
419
- if node .get ('attributes' ):
420
- objects [object_name ]['attribute_paths' ].append (
421
- path + ('attributes' , )
422
- )
423
- else :
424
- objects [object_name ]['attribute_paths' ].append (path )
413
+ object_name = path [- 1 ]
414
+ if object_name not in objects :
415
+ objects [object_name ] = {'meta_paths' : [], 'attribute_paths' : [],
416
+ 'additional_attributes' : {}}
425
417
426
- objects [object_name ]['meta_paths' ].append (path )
418
+ if node .get ('attributes' ):
419
+ objects [object_name ]['attribute_paths' ].append (
420
+ path + ('attributes' , )
421
+ )
422
+ else :
423
+ objects [object_name ]['attribute_paths' ].append (path )
424
+
425
+ objects [object_name ]['meta_paths' ].append (path )
427
426
428
427
return objects
429
428
@@ -459,15 +458,26 @@ def _patch_objects():
459
458
def _get_arrays ():
460
459
"""Very few arrays, but this dict is the complement of OBJECTS."""
461
460
arrays = {}
462
- for object_name , object_dict in OBJECTS .items ():
463
- meta_paths = object_dict ['meta_paths' ]
464
- for meta_path in meta_paths :
465
- meta_dict = utils .get_by_path (GRAPH_REFERENCE , meta_path )
466
- if meta_dict .get ('_isLinkedToArray' ):
467
-
468
- # TODO can we have multiply defined arrays?
469
- arrays [object_name + 's' ] = {'meta_paths' : [meta_path ],
470
- 'items' : [object_name ]}
461
+ for node , path in utils .node_generator (GRAPH_REFERENCE ):
462
+
463
+ if any ([key in path for key in GRAPH_REFERENCE ['defs' ]['metaKeys' ]]):
464
+ continue # objects don't exist under nested meta keys
465
+ if node .get ('role' ) != 'object' :
466
+ continue
467
+ if 'items' not in node :
468
+ continue
469
+
470
+ object_name = path [- 1 ]
471
+ if object_name not in arrays :
472
+ items = node ['items' ]
473
+
474
+ # If items is a dict, it's anyOf them.
475
+ if isinstance (items , dict ):
476
+ item_names = list (items .keys ())
477
+ else :
478
+ item_names = [object_name [:- 1 ]]
479
+ arrays [object_name ] = {'meta_paths' : [path ], 'items' : item_names }
480
+
471
481
return arrays
472
482
473
483
0 commit comments