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:
Gabriel Luiz Freitas Almeida 2024-06-26 16:12:00 -03:00
commit f7a61f5847

View file

@ -41,6 +41,12 @@ class Message(Data):
value = str(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")
@classmethod
def validate_files(cls, value):