Skip to content

Commit fd679b6

Browse files
authored
Update _base.py
默认使用别名进行序列化
1 parent 596e6db commit fd679b6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/a2a/_base.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from typing import Any
12
from pydantic import BaseModel, ConfigDict
23
from pydantic.alias_generators import to_camel
34

@@ -34,3 +35,13 @@ class A2ABaseModel(BaseModel):
3435
populate_by_name=True,
3536
alias_generator=to_camel_custom,
3637
)
38+
39+
def model_dump(
40+
self,
41+
**kwargs
42+
) -> dict[str, Any]:
43+
44+
if not 'by_alias' in kwargs:
45+
kwargs['by_alias'] = True
46+
47+
return super().model_dump(**kwargs)

0 commit comments

Comments
 (0)