feat: Add flow_id serialization in Message class
This commit adds the `serialize_flow_id` method to the `Message` class in the `message.py` file. This method serializes the `flow_id` attribute of a `Message` object, converting it to a UUID if it is a string. This ensures consistent serialization of the `flow_id` attribute when working with the `Message` class.
This commit is contained in:
parent
5ff9bed407
commit
86f25f3b2c
1 changed files with 6 additions and 0 deletions
|
|
@ -41,6 +41,12 @@ class Message(Data):
|
||||||
value = str(value)
|
value = str(value)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
@field_serializer("flow_id")
|
||||||
|
def serialize_flow_id(value):
|
||||||
|
if isinstance(value, str):
|
||||||
|
return UUID(value)
|
||||||
|
return value
|
||||||
|
|
||||||
@field_validator("files", mode="before")
|
@field_validator("files", mode="before")
|
||||||
@classmethod
|
@classmethod
|
||||||
def validate_files(cls, value):
|
def validate_files(cls, value):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue