Skip to content

Commit

Permalink
Fix self-$refs, put itemIdentifier on top
Browse files Browse the repository at this point in the history
  • Loading branch information
avillar committed Oct 11, 2023
1 parent b944979 commit 2a1f96c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ogc/bblocks/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 2a1f96c

Please sign in to comment.