[PYTHON] switch from mutable bytearray to immutable bytes to avoid pydantic error (#22988)

* switch from mutable bytearray to immutable bytes

* update python samples
This commit is contained in:
James Kent
2026-02-23 17:54:26 -06:00
committed by GitHub
parent 905b930144
commit a5e2fdf667
33 changed files with 231 additions and 232 deletions

View File

@@ -17,7 +17,7 @@ Method | HTTP request | Description
# **test_binary_gif**
> bytearray test_binary_gif()
> bytes test_binary_gif()
Test binary (gif) response body
@@ -60,7 +60,7 @@ This endpoint does not need any parameter.
### Return type
**bytearray**
**bytes**
### Authorization
@@ -105,7 +105,7 @@ configuration = openapi_client.Configuration(
with openapi_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = openapi_client.BodyApi(api_client)
body = None # bytearray | (optional)
body = None # bytes | (optional)
try:
# Test body parameter(s)
@@ -123,7 +123,7 @@ with openapi_client.ApiClient(configuration) as api_client:
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | **bytearray**| | [optional]
**body** | **bytes**| | [optional]
### Return type
@@ -172,7 +172,7 @@ configuration = openapi_client.Configuration(
with openapi_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = openapi_client.BodyApi(api_client)
files = None # List[bytearray] |
files = None # List[bytes] |
try:
# Test array of binary in multipart mime
@@ -190,7 +190,7 @@ with openapi_client.ApiClient(configuration) as api_client:
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**files** | **List[bytearray]**| |
**files** | **List[bytes]**| |
### Return type
@@ -239,7 +239,7 @@ configuration = openapi_client.Configuration(
with openapi_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = openapi_client.BodyApi(api_client)
my_file = None # bytearray | (optional)
my_file = None # bytes | (optional)
try:
# Test single binary in multipart mime
@@ -257,7 +257,7 @@ with openapi_client.ApiClient(configuration) as api_client:
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**my_file** | **bytearray**| | [optional]
**my_file** | **bytes**| | [optional]
### Return type

View File

@@ -56,7 +56,7 @@ class BodyApi:
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> bytearray:
) -> bytes:
"""Test binary (gif) response body
Test binary (gif) response body
@@ -91,7 +91,7 @@ class BodyApi:
)
_response_types_map: Dict[str, Optional[str]] = {
'200': "bytearray",
'200': "bytes",
}
response_data = self.api_client.call_api(
*_param,
@@ -119,7 +119,7 @@ class BodyApi:
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> ApiResponse[bytearray]:
) -> ApiResponse[bytes]:
"""Test binary (gif) response body
Test binary (gif) response body
@@ -154,7 +154,7 @@ class BodyApi:
)
_response_types_map: Dict[str, Optional[str]] = {
'200': "bytearray",
'200': "bytes",
}
response_data = self.api_client.call_api(
*_param,
@@ -217,7 +217,7 @@ class BodyApi:
)
_response_types_map: Dict[str, Optional[str]] = {
'200': "bytearray",
'200': "bytes",
}
response_data = self.api_client.call_api(
*_param,
@@ -308,7 +308,7 @@ class BodyApi:
Test body parameter(s)
:param body:
:type body: bytearray
:type body: bytes
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
@@ -375,7 +375,7 @@ class BodyApi:
Test body parameter(s)
:param body:
:type body: bytearray
:type body: bytes
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
@@ -442,7 +442,7 @@ class BodyApi:
Test body parameter(s)
:param body:
:type body: bytearray
:type body: bytes
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
@@ -589,7 +589,7 @@ class BodyApi:
Test array of binary in multipart mime
:param files: (required)
:type files: List[bytearray]
:type files: List[bytes]
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
@@ -656,7 +656,7 @@ class BodyApi:
Test array of binary in multipart mime
:param files: (required)
:type files: List[bytearray]
:type files: List[bytes]
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
@@ -723,7 +723,7 @@ class BodyApi:
Test array of binary in multipart mime
:param files: (required)
:type files: List[bytearray]
:type files: List[bytes]
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
@@ -863,7 +863,7 @@ class BodyApi:
Test single binary in multipart mime
:param my_file:
:type my_file: bytearray
:type my_file: bytes
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
@@ -930,7 +930,7 @@ class BodyApi:
Test single binary in multipart mime
:param my_file:
:type my_file: bytearray
:type my_file: bytes
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
@@ -997,7 +997,7 @@ class BodyApi:
Test single binary in multipart mime
:param my_file:
:type my_file: bytearray
:type my_file: bytes
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of

View File

@@ -306,7 +306,7 @@ class ApiClient:
response_text = None
return_data = None
try:
if response_type == "bytearray":
if response_type in ("bytearray", "bytes"):
return_data = response_data.data
elif response_type == "file":
return_data = self.__deserialize_file(response_data)