Skip to content

Commit e3bc228

Browse files
saigiridhar21wing328
authored andcommitted
[python] Adding constructor parameters to Configuration and improving documentation (#3002)
* feat(python): Updated configuration's constructor and documentation * feat(python): Updated documentation * feat(python): Updated pet project * feat(python): Updated pet project * feat(python): Fixing host * feat(python): Updating pet project * feat(python): Fixing indentation
1 parent 6742302 commit e3bc228

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+3862
-559
lines changed

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

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,17 @@ class {{classname}}(object):
4646
{{/sortParamsByRequiredFlag}}
4747
>>> result = thread.get()
4848

49-
:param async_req bool
49+
:param async_req bool: execute request asynchronously
5050
{{#allParams}}
5151
:param {{dataType}} {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional){{/optional}}
5252
{{/allParams}}
53+
:param _preload_content: if False, the urllib3.HTTPResponse object will
54+
be returned without reading/decoding response
55+
data. Default is True.
56+
:param _request_timeout: timeout setting for this request. If one
57+
number provided, it will be total request
58+
timeout. It can also be a pair (tuple) of
59+
(connection, read) timeouts.
5360
:return: {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}}
5461
If the method is called asynchronously,
5562
returns the request thread.
@@ -73,11 +80,20 @@ class {{classname}}(object):
7380
{{/sortParamsByRequiredFlag}}
7481
>>> result = thread.get()
7582

76-
:param async_req bool
83+
:param async_req bool: execute request asynchronously
7784
{{#allParams}}
7885
:param {{dataType}} {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/optional}}
7986
{{/allParams}}
80-
:return: {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}}
87+
:param _return_http_data_only: response data without head status code
88+
and headers
89+
:param _preload_content: if False, the urllib3.HTTPResponse object will
90+
be returned without reading/decoding response
91+
data. Default is True.
92+
:param _request_timeout: timeout setting for this request. If one
93+
number provided, it will be total request
94+
timeout. It can also be a pair (tuple) of
95+
(connection, read) timeouts.
96+
:return: {{#returnType}}tuple({{returnType}}, status_code(int), headers(HTTPHeaderDict)){{/returnType}}{{^returnType}}None{{/returnType}}
8197
If the method is called asynchronously,
8298
returns the request thread.
8399
"""

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ Name | Type | Description | Notes
6161
- **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
6262
- **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
6363

64+
{{#responses.0}}
65+
### HTTP response details
66+
| Status code | Description | Response headers |
67+
|-------------|-------------|------------------|
68+
{{#responses}}
69+
**{{code}}** | {{message}} | {{#headers}} * {{baseName}} - {{description}} <br> {{/headers}}{{^headers.0}} - {{/headers.0}} |
70+
{{/responses}}
71+
{{/responses.0}}
72+
6473
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
6574

6675
{{/operation}}

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

Lines changed: 72 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ class TypeWithDefault(type):
1919
super(TypeWithDefault, cls).__init__(name, bases, dct)
2020
cls._default = None
2121

22-
def __call__(cls):
22+
def __call__(cls, **kwargs):
2323
if cls._default is None:
24-
cls._default = type.__call__(cls)
24+
cls._default = type.__call__(cls, **kwargs)
2525
return copy.copy(cls._default)
2626

2727
def set_default(cls, default):
@@ -33,77 +33,109 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):
3333

3434
Ref: https://openapi-generator.tech
3535
Do not edit the class manually.
36+
37+
:param host: Base url
38+
:param api_key: Dict to store API key(s)
39+
:param api_key_prefix: Dict to store API prefix (e.g. Bearer)
40+
:param username: Username for HTTP basic authentication
41+
:param password: Password for HTTP basic authentication
3642
"""
3743

38-
def __init__(self):
39-
"""Constructor"""
40-
# Default Base url
41-
self.host = "{{{basePath}}}"
42-
# Temp file folder for downloading files
44+
def __init__(self, host="{{{basePath}}}",
45+
api_key={}, api_key_prefix={},
46+
username="", password=""):
47+
"""Constructor
48+
"""
49+
self.host = host
50+
"""Default Base url
51+
"""
4352
self.temp_folder_path = None
44-
53+
"""Temp file folder for downloading files
54+
"""
4555
# Authentication Settings
46-
# dict to store API key(s)
47-
self.api_key = {}
48-
# dict to store API prefix (e.g. Bearer)
49-
self.api_key_prefix = {}
50-
# Username for HTTP basic authentication
51-
self.username = ""
52-
# Password for HTTP basic authentication
53-
self.password = ""
56+
self.api_key = api_key
57+
"""dict to store API key(s)
58+
"""
59+
self.api_key_prefix = api_key_prefix
60+
"""dict to store API prefix (e.g. Bearer)
61+
"""
62+
self.username = username
63+
"""Username for HTTP basic authentication
64+
"""
65+
self.password = password
66+
"""Password for HTTP basic authentication
67+
"""
5468
{{#hasOAuthMethods}}
55-
# access token for OAuth/Bearer
5669
self.access_token = ""
70+
"""access token for OAuth/Bearer
71+
"""
5772
{{/hasOAuthMethods}}
5873
{{^hasOAuthMethods}}
5974
{{#hasBearerMethods}}
60-
# access token for OAuth/Bearer
6175
self.access_token = ""
76+
"""access token for OAuth/Bearer
77+
"""
6278
{{/hasBearerMethods}}
6379
{{/hasOAuthMethods}}
64-
# Logging Settings
6580
self.logger = {}
81+
"""Logging Settings
82+
"""
6683
self.logger["package_logger"] = logging.getLogger("{{packageName}}")
6784
self.logger["urllib3_logger"] = logging.getLogger("urllib3")
68-
# Log format
6985
self.logger_format = '%(asctime)s %(levelname)s %(message)s'
70-
# Log stream handler
86+
"""Log format
87+
"""
7188
self.logger_stream_handler = None
72-
# Log file handler
89+
"""Log stream handler
90+
"""
7391
self.logger_file_handler = None
74-
# Debug file location
92+
"""Log file handler
93+
"""
7594
self.logger_file = None
76-
# Debug switch
95+
"""Debug file location
96+
"""
7797
self.debug = False
98+
"""Debug switch
99+
"""
78100

79-
# SSL/TLS verification
80-
# Set this to false to skip verifying SSL certificate when calling API
81-
# from https server.
82101
self.verify_ssl = True
83-
# Set this to customize the certificate file to verify the peer.
102+
"""SSL/TLS verification
103+
Set this to false to skip verifying SSL certificate when calling API
104+
from https server.
105+
"""
84106
self.ssl_ca_cert = None
85-
# client certificate file
107+
"""Set this to customize the certificate file to verify the peer.
108+
"""
86109
self.cert_file = None
87-
# client key file
110+
"""client certificate file
111+
"""
88112
self.key_file = None
89-
# Set this to True/False to enable/disable SSL hostname verification.
113+
"""client key file
114+
"""
90115
self.assert_hostname = None
116+
"""Set this to True/False to enable/disable SSL hostname verification.
117+
"""
91118

92-
# urllib3 connection pool's maximum number of connections saved
93-
# per pool. urllib3 uses 1 connection as default value, but this is
94-
# not the best value when you are making a lot of possibly parallel
95-
# requests to the same host, which is often the case here.
96-
# cpu_count * 5 is used as default value to increase performance.
97119
self.connection_pool_maxsize = multiprocessing.cpu_count() * 5
120+
"""urllib3 connection pool's maximum number of connections saved
121+
per pool. urllib3 uses 1 connection as default value, but this is
122+
not the best value when you are making a lot of possibly parallel
123+
requests to the same host, which is often the case here.
124+
cpu_count * 5 is used as default value to increase performance.
125+
"""
98126

99-
# Proxy URL
100127
self.proxy = None
101-
# Proxy headers
128+
"""Proxy URL
129+
"""
102130
self.proxy_headers = None
103-
# Safe chars for path_param
131+
"""Proxy headers
132+
"""
104133
self.safe_chars_for_path_param = ''
105-
# Adding retries to override urllib3 default value 3
134+
"""Safe chars for path_param
135+
"""
106136
self.retries = None
137+
"""Adding retries to override urllib3 default value 3
138+
"""
107139

108140
@property
109141
def logger_file(self):

samples/client/petstore/python-asyncio/docs/AnotherFakeApi.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,10 @@ No authorization required
5454
- **Content-Type**: application/json
5555
- **Accept**: application/json
5656

57+
### HTTP response details
58+
| Status code | Description | Response headers |
59+
|-------------|-------------|------------------|
60+
**200** | successful operation | - |
61+
5762
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
5863

samples/client/petstore/python-asyncio/docs/FakeApi.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ No authorization required
6565
- **Content-Type**: application/xml, application/xml; charset=utf-8, application/xml; charset=utf-16, text/xml, text/xml; charset=utf-8, text/xml; charset=utf-16
6666
- **Accept**: Not defined
6767

68+
### HTTP response details
69+
| Status code | Description | Response headers |
70+
|-------------|-------------|------------------|
71+
**200** | successful operation | - |
72+
6873
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
6974

7075
# **fake_outer_boolean_serialize**
@@ -113,6 +118,11 @@ No authorization required
113118
- **Content-Type**: Not defined
114119
- **Accept**: */*
115120

121+
### HTTP response details
122+
| Status code | Description | Response headers |
123+
|-------------|-------------|------------------|
124+
**200** | Output boolean | - |
125+
116126
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
117127

118128
# **fake_outer_composite_serialize**
@@ -161,6 +171,11 @@ No authorization required
161171
- **Content-Type**: Not defined
162172
- **Accept**: */*
163173

174+
### HTTP response details
175+
| Status code | Description | Response headers |
176+
|-------------|-------------|------------------|
177+
**200** | Output composite | - |
178+
164179
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
165180

166181
# **fake_outer_number_serialize**
@@ -209,6 +224,11 @@ No authorization required
209224
- **Content-Type**: Not defined
210225
- **Accept**: */*
211226

227+
### HTTP response details
228+
| Status code | Description | Response headers |
229+
|-------------|-------------|------------------|
230+
**200** | Output number | - |
231+
212232
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
213233

214234
# **fake_outer_string_serialize**
@@ -257,6 +277,11 @@ No authorization required
257277
- **Content-Type**: Not defined
258278
- **Accept**: */*
259279

280+
### HTTP response details
281+
| Status code | Description | Response headers |
282+
|-------------|-------------|------------------|
283+
**200** | Output string | - |
284+
260285
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
261286

262287
# **test_body_with_file_schema**
@@ -304,6 +329,11 @@ No authorization required
304329
- **Content-Type**: application/json
305330
- **Accept**: Not defined
306331

332+
### HTTP response details
333+
| Status code | Description | Response headers |
334+
|-------------|-------------|------------------|
335+
**200** | Success | - |
336+
307337
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
308338

309339
# **test_body_with_query_params**
@@ -351,6 +381,11 @@ No authorization required
351381
- **Content-Type**: application/json
352382
- **Accept**: Not defined
353383

384+
### HTTP response details
385+
| Status code | Description | Response headers |
386+
|-------------|-------------|------------------|
387+
**200** | Success | - |
388+
354389
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
355390

356391
# **test_client_model**
@@ -400,6 +435,11 @@ No authorization required
400435
- **Content-Type**: application/json
401436
- **Accept**: application/json
402437

438+
### HTTP response details
439+
| Status code | Description | Response headers |
440+
|-------------|-------------|------------------|
441+
**200** | successful operation | - |
442+
403443
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
404444

405445
# **test_endpoint_parameters**
@@ -479,6 +519,12 @@ void (empty response body)
479519
- **Content-Type**: application/x-www-form-urlencoded
480520
- **Accept**: Not defined
481521

522+
### HTTP response details
523+
| Status code | Description | Response headers |
524+
|-------------|-------------|------------------|
525+
**400** | Invalid username supplied | - |
526+
**404** | User not found | - |
527+
482528
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
483529

484530
# **test_enum_parameters**
@@ -541,6 +587,12 @@ No authorization required
541587
- **Content-Type**: application/x-www-form-urlencoded
542588
- **Accept**: Not defined
543589

590+
### HTTP response details
591+
| Status code | Description | Response headers |
592+
|-------------|-------------|------------------|
593+
**400** | Invalid request | - |
594+
**404** | Not found | - |
595+
544596
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
545597

546598
# **test_group_parameters**
@@ -599,6 +651,11 @@ No authorization required
599651
- **Content-Type**: Not defined
600652
- **Accept**: Not defined
601653

654+
### HTTP response details
655+
| Status code | Description | Response headers |
656+
|-------------|-------------|------------------|
657+
**400** | Someting wrong | - |
658+
602659
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
603660

604661
# **test_inline_additional_properties**
@@ -645,6 +702,11 @@ No authorization required
645702
- **Content-Type**: application/json
646703
- **Accept**: Not defined
647704

705+
### HTTP response details
706+
| Status code | Description | Response headers |
707+
|-------------|-------------|------------------|
708+
**200** | successful operation | - |
709+
648710
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
649711

650712
# **test_json_form_data**
@@ -693,5 +755,10 @@ No authorization required
693755
- **Content-Type**: application/x-www-form-urlencoded
694756
- **Accept**: Not defined
695757

758+
### HTTP response details
759+
| Status code | Description | Response headers |
760+
|-------------|-------------|------------------|
761+
**200** | successful operation | - |
762+
696763
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
697764

samples/client/petstore/python-asyncio/docs/FakeClassnameTags123Api.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,10 @@ Name | Type | Description | Notes
6060
- **Content-Type**: application/json
6161
- **Accept**: application/json
6262

63+
### HTTP response details
64+
| Status code | Description | Response headers |
65+
|-------------|-------------|------------------|
66+
**200** | successful operation | - |
67+
6368
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
6469

0 commit comments

Comments
 (0)