Skip to content

Commit 7748b69

Browse files
committed
Wrap bare context.jsonld objects in @context during schema annotation
If a local context file passed to annotate_schema lacks a top-level '@context' key, wrap the whole object in one before handing it to the ogc-na-tools SchemaAnnotator. This lets building blocks provide a bare context mapping without the envelope.
1 parent 3d439a6 commit 7748b69

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

ogc/bblocks/schema.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ def annotate_schema(bblock: BuildingBlock,
7373
if not schema_fn and not schema_url:
7474
return result
7575

76+
if isinstance(context, Path) and context.is_file():
77+
context = load_yaml(filename=context)
78+
if isinstance(context, dict) and '@context' not in context:
79+
context = {'@context': context}
80+
7681
override_schema = load_yaml(filename=schema_fn, url=schema_url, test_alternate_suffix=False)
7782
override_schema = resolve_all_schema_references(override_schema, bblocks_register, bblock,
7883
bblock.schema, base_url)

0 commit comments

Comments
 (0)