forked from loafle/openapi-generator-original
[python] asyncio supports _preload_content; remove unsed imports (#107)
* chore: update python samples * feat: python/asyncio support for _preload_content * feat: remove unused imports from python clients; fix discriminator
This commit is contained in:
committed by
William Cheng
parent
76b7307a6e
commit
7184f1ec68
@@ -419,7 +419,7 @@ Name | Type | Description | Notes
|
||||
**enum_query_string** | **str**| Query parameter enum test (string) | [optional] [default to '-efg']
|
||||
**enum_query_integer** | **int**| Query parameter enum test (double) | [optional]
|
||||
**enum_query_double** | **float**| Query parameter enum test (double) | [optional]
|
||||
**enum_form_string_array** | **list[str]**| Form parameter enum test (string array) | [optional] [default to '$']
|
||||
**enum_form_string_array** | [**list[str]**](str.md)| Form parameter enum test (string array) | [optional] [default to '$']
|
||||
**enum_form_string** | **str**| Form parameter enum test (string) | [optional] [default to '-efg']
|
||||
|
||||
### Return type
|
||||
|
||||
@@ -102,7 +102,7 @@ class Animal(object):
|
||||
|
||||
def get_real_child_model(self, data):
|
||||
"""Returns the real base class specified by the discriminator"""
|
||||
discriminator_value = data[self.discriminator].lower()
|
||||
discriminator_value = data[self.discriminator]
|
||||
return self.discriminator_value_class_map.get(discriminator_value)
|
||||
|
||||
def to_dict(self):
|
||||
|
||||
@@ -15,8 +15,6 @@ import re # noqa: F401
|
||||
|
||||
import six
|
||||
|
||||
from petstore_api.models.animal import Animal # noqa: F401,E501
|
||||
|
||||
|
||||
class AnimalFarm(object):
|
||||
"""NOTE: This class is auto generated by OpenAPI Generator.
|
||||
|
||||
@@ -15,8 +15,6 @@ import re # noqa: F401
|
||||
|
||||
import six
|
||||
|
||||
from petstore_api.models.read_only_first import ReadOnlyFirst # noqa: F401,E501
|
||||
|
||||
|
||||
class ArrayTest(object):
|
||||
"""NOTE: This class is auto generated by OpenAPI Generator.
|
||||
|
||||
@@ -15,8 +15,6 @@ import re # noqa: F401
|
||||
|
||||
import six
|
||||
|
||||
from petstore_api.models.animal import Animal # noqa: F401,E501
|
||||
|
||||
|
||||
class Cat(object):
|
||||
"""NOTE: This class is auto generated by OpenAPI Generator.
|
||||
|
||||
@@ -15,8 +15,6 @@ import re # noqa: F401
|
||||
|
||||
import six
|
||||
|
||||
from petstore_api.models.animal import Animal # noqa: F401,E501
|
||||
|
||||
|
||||
class Dog(object):
|
||||
"""NOTE: This class is auto generated by OpenAPI Generator.
|
||||
|
||||
@@ -15,8 +15,6 @@ import re # noqa: F401
|
||||
|
||||
import six
|
||||
|
||||
from petstore_api.models.outer_enum import OuterEnum # noqa: F401,E501
|
||||
|
||||
|
||||
class EnumTest(object):
|
||||
"""NOTE: This class is auto generated by OpenAPI Generator.
|
||||
|
||||
@@ -15,8 +15,6 @@ import re # noqa: F401
|
||||
|
||||
import six
|
||||
|
||||
from petstore_api.models.animal import Animal # noqa: F401,E501
|
||||
|
||||
|
||||
class MixedPropertiesAndAdditionalPropertiesClass(object):
|
||||
"""NOTE: This class is auto generated by OpenAPI Generator.
|
||||
|
||||
@@ -15,9 +15,6 @@ import re # noqa: F401
|
||||
|
||||
import six
|
||||
|
||||
from petstore_api.models.category import Category # noqa: F401,E501
|
||||
from petstore_api.models.tag import Tag # noqa: F401,E501
|
||||
|
||||
|
||||
class Pet(object):
|
||||
"""NOTE: This class is auto generated by OpenAPI Generator.
|
||||
|
||||
@@ -18,6 +18,7 @@ import ssl
|
||||
|
||||
import aiohttp
|
||||
import certifi
|
||||
import asyncio
|
||||
# python 2 and python 3 compatibility library
|
||||
from six.moves.urllib.parse import urlencode
|
||||
|
||||
@@ -78,6 +79,9 @@ class RESTClientObject(object):
|
||||
connector=connector
|
||||
)
|
||||
|
||||
def __del__(self):
|
||||
asyncio.ensure_future(self.pool_manager.close())
|
||||
|
||||
async def request(self, method, url, query_params=None, headers=None,
|
||||
body=None, post_params=None, _preload_content=True,
|
||||
_request_timeout=None):
|
||||
@@ -160,15 +164,17 @@ class RESTClientObject(object):
|
||||
declared content type."""
|
||||
raise ApiException(status=0, reason=msg)
|
||||
|
||||
async with self.pool_manager.request(**args) as r:
|
||||
r = await self.pool_manager.request(**args)
|
||||
if _preload_content:
|
||||
|
||||
data = await r.text()
|
||||
r = RESTResponse(r, data)
|
||||
|
||||
# log response body
|
||||
logger.debug("response body: %s", r.data)
|
||||
# log response body
|
||||
logger.debug("response body: %s", r.data)
|
||||
|
||||
if not 200 <= r.status <= 299:
|
||||
raise ApiException(http_resp=r)
|
||||
if not 200 <= r.status <= 299:
|
||||
raise ApiException(http_resp=r)
|
||||
|
||||
return r
|
||||
|
||||
|
||||
Reference in New Issue
Block a user