forked from loafle/openapi-generator-original
[python] Add tests and fix enum path parameters (#16769)
* test: Tests for enum params in path, query and header * fix: Get enum ref values correctly in path parameters Closes #16688 * fix java tests failure --------- Co-authored-by: William Cheng <wing328hk@gmail.com>
This commit is contained in:
@@ -20,10 +20,11 @@ import warnings
|
||||
from pydantic import validate_call, ValidationError
|
||||
from typing import Dict, List, Optional, Tuple
|
||||
|
||||
from pydantic import StrictBool, StrictInt, StrictStr
|
||||
from pydantic import StrictBool, StrictInt, StrictStr, field_validator
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from openapi_client.models.string_enum_ref import StringEnumRef
|
||||
|
||||
from openapi_client.api_client import ApiClient
|
||||
from openapi_client.api_response import ApiResponse
|
||||
@@ -46,14 +47,14 @@ class HeaderApi:
|
||||
self.api_client = api_client
|
||||
|
||||
@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
|
||||
def test_header_integer_boolean_string_enums(self, integer_header : Optional[StrictInt] = None, boolean_header : Optional[StrictBool] = None, string_header : Optional[StrictStr] = None, enum_nonref_string_header : Optional[StrictStr] = None, enum_ref_string_header : Optional[StringEnumRef] = None, **kwargs) -> str: # noqa: E501
|
||||
"""Test header parameter(s) # noqa: E501
|
||||
|
||||
Test header parameter(s) # noqa: E501
|
||||
This method makes a synchronous HTTP request by default. To make an
|
||||
asynchronous HTTP request, please pass async_req=True
|
||||
|
||||
>>> thread = api.test_header_integer_boolean_string(integer_header, boolean_header, string_header, async_req=True)
|
||||
>>> thread = api.test_header_integer_boolean_string_enums(integer_header, boolean_header, string_header, enum_nonref_string_header, enum_ref_string_header, async_req=True)
|
||||
>>> result = thread.get()
|
||||
|
||||
:param integer_header:
|
||||
@@ -62,6 +63,10 @@ class HeaderApi:
|
||||
:type boolean_header: bool
|
||||
:param string_header:
|
||||
:type string_header: str
|
||||
:param enum_nonref_string_header:
|
||||
:type enum_nonref_string_header: str
|
||||
:param enum_ref_string_header:
|
||||
:type enum_ref_string_header: StringEnumRef
|
||||
:param async_req: Whether to execute the request asynchronously.
|
||||
:type async_req: bool, optional
|
||||
:param _request_timeout: timeout setting for this request.
|
||||
@@ -75,19 +80,19 @@ class HeaderApi:
|
||||
"""
|
||||
kwargs['_return_http_data_only'] = True
|
||||
if '_preload_content' in kwargs:
|
||||
message = "Error! Please call the test_header_integer_boolean_string_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
|
||||
message = "Error! Please call the test_header_integer_boolean_string_enums_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
|
||||
raise ValueError(message)
|
||||
return self.test_header_integer_boolean_string_with_http_info(integer_header, boolean_header, string_header, **kwargs) # noqa: E501
|
||||
return self.test_header_integer_boolean_string_enums_with_http_info(integer_header, boolean_header, string_header, enum_nonref_string_header, enum_ref_string_header, **kwargs) # noqa: E501
|
||||
|
||||
@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
|
||||
def test_header_integer_boolean_string_enums_with_http_info(self, integer_header : Optional[StrictInt] = None, boolean_header : Optional[StrictBool] = None, string_header : Optional[StrictStr] = None, enum_nonref_string_header : Optional[StrictStr] = None, enum_ref_string_header : Optional[StringEnumRef] = None, **kwargs) -> ApiResponse: # noqa: E501
|
||||
"""Test header parameter(s) # noqa: E501
|
||||
|
||||
Test header parameter(s) # noqa: E501
|
||||
This method makes a synchronous HTTP request by default. To make an
|
||||
asynchronous HTTP request, please pass async_req=True
|
||||
|
||||
>>> thread = api.test_header_integer_boolean_string_with_http_info(integer_header, boolean_header, string_header, async_req=True)
|
||||
>>> thread = api.test_header_integer_boolean_string_enums_with_http_info(integer_header, boolean_header, string_header, enum_nonref_string_header, enum_ref_string_header, async_req=True)
|
||||
>>> result = thread.get()
|
||||
|
||||
:param integer_header:
|
||||
@@ -96,6 +101,10 @@ class HeaderApi:
|
||||
:type boolean_header: bool
|
||||
:param string_header:
|
||||
:type string_header: str
|
||||
:param enum_nonref_string_header:
|
||||
:type enum_nonref_string_header: str
|
||||
:param enum_ref_string_header:
|
||||
:type enum_ref_string_header: StringEnumRef
|
||||
:param async_req: Whether to execute the request asynchronously.
|
||||
:type async_req: bool, optional
|
||||
:param _preload_content: if False, the ApiResponse.data will
|
||||
@@ -126,7 +135,9 @@ class HeaderApi:
|
||||
_all_params = [
|
||||
'integer_header',
|
||||
'boolean_header',
|
||||
'string_header'
|
||||
'string_header',
|
||||
'enum_nonref_string_header',
|
||||
'enum_ref_string_header'
|
||||
]
|
||||
_all_params.extend(
|
||||
[
|
||||
@@ -145,7 +156,7 @@ class HeaderApi:
|
||||
if _key not in _all_params:
|
||||
raise ApiTypeError(
|
||||
"Got an unexpected keyword argument '%s'"
|
||||
" to method test_header_integer_boolean_string" % _key
|
||||
" to method test_header_integer_boolean_string_enums" % _key
|
||||
)
|
||||
_params[_key] = _val
|
||||
del _params['kwargs']
|
||||
@@ -168,6 +179,12 @@ class HeaderApi:
|
||||
if _params['string_header'] is not None:
|
||||
_header_params['string_header'] = _params['string_header']
|
||||
|
||||
if _params['enum_nonref_string_header'] is not None:
|
||||
_header_params['enum_nonref_string_header'] = _params['enum_nonref_string_header']
|
||||
|
||||
if _params['enum_ref_string_header'] is not None:
|
||||
_header_params['enum_ref_string_header'] = _params['enum_ref_string_header']
|
||||
|
||||
# process the form parameters
|
||||
_form_params: List[Tuple[str, str]] = []
|
||||
_files: Dict[str, str] = {}
|
||||
@@ -185,7 +202,7 @@ class HeaderApi:
|
||||
}
|
||||
|
||||
return self.api_client.call_api(
|
||||
'/header/integer/boolean/string', 'GET',
|
||||
'/header/integer/boolean/string/enums', 'GET',
|
||||
_path_params,
|
||||
_query_params,
|
||||
_header_params,
|
||||
|
||||
@@ -20,8 +20,9 @@ import warnings
|
||||
from pydantic import validate_call, ValidationError
|
||||
from typing import Dict, List, Optional, Tuple
|
||||
|
||||
from pydantic import StrictInt, StrictStr
|
||||
from pydantic import StrictInt, StrictStr, field_validator
|
||||
|
||||
from openapi_client.models.string_enum_ref import StringEnumRef
|
||||
|
||||
from openapi_client.api_client import ApiClient
|
||||
from openapi_client.api_response import ApiResponse
|
||||
@@ -44,20 +45,24 @@ class PathApi:
|
||||
self.api_client = api_client
|
||||
|
||||
@validate_call
|
||||
def tests_path_string_path_string_integer_path_integer(self, path_string : StrictStr, path_integer : StrictInt, **kwargs) -> str: # noqa: E501
|
||||
def tests_path_string_path_string_integer_path_integer_enum_nonref_string_path_enum_ref_string_path(self, path_string : StrictStr, path_integer : StrictInt, enum_nonref_string_path : StrictStr, enum_ref_string_path : StringEnumRef, **kwargs) -> str: # noqa: E501
|
||||
"""Test path parameter(s) # noqa: E501
|
||||
|
||||
Test path parameter(s) # noqa: E501
|
||||
This method makes a synchronous HTTP request by default. To make an
|
||||
asynchronous HTTP request, please pass async_req=True
|
||||
|
||||
>>> thread = api.tests_path_string_path_string_integer_path_integer(path_string, path_integer, async_req=True)
|
||||
>>> thread = api.tests_path_string_path_string_integer_path_integer_enum_nonref_string_path_enum_ref_string_path(path_string, path_integer, enum_nonref_string_path, enum_ref_string_path, async_req=True)
|
||||
>>> result = thread.get()
|
||||
|
||||
:param path_string: (required)
|
||||
:type path_string: str
|
||||
:param path_integer: (required)
|
||||
:type path_integer: int
|
||||
:param enum_nonref_string_path: (required)
|
||||
:type enum_nonref_string_path: str
|
||||
:param enum_ref_string_path: (required)
|
||||
:type enum_ref_string_path: StringEnumRef
|
||||
:param async_req: Whether to execute the request asynchronously.
|
||||
:type async_req: bool, optional
|
||||
:param _request_timeout: timeout setting for this request.
|
||||
@@ -71,25 +76,29 @@ class PathApi:
|
||||
"""
|
||||
kwargs['_return_http_data_only'] = True
|
||||
if '_preload_content' in kwargs:
|
||||
message = "Error! Please call the tests_path_string_path_string_integer_path_integer_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
|
||||
message = "Error! Please call the tests_path_string_path_string_integer_path_integer_enum_nonref_string_path_enum_ref_string_path_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
|
||||
raise ValueError(message)
|
||||
return self.tests_path_string_path_string_integer_path_integer_with_http_info(path_string, path_integer, **kwargs) # noqa: E501
|
||||
return self.tests_path_string_path_string_integer_path_integer_enum_nonref_string_path_enum_ref_string_path_with_http_info(path_string, path_integer, enum_nonref_string_path, enum_ref_string_path, **kwargs) # noqa: E501
|
||||
|
||||
@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
|
||||
def tests_path_string_path_string_integer_path_integer_enum_nonref_string_path_enum_ref_string_path_with_http_info(self, path_string : StrictStr, path_integer : StrictInt, enum_nonref_string_path : StrictStr, enum_ref_string_path : StringEnumRef, **kwargs) -> ApiResponse: # noqa: E501
|
||||
"""Test path parameter(s) # noqa: E501
|
||||
|
||||
Test path parameter(s) # noqa: E501
|
||||
This method makes a synchronous HTTP request by default. To make an
|
||||
asynchronous HTTP request, please pass async_req=True
|
||||
|
||||
>>> thread = api.tests_path_string_path_string_integer_path_integer_with_http_info(path_string, path_integer, async_req=True)
|
||||
>>> thread = api.tests_path_string_path_string_integer_path_integer_enum_nonref_string_path_enum_ref_string_path_with_http_info(path_string, path_integer, enum_nonref_string_path, enum_ref_string_path, async_req=True)
|
||||
>>> result = thread.get()
|
||||
|
||||
:param path_string: (required)
|
||||
:type path_string: str
|
||||
:param path_integer: (required)
|
||||
:type path_integer: int
|
||||
:param enum_nonref_string_path: (required)
|
||||
:type enum_nonref_string_path: str
|
||||
:param enum_ref_string_path: (required)
|
||||
:type enum_ref_string_path: StringEnumRef
|
||||
:param async_req: Whether to execute the request asynchronously.
|
||||
:type async_req: bool, optional
|
||||
:param _preload_content: if False, the ApiResponse.data will
|
||||
@@ -119,7 +128,9 @@ class PathApi:
|
||||
|
||||
_all_params = [
|
||||
'path_string',
|
||||
'path_integer'
|
||||
'path_integer',
|
||||
'enum_nonref_string_path',
|
||||
'enum_ref_string_path'
|
||||
]
|
||||
_all_params.extend(
|
||||
[
|
||||
@@ -138,7 +149,7 @@ class PathApi:
|
||||
if _key not in _all_params:
|
||||
raise ApiTypeError(
|
||||
"Got an unexpected keyword argument '%s'"
|
||||
" to method tests_path_string_path_string_integer_path_integer" % _key
|
||||
" to method tests_path_string_path_string_integer_path_integer_enum_nonref_string_path_enum_ref_string_path" % _key
|
||||
)
|
||||
_params[_key] = _val
|
||||
del _params['kwargs']
|
||||
@@ -153,6 +164,12 @@ class PathApi:
|
||||
if _params['path_integer'] is not None:
|
||||
_path_params['path_integer'] = _params['path_integer']
|
||||
|
||||
if _params['enum_nonref_string_path'] is not None:
|
||||
_path_params['enum_nonref_string_path'] = _params['enum_nonref_string_path']
|
||||
|
||||
if _params['enum_ref_string_path'] is not None:
|
||||
_path_params['enum_ref_string_path'] = _params['enum_ref_string_path'].value
|
||||
|
||||
|
||||
# process the query parameters
|
||||
_query_params: List[Tuple[str, str]] = []
|
||||
@@ -175,7 +192,7 @@ class PathApi:
|
||||
}
|
||||
|
||||
return self.api_client.call_api(
|
||||
'/path/string/{path_string}/integer/{path_integer}', 'GET',
|
||||
'/path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path}', 'GET',
|
||||
_path_params,
|
||||
_query_params,
|
||||
_header_params,
|
||||
|
||||
@@ -22,7 +22,7 @@ from typing import Dict, List, Optional, Tuple
|
||||
|
||||
from datetime import date, datetime
|
||||
|
||||
from pydantic import StrictBool, StrictInt, StrictStr
|
||||
from pydantic import StrictBool, StrictInt, StrictStr, field_validator
|
||||
|
||||
from typing import Any, Optional
|
||||
|
||||
@@ -51,16 +51,18 @@ class QueryApi:
|
||||
self.api_client = api_client
|
||||
|
||||
@validate_call
|
||||
def test_enum_ref_string(self, enum_ref_string_query : Optional[StringEnumRef] = None, **kwargs) -> str: # noqa: E501
|
||||
def test_enum_ref_string(self, enum_nonref_string_query : Optional[StrictStr] = None, enum_ref_string_query : Optional[StringEnumRef] = None, **kwargs) -> str: # noqa: E501
|
||||
"""Test query parameter(s) # noqa: E501
|
||||
|
||||
Test query parameter(s) # noqa: E501
|
||||
This method makes a synchronous HTTP request by default. To make an
|
||||
asynchronous HTTP request, please pass async_req=True
|
||||
|
||||
>>> thread = api.test_enum_ref_string(enum_ref_string_query, async_req=True)
|
||||
>>> thread = api.test_enum_ref_string(enum_nonref_string_query, enum_ref_string_query, async_req=True)
|
||||
>>> result = thread.get()
|
||||
|
||||
:param enum_nonref_string_query:
|
||||
:type enum_nonref_string_query: str
|
||||
:param enum_ref_string_query:
|
||||
:type enum_ref_string_query: StringEnumRef
|
||||
:param async_req: Whether to execute the request asynchronously.
|
||||
@@ -78,19 +80,21 @@ class QueryApi:
|
||||
if '_preload_content' in kwargs:
|
||||
message = "Error! Please call the test_enum_ref_string_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
|
||||
raise ValueError(message)
|
||||
return self.test_enum_ref_string_with_http_info(enum_ref_string_query, **kwargs) # noqa: E501
|
||||
return self.test_enum_ref_string_with_http_info(enum_nonref_string_query, enum_ref_string_query, **kwargs) # noqa: E501
|
||||
|
||||
@validate_call
|
||||
def test_enum_ref_string_with_http_info(self, enum_ref_string_query : Optional[StringEnumRef] = None, **kwargs) -> ApiResponse: # noqa: E501
|
||||
def test_enum_ref_string_with_http_info(self, enum_nonref_string_query : Optional[StrictStr] = None, enum_ref_string_query : Optional[StringEnumRef] = None, **kwargs) -> ApiResponse: # noqa: E501
|
||||
"""Test query parameter(s) # noqa: E501
|
||||
|
||||
Test query parameter(s) # noqa: E501
|
||||
This method makes a synchronous HTTP request by default. To make an
|
||||
asynchronous HTTP request, please pass async_req=True
|
||||
|
||||
>>> thread = api.test_enum_ref_string_with_http_info(enum_ref_string_query, async_req=True)
|
||||
>>> thread = api.test_enum_ref_string_with_http_info(enum_nonref_string_query, enum_ref_string_query, async_req=True)
|
||||
>>> result = thread.get()
|
||||
|
||||
:param enum_nonref_string_query:
|
||||
:type enum_nonref_string_query: str
|
||||
:param enum_ref_string_query:
|
||||
:type enum_ref_string_query: StringEnumRef
|
||||
:param async_req: Whether to execute the request asynchronously.
|
||||
@@ -121,6 +125,7 @@ class QueryApi:
|
||||
_params = locals()
|
||||
|
||||
_all_params = [
|
||||
'enum_nonref_string_query',
|
||||
'enum_ref_string_query'
|
||||
]
|
||||
_all_params.extend(
|
||||
@@ -152,6 +157,9 @@ class QueryApi:
|
||||
|
||||
# process the query parameters
|
||||
_query_params: List[Tuple[str, str]] = []
|
||||
if _params.get('enum_nonref_string_query') is not None: # noqa: E501
|
||||
_query_params.append(('enum_nonref_string_query', _params['enum_nonref_string_query']))
|
||||
|
||||
if _params.get('enum_ref_string_query') is not None: # noqa: E501
|
||||
_query_params.append(('enum_ref_string_query', _params['enum_ref_string_query'].value))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user