File tree Expand file tree Collapse file tree
modules/openapi-generator/src/main/resources/python Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -413,6 +413,9 @@ conf = {{{packageName}}}.Configuration(
413413 self.proxy: Optional[str] = None
414414 """Proxy URL
415415 """
416+ self.no_proxy: Optional[str] = None
417+ """Hosts for which to bypass the proxy
418+ """
416419 self.proxy_headers = None
417420 """Proxy headers
418421 """
Original file line number Diff line number Diff line change @@ -6,8 +6,11 @@ import io
66import json
77import re
88import ssl
9+ from urllib.parse import urlparse
10+ from urllib.request import getproxies
911
1012import urllib3
13+ from requests.utils import should_bypass_proxies
1114
1215from { {packageName} }.exceptions import ApiException, ApiValueError
1316
@@ -89,14 +92,15 @@ class RESTClientObject:
8992 # https pool manager
9093 self.pool_manager: urllib3.PoolManager
9194
92- if configuration.proxy:
93- if is_socks_proxy_url(configuration.proxy):
95+ proxy = getproxies().get(urlparse(configuration.host).scheme) if configuration.proxy is None else configuration.proxy
96+ if proxy and not should_bypass_proxies(configuration.host, configuration.no_proxy):
97+ if is_socks_proxy_url(proxy):
9498 from urllib3.contrib.socks import SOCKSProxyManager
95- pool_args["proxy_url"] = configuration. proxy
99+ pool_args["proxy_url"] = proxy
96100 pool_args["headers"] = configuration.proxy_headers
97101 self.pool_manager = SOCKSProxyManager(**pool_args)
98102 else:
99- pool_args["proxy_url"] = configuration. proxy
103+ pool_args["proxy_url"] = proxy
100104 pool_args["proxy_headers"] = configuration.proxy_headers
101105 self.pool_manager = urllib3.ProxyManager(**pool_args)
102106 else:
You can’t perform that action at this time.
0 commit comments