forked from loafle/openapi-generator-original
[python-pydantic-v1] Fix bug in serialization for SecretStr by applying changes from #18023 (#20102)
* Apply changes of #18023 * Regenerate samples --------- Co-authored-by: tweber2 <tim.weber@vector.com>
This commit is contained in:
parent
7087104741
commit
66908020e0
@ -15,6 +15,7 @@ import re
|
||||
import tempfile
|
||||
|
||||
from urllib.parse import quote
|
||||
from pydantic import SecretStr
|
||||
{{#tornado}}
|
||||
import tornado.gen
|
||||
{{/tornado}}
|
||||
@ -285,6 +286,7 @@ class ApiClient:
|
||||
"""Builds a JSON POST object.
|
||||
|
||||
If obj is None, return None.
|
||||
If obj is SecretStr, return obj.get_secret_value()
|
||||
If obj is str, int, long, float, bool, return directly.
|
||||
If obj is datetime.datetime, datetime.date
|
||||
convert to string in iso8601 format.
|
||||
@ -297,6 +299,8 @@ class ApiClient:
|
||||
"""
|
||||
if obj is None:
|
||||
return None
|
||||
elif isinstance(obj, SecretStr):
|
||||
return obj.get_secret_value()
|
||||
elif isinstance(obj, self.PRIMITIVE_TYPES):
|
||||
return obj
|
||||
elif isinstance(obj, list):
|
||||
@ -316,7 +320,10 @@ class ApiClient:
|
||||
# and attributes which value is not None.
|
||||
# Convert attribute name to json key in
|
||||
# model definition for request.
|
||||
obj_dict = obj.to_dict()
|
||||
if hasattr(obj, 'to_dict') and callable(getattr(obj, 'to_dict')):
|
||||
obj_dict = obj.to_dict()
|
||||
else:
|
||||
obj_dict = obj.__dict__
|
||||
|
||||
return {key: self.sanitize_for_serialization(val)
|
||||
for key, val in obj_dict.items()}
|
||||
|
@ -24,6 +24,7 @@ import re
|
||||
import tempfile
|
||||
|
||||
from urllib.parse import quote
|
||||
from pydantic import SecretStr
|
||||
|
||||
from openapi_client.configuration import Configuration
|
||||
from openapi_client.api_response import ApiResponse
|
||||
@ -261,6 +262,7 @@ class ApiClient:
|
||||
"""Builds a JSON POST object.
|
||||
|
||||
If obj is None, return None.
|
||||
If obj is SecretStr, return obj.get_secret_value()
|
||||
If obj is str, int, long, float, bool, return directly.
|
||||
If obj is datetime.datetime, datetime.date
|
||||
convert to string in iso8601 format.
|
||||
@ -273,6 +275,8 @@ class ApiClient:
|
||||
"""
|
||||
if obj is None:
|
||||
return None
|
||||
elif isinstance(obj, SecretStr):
|
||||
return obj.get_secret_value()
|
||||
elif isinstance(obj, self.PRIMITIVE_TYPES):
|
||||
return obj
|
||||
elif isinstance(obj, list):
|
||||
@ -292,7 +296,10 @@ class ApiClient:
|
||||
# and attributes which value is not None.
|
||||
# Convert attribute name to json key in
|
||||
# model definition for request.
|
||||
obj_dict = obj.to_dict()
|
||||
if hasattr(obj, 'to_dict') and callable(getattr(obj, 'to_dict')):
|
||||
obj_dict = obj.to_dict()
|
||||
else:
|
||||
obj_dict = obj.__dict__
|
||||
|
||||
return {key: self.sanitize_for_serialization(val)
|
||||
for key, val in obj_dict.items()}
|
||||
|
@ -22,6 +22,7 @@ import re
|
||||
import tempfile
|
||||
|
||||
from urllib.parse import quote
|
||||
from pydantic import SecretStr
|
||||
|
||||
from petstore_api.configuration import Configuration
|
||||
from petstore_api.api_response import ApiResponse
|
||||
@ -241,6 +242,7 @@ class ApiClient:
|
||||
"""Builds a JSON POST object.
|
||||
|
||||
If obj is None, return None.
|
||||
If obj is SecretStr, return obj.get_secret_value()
|
||||
If obj is str, int, long, float, bool, return directly.
|
||||
If obj is datetime.datetime, datetime.date
|
||||
convert to string in iso8601 format.
|
||||
@ -253,6 +255,8 @@ class ApiClient:
|
||||
"""
|
||||
if obj is None:
|
||||
return None
|
||||
elif isinstance(obj, SecretStr):
|
||||
return obj.get_secret_value()
|
||||
elif isinstance(obj, self.PRIMITIVE_TYPES):
|
||||
return obj
|
||||
elif isinstance(obj, list):
|
||||
@ -272,7 +276,10 @@ class ApiClient:
|
||||
# and attributes which value is not None.
|
||||
# Convert attribute name to json key in
|
||||
# model definition for request.
|
||||
obj_dict = obj.to_dict()
|
||||
if hasattr(obj, 'to_dict') and callable(getattr(obj, 'to_dict')):
|
||||
obj_dict = obj.to_dict()
|
||||
else:
|
||||
obj_dict = obj.__dict__
|
||||
|
||||
return {key: self.sanitize_for_serialization(val)
|
||||
for key, val in obj_dict.items()}
|
||||
|
@ -23,6 +23,7 @@ import re
|
||||
import tempfile
|
||||
|
||||
from urllib.parse import quote
|
||||
from pydantic import SecretStr
|
||||
|
||||
from petstore_api.configuration import Configuration
|
||||
from petstore_api.api_response import ApiResponse
|
||||
@ -260,6 +261,7 @@ class ApiClient:
|
||||
"""Builds a JSON POST object.
|
||||
|
||||
If obj is None, return None.
|
||||
If obj is SecretStr, return obj.get_secret_value()
|
||||
If obj is str, int, long, float, bool, return directly.
|
||||
If obj is datetime.datetime, datetime.date
|
||||
convert to string in iso8601 format.
|
||||
@ -272,6 +274,8 @@ class ApiClient:
|
||||
"""
|
||||
if obj is None:
|
||||
return None
|
||||
elif isinstance(obj, SecretStr):
|
||||
return obj.get_secret_value()
|
||||
elif isinstance(obj, self.PRIMITIVE_TYPES):
|
||||
return obj
|
||||
elif isinstance(obj, list):
|
||||
@ -291,7 +295,10 @@ class ApiClient:
|
||||
# and attributes which value is not None.
|
||||
# Convert attribute name to json key in
|
||||
# model definition for request.
|
||||
obj_dict = obj.to_dict()
|
||||
if hasattr(obj, 'to_dict') and callable(getattr(obj, 'to_dict')):
|
||||
obj_dict = obj.to_dict()
|
||||
else:
|
||||
obj_dict = obj.__dict__
|
||||
|
||||
return {key: self.sanitize_for_serialization(val)
|
||||
for key, val in obj_dict.items()}
|
||||
|
Loading…
x
Reference in New Issue
Block a user