Skip to content
Merged
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 @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
{{/tornado}}
{{/async}}
safe_chars_for_path_param: str='',
client_side_validation: bool=True,
socket_options: Optional[Any]=None,
Expand Down Expand Up @@ -505,6 +520,15 @@ conf = {{{packageName}}}.Configuration(
self.proxy_headers = proxy_headers
"""Proxy headers
"""
{{^async}}
{{^tornado}}
self.proxy_ssl_context = proxy_ssl_context
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
"""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
"""
Expand Down Expand Up @@ -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))
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -350,6 +353,11 @@ def __init__(
self.proxy_headers = proxy_headers
"""Proxy headers
"""
self.proxy_ssl_context = proxy_ssl_context
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
"""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
"""
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Clients resolved to supported urllib3 1.25.x fail when callers set this option, because that release does not implement ProxyManager.proxy_ssl_context. Raise the generated urllib3 minimum to 1.26.0 (including all package metadata/templates), or guard/reject the option for older versions.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/echo_api/python-pydantic-v1/openapi_client/rest.py, line 110:

<comment>Clients resolved to supported urllib3 1.25.x fail when callers set this option, because that release does not implement `ProxyManager.proxy_ssl_context`. Raise the generated urllib3 minimum to 1.26.0 (including all package metadata/templates), or guard/reject the option for older versions.</comment>

<file context>
@@ -106,6 +106,8 @@ def __init__(self, configuration, pools_size=4, maxsize=None) -> None:
                     )
             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,
</file context>

self.pool_manager = urllib3.ProxyManager(
num_pools=pools_size,
maxsize=maxsize,
Expand Down
2 changes: 1 addition & 1 deletion samples/client/echo_api/python-pydantic-v1/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion samples/client/echo_api/python-pydantic-v1/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 12 additions & 0 deletions samples/client/echo_api/python/openapi_client/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
"""
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions samples/client/echo_api/python/openapi_client/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -330,6 +333,11 @@ def __init__(
self.proxy_headers = proxy_headers
"""Proxy headers
"""
self.proxy_ssl_context = proxy_ssl_context
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
"""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
"""
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading
Loading