diff --git a/ogc/bblocks/util.py b/ogc/bblocks/util.py index e41bc64..2076cc2 100644 --- a/ogc/bblocks/util.py +++ b/ogc/bblocks/util.py @@ -72,7 +72,10 @@ def __init__(self, identifier: str, metadata_file: Path, except Exception as e: raise BuildingBlockError('Error validating building block metadata') from e - self.metadata['itemIdentifier'] = identifier + self.metadata = { + 'itemIdentifier': identifier, + **self.metadata, + } self._lazy_properties = {} @@ -562,13 +565,13 @@ def resolve_schema_reference(ref: str, ref = schema.pop(BBLOCKS_REF_ANNOTATION, ref) - if (from_bblock.schema.is_file() or from_bblock.metadata.get('schema')) and not is_url(ref): + if ref[0] != '#' and (from_bblock.schema.is_file() or from_bblock.metadata.get('schema')) and not is_url(ref): # Update local $ref if not to another bblock schema if from_bblock.schema.is_file(): original = from_bblock.schema.parent / ref else: original = from_bblock.files_path / ref - if (original.stem != 'schema' or original.prefix not in ('.json', '.yaml') + if (original.stem != 'schema' or original.suffix not in ('.json', '.yaml') or not original.parent.joinpath('bblock.json').is_file()): # $ref is to non-bblock canonical schema.json/schema.yaml -> update ref = os.path.relpath(original, from_bblock.annotated_path)