Skip to content
Closed
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
2 changes: 1 addition & 1 deletion src/rune/runtime/base_data_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def _unwrap_cow_inputs(cls, data: Any) -> Any:
@model_serializer(mode='wrap')
def _serialize_refs(self, serializer, info):
'''should replace objects with refs while serializing'''
res = serializer(self, info)
res = serializer(self)
refs = self._get_rune_refs_container()
for property_nm, (key, ref_type) in refs.items():
res[property_nm] = {ref_type.rune_ref_tag: key}
Expand Down
2 changes: 1 addition & 1 deletion src/rune/runtime/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ class EnumWithMetaMixin:
def serialise(cls, obj, handler, info) -> dict:
'''used as serialisation method with pydantic'''
res = obj.serialise_meta()
res['@data'] = handler(obj.enum_instance, info)
res['@data'] = handler(obj.enum_instance)
return res

@classmethod
Expand Down
8 changes: 8 additions & 0 deletions test/test_basic_types_with_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,14 @@ def test_fail_create_constrained_num_model():
ConstrainedNumberModel(amount=NumberWithMeta(-1))


def test_dump_annotated_enum_scheme():
'''test the serialisation of an enum with meta'''
scheme_json = '{"enum_t":{"@scheme":"http://fpml.org","@data":"B"}}'
model = AnnotatedEnumModel.model_validate_json(scheme_json)
json_str = model.model_dump_json(exclude_unset=True)
assert json_str == scheme_json


def test_annotated_enum_assignment():
'''test assignment'''
model = AnnotatedEnumModel(enum_t=EnumType.B)
Expand Down
Loading