Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class ApiClient(object):
the API.
:param cookie: a cookie to include in the header when making calls
to the API
:param async_req: use either synchronous or asynchronous requests
"""

PRIMITIVE_TYPES = (float, bool, bytes, six.text_type) + six.integer_types
Expand All @@ -55,12 +56,14 @@ class ApiClient(object):
}

def __init__(self, configuration=None, header_name=None, header_value=None,
cookie=None):
cookie=None, async_req=True):
if configuration is None:
configuration = Configuration()
self.configuration = configuration

self.pool = ThreadPool()
self.async_req = async_req
if async_req:
self.pool = ThreadPool()
self.rest_client = rest.RESTClientObject(configuration)
self.default_headers = {}
if header_name is not None:
Expand All @@ -70,8 +73,9 @@ class ApiClient(object):
self.user_agent = '{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{{packageVersion}}}/python{{/httpUserAgent}}'

def __del__(self):
self.pool.close()
self.pool.join()
if self.async_req:
self.pool.close()
self.pool.join()

@property
def user_agent(self):
Expand Down Expand Up @@ -319,7 +323,7 @@ class ApiClient(object):
If parameter async is False or missing,
then the method will return the response directly.
"""
if not async:
if not async or not self.async_req:
return self.__call_api(resource_path, method,
path_params, query_params, header_params,
body, post_params, files,
Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/python/docs/EnumTest.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**enum_string** | **str** | | [optional]
**enum_string_required** | **str** | |
**enum_integer** | **int** | | [optional]
**enum_number** | **float** | | [optional]
**outer_enum** | [**OuterEnum**](OuterEnum.md) | | [optional]
Expand Down
14 changes: 9 additions & 5 deletions samples/client/petstore/python/petstore_api/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class ApiClient(object):
the API.
:param cookie: a cookie to include in the header when making calls
to the API
:param async_req: use either synchronous or asynchronous requests
"""

PRIMITIVE_TYPES = (float, bool, bytes, six.text_type) + six.integer_types
Expand All @@ -61,12 +62,14 @@ class ApiClient(object):
}

def __init__(self, configuration=None, header_name=None, header_value=None,
cookie=None):
cookie=None, async_req=True):
if configuration is None:
configuration = Configuration()
self.configuration = configuration

self.pool = ThreadPool()
self.async_req = async_req
if async_req:
self.pool = ThreadPool()
self.rest_client = rest.RESTClientObject(configuration)
self.default_headers = {}
if header_name is not None:
Expand All @@ -76,8 +79,9 @@ def __init__(self, configuration=None, header_name=None, header_value=None,
self.user_agent = 'Swagger-Codegen/1.0.0/python'

def __del__(self):
self.pool.close()
self.pool.join()
if self.async_req:
self.pool.close()
self.pool.join()

@property
def user_agent(self):
Expand Down Expand Up @@ -313,7 +317,7 @@ def call_api(self, resource_path, method,
If parameter async is False or missing,
then the method will return the response directly.
"""
if not async:
if not async or not self.async_req:
return self.__call_api(resource_path, method,
path_params, query_params, header_params,
body, post_params, files,
Expand Down
35 changes: 34 additions & 1 deletion samples/client/petstore/python/petstore_api/models/enum_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,33 @@ class EnumTest(object):
"""
swagger_types = {
'enum_string': 'str',
'enum_string_required': 'str',
'enum_integer': 'int',
'enum_number': 'float',
'outer_enum': 'OuterEnum'
}

attribute_map = {
'enum_string': 'enum_string',
'enum_string_required': 'enum_string_required',
'enum_integer': 'enum_integer',
'enum_number': 'enum_number',
'outer_enum': 'outerEnum'
}

def __init__(self, enum_string=None, enum_integer=None, enum_number=None, outer_enum=None): # noqa: E501
def __init__(self, enum_string=None, enum_string_required=None, enum_integer=None, enum_number=None, outer_enum=None): # noqa: E501
"""EnumTest - a model defined in Swagger""" # noqa: E501

self._enum_string = None
self._enum_string_required = None
self._enum_integer = None
self._enum_number = None
self._outer_enum = None
self.discriminator = None

if enum_string is not None:
self.enum_string = enum_string
self.enum_string_required = enum_string_required
if enum_integer is not None:
self.enum_integer = enum_integer
if enum_number is not None:
Expand Down Expand Up @@ -91,6 +95,35 @@ def enum_string(self, enum_string):

self._enum_string = enum_string

@property
def enum_string_required(self):
"""Gets the enum_string_required of this EnumTest. # noqa: E501


:return: The enum_string_required of this EnumTest. # noqa: E501
:rtype: str
"""
return self._enum_string_required

@enum_string_required.setter
def enum_string_required(self, enum_string_required):
"""Sets the enum_string_required of this EnumTest.


:param enum_string_required: The enum_string_required of this EnumTest. # noqa: E501
:type: str
"""
if enum_string_required is None:
raise ValueError("Invalid value for `enum_string_required`, must not be `None`") # noqa: E501
allowed_values = ["UPPER", "lower", ""] # noqa: E501
if enum_string_required not in allowed_values:
raise ValueError(
"Invalid value for `enum_string_required` ({0}), must be one of {1}" # noqa: E501
.format(enum_string_required, allowed_values)
)

self._enum_string_required = enum_string_required

@property
def enum_integer(self):
"""Gets the enum_integer of this EnumTest. # noqa: E501
Expand Down