diff --git a/modules/openapi-generator/src/main/resources/python-pydantic-v1/README_onlypackage.mustache b/modules/openapi-generator/src/main/resources/python-pydantic-v1/README_onlypackage.mustache index e9bedf610cb3..2fb2c65af442 100644 --- a/modules/openapi-generator/src/main/resources/python-pydantic-v1/README_onlypackage.mustache +++ b/modules/openapi-generator/src/main/resources/python-pydantic-v1/README_onlypackage.mustache @@ -26,7 +26,7 @@ This python library package is generated without supporting files like setup.py To be able to use it, you will need these dependencies in your own package that uses this library: -* urllib3 >= 1.25.3 +* urllib3 >= 1.26.0 * python-dateutil {{#asyncio}} * aiohttp diff --git a/modules/openapi-generator/src/main/resources/python-pydantic-v1/configuration.mustache b/modules/openapi-generator/src/main/resources/python-pydantic-v1/configuration.mustache index b69d90153301..e77d3413edc2 100644 --- a/modules/openapi-generator/src/main/resources/python-pydantic-v1/configuration.mustache +++ b/modules/openapi-generator/src/main/resources/python-pydantic-v1/configuration.mustache @@ -259,6 +259,15 @@ conf = {{{packageName}}}.Configuration( self.proxy_headers = None """Proxy headers """ +{{^asyncio}} +{{^tornado}} + self.proxy_ssl_context = None + """SSL context used only for the TLS handshake with the proxy itself + (e.g. an HTTPS CONNECT tunnel), independent of the destination TLS + settings above. + """ +{{/tornado}} +{{/asyncio}} self.safe_chars_for_path_param = '' """Safe chars for path_param """ @@ -285,6 +294,14 @@ conf = {{{packageName}}}.Configuration( result = cls.__new__(cls) memo[id(self)] = result for k, v in self.__dict__.items(): +{{^asyncio}} +{{^tornado}} + if k == 'proxy_ssl_context': + # ssl.SSLContext holds unpicklable C state and can't be deepcopied. + setattr(result, k, v) + continue +{{/tornado}} +{{/asyncio}} if k not in ('logger', 'logger_file_handler'): setattr(result, k, copy.deepcopy(v, memo)) # shallow copy of loggers diff --git a/modules/openapi-generator/src/main/resources/python-pydantic-v1/pyproject.mustache b/modules/openapi-generator/src/main/resources/python-pydantic-v1/pyproject.mustache index 8892d1566f32..5b8f45a9827f 100644 --- a/modules/openapi-generator/src/main/resources/python-pydantic-v1/pyproject.mustache +++ b/modules/openapi-generator/src/main/resources/python-pydantic-v1/pyproject.mustache @@ -12,7 +12,7 @@ include = ["{{packageName}}/py.typed"] [tool.poetry.dependencies] python = "^3.8" -urllib3 = ">= 1.25.3" +urllib3 = ">= 1.26.0" python-dateutil = ">=2.8.2" {{#asyncio}} aiohttp = ">= 3.8.4" diff --git a/modules/openapi-generator/src/main/resources/python-pydantic-v1/requirements.mustache b/modules/openapi-generator/src/main/resources/python-pydantic-v1/requirements.mustache index 8add30ffd46a..0724c06b0748 100644 --- a/modules/openapi-generator/src/main/resources/python-pydantic-v1/requirements.mustache +++ b/modules/openapi-generator/src/main/resources/python-pydantic-v1/requirements.mustache @@ -1,6 +1,6 @@ python_dateutil >= 2.5.3 setuptools >= 21.0.0 -urllib3 >= 1.25.3, < 3.0.0 +urllib3 >= 1.26.0, < 3.0.0 pydantic >= 1.10.5, < 2 aenum >= 3.1.11 {{#asyncio}} diff --git a/modules/openapi-generator/src/main/resources/python-pydantic-v1/rest.mustache b/modules/openapi-generator/src/main/resources/python-pydantic-v1/rest.mustache index f02f28cf2128..9ec8e7d4f549 100644 --- a/modules/openapi-generator/src/main/resources/python-pydantic-v1/rest.mustache +++ b/modules/openapi-generator/src/main/resources/python-pydantic-v1/rest.mustache @@ -96,6 +96,8 @@ class RESTClientObject: **addition_pool_args ) else: + if configuration.proxy_ssl_context is not None: + addition_pool_args['proxy_ssl_context'] = configuration.proxy_ssl_context self.pool_manager = urllib3.ProxyManager( num_pools=pools_size, maxsize=maxsize, diff --git a/modules/openapi-generator/src/main/resources/python-pydantic-v1/setup.mustache b/modules/openapi-generator/src/main/resources/python-pydantic-v1/setup.mustache index fed7c0b3eecd..3cd0e9c82946 100644 --- a/modules/openapi-generator/src/main/resources/python-pydantic-v1/setup.mustache +++ b/modules/openapi-generator/src/main/resources/python-pydantic-v1/setup.mustache @@ -18,7 +18,7 @@ PYTHON_REQUIRES = ">=3.7" {{#apis}} {{#-last}} REQUIRES = [ - "urllib3 >= 1.25.3, < 3.0.0", + "urllib3 >= 1.26.0, < 3.0.0", "python-dateutil", {{#asyncio}} "aiohttp >= 3.0.0", diff --git a/modules/openapi-generator/src/main/resources/python/configuration.mustache b/modules/openapi-generator/src/main/resources/python/configuration.mustache index db0afd15517c..2d40eb8cb826 100644 --- a/modules/openapi-generator/src/main/resources/python/configuration.mustache +++ b/modules/openapi-generator/src/main/resources/python/configuration.mustache @@ -14,6 +14,11 @@ from logging import FileHandler {{^async}} import multiprocessing {{/async}} +{{^async}} +{{^tornado}} +import ssl +{{/tornado}} +{{/async}} import sys from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union {{^async}} @@ -227,6 +232,11 @@ class Configuration: :param no_proxy: Comma-separated hosts that bypass the proxy. {{/async}} :param proxy_headers: Proxy headers. +{{^async}} +{{^tornado}} + :param proxy_ssl_context: SSL context used only for the TLS handshake with the proxy itself, independent of the destination TLS settings. +{{/tornado}} +{{/async}} :param safe_chars_for_path_param: Safe characters for path parameter encoding. :param client_side_validation: Enable client-side validation. Default True. :param socket_options: Options to pass down to the underlying urllib3 socket. @@ -361,6 +371,11 @@ conf = {{{packageName}}}.Configuration( no_proxy: Optional[str]=None, {{/async}} proxy_headers: Optional[Any]=None, +{{^async}} +{{^tornado}} + proxy_ssl_context: Optional[ssl.SSLContext]=None, +{{/tornado}} +{{/async}} safe_chars_for_path_param: str='', client_side_validation: bool=True, socket_options: Optional[Any]=None, @@ -505,6 +520,15 @@ conf = {{{packageName}}}.Configuration( self.proxy_headers = proxy_headers """Proxy headers """ +{{^async}} +{{^tornado}} + self.proxy_ssl_context = proxy_ssl_context + """SSL context used only for the TLS handshake with the proxy itself + (e.g. an HTTPS CONNECT tunnel), independent of the destination TLS + settings above. + """ +{{/tornado}} +{{/async}} self.safe_chars_for_path_param = safe_chars_for_path_param """Safe chars for path_param """ @@ -557,6 +581,14 @@ conf = {{{packageName}}}.Configuration( if callable(copy_method): setattr(result, k, copy_method()) continue +{{^async}} +{{^tornado}} + if k == 'proxy_ssl_context': + # ssl.SSLContext holds unpicklable C state and can't be deepcopied. + setattr(result, k, v) + continue +{{/tornado}} +{{/async}} {{#asyncio}} if k in ('client_session_kwargs', 'trace_configs'): setattr(result, k, copy.copy(v)) @@ -578,6 +610,14 @@ conf = {{{packageName}}}.Configuration( result.logger_stream_handler = self.logger_stream_handler {{/useIndependentImplicitClients}} {{^useIndependentImplicitClients}} +{{^async}} +{{^tornado}} + if k == 'proxy_ssl_context': + # ssl.SSLContext holds unpicklable C state and can't be deepcopied. + setattr(result, k, v) + continue +{{/tornado}} +{{/async}} if k not in ('logger', 'logger_file_handler'): setattr(result, k, copy.deepcopy(v, memo)) # shallow copy of loggers diff --git a/modules/openapi-generator/src/main/resources/python/rest.mustache b/modules/openapi-generator/src/main/resources/python/rest.mustache index fcccd6afd820..5f56a2d60b32 100644 --- a/modules/openapi-generator/src/main/resources/python/rest.mustache +++ b/modules/openapi-generator/src/main/resources/python/rest.mustache @@ -161,6 +161,8 @@ class RESTClientObject: else: pool_args["proxy_url"] = configuration.proxy pool_args["proxy_headers"] = configuration.proxy_headers + if configuration.proxy_ssl_context is not None: + pool_args["proxy_ssl_context"] = configuration.proxy_ssl_context self.pool_manager = urllib3.ProxyManager(**pool_args) else: self.pool_manager = urllib3.PoolManager(**pool_args) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/configuration.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/configuration.py index 848539a45392..2bbf005e307a 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/configuration.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/configuration.py @@ -16,6 +16,7 @@ import logging from logging import FileHandler import multiprocessing +import ssl import sys from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union from urllib.parse import urlparse @@ -175,6 +176,7 @@ class Configuration: :param proxy: Proxy URL. :param no_proxy: Comma-separated hosts that bypass the proxy. :param proxy_headers: Proxy headers. + :param proxy_ssl_context: SSL context used only for the TLS handshake with the proxy itself, independent of the destination TLS settings. :param safe_chars_for_path_param: Safe characters for path parameter encoding. :param client_side_validation: Enable client-side validation. Default True. :param socket_options: Options to pass down to the underlying urllib3 socket. @@ -227,6 +229,7 @@ def __init__( proxy: Optional[str]=None, no_proxy: Optional[str]=None, proxy_headers: Optional[Any]=None, + proxy_ssl_context: Optional[ssl.SSLContext]=None, safe_chars_for_path_param: str='', client_side_validation: bool=True, socket_options: Optional[Any]=None, @@ -350,6 +353,11 @@ def __init__( self.proxy_headers = proxy_headers """Proxy headers """ + self.proxy_ssl_context = proxy_ssl_context + """SSL context used only for the TLS handshake with the proxy itself + (e.g. an HTTPS CONNECT tunnel), independent of the destination TLS + settings above. + """ self.safe_chars_for_path_param = safe_chars_for_path_param """Safe chars for path_param """ @@ -376,6 +384,10 @@ def __deepcopy__(self, memo: Dict[int, Any]) -> Self: result = cls.__new__(cls) memo[id(self)] = result for k, v in self.__dict__.items(): + if k == 'proxy_ssl_context': + # ssl.SSLContext holds unpicklable C state and can't be deepcopied. + setattr(result, k, v) + continue if k not in ('logger', 'logger_file_handler'): setattr(result, k, copy.deepcopy(v, memo)) # shallow copy of loggers diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/rest.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/rest.py index ef3ed39f4679..9a0c6d4de785 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/rest.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/rest.py @@ -171,6 +171,8 @@ def __init__(self, configuration) -> None: else: pool_args["proxy_url"] = configuration.proxy pool_args["proxy_headers"] = configuration.proxy_headers + if configuration.proxy_ssl_context is not None: + pool_args["proxy_ssl_context"] = configuration.proxy_ssl_context self.pool_manager = urllib3.ProxyManager(**pool_args) else: self.pool_manager = urllib3.PoolManager(**pool_args) diff --git a/samples/client/echo_api/python-pydantic-v1/openapi_client/configuration.py b/samples/client/echo_api/python-pydantic-v1/openapi_client/configuration.py index 40a30ca4ca90..a618cee7e10a 100644 --- a/samples/client/echo_api/python-pydantic-v1/openapi_client/configuration.py +++ b/samples/client/echo_api/python-pydantic-v1/openapi_client/configuration.py @@ -179,6 +179,11 @@ def __init__(self, host=None, self.proxy_headers = None """Proxy headers """ + self.proxy_ssl_context = None + """SSL context used only for the TLS handshake with the proxy itself + (e.g. an HTTPS CONNECT tunnel), independent of the destination TLS + settings above. + """ self.safe_chars_for_path_param = '' """Safe chars for path_param """ @@ -205,6 +210,10 @@ def __deepcopy__(self, memo): result = cls.__new__(cls) memo[id(self)] = result for k, v in self.__dict__.items(): + if k == 'proxy_ssl_context': + # ssl.SSLContext holds unpicklable C state and can't be deepcopied. + setattr(result, k, v) + continue if k not in ('logger', 'logger_file_handler'): setattr(result, k, copy.deepcopy(v, memo)) # shallow copy of loggers diff --git a/samples/client/echo_api/python-pydantic-v1/openapi_client/rest.py b/samples/client/echo_api/python-pydantic-v1/openapi_client/rest.py index 7600e9d54cc7..e1c59ddf82f5 100644 --- a/samples/client/echo_api/python-pydantic-v1/openapi_client/rest.py +++ b/samples/client/echo_api/python-pydantic-v1/openapi_client/rest.py @@ -106,6 +106,8 @@ def __init__(self, configuration, pools_size=4, maxsize=None) -> None: **addition_pool_args ) else: + if configuration.proxy_ssl_context is not None: + addition_pool_args['proxy_ssl_context'] = configuration.proxy_ssl_context self.pool_manager = urllib3.ProxyManager( num_pools=pools_size, maxsize=maxsize, diff --git a/samples/client/echo_api/python-pydantic-v1/pyproject.toml b/samples/client/echo_api/python-pydantic-v1/pyproject.toml index 192e7c548361..ff54392bbebb 100644 --- a/samples/client/echo_api/python-pydantic-v1/pyproject.toml +++ b/samples/client/echo_api/python-pydantic-v1/pyproject.toml @@ -12,7 +12,7 @@ include = ["openapi_client/py.typed"] [tool.poetry.dependencies] python = "^3.8" -urllib3 = ">= 1.25.3" +urllib3 = ">= 1.26.0" python-dateutil = ">=2.8.2" pydantic = "^1.10.5, <2" aenum = ">=3.1.11" diff --git a/samples/client/echo_api/python-pydantic-v1/requirements.txt b/samples/client/echo_api/python-pydantic-v1/requirements.txt index 0a8bf96cadf2..39ac48267898 100644 --- a/samples/client/echo_api/python-pydantic-v1/requirements.txt +++ b/samples/client/echo_api/python-pydantic-v1/requirements.txt @@ -1,5 +1,5 @@ python_dateutil >= 2.5.3 setuptools >= 21.0.0 -urllib3 >= 1.25.3, < 3.0.0 +urllib3 >= 1.26.0, < 3.0.0 pydantic >= 1.10.5, < 2 aenum >= 3.1.11 diff --git a/samples/client/echo_api/python-pydantic-v1/setup.py b/samples/client/echo_api/python-pydantic-v1/setup.py index d91b9d9f069e..7551181347d1 100644 --- a/samples/client/echo_api/python-pydantic-v1/setup.py +++ b/samples/client/echo_api/python-pydantic-v1/setup.py @@ -25,7 +25,7 @@ VERSION = "1.0.0" PYTHON_REQUIRES = ">=3.7" REQUIRES = [ - "urllib3 >= 1.25.3, < 3.0.0", + "urllib3 >= 1.26.0, < 3.0.0", "python-dateutil", "pydantic >= 1.10.5, < 2", "aenum" diff --git a/samples/client/echo_api/python/openapi_client/configuration.py b/samples/client/echo_api/python/openapi_client/configuration.py index 848539a45392..2bbf005e307a 100644 --- a/samples/client/echo_api/python/openapi_client/configuration.py +++ b/samples/client/echo_api/python/openapi_client/configuration.py @@ -16,6 +16,7 @@ import logging from logging import FileHandler import multiprocessing +import ssl import sys from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union from urllib.parse import urlparse @@ -175,6 +176,7 @@ class Configuration: :param proxy: Proxy URL. :param no_proxy: Comma-separated hosts that bypass the proxy. :param proxy_headers: Proxy headers. + :param proxy_ssl_context: SSL context used only for the TLS handshake with the proxy itself, independent of the destination TLS settings. :param safe_chars_for_path_param: Safe characters for path parameter encoding. :param client_side_validation: Enable client-side validation. Default True. :param socket_options: Options to pass down to the underlying urllib3 socket. @@ -227,6 +229,7 @@ def __init__( proxy: Optional[str]=None, no_proxy: Optional[str]=None, proxy_headers: Optional[Any]=None, + proxy_ssl_context: Optional[ssl.SSLContext]=None, safe_chars_for_path_param: str='', client_side_validation: bool=True, socket_options: Optional[Any]=None, @@ -350,6 +353,11 @@ def __init__( self.proxy_headers = proxy_headers """Proxy headers """ + self.proxy_ssl_context = proxy_ssl_context + """SSL context used only for the TLS handshake with the proxy itself + (e.g. an HTTPS CONNECT tunnel), independent of the destination TLS + settings above. + """ self.safe_chars_for_path_param = safe_chars_for_path_param """Safe chars for path_param """ @@ -376,6 +384,10 @@ def __deepcopy__(self, memo: Dict[int, Any]) -> Self: result = cls.__new__(cls) memo[id(self)] = result for k, v in self.__dict__.items(): + if k == 'proxy_ssl_context': + # ssl.SSLContext holds unpicklable C state and can't be deepcopied. + setattr(result, k, v) + continue if k not in ('logger', 'logger_file_handler'): setattr(result, k, copy.deepcopy(v, memo)) # shallow copy of loggers diff --git a/samples/client/echo_api/python/openapi_client/rest.py b/samples/client/echo_api/python/openapi_client/rest.py index 5bd90b34957e..77b4fe56053a 100644 --- a/samples/client/echo_api/python/openapi_client/rest.py +++ b/samples/client/echo_api/python/openapi_client/rest.py @@ -171,6 +171,8 @@ def __init__(self, configuration) -> None: else: pool_args["proxy_url"] = configuration.proxy pool_args["proxy_headers"] = configuration.proxy_headers + if configuration.proxy_ssl_context is not None: + pool_args["proxy_ssl_context"] = configuration.proxy_ssl_context self.pool_manager = urllib3.ProxyManager(**pool_args) else: self.pool_manager = urllib3.PoolManager(**pool_args) diff --git a/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/configuration.py b/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/configuration.py index 96f087a0c127..8e689e45eb90 100644 --- a/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/configuration.py +++ b/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/configuration.py @@ -15,6 +15,7 @@ import logging from logging import FileHandler import multiprocessing +import ssl import sys from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union from urllib.parse import urlparse @@ -172,6 +173,7 @@ class Configuration: :param proxy: Proxy URL. :param no_proxy: Comma-separated hosts that bypass the proxy. :param proxy_headers: Proxy headers. + :param proxy_ssl_context: SSL context used only for the TLS handshake with the proxy itself, independent of the destination TLS settings. :param safe_chars_for_path_param: Safe characters for path parameter encoding. :param client_side_validation: Enable client-side validation. Default True. :param socket_options: Options to pass down to the underlying urllib3 socket. @@ -207,6 +209,7 @@ def __init__( proxy: Optional[str]=None, no_proxy: Optional[str]=None, proxy_headers: Optional[Any]=None, + proxy_ssl_context: Optional[ssl.SSLContext]=None, safe_chars_for_path_param: str='', client_side_validation: bool=True, socket_options: Optional[Any]=None, @@ -330,6 +333,11 @@ def __init__( self.proxy_headers = proxy_headers """Proxy headers """ + self.proxy_ssl_context = proxy_ssl_context + """SSL context used only for the TLS handshake with the proxy itself + (e.g. an HTTPS CONNECT tunnel), independent of the destination TLS + settings above. + """ self.safe_chars_for_path_param = safe_chars_for_path_param """Safe chars for path_param """ @@ -356,6 +364,10 @@ def __deepcopy__(self, memo: Dict[int, Any]) -> Self: result = cls.__new__(cls) memo[id(self)] = result for k, v in self.__dict__.items(): + if k == 'proxy_ssl_context': + # ssl.SSLContext holds unpicklable C state and can't be deepcopied. + setattr(result, k, v) + continue if k not in ('logger', 'logger_file_handler'): setattr(result, k, copy.deepcopy(v, memo)) # shallow copy of loggers diff --git a/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/rest.py b/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/rest.py index 0e0bdcc507a0..c6da043e386b 100644 --- a/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/rest.py +++ b/samples/client/others/python-legacy-model-dictionaries/legacy_model_dict_client/rest.py @@ -170,6 +170,8 @@ def __init__(self, configuration) -> None: else: pool_args["proxy_url"] = configuration.proxy pool_args["proxy_headers"] = configuration.proxy_headers + if configuration.proxy_ssl_context is not None: + pool_args["proxy_ssl_context"] = configuration.proxy_ssl_context self.pool_manager = urllib3.ProxyManager(**pool_args) else: self.pool_manager = urllib3.PoolManager(**pool_args) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/configuration.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/configuration.py index f38713f1cfc0..8f0b80ef4aed 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/configuration.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/configuration.py @@ -15,6 +15,7 @@ import logging from logging import FileHandler import multiprocessing +import ssl import sys from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union from urllib.parse import urlparse @@ -181,6 +182,7 @@ class Configuration: :param proxy: Proxy URL. :param no_proxy: Comma-separated hosts that bypass the proxy. :param proxy_headers: Proxy headers. + :param proxy_ssl_context: SSL context used only for the TLS handshake with the proxy itself, independent of the destination TLS settings. :param safe_chars_for_path_param: Safe characters for path parameter encoding. :param client_side_validation: Enable client-side validation. Default True. :param socket_options: Options to pass down to the underlying urllib3 socket. @@ -292,6 +294,7 @@ def __init__( proxy: Optional[str]=None, no_proxy: Optional[str]=None, proxy_headers: Optional[Any]=None, + proxy_ssl_context: Optional[ssl.SSLContext]=None, safe_chars_for_path_param: str='', client_side_validation: bool=True, socket_options: Optional[Any]=None, @@ -420,6 +423,11 @@ def __init__( self.proxy_headers = proxy_headers """Proxy headers """ + self.proxy_ssl_context = proxy_ssl_context + """SSL context used only for the TLS handshake with the proxy itself + (e.g. an HTTPS CONNECT tunnel), independent of the destination TLS + settings above. + """ self.safe_chars_for_path_param = safe_chars_for_path_param """Safe chars for path_param """ @@ -456,6 +464,10 @@ def __deepcopy__(self, memo: Dict[int, Any]) -> Self: if callable(copy_method): setattr(result, k, copy_method()) continue + if k == 'proxy_ssl_context': + # ssl.SSLContext holds unpicklable C state and can't be deepcopied. + setattr(result, k, v) + continue setattr(result, k, copy.deepcopy(v, memo)) # Loggers and their handlers are process-global. diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/rest.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/rest.py index 1344bf560901..8affe12ad0a2 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/rest.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/rest.py @@ -170,6 +170,8 @@ def __init__(self, configuration) -> None: else: pool_args["proxy_url"] = configuration.proxy pool_args["proxy_headers"] = configuration.proxy_headers + if configuration.proxy_ssl_context is not None: + pool_args["proxy_ssl_context"] = configuration.proxy_ssl_context self.pool_manager = urllib3.ProxyManager(**pool_args) else: self.pool_manager = urllib3.PoolManager(**pool_args) diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/pyproject.toml b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/pyproject.toml index d65781e4a8a8..99cb8cdef767 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/pyproject.toml +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/pyproject.toml @@ -12,7 +12,7 @@ include = ["petstore_api/py.typed"] [tool.poetry.dependencies] python = "^3.8" -urllib3 = ">= 1.25.3" +urllib3 = ">= 1.26.0" python-dateutil = ">=2.8.2" aiohttp = ">= 3.8.4" pem = ">= 19.3.0" diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/requirements.txt b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/requirements.txt index c8ee56b4876d..6f8a93445cf3 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/requirements.txt +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/requirements.txt @@ -1,6 +1,6 @@ python_dateutil >= 2.5.3 setuptools >= 21.0.0 -urllib3 >= 1.25.3, < 3.0.0 +urllib3 >= 1.26.0, < 3.0.0 pydantic >= 1.10.5, < 2 aenum >= 3.1.11 aiohttp >= 3.0.0 diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/setup.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/setup.py index 6c3c289d34cc..3f90b0e52605 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/setup.py +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/setup.py @@ -24,7 +24,7 @@ VERSION = "1.0.0" PYTHON_REQUIRES = ">=3.7" REQUIRES = [ - "urllib3 >= 1.25.3, < 3.0.0", + "urllib3 >= 1.26.0, < 3.0.0", "python-dateutil", "aiohttp >= 3.0.0", "pem>=19.3.0", diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/configuration.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/configuration.py index 4bfa3e213b57..94b30a8c6fd9 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/configuration.py +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/configuration.py @@ -244,6 +244,11 @@ def __init__(self, host=None, self.proxy_headers = None """Proxy headers """ + self.proxy_ssl_context = None + """SSL context used only for the TLS handshake with the proxy itself + (e.g. an HTTPS CONNECT tunnel), independent of the destination TLS + settings above. + """ self.safe_chars_for_path_param = '' """Safe chars for path_param """ @@ -270,6 +275,10 @@ def __deepcopy__(self, memo): result = cls.__new__(cls) memo[id(self)] = result for k, v in self.__dict__.items(): + if k == 'proxy_ssl_context': + # ssl.SSLContext holds unpicklable C state and can't be deepcopied. + setattr(result, k, v) + continue if k not in ('logger', 'logger_file_handler'): setattr(result, k, copy.deepcopy(v, memo)) # shallow copy of loggers diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/rest.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/rest.py index d677d53b40fc..16d3c8490523 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/rest.py +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/rest.py @@ -105,6 +105,8 @@ def __init__(self, configuration, pools_size=4, maxsize=None) -> None: **addition_pool_args ) else: + if configuration.proxy_ssl_context is not None: + addition_pool_args['proxy_ssl_context'] = configuration.proxy_ssl_context self.pool_manager = urllib3.ProxyManager( num_pools=pools_size, maxsize=maxsize, diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/pyproject.toml b/samples/openapi3/client/petstore/python-pydantic-v1/pyproject.toml index d67ebb4ca8e2..1065ebed888c 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/pyproject.toml +++ b/samples/openapi3/client/petstore/python-pydantic-v1/pyproject.toml @@ -12,7 +12,7 @@ include = ["petstore_api/py.typed"] [tool.poetry.dependencies] python = "^3.8" -urllib3 = ">= 1.25.3" +urllib3 = ">= 1.26.0" python-dateutil = ">=2.8.2" pem = ">= 19.3.0" pycryptodome = ">= 3.9.0" diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/requirements.txt b/samples/openapi3/client/petstore/python-pydantic-v1/requirements.txt index 2a3de4f163ef..4ac6bb3d1137 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/requirements.txt +++ b/samples/openapi3/client/petstore/python-pydantic-v1/requirements.txt @@ -1,6 +1,6 @@ python_dateutil >= 2.5.3 setuptools >= 21.0.0 -urllib3 >= 1.25.3, < 3.0.0 +urllib3 >= 1.26.0, < 3.0.0 pydantic >= 1.10.5, < 2 aenum >= 3.1.11 pycryptodome >= 3.9.0 diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/setup.py b/samples/openapi3/client/petstore/python-pydantic-v1/setup.py index 6af2c4f9a0be..40ca1c9a4bf6 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/setup.py +++ b/samples/openapi3/client/petstore/python-pydantic-v1/setup.py @@ -24,7 +24,7 @@ VERSION = "1.0.0" PYTHON_REQUIRES = ">=3.7" REQUIRES = [ - "urllib3 >= 1.25.3, < 3.0.0", + "urllib3 >= 1.26.0, < 3.0.0", "python-dateutil", "pem>=19.3.0", "pycryptodome>=3.9.0", diff --git a/samples/openapi3/client/petstore/python/petstore_api/configuration.py b/samples/openapi3/client/petstore/python/petstore_api/configuration.py index 8e3b6590b385..fcbc987747b6 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/configuration.py +++ b/samples/openapi3/client/petstore/python/petstore_api/configuration.py @@ -15,6 +15,7 @@ import logging from logging import FileHandler import multiprocessing +import ssl import sys from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union from urllib.parse import urlparse @@ -181,6 +182,7 @@ class Configuration: :param proxy: Proxy URL. :param no_proxy: Comma-separated hosts that bypass the proxy. :param proxy_headers: Proxy headers. + :param proxy_ssl_context: SSL context used only for the TLS handshake with the proxy itself, independent of the destination TLS settings. :param safe_chars_for_path_param: Safe characters for path parameter encoding. :param client_side_validation: Enable client-side validation. Default True. :param socket_options: Options to pass down to the underlying urllib3 socket. @@ -292,6 +294,7 @@ def __init__( proxy: Optional[str]=None, no_proxy: Optional[str]=None, proxy_headers: Optional[Any]=None, + proxy_ssl_context: Optional[ssl.SSLContext]=None, safe_chars_for_path_param: str='', client_side_validation: bool=True, socket_options: Optional[Any]=None, @@ -420,6 +423,11 @@ def __init__( self.proxy_headers = proxy_headers """Proxy headers """ + self.proxy_ssl_context = proxy_ssl_context + """SSL context used only for the TLS handshake with the proxy itself + (e.g. an HTTPS CONNECT tunnel), independent of the destination TLS + settings above. + """ self.safe_chars_for_path_param = safe_chars_for_path_param """Safe chars for path_param """ @@ -446,6 +454,10 @@ def __deepcopy__(self, memo: Dict[int, Any]) -> Self: result = cls.__new__(cls) memo[id(self)] = result for k, v in self.__dict__.items(): + if k == 'proxy_ssl_context': + # ssl.SSLContext holds unpicklable C state and can't be deepcopied. + setattr(result, k, v) + continue if k not in ('logger', 'logger_file_handler'): setattr(result, k, copy.deepcopy(v, memo)) # shallow copy of loggers diff --git a/samples/openapi3/client/petstore/python/petstore_api/rest.py b/samples/openapi3/client/petstore/python/petstore_api/rest.py index 075dca30faee..a265bee3515c 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/rest.py +++ b/samples/openapi3/client/petstore/python/petstore_api/rest.py @@ -170,6 +170,8 @@ def __init__(self, configuration) -> None: else: pool_args["proxy_url"] = configuration.proxy pool_args["proxy_headers"] = configuration.proxy_headers + if configuration.proxy_ssl_context is not None: + pool_args["proxy_ssl_context"] = configuration.proxy_ssl_context self.pool_manager = urllib3.ProxyManager(**pool_args) else: self.pool_manager = urllib3.PoolManager(**pool_args)