Skip to content

Commit

Permalink
Serialize by alias
Browse files Browse the repository at this point in the history
  • Loading branch information
callumforrester committed Apr 21, 2023
1 parent 011ffc4 commit d0c1be5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/blueapi/utils/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ def serialize(obj: Any) -> Any:
"""

if isinstance(obj, BaseModel):
return obj.dict()
# Serialize by alias so that our camelCase models leave the service
# with camelCase field names
return obj.dict(by_alias=True)
elif hasattr(obj, "__pydantic_model__"):
return serialize(getattr(obj, "__pydantic_model__"))
else:
Expand Down

0 comments on commit d0c1be5

Please sign in to comment.