forked from loafle/openapi-generator-original
rebuild python client
This commit is contained in:
parent
ddc5293e6a
commit
eb90b907e7
@ -27,6 +27,7 @@ import os
|
|||||||
# python 2 and python 3 compatibility library
|
# python 2 and python 3 compatibility library
|
||||||
from six import iteritems
|
from six import iteritems
|
||||||
|
|
||||||
|
from .. import configuration
|
||||||
from ..api_client import ApiClient
|
from ..api_client import ApiClient
|
||||||
|
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
@ -36,7 +37,10 @@ class {{classname}}(object):
|
|||||||
if api_client:
|
if api_client:
|
||||||
self.api_client = api_client
|
self.api_client = api_client
|
||||||
else:
|
else:
|
||||||
self.api_client = config.api_client
|
if not configuration.api_client:
|
||||||
|
configuration.api_client = ApiClient('{{basePath}}')
|
||||||
|
self.api_client = configuration.api_client
|
||||||
|
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
def {{nickname}}(self, {{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}**kwargs):
|
def {{nickname}}(self, {{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}**kwargs):
|
||||||
"""
|
"""
|
||||||
|
@ -67,7 +67,7 @@ class ApiClient(object):
|
|||||||
if self.cookie:
|
if self.cookie:
|
||||||
header_params['Cookie'] = self.cookie
|
header_params['Cookie'] = self.cookie
|
||||||
if header_params:
|
if header_params:
|
||||||
header_params = ApiClient.sanitize_for_serialization(header_params)
|
header_params = self.sanitize_for_serialization(header_params)
|
||||||
|
|
||||||
# path parameters
|
# path parameters
|
||||||
if path_params:
|
if path_params:
|
||||||
@ -301,6 +301,3 @@ class ApiClient(object):
|
|||||||
querys[auth_setting['key']] = auth_setting['value']
|
querys[auth_setting['key']] = auth_setting['value']
|
||||||
else:
|
else:
|
||||||
raise ValueError('Authentication token must be in `query` or `header`')
|
raise ValueError('Authentication token must be in `query` or `header`')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
import base64
|
import base64
|
||||||
import urllib3
|
import urllib3
|
||||||
|
|
||||||
|
|
||||||
def get_api_key_with_prefix(key):
|
def get_api_key_with_prefix(key):
|
||||||
global api_key
|
global api_key
|
||||||
global api_key_prefix
|
global api_key_prefix
|
||||||
@ -35,11 +35,12 @@ def auth_settings():
|
|||||||
{{/isBasic}}{{/authMethods}}
|
{{/isBasic}}{{/authMethods}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Default Base url
|
# Default Base url
|
||||||
host = "{{basePath}}"
|
host = "{{basePath}}"
|
||||||
|
|
||||||
|
# Default api client
|
||||||
|
api_client = None
|
||||||
|
|
||||||
# Authentication settings
|
# Authentication settings
|
||||||
|
|
||||||
api_key = {}
|
api_key = {}
|
||||||
|
@ -67,7 +67,7 @@ class ApiClient(object):
|
|||||||
if self.cookie:
|
if self.cookie:
|
||||||
header_params['Cookie'] = self.cookie
|
header_params['Cookie'] = self.cookie
|
||||||
if header_params:
|
if header_params:
|
||||||
header_params = ApiClient.sanitize_for_serialization(header_params)
|
header_params = self.sanitize_for_serialization(header_params)
|
||||||
|
|
||||||
# path parameters
|
# path parameters
|
||||||
if path_params:
|
if path_params:
|
||||||
@ -301,6 +301,3 @@ class ApiClient(object):
|
|||||||
querys[auth_setting['key']] = auth_setting['value']
|
querys[auth_setting['key']] = auth_setting['value']
|
||||||
else:
|
else:
|
||||||
raise ValueError('Authentication token must be in `query` or `header`')
|
raise ValueError('Authentication token must be in `query` or `header`')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ import os
|
|||||||
# python 2 and python 3 compatibility library
|
# python 2 and python 3 compatibility library
|
||||||
from six import iteritems
|
from six import iteritems
|
||||||
|
|
||||||
|
from .. import configuration
|
||||||
from ..api_client import ApiClient
|
from ..api_client import ApiClient
|
||||||
|
|
||||||
class PetApi(object):
|
class PetApi(object):
|
||||||
@ -35,7 +36,10 @@ class PetApi(object):
|
|||||||
if api_client:
|
if api_client:
|
||||||
self.api_client = api_client
|
self.api_client = api_client
|
||||||
else:
|
else:
|
||||||
self.api_client = config.api_client
|
if not configuration.api_client:
|
||||||
|
configuration.api_client = ApiClient('http://petstore.swagger.io/v2')
|
||||||
|
self.api_client = configuration.api_client
|
||||||
|
|
||||||
|
|
||||||
def update_pet(self, **kwargs):
|
def update_pet(self, **kwargs):
|
||||||
"""
|
"""
|
||||||
@ -496,6 +500,3 @@ class PetApi(object):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ import os
|
|||||||
# python 2 and python 3 compatibility library
|
# python 2 and python 3 compatibility library
|
||||||
from six import iteritems
|
from six import iteritems
|
||||||
|
|
||||||
|
from .. import configuration
|
||||||
from ..api_client import ApiClient
|
from ..api_client import ApiClient
|
||||||
|
|
||||||
class StoreApi(object):
|
class StoreApi(object):
|
||||||
@ -35,7 +36,10 @@ class StoreApi(object):
|
|||||||
if api_client:
|
if api_client:
|
||||||
self.api_client = api_client
|
self.api_client = api_client
|
||||||
else:
|
else:
|
||||||
self.api_client = config.api_client
|
if not configuration.api_client:
|
||||||
|
configuration.api_client = ApiClient('http://petstore.swagger.io/v2')
|
||||||
|
self.api_client = configuration.api_client
|
||||||
|
|
||||||
|
|
||||||
def get_inventory(self, **kwargs):
|
def get_inventory(self, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
@ -27,6 +27,7 @@ import os
|
|||||||
# python 2 and python 3 compatibility library
|
# python 2 and python 3 compatibility library
|
||||||
from six import iteritems
|
from six import iteritems
|
||||||
|
|
||||||
|
from .. import configuration
|
||||||
from ..api_client import ApiClient
|
from ..api_client import ApiClient
|
||||||
|
|
||||||
class UserApi(object):
|
class UserApi(object):
|
||||||
@ -35,7 +36,10 @@ class UserApi(object):
|
|||||||
if api_client:
|
if api_client:
|
||||||
self.api_client = api_client
|
self.api_client = api_client
|
||||||
else:
|
else:
|
||||||
self.api_client = config.api_client
|
if not configuration.api_client:
|
||||||
|
configuration.api_client = ApiClient('http://petstore.swagger.io/v2')
|
||||||
|
self.api_client = configuration.api_client
|
||||||
|
|
||||||
|
|
||||||
def create_user(self, **kwargs):
|
def create_user(self, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
import base64
|
import base64
|
||||||
import urllib3
|
import urllib3
|
||||||
|
|
||||||
|
|
||||||
def get_api_key_with_prefix(key):
|
def get_api_key_with_prefix(key):
|
||||||
global api_key
|
global api_key
|
||||||
global api_key_prefix
|
global api_key_prefix
|
||||||
@ -28,14 +28,17 @@ def auth_settings():
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Default Base url
|
# Default Base url
|
||||||
host = "http://petstore.swagger.io/v2"
|
host = "http://petstore.swagger.io/v2"
|
||||||
|
|
||||||
|
# Default api client
|
||||||
|
api_client = None
|
||||||
|
|
||||||
# Authentication settings
|
# Authentication settings
|
||||||
|
|
||||||
api_key = {}
|
api_key = {}
|
||||||
api_key_prefix = {}
|
api_key_prefix = {}
|
||||||
username = ''
|
username = ''
|
||||||
password = ''
|
password = ''
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,11 +61,11 @@ class PetApiTests(unittest.TestCase):
|
|||||||
# same default api client
|
# same default api client
|
||||||
self.assertEqual(pet_api.api_client, pet_api2.api_client)
|
self.assertEqual(pet_api.api_client, pet_api2.api_client)
|
||||||
# confirm using the default api client in the config module
|
# confirm using the default api client in the config module
|
||||||
self.assertEqual(pet_api.api_client, config.api_client)
|
self.assertEqual(pet_api.api_client, SwaggerPetstore.configuration.api_client)
|
||||||
# 2 different api clients are not the same
|
# 2 different api clients are not the same
|
||||||
self.assertNotEqual(api_client3, api_client4)
|
self.assertNotEqual(api_client3, api_client4)
|
||||||
# customized pet api not using the default api client
|
# customized pet api not using the default api client
|
||||||
self.assertNotEqual(pet_api3.api_client, config.api_client)
|
self.assertNotEqual(pet_api3.api_client, SwaggerPetstore.configuration.api_client)
|
||||||
# customized pet api not using the old pet api's api client
|
# customized pet api not using the old pet api's api client
|
||||||
self.assertNotEqual(pet_api3.api_client, pet_api2.api_client)
|
self.assertNotEqual(pet_api3.api_client, pet_api2.api_client)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user