Skip to content

Commit 1aac402

Browse files
authored
Revert "Updated template so that generated code now renders docstrings and function parameters nicely in IDE. (#10331)" (#10338)
This reverts commit c8343b2.
1 parent c8343b2 commit 1aac402

File tree

1 file changed

+98
-101
lines changed

1 file changed

+98
-101
lines changed

.generator/templates/api.mustache

Lines changed: 98 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ from {{packageName}}.model_utils import ( # noqa: F401
1818
{{/imports}}
1919

2020

21+
{{#operations}}
2122
class {{classname}}(object):
2223
"""NOTE: This class is auto generated by OpenAPI Generator
2324
Ref: https://openapi-generator.tech
@@ -29,9 +30,102 @@ class {{classname}}(object):
2930
if api_client is None:
3031
api_client = ApiClient()
3132
self.api_client = api_client
32-
{{#operations}}
3333
{{#operation}}
34-
self.{{operationId}}_endpoint = _Endpoint(
34+
35+
def __{{operationId}}(
36+
self,
37+
{{#requiredParams}}
38+
{{^defaultValue}}
39+
{{paramName}},
40+
{{/defaultValue}}
41+
{{/requiredParams}}
42+
{{#requiredParams}}
43+
{{#defaultValue}}
44+
{{paramName}}={{{defaultValue}}},
45+
{{/defaultValue}}
46+
{{/requiredParams}}
47+
**kwargs
48+
):
49+
"""{{{summary}}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501
50+
51+
{{#notes}}
52+
{{{.}}} # noqa: E501
53+
{{/notes}}
54+
This method makes a synchronous HTTP request by default. To make an
55+
asynchronous HTTP request, please pass async_req=True
56+
57+
>>> thread = api.{{operationId}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}}{{paramName}}={{{defaultValue}}}, {{/defaultValue}}{{/requiredParams}}async_req=True)
58+
>>> result = thread.get()
59+
60+
{{#requiredParams}}
61+
{{#-last}}
62+
Args:
63+
{{/-last}}
64+
{{/requiredParams}}
65+
{{#requiredParams}}
66+
{{^defaultValue}}
67+
{{paramName}} ({{dataType}}):{{#description}} {{{.}}}{{/description}}
68+
{{/defaultValue}}
69+
{{/requiredParams}}
70+
{{#requiredParams}}
71+
{{#defaultValue}}
72+
{{paramName}} ({{dataType}}):{{#description}} {{{.}}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}]
73+
{{/defaultValue}}
74+
{{/requiredParams}}
75+
76+
Keyword Args:{{#optionalParams}}
77+
{{paramName}} ({{dataType}}):{{#description}} {{{.}}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}}{{/optionalParams}}
78+
_return_http_data_only (bool): response data without head status
79+
code and headers. Default is True.
80+
_preload_content (bool): if False, the urllib3.HTTPResponse object
81+
will be returned without reading/decoding response data.
82+
Default is True.
83+
_request_timeout (int/float/tuple): timeout setting for this request. If
84+
one number provided, it will be total request timeout. It can also
85+
be a pair (tuple) of (connection, read) timeouts.
86+
Default is None.
87+
_check_input_type (bool): specifies if type checking
88+
should be done one the data sent to the server.
89+
Default is True.
90+
_check_return_type (bool): specifies if type checking
91+
should be done one the data received from the server.
92+
Default is True.
93+
_host_index (int/None): specifies the index of the server
94+
that we want to use.
95+
Default is read from the configuration.
96+
async_req (bool): execute request asynchronously
97+
98+
Returns:
99+
{{returnType}}{{^returnType}}None{{/returnType}}
100+
If the method is called asynchronously, returns the request
101+
thread.
102+
"""
103+
kwargs['async_req'] = kwargs.get(
104+
'async_req', False
105+
)
106+
kwargs['_return_http_data_only'] = kwargs.get(
107+
'_return_http_data_only', True
108+
)
109+
kwargs['_preload_content'] = kwargs.get(
110+
'_preload_content', True
111+
)
112+
kwargs['_request_timeout'] = kwargs.get(
113+
'_request_timeout', None
114+
)
115+
kwargs['_check_input_type'] = kwargs.get(
116+
'_check_input_type', True
117+
)
118+
kwargs['_check_return_type'] = kwargs.get(
119+
'_check_return_type', True
120+
)
121+
kwargs['_host_index'] = kwargs.get('_host_index')
122+
{{#requiredParams}}
123+
kwargs['{{paramName}}'] = \
124+
{{paramName}}
125+
{{/requiredParams}}
126+
return self.call_with_http_info(**kwargs)
127+
128+
self.{{operationId}} = _Endpoint(
35129
settings={
36130
'response_type': {{#returnType}}({{{.}}},){{/returnType}}{{^returnType}}None{{/returnType}},
37131
{{#authMethods}}
@@ -205,105 +299,8 @@ class {{classname}}(object):
205299
'content_type': [],
206300
{{/hasConsumes}}
207301
},
208-
api_client=api_client
209-
)
210-
{{/operation}}
211-
{{/operations}}
212-
213-
{{#operations}}
214-
{{#operation}}
215-
def {{operationId}}(
216-
self,
217-
{{#requiredParams}}
218-
{{^defaultValue}}
219-
{{paramName}},
220-
{{/defaultValue}}
221-
{{/requiredParams}}
222-
{{#requiredParams}}
223-
{{#defaultValue}}
224-
{{paramName}}={{{defaultValue}}},
225-
{{/defaultValue}}
226-
{{/requiredParams}}
227-
**kwargs
228-
):
229-
"""{{{summary}}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501
230-
231-
{{#notes}}
232-
{{{.}}} # noqa: E501
233-
{{/notes}}
234-
This method makes a synchronous HTTP request by default. To make an
235-
asynchronous HTTP request, please pass async_req=True
236-
237-
>>> thread = api.{{operationId}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}}{{paramName}}={{{defaultValue}}}, {{/defaultValue}}{{/requiredParams}}async_req=True)
238-
>>> result = thread.get()
239-
240-
{{#requiredParams}}
241-
{{#-last}}
242-
Args:
243-
{{/-last}}
244-
{{/requiredParams}}
245-
{{#requiredParams}}
246-
{{^defaultValue}}
247-
{{paramName}} ({{dataType}}):{{#description}} {{{.}}}{{/description}}
248-
{{/defaultValue}}
249-
{{/requiredParams}}
250-
{{#requiredParams}}
251-
{{#defaultValue}}
252-
{{paramName}} ({{dataType}}):{{#description}} {{{.}}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}]
253-
{{/defaultValue}}
254-
{{/requiredParams}}
255-
256-
Keyword Args:{{#optionalParams}}
257-
{{paramName}} ({{dataType}}):{{#description}} {{{.}}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}}{{/optionalParams}}
258-
_return_http_data_only (bool): response data without head status
259-
code and headers. Default is True.
260-
_preload_content (bool): if False, the urllib3.HTTPResponse object
261-
will be returned without reading/decoding response data.
262-
Default is True.
263-
_request_timeout (int/float/tuple): timeout setting for this request. If
264-
one number provided, it will be total request timeout. It can also
265-
be a pair (tuple) of (connection, read) timeouts.
266-
Default is None.
267-
_check_input_type (bool): specifies if type checking
268-
should be done one the data sent to the server.
269-
Default is True.
270-
_check_return_type (bool): specifies if type checking
271-
should be done one the data received from the server.
272-
Default is True.
273-
_host_index (int/None): specifies the index of the server
274-
that we want to use.
275-
Default is read from the configuration.
276-
async_req (bool): execute request asynchronously
277-
278-
Returns:
279-
{{returnType}}{{^returnType}}None{{/returnType}}
280-
If the method is called asynchronously, returns the request
281-
thread.
282-
"""
283-
kwargs['async_req'] = kwargs.get(
284-
'async_req', False
285-
)
286-
kwargs['_return_http_data_only'] = kwargs.get(
287-
'_return_http_data_only', True
288-
)
289-
kwargs['_preload_content'] = kwargs.get(
290-
'_preload_content', True
291-
)
292-
kwargs['_request_timeout'] = kwargs.get(
293-
'_request_timeout', None
294-
)
295-
kwargs['_check_input_type'] = kwargs.get(
296-
'_check_input_type', True
302+
api_client=api_client,
303+
callable=__{{operationId}}
297304
)
298-
kwargs['_check_return_type'] = kwargs.get(
299-
'_check_return_type', True
300-
)
301-
kwargs['_host_index'] = kwargs.get('_host_index')
302-
{{#requiredParams}}
303-
kwargs['{{paramName}}'] = \
304-
{{paramName}}
305-
{{/requiredParams}}
306-
return self.{{operationId}}_endpoint.call_with_http_info(**kwargs)
307-
308305
{{/operation}}
309306
{{/operations}}

0 commit comments

Comments
 (0)