Skip to content

Commit 63b3e27

Browse files
committed
templates
1 parent d6c2905 commit 63b3e27

2 files changed

Lines changed: 72 additions & 28 deletions

File tree

modules/openapi-generator/src/main/resources/python-pydantic-v1/configuration.mustache

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,23 @@ class Configuration:
4747
string values to replace variables in templated server configuration.
4848
The validation of enums is performed for variables with defined enum
4949
values before.
50+
:param verify_ssl: bool - Set this to false to skip verifying SSL certificate
51+
when calling API from https server.
5052
:param ssl_ca_cert: str - the path to a file of concatenated CA certificates
5153
in PEM format.
54+
:param retries: Retry configuration (e.g. urllib3.util.retry.Retry).
55+
:param cert_file: The path to a client certificate file, for mTLS.
56+
:param key_file: The path to a client key file, for mTLS.
57+
:param assert_hostname: Set this to True/False to enable/disable SSL hostname verification.
58+
:param tls_server_name: SSL/TLS Server Name Indication (SNI). Set this to the SNI value expected by the server.
59+
:param connection_pool_maxsize: Connection pool max size. Defaults to 100 for asyncio, cpu_count * 5 for sync.
60+
:param proxy: Proxy URL.
61+
:param proxy_headers: Proxy headers.
62+
:param safe_chars_for_path_param: Safe characters for path parameter encoding.
63+
:param client_side_validation: Enable client-side validation. Default True.
64+
:param socket_options: Options to pass down to the underlying urllib3 socket.
65+
:param datetime_format: Datetime format string for serialization.
66+
:param date_format: Date format string for serialization.
5267

5368
{{#hasAuthMethods}}
5469
:Example:
@@ -146,7 +161,13 @@ conf = {{{packageName}}}.Configuration(
146161
{{/hasHttpSignatureMethods}}
147162
server_index=None, server_variables=None,
148163
server_operation_index=None, server_operation_variables=None,
149-
ssl_ca_cert=None,
164+
verify_ssl=True, ssl_ca_cert=None,
165+
retries=None, cert_file=None, key_file=None,
166+
assert_hostname=None, tls_server_name=None,
167+
connection_pool_maxsize=None, proxy=None, proxy_headers=None,
168+
safe_chars_for_path_param='', client_side_validation=True,
169+
socket_options=None,
170+
datetime_format="{{{datetimeFormat}}}", date_format="{{{dateFormat}}}",
150171
) -> None:
151172
"""Constructor
152173
"""
@@ -215,36 +236,36 @@ conf = {{{packageName}}}.Configuration(
215236
"""Debug switch
216237
"""
217238

218-
self.verify_ssl = True
239+
self.verify_ssl = verify_ssl
219240
"""SSL/TLS verification
220241
Set this to false to skip verifying SSL certificate when calling API
221242
from https server.
222243
"""
223244
self.ssl_ca_cert = ssl_ca_cert
224245
"""Set this to customize the certificate file to verify the peer.
225246
"""
226-
self.cert_file = None
247+
self.cert_file = cert_file
227248
"""client certificate file
228249
"""
229-
self.key_file = None
250+
self.key_file = key_file
230251
"""client key file
231252
"""
232-
self.assert_hostname = None
253+
self.assert_hostname = assert_hostname
233254
"""Set this to True/False to enable/disable SSL hostname verification.
234255
"""
235-
self.tls_server_name = None
256+
self.tls_server_name = tls_server_name
236257
"""SSL/TLS Server Name Indication (SNI)
237258
Set this to the SNI value expected by the server.
238259
"""
239260

240261
{{#asyncio}}
241-
self.connection_pool_maxsize = 100
262+
self.connection_pool_maxsize = connection_pool_maxsize if connection_pool_maxsize is not None else 100
242263
"""This value is passed to the aiohttp to limit simultaneous connections.
243264
Default values is 100, None means no-limit.
244265
"""
245266
{{/asyncio}}
246267
{{^asyncio}}
247-
self.connection_pool_maxsize = multiprocessing.cpu_count() * 5
268+
self.connection_pool_maxsize = connection_pool_maxsize if connection_pool_maxsize is not None else multiprocessing.cpu_count() * 5
248269
"""urllib3 connection pool's maximum number of connections saved
249270
per pool. urllib3 uses 1 connection as default value, but this is
250271
not the best value when you are making a lot of possibly parallel
@@ -253,30 +274,30 @@ conf = {{{packageName}}}.Configuration(
253274
"""
254275
{{/asyncio}}
255276

256-
self.proxy = None
277+
self.proxy = proxy
257278
"""Proxy URL
258279
"""
259-
self.proxy_headers = None
280+
self.proxy_headers = proxy_headers
260281
"""Proxy headers
261282
"""
262-
self.safe_chars_for_path_param = ''
283+
self.safe_chars_for_path_param = safe_chars_for_path_param
263284
"""Safe chars for path_param
264285
"""
265-
self.retries = None
286+
self.retries = retries
266287
"""Adding retries to override urllib3 default value 3
267288
"""
268289
# Enable client side validation
269-
self.client_side_validation = True
290+
self.client_side_validation = client_side_validation
270291

271-
self.socket_options = None
292+
self.socket_options = socket_options
272293
"""Options to pass down to the underlying urllib3 socket
273294
"""
274295

275-
self.datetime_format = "{{{datetimeFormat}}}"
296+
self.datetime_format = datetime_format
276297
"""datetime format
277298
"""
278299

279-
self.date_format = "{{{dateFormat}}}"
300+
self.date_format = date_format
280301
"""date format
281302
"""
282303

modules/openapi-generator/src/main/resources/python/configuration.mustache

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ class Configuration:
183183
string values to replace variables in templated server configuration.
184184
The validation of enums is performed for variables with defined enum
185185
values before.
186+
:param verify_ssl: bool - Set this to false to skip verifying SSL certificate
187+
when calling API from https server.
186188
:param ssl_ca_cert: str - the path to a file of concatenated CA certificates
187189
in PEM format.
188190
{{#async}}
@@ -195,6 +197,16 @@ class Configuration:
195197
in PEM (str) or DER (bytes) format.
196198
:param cert_file: the path to a client certificate file, for mTLS.
197199
:param key_file: the path to a client key file, for mTLS.
200+
:param assert_hostname: Set this to True/False to enable/disable SSL hostname verification.
201+
:param tls_server_name: SSL/TLS Server Name Indication (SNI). Set this to the SNI value expected by the server.
202+
:param connection_pool_maxsize: Connection pool max size. Defaults to 100 for async, cpu_count * 5 for sync.
203+
:param proxy: Proxy URL.
204+
:param proxy_headers: Proxy headers.
205+
:param safe_chars_for_path_param: Safe characters for path parameter encoding.
206+
:param client_side_validation: Enable client-side validation. Default True.
207+
:param socket_options: Options to pass down to the underlying urllib3 socket.
208+
:param datetime_format: Datetime format string for serialization.
209+
:param date_format: Date format string for serialization.
198210

199211
{{#hasAuthMethods}}
200212
:Example:
@@ -299,11 +311,22 @@ conf = {{{packageName}}}.Configuration(
299311
server_operation_index: Optional[Dict[int, int]]=None,
300312
server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
301313
ignore_operation_servers: bool=False,
314+
verify_ssl: bool=True,
302315
ssl_ca_cert: Optional[str]=None,
303316
retries: Optional[Union[int, Any]] = None,
304317
ca_cert_data: Optional[Union[str, bytes]] = None,
305318
cert_file: Optional[str]=None,
306319
key_file: Optional[str]=None,
320+
assert_hostname: Optional[bool]=None,
321+
tls_server_name: Optional[str]=None,
322+
connection_pool_maxsize: Optional[int]=None,
323+
proxy: Optional[str]=None,
324+
proxy_headers: Optional[Any]=None,
325+
safe_chars_for_path_param: str='',
326+
client_side_validation: bool=True,
327+
socket_options: Optional[Any]=None,
328+
datetime_format: str="{{{datetimeFormat}}}",
329+
date_format: str="{{{dateFormat}}}",
307330
*,
308331
debug: Optional[bool] = None,
309332
) -> None:
@@ -382,7 +405,7 @@ conf = {{{packageName}}}.Configuration(
382405
"""Debug switch
383406
"""
384407

385-
self.verify_ssl = True
408+
self.verify_ssl = verify_ssl
386409
"""SSL/TLS verification
387410
Set this to false to skip verifying SSL certificate when calling API
388411
from https server.
@@ -400,22 +423,22 @@ conf = {{{packageName}}}.Configuration(
400423
self.key_file = key_file
401424
"""client key file
402425
"""
403-
self.assert_hostname = None
426+
self.assert_hostname = assert_hostname
404427
"""Set this to True/False to enable/disable SSL hostname verification.
405428
"""
406-
self.tls_server_name = None
429+
self.tls_server_name = tls_server_name
407430
"""SSL/TLS Server Name Indication (SNI)
408431
Set this to the SNI value expected by the server.
409432
"""
410433

411434
{{#async}}
412-
self.connection_pool_maxsize = 100
435+
self.connection_pool_maxsize = connection_pool_maxsize if connection_pool_maxsize is not None else 100
413436
"""This value is passed to the aiohttp to limit simultaneous connections.
414437
Default values is 100, None means no-limit.
415438
"""
416439
{{/async}}
417440
{{^async}}
418-
self.connection_pool_maxsize = multiprocessing.cpu_count() * 5
441+
self.connection_pool_maxsize = connection_pool_maxsize if connection_pool_maxsize is not None else multiprocessing.cpu_count() * 5
419442
"""urllib3 connection pool's maximum number of connections saved
420443
per pool. urllib3 uses 1 connection as default value, but this is
421444
not the best value when you are making a lot of possibly parallel
@@ -424,30 +447,30 @@ conf = {{{packageName}}}.Configuration(
424447
"""
425448
{{/async}}
426449

427-
self.proxy: Optional[str] = None
450+
self.proxy = proxy
428451
"""Proxy URL
429452
"""
430-
self.proxy_headers = None
453+
self.proxy_headers = proxy_headers
431454
"""Proxy headers
432455
"""
433-
self.safe_chars_for_path_param = ''
456+
self.safe_chars_for_path_param = safe_chars_for_path_param
434457
"""Safe chars for path_param
435458
"""
436459
self.retries = retries
437460
"""Retry configuration
438461
"""
439462
# Enable client side validation
440-
self.client_side_validation = True
463+
self.client_side_validation = client_side_validation
441464

442-
self.socket_options = None
465+
self.socket_options = socket_options
443466
"""Options to pass down to the underlying urllib3 socket
444467
"""
445468

446-
self.datetime_format = "{{{datetimeFormat}}}"
469+
self.datetime_format = datetime_format
447470
"""datetime format
448471
"""
449472

450-
self.date_format = "{{{dateFormat}}}"
473+
self.date_format = date_format
451474
"""date format
452475
"""
453476

0 commit comments

Comments
 (0)