mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-11 16:22:48 +00:00
Updated template so that generated code now renders docstrings and function parameters nicely in IDE. (#10331)
Endpoints are still accessible in generated code, mainly to satisfy some test cases.
This commit is contained in:
@@ -18,7 +18,6 @@ from {{packageName}}.model_utils import ( # noqa: F401
|
||||
{{/imports}}
|
||||
|
||||
|
||||
{{#operations}}
|
||||
class {{classname}}(object):
|
||||
"""NOTE: This class is auto generated by OpenAPI Generator
|
||||
Ref: https://openapi-generator.tech
|
||||
@@ -30,102 +29,9 @@ class {{classname}}(object):
|
||||
if api_client is None:
|
||||
api_client = ApiClient()
|
||||
self.api_client = api_client
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
|
||||
def __{{operationId}}(
|
||||
self,
|
||||
{{#requiredParams}}
|
||||
{{^defaultValue}}
|
||||
{{paramName}},
|
||||
{{/defaultValue}}
|
||||
{{/requiredParams}}
|
||||
{{#requiredParams}}
|
||||
{{#defaultValue}}
|
||||
{{paramName}}={{{defaultValue}}},
|
||||
{{/defaultValue}}
|
||||
{{/requiredParams}}
|
||||
**kwargs
|
||||
):
|
||||
"""{{{summary}}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501
|
||||
|
||||
{{#notes}}
|
||||
{{{.}}} # noqa: E501
|
||||
{{/notes}}
|
||||
This method makes a synchronous HTTP request by default. To make an
|
||||
asynchronous HTTP request, please pass async_req=True
|
||||
|
||||
>>> thread = api.{{operationId}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}}{{paramName}}={{{defaultValue}}}, {{/defaultValue}}{{/requiredParams}}async_req=True)
|
||||
>>> result = thread.get()
|
||||
|
||||
{{#requiredParams}}
|
||||
{{#-last}}
|
||||
Args:
|
||||
{{/-last}}
|
||||
{{/requiredParams}}
|
||||
{{#requiredParams}}
|
||||
{{^defaultValue}}
|
||||
{{paramName}} ({{dataType}}):{{#description}} {{{.}}}{{/description}}
|
||||
{{/defaultValue}}
|
||||
{{/requiredParams}}
|
||||
{{#requiredParams}}
|
||||
{{#defaultValue}}
|
||||
{{paramName}} ({{dataType}}):{{#description}} {{{.}}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}]
|
||||
{{/defaultValue}}
|
||||
{{/requiredParams}}
|
||||
|
||||
Keyword Args:{{#optionalParams}}
|
||||
{{paramName}} ({{dataType}}):{{#description}} {{{.}}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}}{{/optionalParams}}
|
||||
_return_http_data_only (bool): response data without head status
|
||||
code and headers. Default is True.
|
||||
_preload_content (bool): if False, the urllib3.HTTPResponse object
|
||||
will be returned without reading/decoding response data.
|
||||
Default is True.
|
||||
_request_timeout (int/float/tuple): timeout setting for this request. If
|
||||
one number provided, it will be total request timeout. It can also
|
||||
be a pair (tuple) of (connection, read) timeouts.
|
||||
Default is None.
|
||||
_check_input_type (bool): specifies if type checking
|
||||
should be done one the data sent to the server.
|
||||
Default is True.
|
||||
_check_return_type (bool): specifies if type checking
|
||||
should be done one the data received from the server.
|
||||
Default is True.
|
||||
_host_index (int/None): specifies the index of the server
|
||||
that we want to use.
|
||||
Default is read from the configuration.
|
||||
async_req (bool): execute request asynchronously
|
||||
|
||||
Returns:
|
||||
{{returnType}}{{^returnType}}None{{/returnType}}
|
||||
If the method is called asynchronously, returns the request
|
||||
thread.
|
||||
"""
|
||||
kwargs['async_req'] = kwargs.get(
|
||||
'async_req', False
|
||||
)
|
||||
kwargs['_return_http_data_only'] = kwargs.get(
|
||||
'_return_http_data_only', True
|
||||
)
|
||||
kwargs['_preload_content'] = kwargs.get(
|
||||
'_preload_content', True
|
||||
)
|
||||
kwargs['_request_timeout'] = kwargs.get(
|
||||
'_request_timeout', None
|
||||
)
|
||||
kwargs['_check_input_type'] = kwargs.get(
|
||||
'_check_input_type', True
|
||||
)
|
||||
kwargs['_check_return_type'] = kwargs.get(
|
||||
'_check_return_type', True
|
||||
)
|
||||
kwargs['_host_index'] = kwargs.get('_host_index')
|
||||
{{#requiredParams}}
|
||||
kwargs['{{paramName}}'] = \
|
||||
{{paramName}}
|
||||
{{/requiredParams}}
|
||||
return self.call_with_http_info(**kwargs)
|
||||
|
||||
self.{{operationId}} = _Endpoint(
|
||||
self.{{operationId}}_endpoint = _Endpoint(
|
||||
settings={
|
||||
'response_type': {{#returnType}}({{{.}}},){{/returnType}}{{^returnType}}None{{/returnType}},
|
||||
{{#authMethods}}
|
||||
@@ -299,8 +205,105 @@ class {{classname}}(object):
|
||||
'content_type': [],
|
||||
{{/hasConsumes}}
|
||||
},
|
||||
api_client=api_client,
|
||||
callable=__{{operationId}}
|
||||
api_client=api_client
|
||||
)
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
def {{operationId}}(
|
||||
self,
|
||||
{{#requiredParams}}
|
||||
{{^defaultValue}}
|
||||
{{paramName}},
|
||||
{{/defaultValue}}
|
||||
{{/requiredParams}}
|
||||
{{#requiredParams}}
|
||||
{{#defaultValue}}
|
||||
{{paramName}}={{{defaultValue}}},
|
||||
{{/defaultValue}}
|
||||
{{/requiredParams}}
|
||||
**kwargs
|
||||
):
|
||||
"""{{{summary}}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501
|
||||
|
||||
{{#notes}}
|
||||
{{{.}}} # noqa: E501
|
||||
{{/notes}}
|
||||
This method makes a synchronous HTTP request by default. To make an
|
||||
asynchronous HTTP request, please pass async_req=True
|
||||
|
||||
>>> thread = api.{{operationId}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}}{{paramName}}={{{defaultValue}}}, {{/defaultValue}}{{/requiredParams}}async_req=True)
|
||||
>>> result = thread.get()
|
||||
|
||||
{{#requiredParams}}
|
||||
{{#-last}}
|
||||
Args:
|
||||
{{/-last}}
|
||||
{{/requiredParams}}
|
||||
{{#requiredParams}}
|
||||
{{^defaultValue}}
|
||||
{{paramName}} ({{dataType}}):{{#description}} {{{.}}}{{/description}}
|
||||
{{/defaultValue}}
|
||||
{{/requiredParams}}
|
||||
{{#requiredParams}}
|
||||
{{#defaultValue}}
|
||||
{{paramName}} ({{dataType}}):{{#description}} {{{.}}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}]
|
||||
{{/defaultValue}}
|
||||
{{/requiredParams}}
|
||||
|
||||
Keyword Args:{{#optionalParams}}
|
||||
{{paramName}} ({{dataType}}):{{#description}} {{{.}}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}}{{/optionalParams}}
|
||||
_return_http_data_only (bool): response data without head status
|
||||
code and headers. Default is True.
|
||||
_preload_content (bool): if False, the urllib3.HTTPResponse object
|
||||
will be returned without reading/decoding response data.
|
||||
Default is True.
|
||||
_request_timeout (int/float/tuple): timeout setting for this request. If
|
||||
one number provided, it will be total request timeout. It can also
|
||||
be a pair (tuple) of (connection, read) timeouts.
|
||||
Default is None.
|
||||
_check_input_type (bool): specifies if type checking
|
||||
should be done one the data sent to the server.
|
||||
Default is True.
|
||||
_check_return_type (bool): specifies if type checking
|
||||
should be done one the data received from the server.
|
||||
Default is True.
|
||||
_host_index (int/None): specifies the index of the server
|
||||
that we want to use.
|
||||
Default is read from the configuration.
|
||||
async_req (bool): execute request asynchronously
|
||||
|
||||
Returns:
|
||||
{{returnType}}{{^returnType}}None{{/returnType}}
|
||||
If the method is called asynchronously, returns the request
|
||||
thread.
|
||||
"""
|
||||
kwargs['async_req'] = kwargs.get(
|
||||
'async_req', False
|
||||
)
|
||||
kwargs['_return_http_data_only'] = kwargs.get(
|
||||
'_return_http_data_only', True
|
||||
)
|
||||
kwargs['_preload_content'] = kwargs.get(
|
||||
'_preload_content', True
|
||||
)
|
||||
kwargs['_request_timeout'] = kwargs.get(
|
||||
'_request_timeout', None
|
||||
)
|
||||
kwargs['_check_input_type'] = kwargs.get(
|
||||
'_check_input_type', True
|
||||
)
|
||||
kwargs['_check_return_type'] = kwargs.get(
|
||||
'_check_return_type', True
|
||||
)
|
||||
kwargs['_host_index'] = kwargs.get('_host_index')
|
||||
{{#requiredParams}}
|
||||
kwargs['{{paramName}}'] = \
|
||||
{{paramName}}
|
||||
{{/requiredParams}}
|
||||
return self.{{operationId}}_endpoint.call_with_http_info(**kwargs)
|
||||
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
|
||||
Reference in New Issue
Block a user