Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions sdk/basyx/aas/adapter/json/json_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions sdk/basyx/aas/model/submodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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")
Expand Down Expand Up @@ -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,
Expand All @@ -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):
Expand Down
Loading