Skip to content

Commit 6f6c8ed

Browse files
authored
[Python] Fixed docstrings in api.mustache (#6391)
* [Python] Fixed docstrings Fixes swagger-api/swagger-codegen#9630 * Updated generated files * Fixed python-experimental * Updated generated files * Fully fixed the format of the docstrings * Updated generated files * Updated generated files in openapi3
1 parent e708cdc commit 6f6c8ed

File tree

240 files changed

+3920
-1882
lines changed

Some content is hidden

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

240 files changed

+3920
-1882
lines changed

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

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class {{classname}}(object):
3838
{{/notes}}
3939
This method makes a synchronous HTTP request by default. To make an
4040
asynchronous HTTP request, please pass async_req=True
41+
4142
{{#sortParamsByRequiredFlag}}
4243
>>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async_req=True)
4344
{{/sortParamsByRequiredFlag}}
@@ -46,20 +47,24 @@ class {{classname}}(object):
4647
{{/sortParamsByRequiredFlag}}
4748
>>> result = thread.get()
4849

49-
:param async_req bool: execute request asynchronously
5050
{{#allParams}}
51-
:param {{dataType}} {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional){{/optional}}
51+
:param {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional){{/optional}}
52+
:type {{paramName}}: {{dataType}}{{#optional}}, optional{{/optional}}
5253
{{/allParams}}
54+
:param async_req: Whether to execute the request asynchronously.
55+
:type async_req: bool, optional
5356
:param _preload_content: if False, the urllib3.HTTPResponse object will
5457
be returned without reading/decoding response
5558
data. Default is True.
59+
:type _preload_content: bool, optional
5660
:param _request_timeout: timeout setting for this request. If one
5761
number provided, it will be total request
5862
timeout. It can also be a pair (tuple) of
5963
(connection, read) timeouts.
60-
:return: {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}}
64+
:return: Returns the result object.
6165
If the method is called asynchronously,
6266
returns the request thread.
67+
:rtype: {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}}
6368
"""
6469
kwargs['_return_http_data_only'] = True
6570
return self.{{operationId}}_with_http_info({{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs) # noqa: E501
@@ -72,6 +77,7 @@ class {{classname}}(object):
7277
{{/notes}}
7378
This method makes a synchronous HTTP request by default. To make an
7479
asynchronous HTTP request, please pass async_req=True
80+
7581
{{#sortParamsByRequiredFlag}}
7682
>>> thread = api.{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async_req=True)
7783
{{/sortParamsByRequiredFlag}}
@@ -80,22 +86,27 @@ class {{classname}}(object):
8086
{{/sortParamsByRequiredFlag}}
8187
>>> result = thread.get()
8288

83-
:param async_req bool: execute request asynchronously
8489
{{#allParams}}
85-
:param {{dataType}} {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/optional}}
90+
:param {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional){{/optional}}
91+
:type {{paramName}}: {{dataType}}{{#optional}}, optional{{/optional}}
8692
{{/allParams}}
93+
:param async_req: Whether to execute the request asynchronously.
94+
:type async_req: bool, optional
8795
:param _return_http_data_only: response data without head status code
8896
and headers
97+
:type _return_http_data_only: bool, optional
8998
:param _preload_content: if False, the urllib3.HTTPResponse object will
9099
be returned without reading/decoding response
91100
data. Default is True.
101+
:type _preload_content: bool, optional
92102
:param _request_timeout: timeout setting for this request. If one
93103
number provided, it will be total request
94104
timeout. It can also be a pair (tuple) of
95105
(connection, read) timeouts.
96-
:return: {{#returnType}}tuple({{returnType}}, status_code(int), headers(HTTPHeaderDict)){{/returnType}}{{^returnType}}None{{/returnType}}
106+
:return: Returns the result object.
97107
If the method is called asynchronously,
98108
returns the request thread.
109+
:rtype: {{#returnType}}tuple({{returnType}}, status_code(int), headers(HTTPHeaderDict)){{/returnType}}{{^returnType}}None{{/returnType}}
99110
"""
100111

101112
{{#servers.0}}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class {{classname}}(object):
107107
{{/description}}
108108

109109
:param {{name}}: The {{name}} of this {{classname}}. # noqa: E501
110-
:type: {{dataType}}
110+
:type {{name}}: {{dataType}}
111111
"""
112112
{{^isNullable}}
113113
{{#required}}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class {{classname}}(object):
6666
{{/notes}}
6767
This method makes a synchronous HTTP request by default. To make an
6868
asynchronous HTTP request, please pass async_req=True
69+
6970
>>> thread = api.{{operationId}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}}{{paramName}}={{{defaultValue}}}, {{/defaultValue}}{{/requiredParams}}async_req=True)
7071
>>> result = thread.get()
7172

modules/openapi-generator/src/main/resources/python/python-experimental/api_client.mustache

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ class ApiClient(object):
291291
({str: (bool, str, int, float, date, datetime, str, none_type)},)
292292
:param _check_type: boolean, whether to check the types of the data
293293
received from the server
294+
:type _check_type: bool
294295

295296
:return: deserialized object.
296297
"""
@@ -350,22 +351,28 @@ class ApiClient(object):
350351
(float, none_type)
351352
([int, none_type],)
352353
({str: (bool, str, int, float, date, datetime, str, none_type)},)
353-
:param files dict: key -> field name, value -> a list of open file
354+
:param files: key -> field name, value -> a list of open file
354355
objects for `multipart/form-data`.
356+
:type files: dict
355357
:param async_req bool: execute request asynchronously
358+
:type async_req: bool, optional
356359
:param _return_http_data_only: response data without head status code
357360
and headers
361+
:type _return_http_data_only: bool, optional
358362
:param collection_formats: dict of collection formats for path, query,
359363
header, and post parameters.
364+
:type collection_formats: dict, optional
360365
:param _preload_content: if False, the urllib3.HTTPResponse object will
361366
be returned without reading/decoding response
362367
data. Default is True.
368+
:type _preload_content: bool, optional
363369
:param _request_timeout: timeout setting for this request. If one
364370
number provided, it will be total request
365371
timeout. It can also be a pair (tuple) of
366372
(connection, read) timeouts.
367373
:param _check_type: boolean describing if the data back from the server
368374
should have its type checked.
375+
:type _check_type: bool, optional
369376
:return:
370377
If async_req parameter is True,
371378
the request will be called asynchronously.
@@ -559,9 +566,9 @@ class ApiClient(object):
559566
:param headers: Header parameters dict to be updated.
560567
:param querys: Query parameters tuple list to be updated.
561568
:param auth_settings: Authentication setting identifiers list.
562-
:resource_path: A string representation of the HTTP request resource path.
563-
:method: A string representation of the HTTP request method.
564-
:body: A object representing the body of the HTTP request.
569+
:param resource_path: A string representation of the HTTP request resource path.
570+
:param method: A string representation of the HTTP request method.
571+
:param body: A object representing the body of the HTTP request.
565572
The object type is the return value of sanitize_for_serialization().
566573
"""
567574
if not auth_settings:

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

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,26 @@ def call_123_test_special_tags(self, body, **kwargs): # noqa: E501
4242
To test special tags and operation ID starting with number # noqa: E501
4343
This method makes a synchronous HTTP request by default. To make an
4444
asynchronous HTTP request, please pass async_req=True
45+
4546
>>> thread = api.call_123_test_special_tags(body, async_req=True)
4647
>>> result = thread.get()
4748
48-
:param async_req bool: execute request asynchronously
49-
:param Client body: client model (required)
49+
:param body: client model (required)
50+
:type body: Client
51+
:param async_req: Whether to execute the request asynchronously.
52+
:type async_req: bool, optional
5053
:param _preload_content: if False, the urllib3.HTTPResponse object will
5154
be returned without reading/decoding response
5255
data. Default is True.
56+
:type _preload_content: bool, optional
5357
:param _request_timeout: timeout setting for this request. If one
5458
number provided, it will be total request
5559
timeout. It can also be a pair (tuple) of
5660
(connection, read) timeouts.
57-
:return: Client
61+
:return: Returns the result object.
5862
If the method is called asynchronously,
5963
returns the request thread.
64+
:rtype: Client
6065
"""
6166
kwargs['_return_http_data_only'] = True
6267
return self.call_123_test_special_tags_with_http_info(body, **kwargs) # noqa: E501
@@ -67,23 +72,29 @@ def call_123_test_special_tags_with_http_info(self, body, **kwargs): # noqa: E5
6772
To test special tags and operation ID starting with number # noqa: E501
6873
This method makes a synchronous HTTP request by default. To make an
6974
asynchronous HTTP request, please pass async_req=True
75+
7076
>>> thread = api.call_123_test_special_tags_with_http_info(body, async_req=True)
7177
>>> result = thread.get()
7278
73-
:param async_req bool: execute request asynchronously
74-
:param Client body: client model (required)
79+
:param body: client model (required)
80+
:type body: Client
81+
:param async_req: Whether to execute the request asynchronously.
82+
:type async_req: bool, optional
7583
:param _return_http_data_only: response data without head status code
7684
and headers
85+
:type _return_http_data_only: bool, optional
7786
:param _preload_content: if False, the urllib3.HTTPResponse object will
7887
be returned without reading/decoding response
7988
data. Default is True.
89+
:type _preload_content: bool, optional
8090
:param _request_timeout: timeout setting for this request. If one
8191
number provided, it will be total request
8292
timeout. It can also be a pair (tuple) of
8393
(connection, read) timeouts.
84-
:return: tuple(Client, status_code(int), headers(HTTPHeaderDict))
94+
:return: Returns the result object.
8595
If the method is called asynchronously,
8696
returns the request thread.
97+
:rtype: tuple(Client, status_code(int), headers(HTTPHeaderDict))
8798
"""
8899

89100
local_var_params = locals()

0 commit comments

Comments
 (0)