Skip to content

Commit

Permalink
Add support for decimals
Browse files Browse the repository at this point in the history
  • Loading branch information
sidpan1 committed Sep 10, 2024
1 parent 0c3cadd commit 8f22199
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion onelens_backend_client_v2/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
""" # noqa: E501

import datetime
from decimal import Decimal
import json
import mimetypes
import os
Expand Down Expand Up @@ -350,13 +351,17 @@ def sanitize_for_serialization(self, obj):
return str(obj)
elif isinstance(obj, Enum):
return obj.value
else:
elif isinstance(obj, Decimal):
return float(obj)
elif isinstance(obj, pydantic.BaseModel):
# Convert model obj to dict except
# attributes `openapi_types`, `attribute_map`
# and attributes which value is not None.
# Convert attribute name to json key in
# model definition for request.
obj_dict = obj.model_dump(exclude_unset=True)
else:
return str(obj)

return {
key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()
Expand Down

0 comments on commit 8f22199

Please sign in to comment.