forked from loafle/openapi-generator-original
[PYTHON] generate code based on pydantic v2 (#16685)
* [python] replace validator with field_validator
* [python] replace parse_obj with model_validate
* [python] replace dict with model_dump
* [python] replace construct with model_construct
* [python] replace __fields_set__ with model_fields_set
* [python] replace __fields_set__ in the test cases with model_fields_set
* [python] replace validate_arguments with validate_call
* [python] replace max_items, min_items with max_length, min_length
* [python] replace Config class with model_config
* [python] replace allow_population_by_field_name with populate_by_name
* [python] remove {{{classname}}}_ONE_OF_SCHEMAS
* [python] update test cases
* [python] update samples
* [python] fix typos in test cases
This commit is contained in:
@@ -17,7 +17,7 @@ import re # noqa: F401
|
||||
import io
|
||||
import warnings
|
||||
|
||||
from pydantic import validate_arguments, ValidationError
|
||||
from pydantic import validate_call, ValidationError
|
||||
|
||||
|
||||
from openapi_client.api_client import ApiClient
|
||||
@@ -40,7 +40,7 @@ class AuthApi:
|
||||
api_client = ApiClient.get_default()
|
||||
self.api_client = api_client
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_auth_http_basic(self, **kwargs) -> str: # noqa: E501
|
||||
"""To test HTTP basic authentication # noqa: E501
|
||||
|
||||
@@ -68,7 +68,7 @@ class AuthApi:
|
||||
raise ValueError(message)
|
||||
return self.test_auth_http_basic_with_http_info(**kwargs) # noqa: E501
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_auth_http_basic_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501
|
||||
"""To test HTTP basic authentication # noqa: E501
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import re # noqa: F401
|
||||
import io
|
||||
import warnings
|
||||
|
||||
from pydantic import validate_arguments, ValidationError
|
||||
from pydantic import validate_call, ValidationError
|
||||
|
||||
from pydantic import Field
|
||||
from typing_extensions import Annotated
|
||||
@@ -48,7 +48,7 @@ class BodyApi:
|
||||
api_client = ApiClient.get_default()
|
||||
self.api_client = api_client
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_binary_gif(self, **kwargs) -> bytearray: # noqa: E501
|
||||
"""Test binary (gif) response body # noqa: E501
|
||||
|
||||
@@ -76,7 +76,7 @@ class BodyApi:
|
||||
raise ValueError(message)
|
||||
return self.test_binary_gif_with_http_info(**kwargs) # noqa: E501
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_binary_gif_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501
|
||||
"""Test binary (gif) response body # noqa: E501
|
||||
|
||||
@@ -180,7 +180,7 @@ class BodyApi:
|
||||
collection_formats=_collection_formats,
|
||||
_request_auth=_params.get('_request_auth'))
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_body_application_octetstream_binary(self, body : Optional[Union[StrictBytes, StrictStr]] = None, **kwargs) -> str: # noqa: E501
|
||||
"""Test body parameter(s) # noqa: E501
|
||||
|
||||
@@ -210,7 +210,7 @@ class BodyApi:
|
||||
raise ValueError(message)
|
||||
return self.test_body_application_octetstream_binary_with_http_info(body, **kwargs) # noqa: E501
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_body_application_octetstream_binary_with_http_info(self, body : Optional[Union[StrictBytes, StrictStr]] = None, **kwargs) -> ApiResponse: # noqa: E501
|
||||
"""Test body parameter(s) # noqa: E501
|
||||
|
||||
@@ -332,7 +332,7 @@ class BodyApi:
|
||||
collection_formats=_collection_formats,
|
||||
_request_auth=_params.get('_request_auth'))
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_body_multipart_formdata_array_of_binary(self, files : List[Union[StrictBytes, StrictStr]], **kwargs) -> str: # noqa: E501
|
||||
"""Test array of binary in multipart mime # noqa: E501
|
||||
|
||||
@@ -362,7 +362,7 @@ class BodyApi:
|
||||
raise ValueError(message)
|
||||
return self.test_body_multipart_formdata_array_of_binary_with_http_info(files, **kwargs) # noqa: E501
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_body_multipart_formdata_array_of_binary_with_http_info(self, files : List[Union[StrictBytes, StrictStr]], **kwargs) -> ApiResponse: # noqa: E501
|
||||
"""Test array of binary in multipart mime # noqa: E501
|
||||
|
||||
@@ -480,7 +480,7 @@ class BodyApi:
|
||||
collection_formats=_collection_formats,
|
||||
_request_auth=_params.get('_request_auth'))
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_echo_body_free_form_object_response_string(self, body : Annotated[Optional[Dict[str, Any]], Field(description="Free form object")] = None, **kwargs) -> str: # noqa: E501
|
||||
"""Test free form object # noqa: E501
|
||||
|
||||
@@ -510,7 +510,7 @@ class BodyApi:
|
||||
raise ValueError(message)
|
||||
return self.test_echo_body_free_form_object_response_string_with_http_info(body, **kwargs) # noqa: E501
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_echo_body_free_form_object_response_string_with_http_info(self, body : Annotated[Optional[Dict[str, Any]], Field(description="Free form object")] = None, **kwargs) -> ApiResponse: # noqa: E501
|
||||
"""Test free form object # noqa: E501
|
||||
|
||||
@@ -627,7 +627,7 @@ class BodyApi:
|
||||
collection_formats=_collection_formats,
|
||||
_request_auth=_params.get('_request_auth'))
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_echo_body_pet(self, pet : Annotated[Optional[Pet], Field(description="Pet object that needs to be added to the store")] = None, **kwargs) -> Pet: # noqa: E501
|
||||
"""Test body parameter(s) # noqa: E501
|
||||
|
||||
@@ -657,7 +657,7 @@ class BodyApi:
|
||||
raise ValueError(message)
|
||||
return self.test_echo_body_pet_with_http_info(pet, **kwargs) # noqa: E501
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_echo_body_pet_with_http_info(self, pet : Annotated[Optional[Pet], Field(description="Pet object that needs to be added to the store")] = None, **kwargs) -> ApiResponse: # noqa: E501
|
||||
"""Test body parameter(s) # noqa: E501
|
||||
|
||||
@@ -774,7 +774,7 @@ class BodyApi:
|
||||
collection_formats=_collection_formats,
|
||||
_request_auth=_params.get('_request_auth'))
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_echo_body_pet_response_string(self, pet : Annotated[Optional[Pet], Field(description="Pet object that needs to be added to the store")] = None, **kwargs) -> str: # noqa: E501
|
||||
"""Test empty response body # noqa: E501
|
||||
|
||||
@@ -804,7 +804,7 @@ class BodyApi:
|
||||
raise ValueError(message)
|
||||
return self.test_echo_body_pet_response_string_with_http_info(pet, **kwargs) # noqa: E501
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_echo_body_pet_response_string_with_http_info(self, pet : Annotated[Optional[Pet], Field(description="Pet object that needs to be added to the store")] = None, **kwargs) -> ApiResponse: # noqa: E501
|
||||
"""Test empty response body # noqa: E501
|
||||
|
||||
@@ -921,7 +921,7 @@ class BodyApi:
|
||||
collection_formats=_collection_formats,
|
||||
_request_auth=_params.get('_request_auth'))
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_echo_body_tag_response_string(self, tag : Annotated[Optional[Tag], Field(description="Tag object")] = None, **kwargs) -> str: # noqa: E501
|
||||
"""Test empty json (request body) # noqa: E501
|
||||
|
||||
@@ -951,7 +951,7 @@ class BodyApi:
|
||||
raise ValueError(message)
|
||||
return self.test_echo_body_tag_response_string_with_http_info(tag, **kwargs) # noqa: E501
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_echo_body_tag_response_string_with_http_info(self, tag : Annotated[Optional[Tag], Field(description="Tag object")] = None, **kwargs) -> ApiResponse: # noqa: E501
|
||||
"""Test empty json (request body) # noqa: E501
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import re # noqa: F401
|
||||
import io
|
||||
import warnings
|
||||
|
||||
from pydantic import validate_arguments, ValidationError
|
||||
from pydantic import validate_call, ValidationError
|
||||
|
||||
from pydantic import StrictBool, StrictInt, StrictStr
|
||||
|
||||
@@ -44,7 +44,7 @@ class FormApi:
|
||||
api_client = ApiClient.get_default()
|
||||
self.api_client = api_client
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_form_integer_boolean_string(self, integer_form : Optional[StrictInt] = None, boolean_form : Optional[StrictBool] = None, string_form : Optional[StrictStr] = None, **kwargs) -> str: # noqa: E501
|
||||
"""Test form parameter(s) # noqa: E501
|
||||
|
||||
@@ -78,7 +78,7 @@ class FormApi:
|
||||
raise ValueError(message)
|
||||
return self.test_form_integer_boolean_string_with_http_info(integer_form, boolean_form, string_form, **kwargs) # noqa: E501
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_form_integer_boolean_string_with_http_info(self, integer_form : Optional[StrictInt] = None, boolean_form : Optional[StrictBool] = None, string_form : Optional[StrictStr] = None, **kwargs) -> ApiResponse: # noqa: E501
|
||||
"""Test form parameter(s) # noqa: E501
|
||||
|
||||
@@ -207,7 +207,7 @@ class FormApi:
|
||||
collection_formats=_collection_formats,
|
||||
_request_auth=_params.get('_request_auth'))
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_form_oneof(self, form1 : Optional[StrictStr] = None, form2 : Optional[StrictInt] = None, form3 : Optional[StrictStr] = None, form4 : Optional[StrictBool] = None, id : Optional[StrictInt] = None, name : Optional[StrictStr] = None, **kwargs) -> str: # noqa: E501
|
||||
"""Test form parameter(s) for oneOf schema # noqa: E501
|
||||
|
||||
@@ -247,7 +247,7 @@ class FormApi:
|
||||
raise ValueError(message)
|
||||
return self.test_form_oneof_with_http_info(form1, form2, form3, form4, id, name, **kwargs) # noqa: E501
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_form_oneof_with_http_info(self, form1 : Optional[StrictStr] = None, form2 : Optional[StrictInt] = None, form3 : Optional[StrictStr] = None, form4 : Optional[StrictBool] = None, id : Optional[StrictInt] = None, name : Optional[StrictStr] = None, **kwargs) -> ApiResponse: # noqa: E501
|
||||
"""Test form parameter(s) for oneOf schema # noqa: E501
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import re # noqa: F401
|
||||
import io
|
||||
import warnings
|
||||
|
||||
from pydantic import validate_arguments, ValidationError
|
||||
from pydantic import validate_call, ValidationError
|
||||
|
||||
from pydantic import StrictBool, StrictInt, StrictStr
|
||||
|
||||
@@ -44,7 +44,7 @@ class HeaderApi:
|
||||
api_client = ApiClient.get_default()
|
||||
self.api_client = api_client
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_header_integer_boolean_string(self, integer_header : Optional[StrictInt] = None, boolean_header : Optional[StrictBool] = None, string_header : Optional[StrictStr] = None, **kwargs) -> str: # noqa: E501
|
||||
"""Test header parameter(s) # noqa: E501
|
||||
|
||||
@@ -78,7 +78,7 @@ class HeaderApi:
|
||||
raise ValueError(message)
|
||||
return self.test_header_integer_boolean_string_with_http_info(integer_header, boolean_header, string_header, **kwargs) # noqa: E501
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_header_integer_boolean_string_with_http_info(self, integer_header : Optional[StrictInt] = None, boolean_header : Optional[StrictBool] = None, string_header : Optional[StrictStr] = None, **kwargs) -> ApiResponse: # noqa: E501
|
||||
"""Test header parameter(s) # noqa: E501
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import re # noqa: F401
|
||||
import io
|
||||
import warnings
|
||||
|
||||
from pydantic import validate_arguments, ValidationError
|
||||
from pydantic import validate_call, ValidationError
|
||||
|
||||
from pydantic import StrictInt, StrictStr
|
||||
|
||||
@@ -42,7 +42,7 @@ class PathApi:
|
||||
api_client = ApiClient.get_default()
|
||||
self.api_client = api_client
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def tests_path_string_path_string_integer_path_integer(self, path_string : StrictStr, path_integer : StrictInt, **kwargs) -> str: # noqa: E501
|
||||
"""Test path parameter(s) # noqa: E501
|
||||
|
||||
@@ -74,7 +74,7 @@ class PathApi:
|
||||
raise ValueError(message)
|
||||
return self.tests_path_string_path_string_integer_path_integer_with_http_info(path_string, path_integer, **kwargs) # noqa: E501
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def tests_path_string_path_string_integer_path_integer_with_http_info(self, path_string : StrictStr, path_integer : StrictInt, **kwargs) -> ApiResponse: # noqa: E501
|
||||
"""Test path parameter(s) # noqa: E501
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import re # noqa: F401
|
||||
import io
|
||||
import warnings
|
||||
|
||||
from pydantic import validate_arguments, ValidationError
|
||||
from pydantic import validate_call, ValidationError
|
||||
|
||||
from datetime import date, datetime
|
||||
|
||||
@@ -49,7 +49,7 @@ class QueryApi:
|
||||
api_client = ApiClient.get_default()
|
||||
self.api_client = api_client
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_enum_ref_string(self, enum_ref_string_query : Optional[StringEnumRef] = None, **kwargs) -> str: # noqa: E501
|
||||
"""Test query parameter(s) # noqa: E501
|
||||
|
||||
@@ -79,7 +79,7 @@ class QueryApi:
|
||||
raise ValueError(message)
|
||||
return self.test_enum_ref_string_with_http_info(enum_ref_string_query, **kwargs) # noqa: E501
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_enum_ref_string_with_http_info(self, enum_ref_string_query : Optional[StringEnumRef] = None, **kwargs) -> ApiResponse: # noqa: E501
|
||||
"""Test query parameter(s) # noqa: E501
|
||||
|
||||
@@ -189,7 +189,7 @@ class QueryApi:
|
||||
collection_formats=_collection_formats,
|
||||
_request_auth=_params.get('_request_auth'))
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_query_datetime_date_string(self, datetime_query : Optional[datetime] = None, date_query : Optional[date] = None, string_query : Optional[StrictStr] = None, **kwargs) -> str: # noqa: E501
|
||||
"""Test query parameter(s) # noqa: E501
|
||||
|
||||
@@ -223,7 +223,7 @@ class QueryApi:
|
||||
raise ValueError(message)
|
||||
return self.test_query_datetime_date_string_with_http_info(datetime_query, date_query, string_query, **kwargs) # noqa: E501
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_query_datetime_date_string_with_http_info(self, datetime_query : Optional[datetime] = None, date_query : Optional[date] = None, string_query : Optional[StrictStr] = None, **kwargs) -> ApiResponse: # noqa: E501
|
||||
"""Test query parameter(s) # noqa: E501
|
||||
|
||||
@@ -351,7 +351,7 @@ class QueryApi:
|
||||
collection_formats=_collection_formats,
|
||||
_request_auth=_params.get('_request_auth'))
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_query_integer_boolean_string(self, integer_query : Optional[StrictInt] = None, boolean_query : Optional[StrictBool] = None, string_query : Optional[StrictStr] = None, **kwargs) -> str: # noqa: E501
|
||||
"""Test query parameter(s) # noqa: E501
|
||||
|
||||
@@ -385,7 +385,7 @@ class QueryApi:
|
||||
raise ValueError(message)
|
||||
return self.test_query_integer_boolean_string_with_http_info(integer_query, boolean_query, string_query, **kwargs) # noqa: E501
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_query_integer_boolean_string_with_http_info(self, integer_query : Optional[StrictInt] = None, boolean_query : Optional[StrictBool] = None, string_query : Optional[StrictStr] = None, **kwargs) -> ApiResponse: # noqa: E501
|
||||
"""Test query parameter(s) # noqa: E501
|
||||
|
||||
@@ -507,7 +507,7 @@ class QueryApi:
|
||||
collection_formats=_collection_formats,
|
||||
_request_auth=_params.get('_request_auth'))
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_query_style_deep_object_explode_true_object(self, query_object : Optional[Pet] = None, **kwargs) -> str: # noqa: E501
|
||||
"""Test query parameter(s) # noqa: E501
|
||||
|
||||
@@ -537,7 +537,7 @@ class QueryApi:
|
||||
raise ValueError(message)
|
||||
return self.test_query_style_deep_object_explode_true_object_with_http_info(query_object, **kwargs) # noqa: E501
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_query_style_deep_object_explode_true_object_with_http_info(self, query_object : Optional[Pet] = None, **kwargs) -> ApiResponse: # noqa: E501
|
||||
"""Test query parameter(s) # noqa: E501
|
||||
|
||||
@@ -647,7 +647,7 @@ class QueryApi:
|
||||
collection_formats=_collection_formats,
|
||||
_request_auth=_params.get('_request_auth'))
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_query_style_deep_object_explode_true_object_all_of(self, query_object : Optional[Any] = None, **kwargs) -> str: # noqa: E501
|
||||
"""Test query parameter(s) # noqa: E501
|
||||
|
||||
@@ -677,7 +677,7 @@ class QueryApi:
|
||||
raise ValueError(message)
|
||||
return self.test_query_style_deep_object_explode_true_object_all_of_with_http_info(query_object, **kwargs) # noqa: E501
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_query_style_deep_object_explode_true_object_all_of_with_http_info(self, query_object : Optional[Any] = None, **kwargs) -> ApiResponse: # noqa: E501
|
||||
"""Test query parameter(s) # noqa: E501
|
||||
|
||||
@@ -787,7 +787,7 @@ class QueryApi:
|
||||
collection_formats=_collection_formats,
|
||||
_request_auth=_params.get('_request_auth'))
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_query_style_form_explode_true_array_string(self, query_object : Optional[TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter] = None, **kwargs) -> str: # noqa: E501
|
||||
"""Test query parameter(s) # noqa: E501
|
||||
|
||||
@@ -817,7 +817,7 @@ class QueryApi:
|
||||
raise ValueError(message)
|
||||
return self.test_query_style_form_explode_true_array_string_with_http_info(query_object, **kwargs) # noqa: E501
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_query_style_form_explode_true_array_string_with_http_info(self, query_object : Optional[TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter] = None, **kwargs) -> ApiResponse: # noqa: E501
|
||||
"""Test query parameter(s) # noqa: E501
|
||||
|
||||
@@ -927,7 +927,7 @@ class QueryApi:
|
||||
collection_formats=_collection_formats,
|
||||
_request_auth=_params.get('_request_auth'))
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_query_style_form_explode_true_object(self, query_object : Optional[Pet] = None, **kwargs) -> str: # noqa: E501
|
||||
"""Test query parameter(s) # noqa: E501
|
||||
|
||||
@@ -957,7 +957,7 @@ class QueryApi:
|
||||
raise ValueError(message)
|
||||
return self.test_query_style_form_explode_true_object_with_http_info(query_object, **kwargs) # noqa: E501
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_query_style_form_explode_true_object_with_http_info(self, query_object : Optional[Pet] = None, **kwargs) -> ApiResponse: # noqa: E501
|
||||
"""Test query parameter(s) # noqa: E501
|
||||
|
||||
@@ -1067,7 +1067,7 @@ class QueryApi:
|
||||
collection_formats=_collection_formats,
|
||||
_request_auth=_params.get('_request_auth'))
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_query_style_form_explode_true_object_all_of(self, query_object : Optional[Any] = None, **kwargs) -> str: # noqa: E501
|
||||
"""Test query parameter(s) # noqa: E501
|
||||
|
||||
@@ -1097,7 +1097,7 @@ class QueryApi:
|
||||
raise ValueError(message)
|
||||
return self.test_query_style_form_explode_true_object_all_of_with_http_info(query_object, **kwargs) # noqa: E501
|
||||
|
||||
@validate_arguments
|
||||
@validate_call
|
||||
def test_query_style_form_explode_true_object_all_of_with_http_info(self, query_object : Optional[Any] = None, **kwargs) -> ApiResponse: # noqa: E501
|
||||
"""Test query parameter(s) # noqa: E501
|
||||
|
||||
|
||||
Reference in New Issue
Block a user