forked from loafle/openapi-generator-original
Updated python client.
* Rename `ResponseError` exception to `ApiException` * Use `File.separatorChar` to build file path in PythonClientCodegen.java * Rename `config.py` module to `configuration.py` * Rename `swagger.py` module to `api_client.py`
This commit is contained in:
@@ -7,4 +7,4 @@ from __future__ import absolute_import
|
||||
{{#apiInfo}}{{#apis}}from .apis.{{classVarName}} import {{classname}}
|
||||
{{/apis}}{{/apiInfo}}
|
||||
# import ApiClient
|
||||
from .swagger import ApiClient
|
||||
from .api_client import ApiClient
|
||||
|
||||
@@ -29,7 +29,7 @@ from six import iteritems
|
||||
|
||||
from ..util import remove_none
|
||||
|
||||
from .. import config
|
||||
from ..api_client import ApiClient
|
||||
|
||||
{{#operations}}
|
||||
class {{classname}}(object):
|
||||
|
||||
@@ -28,7 +28,7 @@ except ImportError:
|
||||
# for python2
|
||||
from urllib import quote
|
||||
|
||||
from . import config
|
||||
from . import configuration
|
||||
|
||||
class ApiClient(object):
|
||||
"""
|
||||
@@ -38,7 +38,7 @@ class ApiClient(object):
|
||||
:param header_name: a header to pass when making calls to the API
|
||||
:param header_value: a header value to pass when making calls to the API
|
||||
"""
|
||||
def __init__(self, host=config.host, header_name=None, header_value=None):
|
||||
def __init__(self, host=configuration.host, header_name=None, header_value=None):
|
||||
self.default_headers = {}
|
||||
if header_name is not None:
|
||||
self.default_headers[header_name] = header_value
|
||||
@@ -292,7 +292,7 @@ class ApiClient(object):
|
||||
return
|
||||
|
||||
for auth in auth_settings:
|
||||
auth_setting = config.auth_settings().get(auth)
|
||||
auth_setting = configuration.auth_settings().get(auth)
|
||||
if auth_setting:
|
||||
if auth_setting['in'] == 'header':
|
||||
headers[auth_setting['key']] = auth_setting['value']
|
||||
@@ -120,7 +120,7 @@ class RESTClientObject(object):
|
||||
r = RESTResponse(r)
|
||||
|
||||
if r.status not in range(200, 206):
|
||||
raise ErrorResponse(r)
|
||||
raise ApiException(r)
|
||||
|
||||
return self.process_response(r)
|
||||
|
||||
@@ -157,7 +157,7 @@ class RESTClientObject(object):
|
||||
return self.request("PATCH", url, headers=headers, post_params=post_params, body=body)
|
||||
|
||||
|
||||
class ErrorResponse(Exception):
|
||||
class ApiException(Exception):
|
||||
"""
|
||||
Non-2xx HTTP response
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user