Skip to content

Commit 1f93f09

Browse files
authored
Merge pull request #8401 from tomplus/feat/python37
feat: support for python3.7 (async is a keyword)
2 parents 7b6be0e + 9f2d16d commit 1f93f09

26 files changed

+847
-661
lines changed

modules/swagger-codegen/src/main/resources/python/api.mustache

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ class {{classname}}(object):
3333
{{{notes}}} # noqa: E501
3434
{{/notes}}
3535
This method makes a synchronous HTTP request by default. To make an
36-
asynchronous HTTP request, please pass async=True
36+
asynchronous HTTP request, please pass async_req=True
3737
{{#sortParamsByRequiredFlag}}
38-
>>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async=True)
38+
>>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async_req=True)
3939
{{/sortParamsByRequiredFlag}}
4040
{{^sortParamsByRequiredFlag}}
41-
>>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/allParams}}async=True)
41+
>>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/allParams}}async_req=True)
4242
{{/sortParamsByRequiredFlag}}
4343
>>> result = thread.get()
4444

45-
:param async bool
45+
:param async_req bool
4646
{{#allParams}}
4747
:param {{dataType}} {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional){{/optional}}
4848
{{/allParams}}
@@ -51,7 +51,7 @@ class {{classname}}(object):
5151
returns the request thread.
5252
"""
5353
kwargs['_return_http_data_only'] = True
54-
if kwargs.get('async'):
54+
if kwargs.get('async_req'):
5555
return self.{{operationId}}_with_http_info({{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs) # noqa: E501
5656
else:
5757
(data) = self.{{operationId}}_with_http_info({{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs) # noqa: E501
@@ -64,16 +64,16 @@ class {{classname}}(object):
6464
{{{notes}}} # noqa: E501
6565
{{/notes}}
6666
This method makes a synchronous HTTP request by default. To make an
67-
asynchronous HTTP request, please pass async=True
67+
asynchronous HTTP request, please pass async_req=True
6868
{{#sortParamsByRequiredFlag}}
69-
>>> thread = api.{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async=True)
69+
>>> thread = api.{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async_req=True)
7070
{{/sortParamsByRequiredFlag}}
7171
{{^sortParamsByRequiredFlag}}
72-
>>> thread = api.{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/allParams}}async=True)
72+
>>> thread = api.{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/allParams}}async_req=True)
7373
{{/sortParamsByRequiredFlag}}
7474
>>> result = thread.get()
7575

76-
:param async bool
76+
:param async_req bool
7777
{{#allParams}}
7878
:param {{dataType}} {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/optional}}
7979
{{/allParams}}
@@ -83,7 +83,7 @@ class {{classname}}(object):
8383
"""
8484

8585
all_params = [{{#allParams}}'{{paramName}}'{{#hasMore}}, {{/hasMore}}{{/allParams}}] # noqa: E501
86-
all_params.append('async')
86+
all_params.append('async_req')
8787
all_params.append('_return_http_data_only')
8888
all_params.append('_preload_content')
8989
all_params.append('_request_timeout')
@@ -205,7 +205,7 @@ class {{classname}}(object):
205205
files=local_var_files,
206206
response_type={{#returnType}}'{{returnType}}'{{/returnType}}{{^returnType}}None{{/returnType}}, # noqa: E501
207207
auth_settings=auth_settings,
208-
async=params.get('async'),
208+
async_req=params.get('async_req'),
209209
_return_http_data_only=params.get('_return_http_data_only'),
210210
_preload_content=params.get('_preload_content', True),
211211
_request_timeout=params.get('_request_timeout'),

modules/swagger-codegen/src/main/resources/python/api_client.mustache

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,12 +280,12 @@ class ApiClient(object):
280280
def call_api(self, resource_path, method,
281281
path_params=None, query_params=None, header_params=None,
282282
body=None, post_params=None, files=None,
283-
response_type=None, auth_settings=None, async=None,
283+
response_type=None, auth_settings=None, async_req=None,
284284
_return_http_data_only=None, collection_formats=None,
285285
_preload_content=True, _request_timeout=None):
286286
"""Makes the HTTP request (synchronous) and returns deserialized data.
287287

288-
To make an async request, set the async parameter.
288+
To make an async request, set the async_req parameter.
289289

290290
:param resource_path: Path to method endpoint.
291291
:param method: Method to call.
@@ -300,7 +300,7 @@ class ApiClient(object):
300300
:param response: Response data type.
301301
:param files dict: key -> filename, value -> filepath,
302302
for `multipart/form-data`.
303-
:param async bool: execute request asynchronously
303+
:param async_req bool: execute request asynchronously
304304
:param _return_http_data_only: response data without head status code
305305
and headers
306306
:param collection_formats: dict of collection formats for path, query,
@@ -313,13 +313,13 @@ class ApiClient(object):
313313
timeout. It can also be a pair (tuple) of
314314
(connection, read) timeouts.
315315
:return:
316-
If async parameter is True,
316+
If async_req parameter is True,
317317
the request will be called asynchronously.
318318
The method will return the request thread.
319-
If parameter async is False or missing,
319+
If parameter async_req is False or missing,
320320
then the method will return the response directly.
321321
"""
322-
if not async:
322+
if not async_req:
323323
return self.__call_api(resource_path, method,
324324
path_params, query_params, header_params,
325325
body, post_params, files,

samples/client/petstore/python-asyncio/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ import time
5050
import petstore_api
5151
from petstore_api.rest import ApiException
5252
from pprint import pprint
53+
5354
# create an instance of the API class
54-
api_instance = petstore_api.AnotherFakeApi()
55+
api_instance = petstore_api.AnotherFakeApi(petstore_api.ApiClient(configuration))
5556
body = petstore_api.Client() # Client | client model
5657

5758
try:
@@ -74,6 +75,7 @@ Class | Method | HTTP request | Description
7475
*FakeApi* | [**fake_outer_composite_serialize**](docs/FakeApi.md#fake_outer_composite_serialize) | **POST** /fake/outer/composite |
7576
*FakeApi* | [**fake_outer_number_serialize**](docs/FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number |
7677
*FakeApi* | [**fake_outer_string_serialize**](docs/FakeApi.md#fake_outer_string_serialize) | **POST** /fake/outer/string |
78+
*FakeApi* | [**test_body_with_query_params**](docs/FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params |
7779
*FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model
7880
*FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
7981
*FakeApi* | [**test_enum_parameters**](docs/FakeApi.md#test_enum_parameters) | **GET** /fake | To test enum parameters

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
Name | Type | Description | Notes
55
------------ | ------------- | ------------- | -------------
66
**enum_string** | **str** | | [optional]
7+
**enum_string_required** | **str** | |
78
**enum_integer** | **int** | | [optional]
89
**enum_number** | **float** | | [optional]
910
**outer_enum** | [**OuterEnum**](OuterEnum.md) | | [optional]

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

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Method | HTTP request | Description
88
[**fake_outer_composite_serialize**](FakeApi.md#fake_outer_composite_serialize) | **POST** /fake/outer/composite |
99
[**fake_outer_number_serialize**](FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number |
1010
[**fake_outer_string_serialize**](FakeApi.md#fake_outer_string_serialize) | **POST** /fake/outer/string |
11+
[**test_body_with_query_params**](FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params |
1112
[**test_client_model**](FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model
1213
[**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
1314
[**test_enum_parameters**](FakeApi.md#test_enum_parameters) | **GET** /fake | To test enum parameters
@@ -203,6 +204,52 @@ No authorization required
203204

204205
[[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)
205206

207+
# **test_body_with_query_params**
208+
> test_body_with_query_params(body, query)
209+
210+
211+
212+
### Example
213+
```python
214+
from __future__ import print_function
215+
import time
216+
import petstore_api
217+
from petstore_api.rest import ApiException
218+
from pprint import pprint
219+
220+
# create an instance of the API class
221+
api_instance = petstore_api.FakeApi()
222+
body = petstore_api.User() # User |
223+
query = 'query_example' # str |
224+
225+
try:
226+
api_instance.test_body_with_query_params(body, query)
227+
except ApiException as e:
228+
print("Exception when calling FakeApi->test_body_with_query_params: %s\n" % e)
229+
```
230+
231+
### Parameters
232+
233+
Name | Type | Description | Notes
234+
------------- | ------------- | ------------- | -------------
235+
**body** | [**User**](User.md)| |
236+
**query** | **str**| |
237+
238+
### Return type
239+
240+
void (empty response body)
241+
242+
### Authorization
243+
244+
No authorization required
245+
246+
### HTTP request headers
247+
248+
- **Content-Type**: application/json
249+
- **Accept**: Not defined
250+
251+
[[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)
252+
206253
# **test_client_model**
207254
> Client test_client_model(body)
208255
@@ -252,7 +299,7 @@ No authorization required
252299
[[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)
253300

254301
# **test_endpoint_parameters**
255-
> test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer=integer, int32=int32, int64=int64, float=float, string=string, binary=binary, date=date, date_time=date_time, password=password, param_callback=param_callback)
302+
> test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer=integer, int32=int32, int64=int64, _float=_float, string=string, binary=binary, _date=_date, date_time=date_time, password=password, param_callback=param_callback)
256303
257304
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
258305

@@ -280,17 +327,17 @@ byte = 'B' # str | None
280327
integer = 56 # int | None (optional)
281328
int32 = 56 # int | None (optional)
282329
int64 = 789 # int | None (optional)
283-
float = 3.4 # float | None (optional)
330+
_float = 3.4 # float | None (optional)
284331
string = 'string_example' # str | None (optional)
285332
binary = 'B' # str | None (optional)
286-
date = '2013-10-20' # date | None (optional)
333+
_date = '2013-10-20' # date | None (optional)
287334
date_time = '2013-10-20T19:20:30+01:00' # datetime | None (optional)
288335
password = 'password_example' # str | None (optional)
289336
param_callback = 'param_callback_example' # str | None (optional)
290337

291338
try:
292339
# Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
293-
api_instance.test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer=integer, int32=int32, int64=int64, float=float, string=string, binary=binary, date=date, date_time=date_time, password=password, param_callback=param_callback)
340+
api_instance.test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer=integer, int32=int32, int64=int64, _float=_float, string=string, binary=binary, _date=_date, date_time=date_time, password=password, param_callback=param_callback)
294341
except ApiException as e:
295342
print("Exception when calling FakeApi->test_endpoint_parameters: %s\n" % e)
296343
```
@@ -306,10 +353,10 @@ Name | Type | Description | Notes
306353
**integer** | **int**| None | [optional]
307354
**int32** | **int**| None | [optional]
308355
**int64** | **int**| None | [optional]
309-
**float** | **float**| None | [optional]
356+
**_float** | **float**| None | [optional]
310357
**string** | **str**| None | [optional]
311358
**binary** | **str**| None | [optional]
312-
**date** | **date**| None | [optional]
359+
**_date** | **date**| None | [optional]
313360
**date_time** | **datetime**| None | [optional]
314361
**password** | **str**| None | [optional]
315362
**param_callback** | **str**| None | [optional]

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ Name | Type | Description | Notes
77
**int32** | **int** | | [optional]
88
**int64** | **int** | | [optional]
99
**number** | **float** | |
10-
**float** | **float** | | [optional]
10+
**_float** | **float** | | [optional]
1111
**double** | **float** | | [optional]
1212
**string** | **str** | | [optional]
1313
**byte** | **str** | |
1414
**binary** | **str** | | [optional]
15-
**date** | **date** | |
15+
**_date** | **date** | |
1616
**date_time** | **datetime** | | [optional]
1717
**uuid** | **str** | | [optional]
1818
**password** | **str** | |

samples/client/petstore/python-asyncio/petstore_api/api/another_fake_api.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,18 @@ def test_special_tags(self, body, **kwargs): # noqa: E501
3838
3939
To test special tags # noqa: E501
4040
This method makes a synchronous HTTP request by default. To make an
41-
asynchronous HTTP request, please pass async=True
42-
>>> thread = api.test_special_tags(body, async=True)
41+
asynchronous HTTP request, please pass async_req=True
42+
>>> thread = api.test_special_tags(body, async_req=True)
4343
>>> result = thread.get()
4444
45-
:param async bool
45+
:param async_req bool
4646
:param Client body: client model (required)
4747
:return: Client
4848
If the method is called asynchronously,
4949
returns the request thread.
5050
"""
5151
kwargs['_return_http_data_only'] = True
52-
if kwargs.get('async'):
52+
if kwargs.get('async_req'):
5353
return self.test_special_tags_with_http_info(body, **kwargs) # noqa: E501
5454
else:
5555
(data) = self.test_special_tags_with_http_info(body, **kwargs) # noqa: E501
@@ -60,19 +60,19 @@ def test_special_tags_with_http_info(self, body, **kwargs): # noqa: E501
6060
6161
To test special tags # noqa: E501
6262
This method makes a synchronous HTTP request by default. To make an
63-
asynchronous HTTP request, please pass async=True
64-
>>> thread = api.test_special_tags_with_http_info(body, async=True)
63+
asynchronous HTTP request, please pass async_req=True
64+
>>> thread = api.test_special_tags_with_http_info(body, async_req=True)
6565
>>> result = thread.get()
6666
67-
:param async bool
67+
:param async_req bool
6868
:param Client body: client model (required)
6969
:return: Client
7070
If the method is called asynchronously,
7171
returns the request thread.
7272
"""
7373

7474
all_params = ['body'] # noqa: E501
75-
all_params.append('async')
75+
all_params.append('async_req')
7676
all_params.append('_return_http_data_only')
7777
all_params.append('_preload_content')
7878
all_params.append('_request_timeout')
@@ -126,7 +126,7 @@ def test_special_tags_with_http_info(self, body, **kwargs): # noqa: E501
126126
files=local_var_files,
127127
response_type='Client', # noqa: E501
128128
auth_settings=auth_settings,
129-
async=params.get('async'),
129+
async_req=params.get('async_req'),
130130
_return_http_data_only=params.get('_return_http_data_only'),
131131
_preload_content=params.get('_preload_content', True),
132132
_request_timeout=params.get('_request_timeout'),

0 commit comments

Comments
 (0)