Skip to content

Commit

Permalink
aas.adapter.json: deserialize ModelReferences with last key type
Browse files Browse the repository at this point in the history
  • Loading branch information
JGrothoff committed Nov 18, 2024
1 parent 9615d33 commit 968597b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sdk/basyx/aas/adapter/json/json_deserialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,11 @@ def _construct_model_reference(cls, dct: Dict[str, object], type_: Type[T], obje
if reference_type is not model.ModelReference:
raise ValueError(f"Expected a reference of type {model.ModelReference}, got {reference_type}!")
keys = [cls._construct_key(key_data) for key_data in _get_ts(dct, "keys", list)]
if keys and not issubclass(KEY_TYPES_CLASSES_INVERSE.get(keys[-1].type, type(None)), type_):
last_key_type = KEY_TYPES_CLASSES_INVERSE.get(keys[-1].type, type(None))
if keys and not issubclass(last_key_type, type_):
logger.warning("type %s of last key of reference to %s does not match reference type %s",
keys[-1].type.name, " / ".join(str(k) for k in keys), type_.__name__)
return object_class(tuple(keys), type_, cls._construct_reference(_get_ts(dct, 'referredSemanticId', dict))
return object_class(tuple(keys), last_key_type, cls._construct_reference(_get_ts(dct, 'referredSemanticId', dict))
if 'referredSemanticId' in dct else None)

@classmethod
Expand Down

0 comments on commit 968597b

Please sign in to comment.