[Python] correct return types if multiple responses are defined (#7427)

* update python mustache templates

* bug fix

* rm response_type

* generated samples

* resolve conflict

* samples

* set None if a type is empty

* regenerated samples
This commit is contained in:
Kuzma
2020-10-03 18:37:08 +03:00
committed by GitHub
parent 48762b5d4e
commit 4e5ecf271a
31 changed files with 697 additions and 186 deletions

View File

@@ -153,6 +153,10 @@ class AnotherFakeApi(object):
# Authentication setting
auth_settings = [] # noqa: E501
response_types_map = {
200: "Client",
}
return self.api_client.call_api(
'/another-fake/dummy', 'PATCH',
@@ -162,7 +166,7 @@ class AnotherFakeApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='Client', # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501

View File

@@ -149,6 +149,8 @@ class FakeApi(object):
# Authentication setting
auth_settings = [] # noqa: E501
response_types_map = {}
return self.api_client.call_api(
'/fake/create_xml_item', 'POST',
@@ -158,7 +160,7 @@ class FakeApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type=None, # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -276,6 +278,10 @@ class FakeApi(object):
# Authentication setting
auth_settings = [] # noqa: E501
response_types_map = {
200: "bool",
}
return self.api_client.call_api(
'/fake/outer/boolean', 'POST',
@@ -285,7 +291,7 @@ class FakeApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='bool', # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -403,6 +409,10 @@ class FakeApi(object):
# Authentication setting
auth_settings = [] # noqa: E501
response_types_map = {
200: "OuterComposite",
}
return self.api_client.call_api(
'/fake/outer/composite', 'POST',
@@ -412,7 +422,7 @@ class FakeApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='OuterComposite', # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -530,6 +540,10 @@ class FakeApi(object):
# Authentication setting
auth_settings = [] # noqa: E501
response_types_map = {
200: "float",
}
return self.api_client.call_api(
'/fake/outer/number', 'POST',
@@ -539,7 +553,7 @@ class FakeApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='float', # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -657,6 +671,10 @@ class FakeApi(object):
# Authentication setting
auth_settings = [] # noqa: E501
response_types_map = {
200: "str",
}
return self.api_client.call_api(
'/fake/outer/string', 'POST',
@@ -666,7 +684,7 @@ class FakeApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='str', # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -788,6 +806,8 @@ class FakeApi(object):
# Authentication setting
auth_settings = [] # noqa: E501
response_types_map = {}
return self.api_client.call_api(
'/fake/body-with-file-schema', 'PUT',
@@ -797,7 +817,7 @@ class FakeApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type=None, # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -928,6 +948,8 @@ class FakeApi(object):
# Authentication setting
auth_settings = [] # noqa: E501
response_types_map = {}
return self.api_client.call_api(
'/fake/body-with-query-params', 'PUT',
@@ -937,7 +959,7 @@ class FakeApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type=None, # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -1063,6 +1085,10 @@ class FakeApi(object):
# Authentication setting
auth_settings = [] # noqa: E501
response_types_map = {
200: "Client",
}
return self.api_client.call_api(
'/fake', 'PATCH',
@@ -1072,7 +1098,7 @@ class FakeApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='Client', # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -1325,6 +1351,8 @@ class FakeApi(object):
# Authentication setting
auth_settings = ['http_basic_test'] # noqa: E501
response_types_map = {}
return self.api_client.call_api(
'/fake', 'POST',
@@ -1334,7 +1362,7 @@ class FakeApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type=None, # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -1504,6 +1532,8 @@ class FakeApi(object):
# Authentication setting
auth_settings = [] # noqa: E501
response_types_map = {}
return self.api_client.call_api(
'/fake', 'GET',
@@ -1513,7 +1543,7 @@ class FakeApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type=None, # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -1674,6 +1704,8 @@ class FakeApi(object):
body_params = None
# Authentication setting
auth_settings = [] # noqa: E501
response_types_map = {}
return self.api_client.call_api(
'/fake', 'DELETE',
@@ -1683,7 +1715,7 @@ class FakeApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type=None, # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -1803,6 +1835,8 @@ class FakeApi(object):
# Authentication setting
auth_settings = [] # noqa: E501
response_types_map = {}
return self.api_client.call_api(
'/fake/inline-additionalProperties', 'POST',
@@ -1812,7 +1846,7 @@ class FakeApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type=None, # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -1943,6 +1977,8 @@ class FakeApi(object):
# Authentication setting
auth_settings = [] # noqa: E501
response_types_map = {}
return self.api_client.call_api(
'/fake/jsonFormData', 'GET',
@@ -1952,7 +1988,7 @@ class FakeApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type=None, # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -2119,6 +2155,8 @@ class FakeApi(object):
body_params = None
# Authentication setting
auth_settings = [] # noqa: E501
response_types_map = {}
return self.api_client.call_api(
'/fake/test-query-paramters', 'PUT',
@@ -2128,7 +2166,7 @@ class FakeApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type=None, # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501

View File

@@ -153,6 +153,10 @@ class FakeClassnameTags123Api(object):
# Authentication setting
auth_settings = ['api_key_query'] # noqa: E501
response_types_map = {
200: "Client",
}
return self.api_client.call_api(
'/fake_classname_test', 'PATCH',
@@ -162,7 +166,7 @@ class FakeClassnameTags123Api(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='Client', # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501

View File

@@ -147,6 +147,8 @@ class PetApi(object):
# Authentication setting
auth_settings = ['petstore_auth'] # noqa: E501
response_types_map = {}
return self.api_client.call_api(
'/pet', 'POST',
@@ -156,7 +158,7 @@ class PetApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type=None, # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -279,6 +281,8 @@ class PetApi(object):
body_params = None
# Authentication setting
auth_settings = ['petstore_auth'] # noqa: E501
response_types_map = {}
return self.api_client.call_api(
'/pet/{petId}', 'DELETE',
@@ -288,7 +292,7 @@ class PetApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type=None, # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -411,6 +415,11 @@ class PetApi(object):
# Authentication setting
auth_settings = ['petstore_auth'] # noqa: E501
response_types_map = {
200: "list[Pet]",
400: None,
}
return self.api_client.call_api(
'/pet/findByStatus', 'GET',
@@ -420,7 +429,7 @@ class PetApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='list[Pet]', # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -543,6 +552,11 @@ class PetApi(object):
# Authentication setting
auth_settings = ['petstore_auth'] # noqa: E501
response_types_map = {
200: "list[Pet]",
400: None,
}
return self.api_client.call_api(
'/pet/findByTags', 'GET',
@@ -552,7 +566,7 @@ class PetApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='list[Pet]', # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -674,6 +688,12 @@ class PetApi(object):
# Authentication setting
auth_settings = ['api_key'] # noqa: E501
response_types_map = {
200: "Pet",
400: None,
404: None,
}
return self.api_client.call_api(
'/pet/{petId}', 'GET',
@@ -683,7 +703,7 @@ class PetApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='Pet', # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -803,6 +823,8 @@ class PetApi(object):
# Authentication setting
auth_settings = ['petstore_auth'] # noqa: E501
response_types_map = {}
return self.api_client.call_api(
'/pet', 'PUT',
@@ -812,7 +834,7 @@ class PetApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type=None, # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -946,6 +968,8 @@ class PetApi(object):
# Authentication setting
auth_settings = ['petstore_auth'] # noqa: E501
response_types_map = {}
return self.api_client.call_api(
'/pet/{petId}', 'POST',
@@ -955,7 +979,7 @@ class PetApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type=None, # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -1093,6 +1117,10 @@ class PetApi(object):
# Authentication setting
auth_settings = ['petstore_auth'] # noqa: E501
response_types_map = {
200: "ApiResponse",
}
return self.api_client.call_api(
'/pet/{petId}/uploadImage', 'POST',
@@ -1102,7 +1130,7 @@ class PetApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='ApiResponse', # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -1244,6 +1272,10 @@ class PetApi(object):
# Authentication setting
auth_settings = ['petstore_auth'] # noqa: E501
response_types_map = {
200: "ApiResponse",
}
return self.api_client.call_api(
'/fake/{petId}/uploadImageWithRequiredFile', 'POST',
@@ -1253,7 +1285,7 @@ class PetApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='ApiResponse', # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501

View File

@@ -145,6 +145,8 @@ class StoreApi(object):
body_params = None
# Authentication setting
auth_settings = [] # noqa: E501
response_types_map = {}
return self.api_client.call_api(
'/store/order/{order_id}', 'DELETE',
@@ -154,7 +156,7 @@ class StoreApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type=None, # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -265,6 +267,10 @@ class StoreApi(object):
# Authentication setting
auth_settings = ['api_key'] # noqa: E501
response_types_map = {
200: "dict(str, int)",
}
return self.api_client.call_api(
'/store/inventory', 'GET',
@@ -274,7 +280,7 @@ class StoreApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='dict(str, int)', # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -400,6 +406,12 @@ class StoreApi(object):
# Authentication setting
auth_settings = [] # noqa: E501
response_types_map = {
200: "Order",
400: None,
404: None,
}
return self.api_client.call_api(
'/store/order/{order_id}', 'GET',
@@ -409,7 +421,7 @@ class StoreApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='Order', # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -529,6 +541,11 @@ class StoreApi(object):
# Authentication setting
auth_settings = [] # noqa: E501
response_types_map = {
200: "Order",
400: None,
}
return self.api_client.call_api(
'/store/order', 'POST',
@@ -538,7 +555,7 @@ class StoreApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='Order', # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501

View File

@@ -145,6 +145,8 @@ class UserApi(object):
body_params = local_var_params['body']
# Authentication setting
auth_settings = [] # noqa: E501
response_types_map = {}
return self.api_client.call_api(
'/user', 'POST',
@@ -154,7 +156,7 @@ class UserApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type=None, # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -270,6 +272,8 @@ class UserApi(object):
body_params = local_var_params['body']
# Authentication setting
auth_settings = [] # noqa: E501
response_types_map = {}
return self.api_client.call_api(
'/user/createWithArray', 'POST',
@@ -279,7 +283,7 @@ class UserApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type=None, # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -395,6 +399,8 @@ class UserApi(object):
body_params = local_var_params['body']
# Authentication setting
auth_settings = [] # noqa: E501
response_types_map = {}
return self.api_client.call_api(
'/user/createWithList', 'POST',
@@ -404,7 +410,7 @@ class UserApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type=None, # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -522,6 +528,8 @@ class UserApi(object):
body_params = None
# Authentication setting
auth_settings = [] # noqa: E501
response_types_map = {}
return self.api_client.call_api(
'/user/{username}', 'DELETE',
@@ -531,7 +539,7 @@ class UserApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type=None, # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -651,6 +659,12 @@ class UserApi(object):
# Authentication setting
auth_settings = [] # noqa: E501
response_types_map = {
200: "User",
400: None,
404: None,
}
return self.api_client.call_api(
'/user/{username}', 'GET',
@@ -660,7 +674,7 @@ class UserApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='User', # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -791,6 +805,11 @@ class UserApi(object):
# Authentication setting
auth_settings = [] # noqa: E501
response_types_map = {
200: "str",
400: None,
}
return self.api_client.call_api(
'/user/login', 'GET',
@@ -800,7 +819,7 @@ class UserApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='str', # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -905,6 +924,8 @@ class UserApi(object):
body_params = None
# Authentication setting
auth_settings = [] # noqa: E501
response_types_map = {}
return self.api_client.call_api(
'/user/logout', 'GET',
@@ -914,7 +935,7 @@ class UserApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type=None, # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
@@ -1043,6 +1064,8 @@ class UserApi(object):
body_params = local_var_params['body']
# Authentication setting
auth_settings = [] # noqa: E501
response_types_map = {}
return self.api_client.call_api(
'/user/{username}', 'PUT',
@@ -1052,7 +1075,7 @@ class UserApi(object):
body=body_params,
post_params=form_params,
files=local_var_files,
response_type=None, # noqa: E501
response_types_map=response_types_map,
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501

View File

@@ -121,7 +121,7 @@ class ApiClient(object):
async def __call_api(
self, resource_path, method, path_params=None,
query_params=None, header_params=None, body=None, post_params=None,
files=None, response_type=None, auth_settings=None,
files=None, response_types_map=None, auth_settings=None,
_return_http_data_only=None, collection_formats=None,
_preload_content=True, _request_timeout=None, _host=None,
_request_auth=None):
@@ -199,6 +199,8 @@ class ApiClient(object):
if not _preload_content:
return return_data
response_type = response_types_map.get(response_data.status, None)
if six.PY3 and response_type not in ["file", "bytes"]:
match = None
@@ -208,6 +210,7 @@ class ApiClient(object):
response_data.data = response_data.data.decode(encoding)
# deserialize response data
if response_type:
return_data = self.deserialize(response_data, response_type)
else:
@@ -325,10 +328,10 @@ class ApiClient(object):
def call_api(self, resource_path, method,
path_params=None, query_params=None, header_params=None,
body=None, post_params=None, files=None,
response_type=None, auth_settings=None, async_req=None,
_return_http_data_only=None, collection_formats=None,
_preload_content=True, _request_timeout=None, _host=None,
_request_auth=None):
response_types_map=None, auth_settings=None,
async_req=None, _return_http_data_only=None,
collection_formats=None,_preload_content=True,
_request_timeout=None, _host=None, _request_auth=None):
"""Makes the HTTP request (synchronous) and returns deserialized data.
To make an async_req request, set the async_req parameter.
@@ -373,7 +376,7 @@ class ApiClient(object):
return self.__call_api(resource_path, method,
path_params, query_params, header_params,
body, post_params, files,
response_type, auth_settings,
response_types_map, auth_settings,
_return_http_data_only, collection_formats,
_preload_content, _request_timeout, _host,
_request_auth)
@@ -383,7 +386,7 @@ class ApiClient(object):
query_params,
header_params, body,
post_params, files,
response_type,
response_types_map,
auth_settings,
_return_http_data_only,
collection_formats,