mirror of
https://github.com/jlengrand/openapi-generator.git
synced 2026-05-18 15:54:42 +00:00
Format python client using pep8
This commit is contained in:
@@ -17,7 +17,8 @@ Copyright 2015 SmartBear Software
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
NOTE: This class is auto generated by the swagger code generator program.
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
@@ -30,6 +31,7 @@ from six import iteritems
|
||||
from ..configuration import Configuration
|
||||
from ..api_client import ApiClient
|
||||
|
||||
|
||||
{{#operations}}
|
||||
class {{classname}}(object):
|
||||
|
||||
@@ -41,37 +43,48 @@ class {{classname}}(object):
|
||||
if not config.api_client:
|
||||
config.api_client = ApiClient('{{basePath}}')
|
||||
self.api_client = config.api_client
|
||||
|
||||
{{#operation}}
|
||||
{{#operation}}
|
||||
|
||||
def {{nickname}}(self, {{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}**kwargs):
|
||||
"""
|
||||
{{{summary}}}
|
||||
{{{notes}}}
|
||||
|
||||
SDK also supports asynchronous requests in which you can define a `callback` function
|
||||
SDK also supports asynchronous requests
|
||||
in which you can define a `callback` function
|
||||
to be passed along and invoked when receiving response:
|
||||
>>> def callback_function(response):
|
||||
>>> pprint(response)
|
||||
>>>
|
||||
>>> thread = api.{{nickname}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}callback=callback_function)
|
||||
|
||||
:param callback function: The callback function for asynchronous request. (optional)
|
||||
{{#allParams}}:param {{dataType}} {{paramName}}: {{{description}}} {{#required}}(required){{/required}}{{#optional}}(optional){{/optional}}
|
||||
{{/allParams}}
|
||||
:param callback function: The callback function
|
||||
for asynchronous request. (optional)
|
||||
{{#allParams}}
|
||||
:param {{dataType}} {{paramName}}: {{{description}}} {{#required}}(required){{/required}}{{#optional}}(optional){{/optional}}
|
||||
{{/allParams}}
|
||||
:return: {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}}
|
||||
If the method is called asynchronously, returns the request thread.
|
||||
If the method is called asynchronously,
|
||||
returns the request thread.
|
||||
"""
|
||||
{{#allParams}}{{#required}}# verify the required parameter '{{paramName}}' is set
|
||||
{{#allParams}}
|
||||
{{#required}}
|
||||
# verify the required parameter '{{paramName}}' is set
|
||||
if {{paramName}} is None:
|
||||
raise ValueError("Missing the required parameter `{{paramName}}` when calling `{{nickname}}`")
|
||||
{{/required}}{{/allParams}}
|
||||
{{/required}}
|
||||
{{/allParams}}
|
||||
|
||||
all_params = [{{#allParams}}'{{paramName}}'{{#hasMore}}, {{/hasMore}}{{/allParams}}]
|
||||
all_params.append('callback')
|
||||
|
||||
params = locals()
|
||||
for key, val in iteritems(params['kwargs']):
|
||||
if key not in all_params:
|
||||
raise TypeError("Got an unexpected keyword argument '%s' to method {{nickname}}" % key)
|
||||
raise TypeError(
|
||||
"Got an unexpected keyword argument '%s'"
|
||||
" to method {{nickname}}" % key
|
||||
)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
@@ -79,45 +92,59 @@ class {{classname}}(object):
|
||||
method = '{{httpMethod}}'
|
||||
|
||||
path_params = {}
|
||||
{{#pathParams}}
|
||||
{{#pathParams}}
|
||||
if '{{paramName}}' in params:
|
||||
path_params['{{baseName}}'] = params['{{paramName}}']
|
||||
{{/pathParams}}
|
||||
path_params['{{baseName}}'] = params['{{paramName}}']
|
||||
{{/pathParams}}
|
||||
|
||||
query_params = {}
|
||||
{{#queryParams}}
|
||||
{{#queryParams}}
|
||||
if '{{paramName}}' in params:
|
||||
query_params['{{baseName}}'] = params['{{paramName}}']
|
||||
{{/queryParams}}
|
||||
{{/queryParams}}
|
||||
|
||||
header_params = {}
|
||||
{{#headerParams}}
|
||||
{{#headerParams}}
|
||||
if '{{paramName}}' in params:
|
||||
header_params['{{baseName}}'] = params['{{paramName}}']
|
||||
{{/headerParams}}
|
||||
{{/headerParams}}
|
||||
|
||||
form_params = {}
|
||||
files = {}
|
||||
{{#formParams}}
|
||||
{{#formParams}}
|
||||
if '{{paramName}}' in params:
|
||||
{{#notFile}}form_params['{{baseName}}'] = params['{{paramName}}']{{/notFile}}{{#isFile}}files['{{baseName}}'] = params['{{paramName}}']{{/isFile}}
|
||||
{{/formParams}}
|
||||
{{/formParams}}
|
||||
|
||||
body_params = None
|
||||
{{#bodyParam}}
|
||||
{{#bodyParam}}
|
||||
if '{{paramName}}' in params:
|
||||
body_params = params['{{paramName}}']
|
||||
{{/bodyParam}}
|
||||
{{/bodyParam}}
|
||||
|
||||
# HTTP header `Accept`
|
||||
header_params['Accept'] = self.api_client.select_header_accept([{{#produces}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/produces}}])
|
||||
header_params['Accept'] = self.api_client.\
|
||||
select_header_accept([{{#produces}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/produces}}])
|
||||
if not header_params['Accept']:
|
||||
del header_params['Accept']
|
||||
|
||||
# HTTP header `Content-Type`
|
||||
header_params['Content-Type'] = self.api_client.select_header_content_type([{{#consumes}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}])
|
||||
header_params['Content-Type'] = self.api_client.\
|
||||
select_header_content_type([{{#consumes}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}])
|
||||
|
||||
# Authentication setting
|
||||
auth_settings = [{{#authMethods}}'{{name}}'{{#hasMore}}, {{/hasMore}}{{/authMethods}}]
|
||||
|
||||
response = self.api_client.call_api(resource_path, method, path_params, query_params, header_params,
|
||||
body=body_params, post_params=form_params, files=files,
|
||||
response_type={{#returnType}}'{{returnType}}'{{/returnType}}{{^returnType}}None{{/returnType}}, auth_settings=auth_settings, callback=params.get('callback'))
|
||||
response = self.api_client.call_api(resource_path, method,
|
||||
path_params,
|
||||
query_params,
|
||||
header_params,
|
||||
body=body_params,
|
||||
post_params=form_params,
|
||||
files=files,
|
||||
response_type={{#returnType}}'{{returnType}}'{{/returnType}}{{^returnType}}None{{/returnType}},
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'))
|
||||
return response
|
||||
{{/operation}}
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
|
||||
Reference in New Issue
Block a user