Skip to content

Commit 5519d0e

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 1b0e0dc commit 5519d0e

File tree

4 files changed

+30
-11
lines changed

4 files changed

+30
-11
lines changed

.generator/templates/api.mustache

+17-6
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}}

.generator/templates/model.mustache

+1-1
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}}

.generator/templates/python-experimental/api.mustache

+1
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

.generator/templates/python-experimental/api_client.mustache

+11-4
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:

0 commit comments

Comments
 (0)