Skip to content

Commit 1ff1dbd

Browse files
Frosty2500ZANDx1
authored andcommitted
adapt serialization
1 parent 5d9810e commit 1ff1dbd

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

sdk/basyx/aas/adapter/json/json_serialization.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,8 @@ def _blob_to_json(cls, obj: model.Blob) -> Dict[str, object]:
476476
:return: dict with the serialized attributes of this object
477477
"""
478478
data = cls._abstract_classes_to_json(obj)
479-
data['contentType'] = obj.content_type
479+
if obj.content_type is not None:
480+
data['contentType'] = obj.content_type
480481
if obj.value is not None:
481482
data['value'] = base64.b64encode(obj.value).decode()
482483
return data
@@ -490,7 +491,8 @@ def _file_to_json(cls, obj: model.File) -> Dict[str, object]:
490491
:return: dict with the serialized attributes of this object
491492
"""
492493
data = cls._abstract_classes_to_json(obj)
493-
data['contentType'] = obj.content_type
494+
if obj.content_type is not None:
495+
data['contentType'] = obj.content_type
494496
if obj.value is not None:
495497
data['value'] = obj.value
496498
return data

sdk/basyx/aas/model/submodel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ class Blob(DataElement):
474474

475475
def __init__(self,
476476
id_short: Optional[base.NameType],
477-
content_type: Optional[base.ContentType],
477+
content_type: Optional[base.ContentType] = None,
478478
value: Optional[base.BlobType] = None,
479479
display_name: Optional[base.MultiLanguageNameType] = None,
480480
category: Optional[base.NameType] = None,
@@ -528,7 +528,7 @@ class File(DataElement):
528528

529529
def __init__(self,
530530
id_short: Optional[base.NameType],
531-
content_type: Optional[base.ContentType],
531+
content_type: Optional[base.ContentType] = None,
532532
value: Optional[base.PathType] = None,
533533
display_name: Optional[base.MultiLanguageNameType] = None,
534534
category: Optional[base.NameType] = None,

0 commit comments

Comments
 (0)