[python-nextgen] Fix enum query parameter (#15278)

* fix enum query parameter in python-nextgen

* update samples
This commit is contained in:
William Cheng
2023-04-22 16:08:59 +08:00
committed by GitHub
parent 33e0c6775f
commit b5745e6f26
32 changed files with 1431 additions and 19 deletions

View File

@@ -91,6 +91,7 @@ Class | Method | HTTP request | Description
*FormApi* | [**test_form_integer_boolean_string**](docs/FormApi.md#test_form_integer_boolean_string) | **POST** /form/integer/boolean/string | Test form parameter(s)
*HeaderApi* | [**test_header_integer_boolean_string**](docs/HeaderApi.md#test_header_integer_boolean_string) | **GET** /header/integer/boolean/string | Test header parameter(s)
*PathApi* | [**tests_path_string_path_string_integer_path_integer**](docs/PathApi.md#tests_path_string_path_string_integer_path_integer) | **GET** /path/string/{path_string}/integer/{path_integer} | Test path parameter(s)
*QueryApi* | [**test_enum_ref_string**](docs/QueryApi.md#test_enum_ref_string) | **GET** /query/enum_ref_string | Test query parameter(s)
*QueryApi* | [**test_query_datetime_date_string**](docs/QueryApi.md#test_query_datetime_date_string) | **GET** /query/datetime/date/string | Test query parameter(s)
*QueryApi* | [**test_query_integer_boolean_string**](docs/QueryApi.md#test_query_integer_boolean_string) | **GET** /query/integer/boolean/string | Test query parameter(s)
*QueryApi* | [**test_query_style_deep_object_explode_true_object**](docs/QueryApi.md#test_query_style_deep_object_explode_true_object) | **GET** /query/style_deepObject/explode_true/object | Test query parameter(s)

View File

@@ -4,6 +4,7 @@ All URIs are relative to *http://localhost:3000*
Method | HTTP request | Description
------------- | ------------- | -------------
[**test_enum_ref_string**](QueryApi.md#test_enum_ref_string) | **GET** /query/enum_ref_string | Test query parameter(s)
[**test_query_datetime_date_string**](QueryApi.md#test_query_datetime_date_string) | **GET** /query/datetime/date/string | Test query parameter(s)
[**test_query_integer_boolean_string**](QueryApi.md#test_query_integer_boolean_string) | **GET** /query/integer/boolean/string | Test query parameter(s)
[**test_query_style_deep_object_explode_true_object**](QueryApi.md#test_query_style_deep_object_explode_true_object) | **GET** /query/style_deepObject/explode_true/object | Test query parameter(s)
@@ -13,6 +14,72 @@ Method | HTTP request | Description
[**test_query_style_form_explode_true_object_all_of**](QueryApi.md#test_query_style_form_explode_true_object_all_of) | **GET** /query/style_form/explode_true/object/allOf | Test query parameter(s)
# **test_enum_ref_string**
> str test_enum_ref_string(enum_ref_string_query=enum_ref_string_query)
Test query parameter(s)
Test query parameter(s)
### Example
```python
import time
import os
import openapi_client
from openapi_client.models.string_enum_ref import StringEnumRef
from openapi_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost:3000
# See configuration.py for a list of all supported configuration parameters.
configuration = openapi_client.Configuration(
host = "http://localhost:3000"
)
# Enter a context with an instance of the API client
with openapi_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = openapi_client.QueryApi(api_client)
enum_ref_string_query = openapi_client.StringEnumRef() # StringEnumRef | (optional)
try:
# Test query parameter(s)
api_response = api_instance.test_enum_ref_string(enum_ref_string_query=enum_ref_string_query)
print("The response of QueryApi->test_enum_ref_string:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling QueryApi->test_enum_ref_string: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**enum_ref_string_query** | [**StringEnumRef**](.md)| | [optional]
### Return type
**str**
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: text/plain
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | Successful operation | - |
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **test_query_datetime_date_string**
> str test_query_datetime_date_string(datetime_query=datetime_query, date_query=date_query, string_query=string_query)

View File

@@ -24,6 +24,7 @@ from pydantic import StrictBool, StrictInt, StrictStr
from typing import Any, Dict, Optional
from openapi_client.models.string_enum_ref import StringEnumRef
from openapi_client.api_client import ApiClient
from openapi_client.exceptions import ( # noqa: F401
@@ -44,6 +45,146 @@ class QueryApi(object):
api_client = ApiClient.get_default()
self.api_client = api_client
@validate_arguments
def test_enum_ref_string(self, 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)
>>> result = thread.get()
:param enum_ref_string_query:
:type enum_ref_string_query: StringEnumRef
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _preload_content: if False, the urllib3.HTTPResponse object will
be returned without reading/decoding response
data. Default is True.
:type _preload_content: bool, optional
: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
(connection, read) timeouts.
:return: Returns the result object.
If the method is called asynchronously,
returns the request thread.
:rtype: str
"""
kwargs['_return_http_data_only'] = True
return self.test_enum_ref_string_with_http_info(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): # 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)
>>> result = thread.get()
:param enum_ref_string_query:
:type enum_ref_string_query: StringEnumRef
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _return_http_data_only: response data without head status code
and headers
:type _return_http_data_only: bool, optional
:param _preload_content: if False, the urllib3.HTTPResponse object will
be returned without reading/decoding response
data. Default is True.
:type _preload_content: bool, optional
: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
(connection, read) timeouts.
:param _request_auth: set to override the auth_settings for an a single
request; this effectively ignores the authentication
in the spec for a single request.
:type _request_auth: dict, optional
:type _content_type: string, optional: force content-type for the request
:return: Returns the result object.
If the method is called asynchronously,
returns the request thread.
:rtype: tuple(str, status_code(int), headers(HTTPHeaderDict))
"""
_params = locals()
_all_params = [
'enum_ref_string_query'
]
_all_params.extend(
[
'async_req',
'_return_http_data_only',
'_preload_content',
'_request_timeout',
'_request_auth',
'_content_type',
'_headers'
]
)
# validate the arguments
for _key, _val in _params['kwargs'].items():
if _key not in _all_params:
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method test_enum_ref_string" % _key
)
_params[_key] = _val
del _params['kwargs']
_collection_formats = {}
# process the path parameters
_path_params = {}
# process the query parameters
_query_params = []
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))
# process the header parameters
_header_params = dict(_params.get('_headers', {}))
# process the form parameters
_form_params = []
_files = {}
# process the body parameter
_body_params = None
# set the HTTP header `Accept`
_header_params['Accept'] = self.api_client.select_header_accept(
['text/plain']) # noqa: E501
# authentication setting
_auth_settings = [] # noqa: E501
_response_types_map = {
'200': "str",
}
return self.api_client.call_api(
'/query/enum_ref_string', 'GET',
_path_params,
_query_params,
_header_params,
body=_body_params,
post_params=_form_params,
files=_files,
response_types_map=_response_types_map,
auth_settings=_auth_settings,
async_req=_params.get('async_req'),
_return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501
_preload_content=_params.get('_preload_content', True),
_request_timeout=_params.get('_request_timeout'),
collection_formats=_collection_formats,
_request_auth=_params.get('_request_auth'))
@validate_arguments
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

View File

@@ -29,6 +29,16 @@ class TestManual(unittest.TestCase):
def tearDown(self):
pass
def testEnumRefString(self):
api_instance = openapi_client.QueryApi()
q = openapi_client.StringEnumRef("unclassified")
# Test query parameter(s)
api_response = api_instance.test_enum_ref_string(enum_ref_string_query=q)
e = EchoServerResponseParser(api_response)
self.assertEqual(e.path, "/query/enum_ref_string?enum_ref_string_query=unclassified")
def testDateTimeQueryWithDateTimeFormat(self):
api_instance = openapi_client.QueryApi()
datetime_format_backup = api_instance.api_client.configuration.datetime_format # backup dateime_format