From 79dacb20a0f0e7cfd02bbcc74cb834d46a7951ca Mon Sep 17 00:00:00 2001 From: Tomasz Prus Date: Fri, 24 Aug 2018 03:43:32 +0200 Subject: [PATCH] fix: python-asyncio/aiohttp with disabled ssl verification (#891) --- .../resources/python/asyncio/rest.mustache | 29 ++++++++++--------- .../python-asyncio/.openapi-generator/VERSION | 2 +- .../client/petstore/python-asyncio/README.md | 6 ++-- .../python-asyncio/docs/AnotherFakeApi.md | 12 ++++---- .../petstore_api/api/another_fake_api.py | 20 ++++++------- .../python-asyncio/petstore_api/rest.py | 29 ++++++++++--------- .../python-tornado/.openapi-generator/VERSION | 2 +- .../client/petstore/python-tornado/README.md | 6 ++-- .../python-tornado/docs/AnotherFakeApi.md | 12 ++++---- .../petstore_api/api/another_fake_api.py | 20 ++++++------- .../python/.openapi-generator/VERSION | 2 +- samples/client/petstore/python/README.md | 6 ++-- .../petstore/python/docs/AnotherFakeApi.md | 12 ++++---- .../petstore_api/api/another_fake_api.py | 20 ++++++------- 14 files changed, 92 insertions(+), 86 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/python/asyncio/rest.mustache b/modules/openapi-generator/src/main/resources/python/asyncio/rest.mustache index 8c9d49dc14f..528e550d74f 100644 --- a/modules/openapi-generator/src/main/resources/python/asyncio/rest.mustache +++ b/modules/openapi-generator/src/main/resources/python/asyncio/rest.mustache @@ -38,21 +38,24 @@ class RESTClientObject(object): def __init__(self, configuration, pools_size=4, maxsize=4): # maxsize is number of requests to host that are allowed in parallel - # ca_certs vs cert_file vs key_file - # http://stackoverflow.com/a/23957365/2985775 - # ca_certs - if configuration.ssl_ca_cert: - ca_certs = configuration.ssl_ca_cert + if configuration.verify_ssl: + + # ca_certs + if configuration.ssl_ca_cert: + ca_certs = configuration.ssl_ca_cert + else: + # if not set certificate file, use Mozilla's root certificates. + ca_certs = certifi.where() + + ssl_context = ssl.create_default_context(cafile=ca_certs) + + if configuration.cert_file: + ssl_context.load_cert_chain( + configuration.cert_file, keyfile=configuration.key_file + ) else: - # if not set certificate file, use Mozilla's root certificates. - ca_certs = certifi.where() - - ssl_context = ssl.create_default_context(cafile=ca_certs) - if configuration.cert_file: - ssl_context.load_cert_chain( - configuration.cert_file, keyfile=configuration.key_file - ) + ssl_context = None connector = aiohttp.TCPConnector( limit=maxsize, diff --git a/samples/client/petstore/python-asyncio/.openapi-generator/VERSION b/samples/client/petstore/python-asyncio/.openapi-generator/VERSION index dde25ef08e8..c791c986fbb 100644 --- a/samples/client/petstore/python-asyncio/.openapi-generator/VERSION +++ b/samples/client/petstore/python-asyncio/.openapi-generator/VERSION @@ -1 +1 @@ -3.1.1-SNAPSHOT \ No newline at end of file +3.2.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/python-asyncio/README.md b/samples/client/petstore/python-asyncio/README.md index b76d6153e89..6e6dbf6180a 100644 --- a/samples/client/petstore/python-asyncio/README.md +++ b/samples/client/petstore/python-asyncio/README.md @@ -57,10 +57,10 @@ client = petstore_api.Client() # Client | client model try: # To test special tags - api_response = api_instance.test_special_tags(client) + api_response = api_instance.call_123_test_special_tags(client) pprint(api_response) except ApiException as e: - print("Exception when calling AnotherFakeApi->test_special_tags: %s\n" % e) + print("Exception when calling AnotherFakeApi->call_123_test_special_tags: %s\n" % e) ``` @@ -70,7 +70,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- -*AnotherFakeApi* | [**test_special_tags**](docs/AnotherFakeApi.md#test_special_tags) | **PATCH** /another-fake/dummy | To test special tags +*AnotherFakeApi* | [**call_123_test_special_tags**](docs/AnotherFakeApi.md#call_123_test_special_tags) | **PATCH** /another-fake/dummy | To test special tags *FakeApi* | [**fake_outer_boolean_serialize**](docs/FakeApi.md#fake_outer_boolean_serialize) | **POST** /fake/outer/boolean | *FakeApi* | [**fake_outer_composite_serialize**](docs/FakeApi.md#fake_outer_composite_serialize) | **POST** /fake/outer/composite | *FakeApi* | [**fake_outer_number_serialize**](docs/FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number | diff --git a/samples/client/petstore/python-asyncio/docs/AnotherFakeApi.md b/samples/client/petstore/python-asyncio/docs/AnotherFakeApi.md index 32d4fa0696c..447ce3edde3 100644 --- a/samples/client/petstore/python-asyncio/docs/AnotherFakeApi.md +++ b/samples/client/petstore/python-asyncio/docs/AnotherFakeApi.md @@ -4,15 +4,15 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* Method | HTTP request | Description ------------- | ------------- | ------------- -[**test_special_tags**](AnotherFakeApi.md#test_special_tags) | **PATCH** /another-fake/dummy | To test special tags +[**call_123_test_special_tags**](AnotherFakeApi.md#call_123_test_special_tags) | **PATCH** /another-fake/dummy | To test special tags -# **test_special_tags** -> Client test_special_tags(client) +# **call_123_test_special_tags** +> Client call_123_test_special_tags(client) To test special tags -To test special tags +To test special tags and operation ID starting with number ### Example ```python @@ -28,10 +28,10 @@ client = petstore_api.Client() # Client | client model try: # To test special tags - api_response = api_instance.test_special_tags(client) + api_response = api_instance.call_123_test_special_tags(client) pprint(api_response) except ApiException as e: - print("Exception when calling AnotherFakeApi->test_special_tags: %s\n" % e) + print("Exception when calling AnotherFakeApi->call_123_test_special_tags: %s\n" % e) ``` ### Parameters diff --git a/samples/client/petstore/python-asyncio/petstore_api/api/another_fake_api.py b/samples/client/petstore/python-asyncio/petstore_api/api/another_fake_api.py index b753906b2e4..782f7fd07b3 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/api/another_fake_api.py +++ b/samples/client/petstore/python-asyncio/petstore_api/api/another_fake_api.py @@ -32,13 +32,13 @@ class AnotherFakeApi(object): api_client = ApiClient() self.api_client = api_client - def test_special_tags(self, client, **kwargs): # noqa: E501 + def call_123_test_special_tags(self, client, **kwargs): # noqa: E501 """To test special tags # noqa: E501 - To test special tags # noqa: E501 + To test special tags and operation ID starting with number # 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_special_tags(client, async_req=True) + >>> thread = api.call_123_test_special_tags(client, async_req=True) >>> result = thread.get() :param async_req bool @@ -49,18 +49,18 @@ class AnotherFakeApi(object): """ kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): - return self.test_special_tags_with_http_info(client, **kwargs) # noqa: E501 + return self.call_123_test_special_tags_with_http_info(client, **kwargs) # noqa: E501 else: - (data) = self.test_special_tags_with_http_info(client, **kwargs) # noqa: E501 + (data) = self.call_123_test_special_tags_with_http_info(client, **kwargs) # noqa: E501 return data - def test_special_tags_with_http_info(self, client, **kwargs): # noqa: E501 + def call_123_test_special_tags_with_http_info(self, client, **kwargs): # noqa: E501 """To test special tags # noqa: E501 - To test special tags # noqa: E501 + To test special tags and operation ID starting with number # 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_special_tags_with_http_info(client, async_req=True) + >>> thread = api.call_123_test_special_tags_with_http_info(client, async_req=True) >>> result = thread.get() :param async_req bool @@ -82,14 +82,14 @@ class AnotherFakeApi(object): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" - " to method test_special_tags" % key + " to method call_123_test_special_tags" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'client' is set if ('client' not in local_var_params or local_var_params['client'] is None): - raise ValueError("Missing the required parameter `client` when calling `test_special_tags`") # noqa: E501 + raise ValueError("Missing the required parameter `client` when calling `call_123_test_special_tags`") # noqa: E501 collection_formats = {} diff --git a/samples/client/petstore/python-asyncio/petstore_api/rest.py b/samples/client/petstore/python-asyncio/petstore_api/rest.py index f0ac582a697..ce7eaf118d7 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/rest.py +++ b/samples/client/petstore/python-asyncio/petstore_api/rest.py @@ -46,21 +46,24 @@ class RESTClientObject(object): def __init__(self, configuration, pools_size=4, maxsize=4): # maxsize is number of requests to host that are allowed in parallel - # ca_certs vs cert_file vs key_file - # http://stackoverflow.com/a/23957365/2985775 - # ca_certs - if configuration.ssl_ca_cert: - ca_certs = configuration.ssl_ca_cert + if configuration.verify_ssl: + + # ca_certs + if configuration.ssl_ca_cert: + ca_certs = configuration.ssl_ca_cert + else: + # if not set certificate file, use Mozilla's root certificates. + ca_certs = certifi.where() + + ssl_context = ssl.create_default_context(cafile=ca_certs) + + if configuration.cert_file: + ssl_context.load_cert_chain( + configuration.cert_file, keyfile=configuration.key_file + ) else: - # if not set certificate file, use Mozilla's root certificates. - ca_certs = certifi.where() - - ssl_context = ssl.create_default_context(cafile=ca_certs) - if configuration.cert_file: - ssl_context.load_cert_chain( - configuration.cert_file, keyfile=configuration.key_file - ) + ssl_context = None connector = aiohttp.TCPConnector( limit=maxsize, diff --git a/samples/client/petstore/python-tornado/.openapi-generator/VERSION b/samples/client/petstore/python-tornado/.openapi-generator/VERSION index dde25ef08e8..c791c986fbb 100644 --- a/samples/client/petstore/python-tornado/.openapi-generator/VERSION +++ b/samples/client/petstore/python-tornado/.openapi-generator/VERSION @@ -1 +1 @@ -3.1.1-SNAPSHOT \ No newline at end of file +3.2.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/python-tornado/README.md b/samples/client/petstore/python-tornado/README.md index b76d6153e89..6e6dbf6180a 100644 --- a/samples/client/petstore/python-tornado/README.md +++ b/samples/client/petstore/python-tornado/README.md @@ -57,10 +57,10 @@ client = petstore_api.Client() # Client | client model try: # To test special tags - api_response = api_instance.test_special_tags(client) + api_response = api_instance.call_123_test_special_tags(client) pprint(api_response) except ApiException as e: - print("Exception when calling AnotherFakeApi->test_special_tags: %s\n" % e) + print("Exception when calling AnotherFakeApi->call_123_test_special_tags: %s\n" % e) ``` @@ -70,7 +70,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- -*AnotherFakeApi* | [**test_special_tags**](docs/AnotherFakeApi.md#test_special_tags) | **PATCH** /another-fake/dummy | To test special tags +*AnotherFakeApi* | [**call_123_test_special_tags**](docs/AnotherFakeApi.md#call_123_test_special_tags) | **PATCH** /another-fake/dummy | To test special tags *FakeApi* | [**fake_outer_boolean_serialize**](docs/FakeApi.md#fake_outer_boolean_serialize) | **POST** /fake/outer/boolean | *FakeApi* | [**fake_outer_composite_serialize**](docs/FakeApi.md#fake_outer_composite_serialize) | **POST** /fake/outer/composite | *FakeApi* | [**fake_outer_number_serialize**](docs/FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number | diff --git a/samples/client/petstore/python-tornado/docs/AnotherFakeApi.md b/samples/client/petstore/python-tornado/docs/AnotherFakeApi.md index 32d4fa0696c..447ce3edde3 100644 --- a/samples/client/petstore/python-tornado/docs/AnotherFakeApi.md +++ b/samples/client/petstore/python-tornado/docs/AnotherFakeApi.md @@ -4,15 +4,15 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* Method | HTTP request | Description ------------- | ------------- | ------------- -[**test_special_tags**](AnotherFakeApi.md#test_special_tags) | **PATCH** /another-fake/dummy | To test special tags +[**call_123_test_special_tags**](AnotherFakeApi.md#call_123_test_special_tags) | **PATCH** /another-fake/dummy | To test special tags -# **test_special_tags** -> Client test_special_tags(client) +# **call_123_test_special_tags** +> Client call_123_test_special_tags(client) To test special tags -To test special tags +To test special tags and operation ID starting with number ### Example ```python @@ -28,10 +28,10 @@ client = petstore_api.Client() # Client | client model try: # To test special tags - api_response = api_instance.test_special_tags(client) + api_response = api_instance.call_123_test_special_tags(client) pprint(api_response) except ApiException as e: - print("Exception when calling AnotherFakeApi->test_special_tags: %s\n" % e) + print("Exception when calling AnotherFakeApi->call_123_test_special_tags: %s\n" % e) ``` ### Parameters diff --git a/samples/client/petstore/python-tornado/petstore_api/api/another_fake_api.py b/samples/client/petstore/python-tornado/petstore_api/api/another_fake_api.py index b753906b2e4..782f7fd07b3 100644 --- a/samples/client/petstore/python-tornado/petstore_api/api/another_fake_api.py +++ b/samples/client/petstore/python-tornado/petstore_api/api/another_fake_api.py @@ -32,13 +32,13 @@ class AnotherFakeApi(object): api_client = ApiClient() self.api_client = api_client - def test_special_tags(self, client, **kwargs): # noqa: E501 + def call_123_test_special_tags(self, client, **kwargs): # noqa: E501 """To test special tags # noqa: E501 - To test special tags # noqa: E501 + To test special tags and operation ID starting with number # 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_special_tags(client, async_req=True) + >>> thread = api.call_123_test_special_tags(client, async_req=True) >>> result = thread.get() :param async_req bool @@ -49,18 +49,18 @@ class AnotherFakeApi(object): """ kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): - return self.test_special_tags_with_http_info(client, **kwargs) # noqa: E501 + return self.call_123_test_special_tags_with_http_info(client, **kwargs) # noqa: E501 else: - (data) = self.test_special_tags_with_http_info(client, **kwargs) # noqa: E501 + (data) = self.call_123_test_special_tags_with_http_info(client, **kwargs) # noqa: E501 return data - def test_special_tags_with_http_info(self, client, **kwargs): # noqa: E501 + def call_123_test_special_tags_with_http_info(self, client, **kwargs): # noqa: E501 """To test special tags # noqa: E501 - To test special tags # noqa: E501 + To test special tags and operation ID starting with number # 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_special_tags_with_http_info(client, async_req=True) + >>> thread = api.call_123_test_special_tags_with_http_info(client, async_req=True) >>> result = thread.get() :param async_req bool @@ -82,14 +82,14 @@ class AnotherFakeApi(object): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" - " to method test_special_tags" % key + " to method call_123_test_special_tags" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'client' is set if ('client' not in local_var_params or local_var_params['client'] is None): - raise ValueError("Missing the required parameter `client` when calling `test_special_tags`") # noqa: E501 + raise ValueError("Missing the required parameter `client` when calling `call_123_test_special_tags`") # noqa: E501 collection_formats = {} diff --git a/samples/client/petstore/python/.openapi-generator/VERSION b/samples/client/petstore/python/.openapi-generator/VERSION index 4395ff59232..c791c986fbb 100644 --- a/samples/client/petstore/python/.openapi-generator/VERSION +++ b/samples/client/petstore/python/.openapi-generator/VERSION @@ -1 +1 @@ -3.2.0-SNAPSHOT \ No newline at end of file +3.2.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/python/README.md b/samples/client/petstore/python/README.md index b76d6153e89..6e6dbf6180a 100644 --- a/samples/client/petstore/python/README.md +++ b/samples/client/petstore/python/README.md @@ -57,10 +57,10 @@ client = petstore_api.Client() # Client | client model try: # To test special tags - api_response = api_instance.test_special_tags(client) + api_response = api_instance.call_123_test_special_tags(client) pprint(api_response) except ApiException as e: - print("Exception when calling AnotherFakeApi->test_special_tags: %s\n" % e) + print("Exception when calling AnotherFakeApi->call_123_test_special_tags: %s\n" % e) ``` @@ -70,7 +70,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- -*AnotherFakeApi* | [**test_special_tags**](docs/AnotherFakeApi.md#test_special_tags) | **PATCH** /another-fake/dummy | To test special tags +*AnotherFakeApi* | [**call_123_test_special_tags**](docs/AnotherFakeApi.md#call_123_test_special_tags) | **PATCH** /another-fake/dummy | To test special tags *FakeApi* | [**fake_outer_boolean_serialize**](docs/FakeApi.md#fake_outer_boolean_serialize) | **POST** /fake/outer/boolean | *FakeApi* | [**fake_outer_composite_serialize**](docs/FakeApi.md#fake_outer_composite_serialize) | **POST** /fake/outer/composite | *FakeApi* | [**fake_outer_number_serialize**](docs/FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number | diff --git a/samples/client/petstore/python/docs/AnotherFakeApi.md b/samples/client/petstore/python/docs/AnotherFakeApi.md index 32d4fa0696c..447ce3edde3 100644 --- a/samples/client/petstore/python/docs/AnotherFakeApi.md +++ b/samples/client/petstore/python/docs/AnotherFakeApi.md @@ -4,15 +4,15 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* Method | HTTP request | Description ------------- | ------------- | ------------- -[**test_special_tags**](AnotherFakeApi.md#test_special_tags) | **PATCH** /another-fake/dummy | To test special tags +[**call_123_test_special_tags**](AnotherFakeApi.md#call_123_test_special_tags) | **PATCH** /another-fake/dummy | To test special tags -# **test_special_tags** -> Client test_special_tags(client) +# **call_123_test_special_tags** +> Client call_123_test_special_tags(client) To test special tags -To test special tags +To test special tags and operation ID starting with number ### Example ```python @@ -28,10 +28,10 @@ client = petstore_api.Client() # Client | client model try: # To test special tags - api_response = api_instance.test_special_tags(client) + api_response = api_instance.call_123_test_special_tags(client) pprint(api_response) except ApiException as e: - print("Exception when calling AnotherFakeApi->test_special_tags: %s\n" % e) + print("Exception when calling AnotherFakeApi->call_123_test_special_tags: %s\n" % e) ``` ### Parameters diff --git a/samples/client/petstore/python/petstore_api/api/another_fake_api.py b/samples/client/petstore/python/petstore_api/api/another_fake_api.py index b753906b2e4..782f7fd07b3 100644 --- a/samples/client/petstore/python/petstore_api/api/another_fake_api.py +++ b/samples/client/petstore/python/petstore_api/api/another_fake_api.py @@ -32,13 +32,13 @@ class AnotherFakeApi(object): api_client = ApiClient() self.api_client = api_client - def test_special_tags(self, client, **kwargs): # noqa: E501 + def call_123_test_special_tags(self, client, **kwargs): # noqa: E501 """To test special tags # noqa: E501 - To test special tags # noqa: E501 + To test special tags and operation ID starting with number # 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_special_tags(client, async_req=True) + >>> thread = api.call_123_test_special_tags(client, async_req=True) >>> result = thread.get() :param async_req bool @@ -49,18 +49,18 @@ class AnotherFakeApi(object): """ kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): - return self.test_special_tags_with_http_info(client, **kwargs) # noqa: E501 + return self.call_123_test_special_tags_with_http_info(client, **kwargs) # noqa: E501 else: - (data) = self.test_special_tags_with_http_info(client, **kwargs) # noqa: E501 + (data) = self.call_123_test_special_tags_with_http_info(client, **kwargs) # noqa: E501 return data - def test_special_tags_with_http_info(self, client, **kwargs): # noqa: E501 + def call_123_test_special_tags_with_http_info(self, client, **kwargs): # noqa: E501 """To test special tags # noqa: E501 - To test special tags # noqa: E501 + To test special tags and operation ID starting with number # 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_special_tags_with_http_info(client, async_req=True) + >>> thread = api.call_123_test_special_tags_with_http_info(client, async_req=True) >>> result = thread.get() :param async_req bool @@ -82,14 +82,14 @@ class AnotherFakeApi(object): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" - " to method test_special_tags" % key + " to method call_123_test_special_tags" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'client' is set if ('client' not in local_var_params or local_var_params['client'] is None): - raise ValueError("Missing the required parameter `client` when calling `test_special_tags`") # noqa: E501 + raise ValueError("Missing the required parameter `client` when calling `call_123_test_special_tags`") # noqa: E501 collection_formats = {}