Skip to content

Commit

Permalink
Python: Correctly serialize enum with its value (OpenAPITools#18327)
Browse files Browse the repository at this point in the history
  • Loading branch information
BaptisteSaves committed Apr 8, 2024
1 parent 453facc commit 12cd078
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ class ApiClient:
"""
if obj is None:
return None
elif isinstance(obj, Enum):
return obj.value
elif isinstance(obj, SecretStr):
return obj.get_secret_value()
elif isinstance(obj, self.PRIMITIVE_TYPES):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ def sanitize_for_serialization(self, obj):
"""
if obj is None:
return None
elif isinstance(obj, Enum):
return obj.value
elif isinstance(obj, SecretStr):
return obj.get_secret_value()
elif isinstance(obj, self.PRIMITIVE_TYPES):
Expand Down
2 changes: 2 additions & 0 deletions samples/client/echo_api/python/openapi_client/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ def sanitize_for_serialization(self, obj):
"""
if obj is None:
return None
elif isinstance(obj, Enum):
return obj.value
elif isinstance(obj, SecretStr):
return obj.get_secret_value()
elif isinstance(obj, self.PRIMITIVE_TYPES):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ def sanitize_for_serialization(self, obj):
"""
if obj is None:
return None
elif isinstance(obj, Enum):
return obj.value
elif isinstance(obj, SecretStr):
return obj.get_secret_value()
elif isinstance(obj, self.PRIMITIVE_TYPES):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ def sanitize_for_serialization(self, obj):
"""
if obj is None:
return None
elif isinstance(obj, Enum):
return obj.value
elif isinstance(obj, SecretStr):
return obj.get_secret_value()
elif isinstance(obj, self.PRIMITIVE_TYPES):
Expand Down

0 comments on commit 12cd078

Please sign in to comment.