Skip to content

Commit

Permalink
Fix context merging when specializing
Browse files Browse the repository at this point in the history
  • Loading branch information
avillar committed Oct 20, 2023
1 parent 1728f90 commit b7965ca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions ogc/na/annotate_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,6 @@ def read_properties(subschema: dict, from_schema: ReferencedSchema,
return None
if subschema.get('type', 'object') != 'object':
return None
subschema_context = {}
for prop, prop_val in subschema.get('properties', {}).items():
if not isinstance(prop_val, dict):
continue
Expand All @@ -663,7 +662,10 @@ def read_properties(subschema: dict, from_schema: ReferencedSchema,

if isinstance(prop_context.get('@id'), str):
pending_subschemas.append((prop_val, from_schema, prop_context['@context']))
onto_context[prop] = prop_context
if prop not in onto_context or isinstance(onto_context[prop], str):
onto_context[prop] = prop_context
else:
merge_contexts(onto_context[prop], prop_context)
else:
pending_subschemas.append((prop_val, from_schema, onto_context))

Expand Down
4 changes: 2 additions & 2 deletions ogc/na/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def git_status(repo_path: str | Path = '.'):
}


def merge_contexts(a: dict, b: dict, from_schema=None, property_chain=None, fix_nest=True) -> dict[str, Any]:
def merge_contexts(a: dict, b: dict, fix_nest=True) -> dict[str, Any]:
if not b:
return a
if not a:
Expand Down Expand Up @@ -313,7 +313,7 @@ def merge_contexts(a: dict, b: dict, from_schema=None, property_chain=None, fix_
elif isinstance(vb['@context'], list):
va['@context'] = [va['@context'], *vb['@context']]
else:
va['@context'] = merge_contexts(va['@context'], vb['@context'], from_schema, property_chain)
va['@context'] = merge_contexts(va['@context'], vb['@context'])
elif vb:
a[term] = vb
for t, tb in b.items():
Expand Down

0 comments on commit b7965ca

Please sign in to comment.