diff --git a/sdk/basyx/aas/adapter/json/json_serialization.py b/sdk/basyx/aas/adapter/json/json_serialization.py index 0b0df016..8b582068 100644 --- a/sdk/basyx/aas/adapter/json/json_serialization.py +++ b/sdk/basyx/aas/adapter/json/json_serialization.py @@ -476,7 +476,8 @@ def _blob_to_json(cls, obj: model.Blob) -> Dict[str, object]: :return: dict with the serialized attributes of this object """ data = cls._abstract_classes_to_json(obj) - data['contentType'] = obj.content_type + if obj.content_type is not None: + data['contentType'] = obj.content_type if obj.value is not None: data['value'] = base64.b64encode(obj.value).decode() return data @@ -490,7 +491,8 @@ def _file_to_json(cls, obj: model.File) -> Dict[str, object]: :return: dict with the serialized attributes of this object """ data = cls._abstract_classes_to_json(obj) - data['contentType'] = obj.content_type + if obj.content_type is not None: + data['contentType'] = obj.content_type if obj.value is not None: data['value'] = obj.value return data diff --git a/sdk/basyx/aas/model/submodel.py b/sdk/basyx/aas/model/submodel.py index 9e7321c4..fb1ccc5a 100644 --- a/sdk/basyx/aas/model/submodel.py +++ b/sdk/basyx/aas/model/submodel.py @@ -464,7 +464,7 @@ class Blob(DataElement): def __init__(self, id_short: Optional[base.NameType], - content_type: base.ContentType, + content_type: Optional[base.ContentType] = None, value: Optional[base.BlobType] = None, display_name: Optional[base.MultiLanguageNameType] = None, category: Optional[base.NameType] = None, @@ -482,7 +482,7 @@ def __init__(self, super().__init__(id_short, display_name, category, description, parent, semantic_id, qualifier, extension, supplemental_semantic_id, embedded_data_specifications) self.value: Optional[base.BlobType] = value - self.content_type: base.ContentType = content_type + self.content_type: Optional[base.ContentType] = content_type @_string_constraints.constrain_content_type("content_type") @@ -518,7 +518,7 @@ class File(DataElement): def __init__(self, id_short: Optional[base.NameType], - content_type: base.ContentType, + content_type: Optional[base.ContentType] = None, value: Optional[base.PathType] = None, display_name: Optional[base.MultiLanguageNameType] = None, category: Optional[base.NameType] = None, @@ -536,7 +536,7 @@ def __init__(self, super().__init__(id_short, display_name, category, description, parent, semantic_id, qualifier, extension, supplemental_semantic_id, embedded_data_specifications) self.value: Optional[base.PathType] = value - self.content_type: base.ContentType = content_type + self.content_type: Optional[base.ContentType] = content_type class ReferenceElement(DataElement):