forked from loafle/openapi-generator-original
[Python] add discard_unknown_keys parameter (#5362)
* add discard_unknown_key parameter * add discard_unknown_key parameter * add discard_unknown_key parameter * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * discard unknown keys in composed schema if configuration.discard_unknown_keys is set * run sample scripts for python * code reformatting * execute script in bin directory * improve unit tests for discarding properties
This commit is contained in:
parent
972ba18e6a
commit
e08e05a2c7
@ -31,6 +31,17 @@ class Configuration(object):
|
||||
The dict value is an API key prefix when generating the auth data.
|
||||
:param username: Username for HTTP basic authentication
|
||||
:param password: Password for HTTP basic authentication
|
||||
:param discard_unknown_keys: Boolean value indicating whether to discard
|
||||
unknown properties. A server may send a response that includes additional
|
||||
properties that are not known by the client in the following scenarios:
|
||||
1. The OpenAPI document is incomplete, i.e. it does not match the server
|
||||
implementation.
|
||||
2. The client was generated using an older version of the OpenAPI document
|
||||
and the server has been upgraded since then.
|
||||
If a schema in the OpenAPI document defines the additionalProperties attribute,
|
||||
then all undeclared properties received by the server are injected into the
|
||||
additional properties map. In that case, there are undeclared properties, and
|
||||
nothing to discard.
|
||||
{{#hasHttpSignatureMethods}}
|
||||
:param signing_info: Configuration parameters for the HTTP signature security scheme.
|
||||
Must be an instance of {{{packageName}}}.signing.HttpSigningConfiguration
|
||||
@ -120,6 +131,7 @@ class Configuration(object):
|
||||
def __init__(self, host="{{{basePath}}}",
|
||||
api_key=None, api_key_prefix=None,
|
||||
username=None, password=None,
|
||||
discard_unknown_keys=False,
|
||||
{{#hasHttpSignatureMethods}}
|
||||
signing_info=None,
|
||||
{{/hasHttpSignatureMethods}}
|
||||
@ -152,6 +164,7 @@ class Configuration(object):
|
||||
self.password = password
|
||||
"""Password for HTTP basic authentication
|
||||
"""
|
||||
self.discard_unknown_keys = discard_unknown_keys
|
||||
{{#hasHttpSignatureMethods}}
|
||||
if signing_info is not None:
|
||||
signing_info.host = host
|
||||
|
@ -11,12 +11,6 @@
|
||||
|
||||
{{> python-experimental/model_templates/method_init_shared }}
|
||||
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
constant_args = {
|
||||
'_check_type': _check_type,
|
||||
'_path_to_item': _path_to_item,
|
||||
@ -34,9 +28,16 @@
|
||||
self._composed_instances = composed_info[0]
|
||||
self._var_name_to_model_instances = composed_info[1]
|
||||
self._additional_properties_model_instances = composed_info[2]
|
||||
unused_args = composed_info[3]
|
||||
|
||||
{{#requiredVars}}
|
||||
self.{{name}} = {{name}}
|
||||
{{/requiredVars}}
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name in unused_args and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
not self._additional_properties_model_instances:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
@ -8,14 +8,14 @@
|
||||
|
||||
{{> python-experimental/model_templates/method_init_shared }}
|
||||
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
{{#requiredVars}}
|
||||
self.{{name}} = {{name}}
|
||||
{{/requiredVars}}
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
@ -20,4 +20,10 @@
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.{{#optionalVars}}
|
||||
{{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501{{/optionalVars}}
|
||||
"""
|
||||
"""
|
||||
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
@ -677,8 +677,9 @@ def attempt_convert_item(input_value, valid_classes, path_to_item,
|
||||
if not valid_classes_coercible or key_type:
|
||||
# we do not handle keytype errors, json will take care
|
||||
# of this for us
|
||||
raise get_type_error(input_value, path_to_item, valid_classes,
|
||||
key_type=key_type)
|
||||
if configuration is None or not configuration.discard_unknown_keys:
|
||||
raise get_type_error(input_value, path_to_item, valid_classes,
|
||||
key_type=key_type)
|
||||
for valid_class in valid_classes_coercible:
|
||||
try:
|
||||
if issubclass(valid_class, OpenApiModel):
|
||||
@ -1117,16 +1118,16 @@ def validate_get_composed_info(constant_args, model_args, self):
|
||||
|
||||
# set any remaining values
|
||||
unused_args = get_unused_args(self, composed_instances, model_args)
|
||||
if len(unused_args) > 0:
|
||||
if len(additional_properties_model_instances) == 0:
|
||||
raise ApiValueError(
|
||||
"Invalid input arguments input when making an instance of "
|
||||
"class %s. Not all inputs were used. The unused input data "
|
||||
"is %s" % (self.__class__.__name__, unused_args)
|
||||
)
|
||||
for var_name, var_value in six.iteritems(unused_args):
|
||||
for instance in additional_properties_model_instances:
|
||||
setattr(instance, var_name, var_value)
|
||||
if len(unused_args) > 0 and \
|
||||
len(additional_properties_model_instances) == 0 and \
|
||||
(self._configuration is None or
|
||||
not self._configuration.discard_unknown_keys):
|
||||
raise ApiValueError(
|
||||
"Invalid input arguments input when making an instance of "
|
||||
"class %s. Not all inputs were used. The unused input data "
|
||||
"is %s" % (self.__class__.__name__, unused_args)
|
||||
)
|
||||
|
||||
# no need to add additional_properties to var_name_to_model_instances here
|
||||
# because additional_properties_model_instances will direct us to that
|
||||
# instance when we use getattr or setattr
|
||||
@ -1135,5 +1136,6 @@ def validate_get_composed_info(constant_args, model_args, self):
|
||||
return [
|
||||
composed_instances,
|
||||
var_name_to_model_instances,
|
||||
additional_properties_model_instances
|
||||
additional_properties_model_instances,
|
||||
unused_args
|
||||
]
|
||||
|
@ -1362,10 +1362,15 @@ components:
|
||||
Cat:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/Animal'
|
||||
- $ref: '#/components/schemas/Address'
|
||||
- type: object
|
||||
properties:
|
||||
declawed:
|
||||
type: boolean
|
||||
Address:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: integer
|
||||
Animal:
|
||||
type: object
|
||||
discriminator:
|
||||
|
@ -36,6 +36,17 @@ class Configuration(object):
|
||||
The dict value is an API key prefix when generating the auth data.
|
||||
:param username: Username for HTTP basic authentication
|
||||
:param password: Password for HTTP basic authentication
|
||||
:param discard_unknown_keys: Boolean value indicating whether to discard
|
||||
unknown properties. A server may send a response that includes additional
|
||||
properties that are not known by the client in the following scenarios:
|
||||
1. The OpenAPI document is incomplete, i.e. it does not match the server
|
||||
implementation.
|
||||
2. The client was generated using an older version of the OpenAPI document
|
||||
and the server has been upgraded since then.
|
||||
If a schema in the OpenAPI document defines the additionalProperties attribute,
|
||||
then all undeclared properties received by the server are injected into the
|
||||
additional properties map. In that case, there are undeclared properties, and
|
||||
nothing to discard.
|
||||
|
||||
:Example:
|
||||
|
||||
@ -74,6 +85,7 @@ class Configuration(object):
|
||||
def __init__(self, host="http://petstore.swagger.io:80/v2",
|
||||
api_key=None, api_key_prefix=None,
|
||||
username=None, password=None,
|
||||
discard_unknown_keys=False,
|
||||
):
|
||||
"""Constructor
|
||||
"""
|
||||
@ -103,6 +115,7 @@ class Configuration(object):
|
||||
self.password = password
|
||||
"""Password for HTTP basic authentication
|
||||
"""
|
||||
self.discard_unknown_keys = discard_unknown_keys
|
||||
self.access_token = None
|
||||
"""access token for OAuth/Bearer
|
||||
"""
|
||||
|
@ -37,6 +37,17 @@ class Configuration(object):
|
||||
The dict value is an API key prefix when generating the auth data.
|
||||
:param username: Username for HTTP basic authentication
|
||||
:param password: Password for HTTP basic authentication
|
||||
:param discard_unknown_keys: Boolean value indicating whether to discard
|
||||
unknown properties. A server may send a response that includes additional
|
||||
properties that are not known by the client in the following scenarios:
|
||||
1. The OpenAPI document is incomplete, i.e. it does not match the server
|
||||
implementation.
|
||||
2. The client was generated using an older version of the OpenAPI document
|
||||
and the server has been upgraded since then.
|
||||
If a schema in the OpenAPI document defines the additionalProperties attribute,
|
||||
then all undeclared properties received by the server are injected into the
|
||||
additional properties map. In that case, there are undeclared properties, and
|
||||
nothing to discard.
|
||||
|
||||
:Example:
|
||||
|
||||
@ -75,6 +86,7 @@ class Configuration(object):
|
||||
def __init__(self, host="http://petstore.swagger.io:80/v2",
|
||||
api_key=None, api_key_prefix=None,
|
||||
username=None, password=None,
|
||||
discard_unknown_keys=False,
|
||||
):
|
||||
"""Constructor
|
||||
"""
|
||||
@ -104,6 +116,7 @@ class Configuration(object):
|
||||
self.password = password
|
||||
"""Password for HTTP basic authentication
|
||||
"""
|
||||
self.discard_unknown_keys = discard_unknown_keys
|
||||
self.access_token = None
|
||||
"""access token for OAuth/Bearer
|
||||
"""
|
||||
|
@ -931,8 +931,9 @@ def attempt_convert_item(input_value, valid_classes, path_to_item,
|
||||
if not valid_classes_coercible or key_type:
|
||||
# we do not handle keytype errors, json will take care
|
||||
# of this for us
|
||||
raise get_type_error(input_value, path_to_item, valid_classes,
|
||||
key_type=key_type)
|
||||
if configuration is None or not configuration.discard_unknown_keys:
|
||||
raise get_type_error(input_value, path_to_item, valid_classes,
|
||||
key_type=key_type)
|
||||
for valid_class in valid_classes_coercible:
|
||||
try:
|
||||
if issubclass(valid_class, OpenApiModel):
|
||||
@ -1371,16 +1372,16 @@ def validate_get_composed_info(constant_args, model_args, self):
|
||||
|
||||
# set any remaining values
|
||||
unused_args = get_unused_args(self, composed_instances, model_args)
|
||||
if len(unused_args) > 0:
|
||||
if len(additional_properties_model_instances) == 0:
|
||||
raise ApiValueError(
|
||||
"Invalid input arguments input when making an instance of "
|
||||
"class %s. Not all inputs were used. The unused input data "
|
||||
"is %s" % (self.__class__.__name__, unused_args)
|
||||
)
|
||||
for var_name, var_value in six.iteritems(unused_args):
|
||||
for instance in additional_properties_model_instances:
|
||||
setattr(instance, var_name, var_value)
|
||||
if len(unused_args) > 0 and \
|
||||
len(additional_properties_model_instances) == 0 and \
|
||||
(self._configuration is None or
|
||||
not self._configuration.discard_unknown_keys):
|
||||
raise ApiValueError(
|
||||
"Invalid input arguments input when making an instance of "
|
||||
"class %s. Not all inputs were used. The unused input data "
|
||||
"is %s" % (self.__class__.__name__, unused_args)
|
||||
)
|
||||
|
||||
# no need to add additional_properties to var_name_to_model_instances here
|
||||
# because additional_properties_model_instances will direct us to that
|
||||
# instance when we use getattr or setattr
|
||||
@ -1389,5 +1390,6 @@ def validate_get_composed_info(constant_args, model_args, self):
|
||||
return [
|
||||
composed_instances,
|
||||
var_name_to_model_instances,
|
||||
additional_properties_model_instances
|
||||
additional_properties_model_instances,
|
||||
unused_args
|
||||
]
|
||||
|
@ -124,4 +124,10 @@ class AdditionalPropertiesAnyType(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -124,4 +124,10 @@ class AdditionalPropertiesArray(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -124,4 +124,10 @@ class AdditionalPropertiesBoolean(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -154,4 +154,10 @@ class AdditionalPropertiesClass(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -124,4 +124,10 @@ class AdditionalPropertiesInteger(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -124,4 +124,10 @@ class AdditionalPropertiesNumber(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -124,4 +124,10 @@ class AdditionalPropertiesObject(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -124,4 +124,10 @@ class AdditionalPropertiesString(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -144,6 +144,12 @@ class Animal(ModelNormal):
|
||||
|
||||
self.class_name = class_name
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
||||
@classmethod
|
||||
|
@ -130,4 +130,10 @@ class ApiResponse(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -124,4 +124,10 @@ class ArrayOfArrayOfNumberOnly(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -124,4 +124,10 @@ class ArrayOfNumberOnly(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -135,4 +135,10 @@ class ArrayTest(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -139,4 +139,10 @@ class Capitalization(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -154,9 +154,16 @@ class Cat(ModelComposed):
|
||||
self._composed_instances = composed_info[0]
|
||||
self._var_name_to_model_instances = composed_info[1]
|
||||
self._additional_properties_model_instances = composed_info[2]
|
||||
unused_args = composed_info[3]
|
||||
|
||||
self.class_name = class_name
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name in unused_args and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
not self._additional_properties_model_instances:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
||||
@staticmethod
|
||||
|
@ -124,4 +124,10 @@ class CatAllOf(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -129,4 +129,10 @@ class Category(ModelNormal):
|
||||
|
||||
self.name = name
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -152,8 +152,15 @@ class Child(ModelComposed):
|
||||
self._composed_instances = composed_info[0]
|
||||
self._var_name_to_model_instances = composed_info[1]
|
||||
self._additional_properties_model_instances = composed_info[2]
|
||||
unused_args = composed_info[3]
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name in unused_args and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
not self._additional_properties_model_instances:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
||||
@staticmethod
|
||||
|
@ -124,4 +124,10 @@ class ChildAllOf(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -151,9 +151,16 @@ class ChildCat(ModelComposed):
|
||||
self._composed_instances = composed_info[0]
|
||||
self._var_name_to_model_instances = composed_info[1]
|
||||
self._additional_properties_model_instances = composed_info[2]
|
||||
unused_args = composed_info[3]
|
||||
|
||||
self.pet_type = pet_type
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name in unused_args and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
not self._additional_properties_model_instances:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
||||
@staticmethod
|
||||
|
@ -124,4 +124,10 @@ class ChildCatAllOf(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -151,9 +151,16 @@ class ChildDog(ModelComposed):
|
||||
self._composed_instances = composed_info[0]
|
||||
self._var_name_to_model_instances = composed_info[1]
|
||||
self._additional_properties_model_instances = composed_info[2]
|
||||
unused_args = composed_info[3]
|
||||
|
||||
self.pet_type = pet_type
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name in unused_args and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
not self._additional_properties_model_instances:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
||||
@staticmethod
|
||||
|
@ -124,4 +124,10 @@ class ChildDogAllOf(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -151,9 +151,16 @@ class ChildLizard(ModelComposed):
|
||||
self._composed_instances = composed_info[0]
|
||||
self._var_name_to_model_instances = composed_info[1]
|
||||
self._additional_properties_model_instances = composed_info[2]
|
||||
unused_args = composed_info[3]
|
||||
|
||||
self.pet_type = pet_type
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name in unused_args and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
not self._additional_properties_model_instances:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
||||
@staticmethod
|
||||
|
@ -124,4 +124,10 @@ class ChildLizardAllOf(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -124,4 +124,10 @@ class ClassModel(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -124,4 +124,10 @@ class Client(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -154,9 +154,16 @@ class Dog(ModelComposed):
|
||||
self._composed_instances = composed_info[0]
|
||||
self._var_name_to_model_instances = composed_info[1]
|
||||
self._additional_properties_model_instances = composed_info[2]
|
||||
unused_args = composed_info[3]
|
||||
|
||||
self.class_name = class_name
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name in unused_args and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
not self._additional_properties_model_instances:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
||||
@staticmethod
|
||||
|
@ -124,4 +124,10 @@ class DogAllOf(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -135,4 +135,10 @@ class EnumArrays(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -123,4 +123,10 @@ class EnumClass(ModelSimple):
|
||||
|
||||
self.value = value
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -161,4 +161,10 @@ class EnumTest(ModelNormal):
|
||||
|
||||
self.enum_string_required = enum_string_required
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -124,4 +124,10 @@ class File(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -132,4 +132,10 @@ class FileSchemaTestClass(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -200,4 +200,10 @@ class FormatTest(ModelNormal):
|
||||
self.date = date
|
||||
self.password = password
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -124,4 +124,10 @@ class Grandparent(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -126,4 +126,10 @@ class GrandparentAnimal(ModelNormal):
|
||||
|
||||
self.pet_type = pet_type
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -127,4 +127,10 @@ class HasOnlyReadOnly(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -124,4 +124,10 @@ class List(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -142,4 +142,10 @@ class MapTest(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -135,4 +135,10 @@ class MixedPropertiesAndAdditionalPropertiesClass(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -127,4 +127,10 @@ class Model200Response(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -124,4 +124,10 @@ class ModelReturn(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -135,4 +135,10 @@ class Name(ModelNormal):
|
||||
|
||||
self.name = name
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -124,4 +124,10 @@ class NumberOnly(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -144,4 +144,10 @@ class Order(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -135,4 +135,10 @@ class OuterComposite(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -123,4 +123,10 @@ class OuterEnum(ModelSimple):
|
||||
|
||||
self.value = value
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -122,4 +122,10 @@ class OuterNumber(ModelSimple):
|
||||
|
||||
self.value = value
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -149,8 +149,15 @@ class Parent(ModelComposed):
|
||||
self._composed_instances = composed_info[0]
|
||||
self._var_name_to_model_instances = composed_info[1]
|
||||
self._additional_properties_model_instances = composed_info[2]
|
||||
unused_args = composed_info[3]
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name in unused_args and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
not self._additional_properties_model_instances:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
||||
@staticmethod
|
||||
|
@ -124,4 +124,10 @@ class ParentAllOf(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -164,9 +164,16 @@ class ParentPet(ModelComposed):
|
||||
self._composed_instances = composed_info[0]
|
||||
self._var_name_to_model_instances = composed_info[1]
|
||||
self._additional_properties_model_instances = composed_info[2]
|
||||
unused_args = composed_info[3]
|
||||
|
||||
self.pet_type = pet_type
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name in unused_args and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
not self._additional_properties_model_instances:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
||||
@staticmethod
|
||||
|
@ -157,4 +157,10 @@ class Pet(ModelNormal):
|
||||
self.name = name
|
||||
self.photo_urls = photo_urls
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -129,4 +129,10 @@ class Player(ModelNormal):
|
||||
|
||||
self.name = name
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -127,4 +127,10 @@ class ReadOnlyFirst(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -124,4 +124,10 @@ class SpecialModelName(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -121,4 +121,10 @@ class StringBooleanMap(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -130,4 +130,10 @@ class Tag(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -148,4 +148,10 @@ class TypeHolderDefault(ModelNormal):
|
||||
self.bool_item = bool_item
|
||||
self.array_item = array_item
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -151,4 +151,10 @@ class TypeHolderExample(ModelNormal):
|
||||
self.bool_item = bool_item
|
||||
self.array_item = array_item
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -145,4 +145,10 @@ class User(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -208,4 +208,10 @@ class XmlItem(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -37,6 +37,17 @@ class Configuration(object):
|
||||
The dict value is an API key prefix when generating the auth data.
|
||||
:param username: Username for HTTP basic authentication
|
||||
:param password: Password for HTTP basic authentication
|
||||
:param discard_unknown_keys: Boolean value indicating whether to discard
|
||||
unknown properties. A server may send a response that includes additional
|
||||
properties that are not known by the client in the following scenarios:
|
||||
1. The OpenAPI document is incomplete, i.e. it does not match the server
|
||||
implementation.
|
||||
2. The client was generated using an older version of the OpenAPI document
|
||||
and the server has been upgraded since then.
|
||||
If a schema in the OpenAPI document defines the additionalProperties attribute,
|
||||
then all undeclared properties received by the server are injected into the
|
||||
additional properties map. In that case, there are undeclared properties, and
|
||||
nothing to discard.
|
||||
|
||||
:Example:
|
||||
|
||||
@ -75,6 +86,7 @@ class Configuration(object):
|
||||
def __init__(self, host="http://petstore.swagger.io:80/v2",
|
||||
api_key=None, api_key_prefix=None,
|
||||
username=None, password=None,
|
||||
discard_unknown_keys=False,
|
||||
):
|
||||
"""Constructor
|
||||
"""
|
||||
@ -104,6 +116,7 @@ class Configuration(object):
|
||||
self.password = password
|
||||
"""Password for HTTP basic authentication
|
||||
"""
|
||||
self.discard_unknown_keys = discard_unknown_keys
|
||||
self.access_token = None
|
||||
"""access token for OAuth/Bearer
|
||||
"""
|
||||
|
@ -37,6 +37,17 @@ class Configuration(object):
|
||||
The dict value is an API key prefix when generating the auth data.
|
||||
:param username: Username for HTTP basic authentication
|
||||
:param password: Password for HTTP basic authentication
|
||||
:param discard_unknown_keys: Boolean value indicating whether to discard
|
||||
unknown properties. A server may send a response that includes additional
|
||||
properties that are not known by the client in the following scenarios:
|
||||
1. The OpenAPI document is incomplete, i.e. it does not match the server
|
||||
implementation.
|
||||
2. The client was generated using an older version of the OpenAPI document
|
||||
and the server has been upgraded since then.
|
||||
If a schema in the OpenAPI document defines the additionalProperties attribute,
|
||||
then all undeclared properties received by the server are injected into the
|
||||
additional properties map. In that case, there are undeclared properties, and
|
||||
nothing to discard.
|
||||
|
||||
:Example:
|
||||
|
||||
@ -75,6 +86,7 @@ class Configuration(object):
|
||||
def __init__(self, host="http://petstore.swagger.io:80/v2",
|
||||
api_key=None, api_key_prefix=None,
|
||||
username=None, password=None,
|
||||
discard_unknown_keys=False,
|
||||
):
|
||||
"""Constructor
|
||||
"""
|
||||
@ -104,6 +116,7 @@ class Configuration(object):
|
||||
self.password = password
|
||||
"""Password for HTTP basic authentication
|
||||
"""
|
||||
self.discard_unknown_keys = discard_unknown_keys
|
||||
self.access_token = None
|
||||
"""access token for OAuth/Bearer
|
||||
"""
|
||||
|
@ -1456,7 +1456,12 @@ components:
|
||||
Cat:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/Animal'
|
||||
- $ref: '#/components/schemas/Address'
|
||||
- $ref: '#/components/schemas/Cat_allOf'
|
||||
Address:
|
||||
additionalProperties:
|
||||
type: integer
|
||||
type: object
|
||||
Animal:
|
||||
discriminator:
|
||||
propertyName: className
|
||||
|
@ -117,6 +117,7 @@ Class | Method | HTTP request | Description
|
||||
## Documentation For Models
|
||||
|
||||
- [additional_properties_class.AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
|
||||
- [address.Address](docs/Address.md)
|
||||
- [animal.Animal](docs/Animal.md)
|
||||
- [api_response.ApiResponse](docs/ApiResponse.md)
|
||||
- [array_of_array_of_number_only.ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
|
||||
|
@ -0,0 +1,10 @@
|
||||
# address.Address
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**any string name** | **int** | any string name can be used but the value must be the correct type | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -41,6 +41,7 @@ from petstore_api.exceptions import ApiException
|
||||
|
||||
# import models into sdk package
|
||||
from petstore_api.models.additional_properties_class import AdditionalPropertiesClass
|
||||
from petstore_api.models.address import Address
|
||||
from petstore_api.models.animal import Animal
|
||||
from petstore_api.models.api_response import ApiResponse
|
||||
from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly
|
||||
|
@ -37,6 +37,17 @@ class Configuration(object):
|
||||
The dict value is an API key prefix when generating the auth data.
|
||||
:param username: Username for HTTP basic authentication
|
||||
:param password: Password for HTTP basic authentication
|
||||
:param discard_unknown_keys: Boolean value indicating whether to discard
|
||||
unknown properties. A server may send a response that includes additional
|
||||
properties that are not known by the client in the following scenarios:
|
||||
1. The OpenAPI document is incomplete, i.e. it does not match the server
|
||||
implementation.
|
||||
2. The client was generated using an older version of the OpenAPI document
|
||||
and the server has been upgraded since then.
|
||||
If a schema in the OpenAPI document defines the additionalProperties attribute,
|
||||
then all undeclared properties received by the server are injected into the
|
||||
additional properties map. In that case, there are undeclared properties, and
|
||||
nothing to discard.
|
||||
:param signing_info: Configuration parameters for the HTTP signature security scheme.
|
||||
Must be an instance of petstore_api.signing.HttpSigningConfiguration
|
||||
|
||||
@ -116,6 +127,7 @@ class Configuration(object):
|
||||
def __init__(self, host="http://petstore.swagger.io:80/v2",
|
||||
api_key=None, api_key_prefix=None,
|
||||
username=None, password=None,
|
||||
discard_unknown_keys=False,
|
||||
signing_info=None,
|
||||
):
|
||||
"""Constructor
|
||||
@ -146,6 +158,7 @@ class Configuration(object):
|
||||
self.password = password
|
||||
"""Password for HTTP basic authentication
|
||||
"""
|
||||
self.discard_unknown_keys = discard_unknown_keys
|
||||
if signing_info is not None:
|
||||
signing_info.host = host
|
||||
self.signing_info = signing_info
|
||||
|
@ -931,8 +931,9 @@ def attempt_convert_item(input_value, valid_classes, path_to_item,
|
||||
if not valid_classes_coercible or key_type:
|
||||
# we do not handle keytype errors, json will take care
|
||||
# of this for us
|
||||
raise get_type_error(input_value, path_to_item, valid_classes,
|
||||
key_type=key_type)
|
||||
if configuration is None or not configuration.discard_unknown_keys:
|
||||
raise get_type_error(input_value, path_to_item, valid_classes,
|
||||
key_type=key_type)
|
||||
for valid_class in valid_classes_coercible:
|
||||
try:
|
||||
if issubclass(valid_class, OpenApiModel):
|
||||
@ -1371,16 +1372,16 @@ def validate_get_composed_info(constant_args, model_args, self):
|
||||
|
||||
# set any remaining values
|
||||
unused_args = get_unused_args(self, composed_instances, model_args)
|
||||
if len(unused_args) > 0:
|
||||
if len(additional_properties_model_instances) == 0:
|
||||
raise ApiValueError(
|
||||
"Invalid input arguments input when making an instance of "
|
||||
"class %s. Not all inputs were used. The unused input data "
|
||||
"is %s" % (self.__class__.__name__, unused_args)
|
||||
)
|
||||
for var_name, var_value in six.iteritems(unused_args):
|
||||
for instance in additional_properties_model_instances:
|
||||
setattr(instance, var_name, var_value)
|
||||
if len(unused_args) > 0 and \
|
||||
len(additional_properties_model_instances) == 0 and \
|
||||
(self._configuration is None or
|
||||
not self._configuration.discard_unknown_keys):
|
||||
raise ApiValueError(
|
||||
"Invalid input arguments input when making an instance of "
|
||||
"class %s. Not all inputs were used. The unused input data "
|
||||
"is %s" % (self.__class__.__name__, unused_args)
|
||||
)
|
||||
|
||||
# no need to add additional_properties to var_name_to_model_instances here
|
||||
# because additional_properties_model_instances will direct us to that
|
||||
# instance when we use getattr or setattr
|
||||
@ -1389,5 +1390,6 @@ def validate_get_composed_info(constant_args, model_args, self):
|
||||
return [
|
||||
composed_instances,
|
||||
var_name_to_model_instances,
|
||||
additional_properties_model_instances
|
||||
additional_properties_model_instances,
|
||||
unused_args
|
||||
]
|
||||
|
@ -127,4 +127,10 @@ class AdditionalPropertiesClass(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -0,0 +1,130 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by: https://openapi-generator.tech
|
||||
"""
|
||||
|
||||
|
||||
from __future__ import absolute_import
|
||||
import re # noqa: F401
|
||||
import sys # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelComposed,
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
int,
|
||||
none_type,
|
||||
str,
|
||||
validate_get_composed_info,
|
||||
)
|
||||
|
||||
|
||||
class Address(ModelNormal):
|
||||
"""NOTE: This class is auto generated by OpenAPI Generator.
|
||||
Ref: https://openapi-generator.tech
|
||||
|
||||
Do not edit the class manually.
|
||||
|
||||
Attributes:
|
||||
allowed_values (dict): The key is the tuple path to the attribute
|
||||
and the for var_name this is (var_name,). The value is a dict
|
||||
with a capitalized key describing the allowed value and an allowed
|
||||
value. These dicts store the allowed enum values.
|
||||
attribute_map (dict): The key is attribute name
|
||||
and the value is json key in definition.
|
||||
discriminator_value_class_map (dict): A dict to go from the discriminator
|
||||
variable value to the discriminator class name.
|
||||
validations (dict): The key is the tuple path to the attribute
|
||||
and the for var_name this is (var_name,). The value is a dict
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
additional_properties_type = (int,) # noqa: E501
|
||||
|
||||
@staticmethod
|
||||
def openapi_types():
|
||||
"""
|
||||
This must be a class method so a model may have properties that are
|
||||
of type self, this ensures that we don't create a cyclic import
|
||||
|
||||
Returns
|
||||
openapi_types (dict): The key is attribute name
|
||||
and the value is attribute type.
|
||||
"""
|
||||
return {
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def discriminator():
|
||||
return None
|
||||
|
||||
attribute_map = {
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def _composed_schemas():
|
||||
return None
|
||||
|
||||
required_properties = set([
|
||||
'_data_store',
|
||||
'_check_type',
|
||||
'_from_server',
|
||||
'_path_to_item',
|
||||
'_configuration',
|
||||
])
|
||||
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""address.Address - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
"""
|
||||
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
@ -144,6 +144,12 @@ class Animal(ModelNormal):
|
||||
|
||||
self.class_name = class_name
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
||||
@classmethod
|
||||
|
@ -130,4 +130,10 @@ class ApiResponse(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -124,4 +124,10 @@ class ArrayOfArrayOfNumberOnly(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -124,4 +124,10 @@ class ArrayOfNumberOnly(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -135,4 +135,10 @@ class ArrayTest(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -139,4 +139,10 @@ class Capitalization(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -28,6 +28,11 @@ from petstore_api.model_utils import ( # noqa: F401
|
||||
str,
|
||||
validate_get_composed_info,
|
||||
)
|
||||
try:
|
||||
from petstore_api.models import address
|
||||
except ImportError:
|
||||
address = sys.modules[
|
||||
'petstore_api.models.address']
|
||||
try:
|
||||
from petstore_api.models import animal
|
||||
except ImportError:
|
||||
@ -154,9 +159,16 @@ class Cat(ModelComposed):
|
||||
self._composed_instances = composed_info[0]
|
||||
self._var_name_to_model_instances = composed_info[1]
|
||||
self._additional_properties_model_instances = composed_info[2]
|
||||
unused_args = composed_info[3]
|
||||
|
||||
self.class_name = class_name
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name in unused_args and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
not self._additional_properties_model_instances:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
||||
@staticmethod
|
||||
@ -172,6 +184,7 @@ class Cat(ModelComposed):
|
||||
'anyOf': [
|
||||
],
|
||||
'allOf': [
|
||||
address.Address,
|
||||
animal.Animal,
|
||||
cat_all_of.CatAllOf,
|
||||
],
|
||||
|
@ -124,4 +124,10 @@ class CatAllOf(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -129,4 +129,10 @@ class Category(ModelNormal):
|
||||
|
||||
self.name = name
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -124,4 +124,10 @@ class ClassModel(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -124,4 +124,10 @@ class Client(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -154,9 +154,16 @@ class Dog(ModelComposed):
|
||||
self._composed_instances = composed_info[0]
|
||||
self._var_name_to_model_instances = composed_info[1]
|
||||
self._additional_properties_model_instances = composed_info[2]
|
||||
unused_args = composed_info[3]
|
||||
|
||||
self.class_name = class_name
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name in unused_args and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
not self._additional_properties_model_instances:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
||||
@staticmethod
|
||||
|
@ -124,4 +124,10 @@ class DogAllOf(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -135,4 +135,10 @@ class EnumArrays(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -123,4 +123,10 @@ class EnumClass(ModelSimple):
|
||||
|
||||
self.value = value
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -185,4 +185,10 @@ class EnumTest(ModelNormal):
|
||||
|
||||
self.enum_string_required = enum_string_required
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -124,4 +124,10 @@ class File(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -132,4 +132,10 @@ class FileSchemaTestClass(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
@ -124,4 +124,10 @@ class Foo(ModelNormal):
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
if var_name not in self.attribute_map and \
|
||||
self._configuration is not None and \
|
||||
self._configuration.discard_unknown_keys and \
|
||||
self.additional_properties_type is None:
|
||||
# discard variable.
|
||||
continue
|
||||
setattr(self, var_name, var_value)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user