@@ -92,11 +92,18 @@ def __init__(self, identifier: str, metadata_file: Path,
9292 self .output_openapi = self .annotated_path / 'openapi.yaml'
9393 self .output_openapi_30 = self .output_openapi .with_stem (f"{ self .output_openapi .stem } -oas30" )
9494
95- shacl_rules = self .metadata .setdefault ('shaclRules' , [])
96- default_shacl_rules = fp / 'rules.shacl'
97- if default_shacl_rules .is_file ():
98- shacl_rules .append ('rules.shacl' )
99- self .shacl_rules = set (r if is_url (r ) else fp / r for r in shacl_rules )
95+ shacl_shapes = self .metadata .setdefault ('shaclShapes' , [])
96+ if not shacl_shapes and self .metadata .get ('shaclRules' ):
97+ shacl_shapes .extend (self .metadata .pop ('shaclRules' ))
98+ default_shacl_shapes = fp / 'shapes.shacl'
99+ if default_shacl_shapes .is_file ():
100+ shacl_shapes .append ('shapes.shacl' )
101+ else :
102+ legacy_shacl_shapes = fp / 'rules.shacl'
103+ if legacy_shacl_shapes .is_file ():
104+ shacl_shapes .append ('rules.shacl' )
105+
106+ self .shacl_shapes = set (r if is_url (r ) else fp / r for r in shacl_shapes )
100107
101108 self .ontology = self ._find_path_or_url ('ontology' ,
102109 ('ontology.ttl' , 'ontology.owl' ))
@@ -466,7 +473,9 @@ def __init__(self,
466473 if identifier in self .bblocks :
467474 continue
468475 dep_graph .add_node (identifier )
469- dep_graph .add_edges_from ([(d , identifier ) for d in imported_bblock .get ('dependsOn' , ())])
476+ dep_graph .add_edges_from ([(d , identifier )
477+ for d in imported_bblock .get ('dependsOn' , ())
478+ if d != identifier ])
470479 for schema_url in imported_bblock .get ('schema' , {}).values ():
471480 self .imported_bblock_files [schema_url ] = identifier
472481 source_schema = imported_bblock .get ('sourceSchema' )
@@ -492,7 +501,9 @@ def __init__(self,
492501 if found_deps :
493502 bblock .metadata ['dependsOn' ] = list (found_deps )
494503 dep_graph .add_node (bblock .identifier )
495- dep_graph .add_edges_from ([(d , bblock .identifier ) for d in bblock .metadata .get ('dependsOn' , ())])
504+ dep_graph .add_edges_from ([(d , bblock .identifier )
505+ for d in bblock .metadata .get ('dependsOn' , ())
506+ if d != bblock .identifier ])
496507
497508 for a , b in dep_graph .edges :
498509 if a not in self .bblocks and a not in self .imported_bblocks :
@@ -595,14 +606,14 @@ def find_dependencies(self, identifier: str, seen: tuple[str] = None) -> list[di
595606
596607 return dependencies
597608
598- def get_inherited_shacl_rules (self , identifier : str ) -> dict [str , set [str | Path ]]:
609+ def get_inherited_shacl_shapes (self , identifier : str ) -> dict [str , set [str | Path ]]:
599610 rules : dict [str , set [str | Path ]] = {}
600611 for dep in self .find_dependencies (identifier ):
601612 if isinstance (dep , BuildingBlock ):
602- if dep .shacl_rules :
603- rules [dep .identifier ] = dep .shacl_rules
613+ if dep .shacl_shapes :
614+ rules [dep .identifier ] = dep .shacl_shapes
604615 else :
605- dep_rules = dep .get ('shaclRules' )
616+ dep_rules = dep .get ('shaclShapes' , dep . get ( ' shaclRules') )
606617 if dep_rules :
607618 if isinstance (dep_rules , list ):
608619 rules .setdefault (dep .get ('itemIdentifier' ), set ()).update (dep_rules )
0 commit comments