Skip to content

Commit 44d3fd9

Browse files
algolia-botEnase
andcommitted
fix(python): missing Decimal to float conversion for body serializer (generated)
algolia/api-clients-automation#4618 Co-authored-by: Sergii Kovalov <[email protected]>
1 parent 5d5e8b1 commit 44d3fd9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Diff for: algoliasearch/http/serializer.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from decimal import Decimal
12
from json import dumps
23
from typing import Any, Dict, Optional
34
from urllib.parse import urlencode
@@ -42,6 +43,7 @@ def body_serializer(obj: Any) -> Any:
4243
4344
If obj is None, return None.
4445
If obj is str, int, long, float, bool, return directly.
46+
If obj is Decimal, convert to float and return.
4547
If obj is list, sanitize each element in the list.
4648
If obj is dict, return the dict.
4749
If obj is OpenAPI model, return the properties dict.
@@ -54,6 +56,8 @@ def body_serializer(obj: Any) -> Any:
5456
return None
5557
elif isinstance(obj, PRIMITIVE_TYPES):
5658
return obj
59+
elif isinstance(obj, Decimal):
60+
return float(obj)
5761
elif isinstance(obj, list):
5862
return [body_serializer(sub_obj) for sub_obj in obj]
5963
elif isinstance(obj, tuple):

0 commit comments

Comments
 (0)