forked from loafle/openapi-generator-original
Fixes Python client Configuration class so each instance uses its own dicts (#4485)
This commit is contained in:
parent
2b36383308
commit
a1a9e70fe4
@ -3,4 +3,5 @@
|
|||||||
|
|
||||||
./bin/python-asyncio-petstore.sh
|
./bin/python-asyncio-petstore.sh
|
||||||
./bin/python-petstore.sh
|
./bin/python-petstore.sh
|
||||||
|
./bin/python-experimental-petstore.sh
|
||||||
./bin/python-tornado-petstore.sh
|
./bin/python-tornado-petstore.sh
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import copy
|
|
||||||
import logging
|
import logging
|
||||||
{{^asyncio}}
|
{{^asyncio}}
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
@ -16,21 +15,7 @@ import six
|
|||||||
from six.moves import http_client as httplib
|
from six.moves import http_client as httplib
|
||||||
|
|
||||||
|
|
||||||
class TypeWithDefault(type):
|
class Configuration(object):
|
||||||
def __init__(cls, name, bases, dct):
|
|
||||||
super(TypeWithDefault, cls).__init__(name, bases, dct)
|
|
||||||
cls._default = None
|
|
||||||
|
|
||||||
def __call__(cls, **kwargs):
|
|
||||||
if cls._default is None:
|
|
||||||
cls._default = type.__call__(cls, **kwargs)
|
|
||||||
return copy.copy(cls._default)
|
|
||||||
|
|
||||||
def set_default(cls, default):
|
|
||||||
cls._default = copy.copy(default)
|
|
||||||
|
|
||||||
|
|
||||||
class Configuration(six.with_metaclass(TypeWithDefault, object)):
|
|
||||||
"""NOTE: This class is auto generated by OpenAPI Generator
|
"""NOTE: This class is auto generated by OpenAPI Generator
|
||||||
|
|
||||||
Ref: https://openapi-generator.tech
|
Ref: https://openapi-generator.tech
|
||||||
@ -44,7 +29,7 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, host="{{{basePath}}}",
|
def __init__(self, host="{{{basePath}}}",
|
||||||
api_key={}, api_key_prefix={},
|
api_key=None, api_key_prefix=None,
|
||||||
username="", password=""):
|
username="", password=""):
|
||||||
"""Constructor
|
"""Constructor
|
||||||
"""
|
"""
|
||||||
@ -55,9 +40,13 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):
|
|||||||
"""Temp file folder for downloading files
|
"""Temp file folder for downloading files
|
||||||
"""
|
"""
|
||||||
# Authentication Settings
|
# Authentication Settings
|
||||||
|
self.api_key = {}
|
||||||
|
if api_key:
|
||||||
self.api_key = api_key
|
self.api_key = api_key
|
||||||
"""dict to store API key(s)
|
"""dict to store API key(s)
|
||||||
"""
|
"""
|
||||||
|
self.api_key_prefix = {}
|
||||||
|
if api_key_prefix:
|
||||||
self.api_key_prefix = api_key_prefix
|
self.api_key_prefix = api_key_prefix
|
||||||
"""dict to store API prefix (e.g. Bearer)
|
"""dict to store API prefix (e.g. Bearer)
|
||||||
"""
|
"""
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import copy
|
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
import urllib3
|
import urllib3
|
||||||
@ -21,21 +20,7 @@ import six
|
|||||||
from six.moves import http_client as httplib
|
from six.moves import http_client as httplib
|
||||||
|
|
||||||
|
|
||||||
class TypeWithDefault(type):
|
class Configuration(object):
|
||||||
def __init__(cls, name, bases, dct):
|
|
||||||
super(TypeWithDefault, cls).__init__(name, bases, dct)
|
|
||||||
cls._default = None
|
|
||||||
|
|
||||||
def __call__(cls, **kwargs):
|
|
||||||
if cls._default is None:
|
|
||||||
cls._default = type.__call__(cls, **kwargs)
|
|
||||||
return copy.copy(cls._default)
|
|
||||||
|
|
||||||
def set_default(cls, default):
|
|
||||||
cls._default = copy.copy(default)
|
|
||||||
|
|
||||||
|
|
||||||
class Configuration(six.with_metaclass(TypeWithDefault, object)):
|
|
||||||
"""NOTE: This class is auto generated by OpenAPI Generator
|
"""NOTE: This class is auto generated by OpenAPI Generator
|
||||||
|
|
||||||
Ref: https://openapi-generator.tech
|
Ref: https://openapi-generator.tech
|
||||||
@ -49,7 +34,7 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, host="http://petstore.swagger.io:80/v2",
|
def __init__(self, host="http://petstore.swagger.io:80/v2",
|
||||||
api_key={}, api_key_prefix={},
|
api_key=None, api_key_prefix=None,
|
||||||
username="", password=""):
|
username="", password=""):
|
||||||
"""Constructor
|
"""Constructor
|
||||||
"""
|
"""
|
||||||
@ -60,9 +45,13 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):
|
|||||||
"""Temp file folder for downloading files
|
"""Temp file folder for downloading files
|
||||||
"""
|
"""
|
||||||
# Authentication Settings
|
# Authentication Settings
|
||||||
|
self.api_key = {}
|
||||||
|
if api_key:
|
||||||
self.api_key = api_key
|
self.api_key = api_key
|
||||||
"""dict to store API key(s)
|
"""dict to store API key(s)
|
||||||
"""
|
"""
|
||||||
|
self.api_key_prefix = {}
|
||||||
|
if api_key_prefix:
|
||||||
self.api_key_prefix = api_key_prefix
|
self.api_key_prefix = api_key_prefix
|
||||||
"""dict to store API prefix (e.g. Bearer)
|
"""dict to store API prefix (e.g. Bearer)
|
||||||
"""
|
"""
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import copy
|
|
||||||
import logging
|
import logging
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
import sys
|
import sys
|
||||||
@ -22,21 +21,7 @@ import six
|
|||||||
from six.moves import http_client as httplib
|
from six.moves import http_client as httplib
|
||||||
|
|
||||||
|
|
||||||
class TypeWithDefault(type):
|
class Configuration(object):
|
||||||
def __init__(cls, name, bases, dct):
|
|
||||||
super(TypeWithDefault, cls).__init__(name, bases, dct)
|
|
||||||
cls._default = None
|
|
||||||
|
|
||||||
def __call__(cls, **kwargs):
|
|
||||||
if cls._default is None:
|
|
||||||
cls._default = type.__call__(cls, **kwargs)
|
|
||||||
return copy.copy(cls._default)
|
|
||||||
|
|
||||||
def set_default(cls, default):
|
|
||||||
cls._default = copy.copy(default)
|
|
||||||
|
|
||||||
|
|
||||||
class Configuration(six.with_metaclass(TypeWithDefault, object)):
|
|
||||||
"""NOTE: This class is auto generated by OpenAPI Generator
|
"""NOTE: This class is auto generated by OpenAPI Generator
|
||||||
|
|
||||||
Ref: https://openapi-generator.tech
|
Ref: https://openapi-generator.tech
|
||||||
@ -50,7 +35,7 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, host="http://petstore.swagger.io:80/v2",
|
def __init__(self, host="http://petstore.swagger.io:80/v2",
|
||||||
api_key={}, api_key_prefix={},
|
api_key=None, api_key_prefix=None,
|
||||||
username="", password=""):
|
username="", password=""):
|
||||||
"""Constructor
|
"""Constructor
|
||||||
"""
|
"""
|
||||||
@ -61,9 +46,13 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):
|
|||||||
"""Temp file folder for downloading files
|
"""Temp file folder for downloading files
|
||||||
"""
|
"""
|
||||||
# Authentication Settings
|
# Authentication Settings
|
||||||
|
self.api_key = {}
|
||||||
|
if api_key:
|
||||||
self.api_key = api_key
|
self.api_key = api_key
|
||||||
"""dict to store API key(s)
|
"""dict to store API key(s)
|
||||||
"""
|
"""
|
||||||
|
self.api_key_prefix = {}
|
||||||
|
if api_key_prefix:
|
||||||
self.api_key_prefix = api_key_prefix
|
self.api_key_prefix = api_key_prefix
|
||||||
"""dict to store API prefix (e.g. Bearer)
|
"""dict to store API prefix (e.g. Bearer)
|
||||||
"""
|
"""
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import copy
|
|
||||||
import logging
|
import logging
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
import sys
|
import sys
|
||||||
@ -22,21 +21,7 @@ import six
|
|||||||
from six.moves import http_client as httplib
|
from six.moves import http_client as httplib
|
||||||
|
|
||||||
|
|
||||||
class TypeWithDefault(type):
|
class Configuration(object):
|
||||||
def __init__(cls, name, bases, dct):
|
|
||||||
super(TypeWithDefault, cls).__init__(name, bases, dct)
|
|
||||||
cls._default = None
|
|
||||||
|
|
||||||
def __call__(cls, **kwargs):
|
|
||||||
if cls._default is None:
|
|
||||||
cls._default = type.__call__(cls, **kwargs)
|
|
||||||
return copy.copy(cls._default)
|
|
||||||
|
|
||||||
def set_default(cls, default):
|
|
||||||
cls._default = copy.copy(default)
|
|
||||||
|
|
||||||
|
|
||||||
class Configuration(six.with_metaclass(TypeWithDefault, object)):
|
|
||||||
"""NOTE: This class is auto generated by OpenAPI Generator
|
"""NOTE: This class is auto generated by OpenAPI Generator
|
||||||
|
|
||||||
Ref: https://openapi-generator.tech
|
Ref: https://openapi-generator.tech
|
||||||
@ -50,7 +35,7 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, host="http://petstore.swagger.io:80/v2",
|
def __init__(self, host="http://petstore.swagger.io:80/v2",
|
||||||
api_key={}, api_key_prefix={},
|
api_key=None, api_key_prefix=None,
|
||||||
username="", password=""):
|
username="", password=""):
|
||||||
"""Constructor
|
"""Constructor
|
||||||
"""
|
"""
|
||||||
@ -61,9 +46,13 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):
|
|||||||
"""Temp file folder for downloading files
|
"""Temp file folder for downloading files
|
||||||
"""
|
"""
|
||||||
# Authentication Settings
|
# Authentication Settings
|
||||||
|
self.api_key = {}
|
||||||
|
if api_key:
|
||||||
self.api_key = api_key
|
self.api_key = api_key
|
||||||
"""dict to store API key(s)
|
"""dict to store API key(s)
|
||||||
"""
|
"""
|
||||||
|
self.api_key_prefix = {}
|
||||||
|
if api_key_prefix:
|
||||||
self.api_key_prefix = api_key_prefix
|
self.api_key_prefix = api_key_prefix
|
||||||
"""dict to store API prefix (e.g. Bearer)
|
"""dict to store API prefix (e.g. Bearer)
|
||||||
"""
|
"""
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import copy
|
|
||||||
import logging
|
import logging
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
import sys
|
import sys
|
||||||
@ -22,21 +21,7 @@ import six
|
|||||||
from six.moves import http_client as httplib
|
from six.moves import http_client as httplib
|
||||||
|
|
||||||
|
|
||||||
class TypeWithDefault(type):
|
class Configuration(object):
|
||||||
def __init__(cls, name, bases, dct):
|
|
||||||
super(TypeWithDefault, cls).__init__(name, bases, dct)
|
|
||||||
cls._default = None
|
|
||||||
|
|
||||||
def __call__(cls, **kwargs):
|
|
||||||
if cls._default is None:
|
|
||||||
cls._default = type.__call__(cls, **kwargs)
|
|
||||||
return copy.copy(cls._default)
|
|
||||||
|
|
||||||
def set_default(cls, default):
|
|
||||||
cls._default = copy.copy(default)
|
|
||||||
|
|
||||||
|
|
||||||
class Configuration(six.with_metaclass(TypeWithDefault, object)):
|
|
||||||
"""NOTE: This class is auto generated by OpenAPI Generator
|
"""NOTE: This class is auto generated by OpenAPI Generator
|
||||||
|
|
||||||
Ref: https://openapi-generator.tech
|
Ref: https://openapi-generator.tech
|
||||||
@ -50,7 +35,7 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, host="http://petstore.swagger.io:80/v2",
|
def __init__(self, host="http://petstore.swagger.io:80/v2",
|
||||||
api_key={}, api_key_prefix={},
|
api_key=None, api_key_prefix=None,
|
||||||
username="", password=""):
|
username="", password=""):
|
||||||
"""Constructor
|
"""Constructor
|
||||||
"""
|
"""
|
||||||
@ -61,9 +46,13 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):
|
|||||||
"""Temp file folder for downloading files
|
"""Temp file folder for downloading files
|
||||||
"""
|
"""
|
||||||
# Authentication Settings
|
# Authentication Settings
|
||||||
|
self.api_key = {}
|
||||||
|
if api_key:
|
||||||
self.api_key = api_key
|
self.api_key = api_key
|
||||||
"""dict to store API key(s)
|
"""dict to store API key(s)
|
||||||
"""
|
"""
|
||||||
|
self.api_key_prefix = {}
|
||||||
|
if api_key_prefix:
|
||||||
self.api_key_prefix = api_key_prefix
|
self.api_key_prefix = api_key_prefix
|
||||||
"""dict to store API prefix (e.g. Bearer)
|
"""dict to store API prefix (e.g. Bearer)
|
||||||
"""
|
"""
|
||||||
|
36
samples/client/petstore/python/tests/test_configuration.py
Normal file
36
samples/client/petstore/python/tests/test_configuration.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
# flake8: noqa
|
||||||
|
|
||||||
|
"""
|
||||||
|
Run the tests.
|
||||||
|
$ pip install nose (optional)
|
||||||
|
$ cd petstore_api-python
|
||||||
|
$ nosetests -v
|
||||||
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
import petstore_api
|
||||||
|
|
||||||
|
|
||||||
|
class TestConfiguration(unittest.TestCase):
|
||||||
|
"""Animal unit test stubs"""
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def testConfiguration(self):
|
||||||
|
# check that different instances use different dictionaries
|
||||||
|
c1 = petstore_api.Configuration()
|
||||||
|
c2 = petstore_api.Configuration()
|
||||||
|
assert id(c1.api_key) != id(c2.api_key)
|
||||||
|
assert id(c1.api_key_prefix) != id(c2.api_key_prefix)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import copy
|
|
||||||
import logging
|
import logging
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
import sys
|
import sys
|
||||||
@ -22,21 +21,7 @@ import six
|
|||||||
from six.moves import http_client as httplib
|
from six.moves import http_client as httplib
|
||||||
|
|
||||||
|
|
||||||
class TypeWithDefault(type):
|
class Configuration(object):
|
||||||
def __init__(cls, name, bases, dct):
|
|
||||||
super(TypeWithDefault, cls).__init__(name, bases, dct)
|
|
||||||
cls._default = None
|
|
||||||
|
|
||||||
def __call__(cls, **kwargs):
|
|
||||||
if cls._default is None:
|
|
||||||
cls._default = type.__call__(cls, **kwargs)
|
|
||||||
return copy.copy(cls._default)
|
|
||||||
|
|
||||||
def set_default(cls, default):
|
|
||||||
cls._default = copy.copy(default)
|
|
||||||
|
|
||||||
|
|
||||||
class Configuration(six.with_metaclass(TypeWithDefault, object)):
|
|
||||||
"""NOTE: This class is auto generated by OpenAPI Generator
|
"""NOTE: This class is auto generated by OpenAPI Generator
|
||||||
|
|
||||||
Ref: https://openapi-generator.tech
|
Ref: https://openapi-generator.tech
|
||||||
@ -50,7 +35,7 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, host="http://petstore.swagger.io:80/v2",
|
def __init__(self, host="http://petstore.swagger.io:80/v2",
|
||||||
api_key={}, api_key_prefix={},
|
api_key=None, api_key_prefix=None,
|
||||||
username="", password=""):
|
username="", password=""):
|
||||||
"""Constructor
|
"""Constructor
|
||||||
"""
|
"""
|
||||||
@ -61,9 +46,13 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):
|
|||||||
"""Temp file folder for downloading files
|
"""Temp file folder for downloading files
|
||||||
"""
|
"""
|
||||||
# Authentication Settings
|
# Authentication Settings
|
||||||
|
self.api_key = {}
|
||||||
|
if api_key:
|
||||||
self.api_key = api_key
|
self.api_key = api_key
|
||||||
"""dict to store API key(s)
|
"""dict to store API key(s)
|
||||||
"""
|
"""
|
||||||
|
self.api_key_prefix = {}
|
||||||
|
if api_key_prefix:
|
||||||
self.api_key_prefix = api_key_prefix
|
self.api_key_prefix = api_key_prefix
|
||||||
"""dict to store API prefix (e.g. Bearer)
|
"""dict to store API prefix (e.g. Bearer)
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user