forked from loafle/openapi-generator-original
[Python] avoid unnecessary dictionary lookup in get_api_key method (#3592)
This commit is contained in:
committed by
William Cheng
parent
f5327b601e
commit
850c493c63
@@ -238,11 +238,13 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):
|
|||||||
:param identifier: The identifier of apiKey.
|
:param identifier: The identifier of apiKey.
|
||||||
:return: The token for api key authentication.
|
:return: The token for api key authentication.
|
||||||
"""
|
"""
|
||||||
if (self.api_key.get(identifier) and
|
key = self.api_key.get(identifier)
|
||||||
self.api_key_prefix.get(identifier)):
|
if key:
|
||||||
return self.api_key_prefix[identifier] + ' ' + self.api_key[identifier] # noqa: E501
|
prefix = self.api_key_prefix.get(identifier)
|
||||||
elif self.api_key.get(identifier):
|
if prefix:
|
||||||
return self.api_key[identifier]
|
return "%s %s" % (prefix, key)
|
||||||
|
else:
|
||||||
|
return key
|
||||||
|
|
||||||
def get_basic_auth_token(self):
|
def get_basic_auth_token(self):
|
||||||
"""Gets HTTP basic authentication header (string).
|
"""Gets HTTP basic authentication header (string).
|
||||||
|
|||||||
@@ -223,11 +223,13 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):
|
|||||||
:param identifier: The identifier of apiKey.
|
:param identifier: The identifier of apiKey.
|
||||||
:return: The token for api key authentication.
|
:return: The token for api key authentication.
|
||||||
"""
|
"""
|
||||||
if (self.api_key.get(identifier) and
|
key = self.api_key.get(identifier)
|
||||||
self.api_key_prefix.get(identifier)):
|
if key:
|
||||||
return self.api_key_prefix[identifier] + ' ' + self.api_key[identifier] # noqa: E501
|
prefix = self.api_key_prefix.get(identifier)
|
||||||
elif self.api_key.get(identifier):
|
if prefix:
|
||||||
return self.api_key[identifier]
|
return "%s %s" % (prefix, key)
|
||||||
|
else:
|
||||||
|
return key
|
||||||
|
|
||||||
def get_basic_auth_token(self):
|
def get_basic_auth_token(self):
|
||||||
"""Gets HTTP basic authentication header (string).
|
"""Gets HTTP basic authentication header (string).
|
||||||
|
|||||||
@@ -227,11 +227,13 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):
|
|||||||
:param identifier: The identifier of apiKey.
|
:param identifier: The identifier of apiKey.
|
||||||
:return: The token for api key authentication.
|
:return: The token for api key authentication.
|
||||||
"""
|
"""
|
||||||
if (self.api_key.get(identifier) and
|
key = self.api_key.get(identifier)
|
||||||
self.api_key_prefix.get(identifier)):
|
if key:
|
||||||
return self.api_key_prefix[identifier] + ' ' + self.api_key[identifier] # noqa: E501
|
prefix = self.api_key_prefix.get(identifier)
|
||||||
elif self.api_key.get(identifier):
|
if prefix:
|
||||||
return self.api_key[identifier]
|
return "%s %s" % (prefix, key)
|
||||||
|
else:
|
||||||
|
return key
|
||||||
|
|
||||||
def get_basic_auth_token(self):
|
def get_basic_auth_token(self):
|
||||||
"""Gets HTTP basic authentication header (string).
|
"""Gets HTTP basic authentication header (string).
|
||||||
|
|||||||
@@ -227,11 +227,13 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):
|
|||||||
:param identifier: The identifier of apiKey.
|
:param identifier: The identifier of apiKey.
|
||||||
:return: The token for api key authentication.
|
:return: The token for api key authentication.
|
||||||
"""
|
"""
|
||||||
if (self.api_key.get(identifier) and
|
key = self.api_key.get(identifier)
|
||||||
self.api_key_prefix.get(identifier)):
|
if key:
|
||||||
return self.api_key_prefix[identifier] + ' ' + self.api_key[identifier] # noqa: E501
|
prefix = self.api_key_prefix.get(identifier)
|
||||||
elif self.api_key.get(identifier):
|
if prefix:
|
||||||
return self.api_key[identifier]
|
return "%s %s" % (prefix, key)
|
||||||
|
else:
|
||||||
|
return key
|
||||||
|
|
||||||
def get_basic_auth_token(self):
|
def get_basic_auth_token(self):
|
||||||
"""Gets HTTP basic authentication header (string).
|
"""Gets HTTP basic authentication header (string).
|
||||||
|
|||||||
@@ -227,11 +227,13 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):
|
|||||||
:param identifier: The identifier of apiKey.
|
:param identifier: The identifier of apiKey.
|
||||||
:return: The token for api key authentication.
|
:return: The token for api key authentication.
|
||||||
"""
|
"""
|
||||||
if (self.api_key.get(identifier) and
|
key = self.api_key.get(identifier)
|
||||||
self.api_key_prefix.get(identifier)):
|
if key:
|
||||||
return self.api_key_prefix[identifier] + ' ' + self.api_key[identifier] # noqa: E501
|
prefix = self.api_key_prefix.get(identifier)
|
||||||
elif self.api_key.get(identifier):
|
if prefix:
|
||||||
return self.api_key[identifier]
|
return "%s %s" % (prefix, key)
|
||||||
|
else:
|
||||||
|
return key
|
||||||
|
|
||||||
def get_basic_auth_token(self):
|
def get_basic_auth_token(self):
|
||||||
"""Gets HTTP basic authentication header (string).
|
"""Gets HTTP basic authentication header (string).
|
||||||
|
|||||||
Reference in New Issue
Block a user