Skip to content

Commit

Permalink
solution for async issue.
Browse files Browse the repository at this point in the history
In python 3 async is the keyword. So our SDK
do not work with python 3. We need to change the async with async_req.
  • Loading branch information
shilpiarya committed Jun 10, 2020
1 parent fd4ef1c commit 4d1dd2d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
22 changes: 11 additions & 11 deletions swagger_templates/python/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ class {{classname}}(object):
{{{notes}}} # noqa: E501
{{/notes}}
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
asynchronous HTTP request, please pass async_req=True
{{#sortParamsByRequiredFlag}}
>>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async=True)
>>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async_req=True)
{{/sortParamsByRequiredFlag}}
{{^sortParamsByRequiredFlag}}
>>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/allParams}}async=True)
>>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/allParams}}async_req=True)
{{/sortParamsByRequiredFlag}}
>>> result = thread.get()

:param async bool
:param async_req bool
{{#allParams}}
:param {{dataType}} {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional){{/optional}}
{{/allParams}}
Expand All @@ -51,7 +51,7 @@ class {{classname}}(object):
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async'):
if kwargs.get('async_req'):
return self.{{operationId}}_with_http_info({{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs) # noqa: E501
else:
(data) = self.{{operationId}}_with_http_info({{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs) # noqa: E501
Expand All @@ -64,16 +64,16 @@ class {{classname}}(object):
{{{notes}}} # noqa: E501
{{/notes}}
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
asynchronous HTTP request, please pass async_req=True
{{#sortParamsByRequiredFlag}}
>>> thread = api.{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async=True)
>>> thread = api.{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async_req=True)
{{/sortParamsByRequiredFlag}}
{{^sortParamsByRequiredFlag}}
>>> thread = api.{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/allParams}}async=True)
>>> thread = api.{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/allParams}}async_req=True)
{{/sortParamsByRequiredFlag}}
>>> result = thread.get()

:param async bool
:param async_req bool
{{#allParams}}
:param {{dataType}} {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/optional}}
{{/allParams}}
Expand All @@ -83,7 +83,7 @@ class {{classname}}(object):
"""

all_params = [{{#allParams}}'{{paramName}}'{{#hasMore}}, {{/hasMore}}{{/allParams}}] # noqa: E501
all_params.append('async')
all_params.append('async_req')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
Expand Down Expand Up @@ -212,7 +212,7 @@ class {{classname}}(object):
files=local_var_files,
response_type={{#returnType}}'{{returnType}}'{{/returnType}}{{^returnType}}None{{/returnType}}, # noqa: E501
auth_settings=auth_settings,
async=params.get('async'),
async_req=params.get('async_req'),
_return_http_data_only=params.get('_return_http_data_only'),
_preload_content=params.get('_preload_content', True),
_request_timeout=params.get('_request_timeout'),
Expand Down
14 changes: 7 additions & 7 deletions swagger_templates/python/api_client.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class ApiClient(object):
{{#tornado}}
@tornado.gen.coroutine
{{/tornado}}
{{#asyncio}}async {{/asyncio}}def __call_api(
{{#asyncio}}async_req {{/asyncio}}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,
Expand Down Expand Up @@ -304,12 +304,12 @@ 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=None,
response_type=None, auth_settings=None, async_req=None,
_return_http_data_only=None, collection_formats=None,
_preload_content=True, _request_timeout=None):
"""Makes the HTTP request (synchronous) and returns deserialized data.

To make an async request, set the async parameter.
To make an async request, set the async_req parameter.

:param resource_path: Path to method endpoint.
:param method: Method to call.
Expand All @@ -324,7 +324,7 @@ class ApiClient(object):
:param response: Response data type.
:param files dict: key -> filename, value -> filepath,
for `multipart/form-data`.
:param async bool: execute request asynchronously
:param async_req bool: execute request asynchronously
:param _return_http_data_only: response data without head status code
and headers
:param collection_formats: dict of collection formats for path, query,
Expand All @@ -337,13 +337,13 @@ class ApiClient(object):
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:return:
If async parameter is True,
If async_req parameter is True,
the request will be called asynchronously.
The method will return the request thread.
If parameter async is False or missing,
If parameter async_req is False or missing,
then the method will return the response directly.
"""
if not async:
if not async_req:
return self.__call_api(resource_path, method,
path_params, query_params, header_params,
body, post_params, files,
Expand Down

0 comments on commit 4d1dd2d

Please sign in to comment.