refactor(backend): add json_encoders to BaseModel configuration (dev-3.x)

This commit introduces a custom JSON encoder for the Default type within
the BaseModel configuration of the aiogram package. By specifying how the
Default type is serialized, this change ensures consistent representation
of Default instances in JSON output, enhancing the predictability of the
serialization process.
This commit is contained in:
zemf4you 2024-04-04 17:34:36 +07:00
parent acf52f468c
commit 7653895dd2

View file

@ -16,6 +16,9 @@ class TelegramObject(BotContextController, BaseModel):
populate_by_name=True,
arbitrary_types_allowed=True,
defer_build=True,
json_encoders={
Default: lambda obj: obj.name,
}
)
@model_validator(mode="before")