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
8 changes: 5 additions & 3 deletions sdk/basyx/aas/adapter/json/json_serialization.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2025 the Eclipse BaSyx Authors
# Copyright (c) 2026 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down 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: 5 additions & 3 deletions sdk/basyx/aas/adapter/xml/xml_serialization.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2025 the Eclipse BaSyx Authors
# Copyright (c) 2026 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down Expand Up @@ -627,7 +627,8 @@ def blob_to_xml(obj: model.Blob,
if obj.value is not None:
et_value.text = base64.b64encode(obj.value).decode()
et_blob.append(et_value)
et_blob.append(_generate_element(NS_AAS + "contentType", text=obj.content_type))
if obj.content_type is not None:
et_blob.append(_generate_element(NS_AAS + "contentType", text=obj.content_type))
return et_blob


Expand All @@ -643,7 +644,8 @@ def file_to_xml(obj: model.File,
et_file = abstract_classes_to_xml(tag, obj)
if obj.value:
et_file.append(_generate_element(NS_AAS + "value", text=obj.value))
et_file.append(_generate_element(NS_AAS + "contentType", text=obj.content_type))
if obj.content_type is not None:
et_file.append(_generate_element(NS_AAS + "contentType", text=obj.content_type))
return et_file


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 @@ -474,7 +474,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 @@ -492,7 +492,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 @@ -528,7 +528,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 @@ -546,7 +546,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