[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:
Robert Schweizer
2023-10-10 11:10:30 +02:00
committed by GitHub
parent 7bb75f4bb4
commit 9e07f85eb5
88 changed files with 1549 additions and 538 deletions

View File

@@ -23,6 +23,7 @@ from pydantic import StrictBool, StrictInt, StrictStr
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
@@ -45,14 +46,14 @@ class HeaderApi:
self.api_client = api_client
@validate_arguments
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:
@@ -61,6 +62,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.
@@ -74,19 +79,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_arguments
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:
@@ -95,6 +100,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
@@ -125,7 +134,9 @@ class HeaderApi:
_all_params = [
'integer_header',
'boolean_header',
'string_header'
'string_header',
'enum_nonref_string_header',
'enum_ref_string_header'
]
_all_params.extend(
[
@@ -144,7 +155,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']
@@ -167,6 +178,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 = []
_files = {}
@@ -184,7 +201,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,

View File

@@ -21,6 +21,7 @@ from pydantic import validate_arguments, ValidationError
from pydantic import StrictInt, StrictStr
from openapi_client.models.string_enum_ref import StringEnumRef
from openapi_client.api_client import ApiClient
from openapi_client.api_response import ApiResponse
@@ -43,20 +44,24 @@ class PathApi:
self.api_client = api_client
@validate_arguments
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.
@@ -70,25 +75,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_arguments
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
@@ -118,7 +127,9 @@ class PathApi:
_all_params = [
'path_string',
'path_integer'
'path_integer',
'enum_nonref_string_path',
'enum_ref_string_path'
]
_all_params.extend(
[
@@ -137,7 +148,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']
@@ -152,6 +163,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']
# process the query parameters
_query_params = []
@@ -174,7 +191,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,

View File

@@ -50,16 +50,18 @@ class QueryApi:
self.api_client = api_client
@validate_arguments
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.
@@ -77,19 +79,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_arguments
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.
@@ -120,6 +124,7 @@ class QueryApi:
_params = locals()
_all_params = [
'enum_nonref_string_query',
'enum_ref_string_query'
]
_all_params.extend(
@@ -151,6 +156,9 @@ class QueryApi:
# process the query parameters
_query_params = []
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))