[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:
Sebastien Rosset 2020-02-21 14:51:24 -08:00 committed by GitHub
parent 972ba18e6a
commit e08e05a2c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
133 changed files with 1156 additions and 52 deletions

View File

@ -31,6 +31,17 @@ class Configuration(object):
The dict value is an API key prefix when generating the auth data. The dict value is an API key prefix when generating the auth data.
:param username: Username for HTTP basic authentication :param username: Username for HTTP basic authentication
:param password: Password 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}} {{#hasHttpSignatureMethods}}
:param signing_info: Configuration parameters for the HTTP signature security scheme. :param signing_info: Configuration parameters for the HTTP signature security scheme.
Must be an instance of {{{packageName}}}.signing.HttpSigningConfiguration Must be an instance of {{{packageName}}}.signing.HttpSigningConfiguration
@ -120,6 +131,7 @@ class Configuration(object):
def __init__(self, host="{{{basePath}}}", def __init__(self, host="{{{basePath}}}",
api_key=None, api_key_prefix=None, api_key=None, api_key_prefix=None,
username=None, password=None, username=None, password=None,
discard_unknown_keys=False,
{{#hasHttpSignatureMethods}} {{#hasHttpSignatureMethods}}
signing_info=None, signing_info=None,
{{/hasHttpSignatureMethods}} {{/hasHttpSignatureMethods}}
@ -152,6 +164,7 @@ class Configuration(object):
self.password = password self.password = password
"""Password for HTTP basic authentication """Password for HTTP basic authentication
""" """
self.discard_unknown_keys = discard_unknown_keys
{{#hasHttpSignatureMethods}} {{#hasHttpSignatureMethods}}
if signing_info is not None: if signing_info is not None:
signing_info.host = host signing_info.host = host

View File

@ -11,12 +11,6 @@
{{> python-experimental/model_templates/method_init_shared }} {{> 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 = { constant_args = {
'_check_type': _check_type, '_check_type': _check_type,
'_path_to_item': _path_to_item, '_path_to_item': _path_to_item,
@ -34,9 +28,16 @@
self._composed_instances = composed_info[0] self._composed_instances = composed_info[0]
self._var_name_to_model_instances = composed_info[1] self._var_name_to_model_instances = composed_info[1]
self._additional_properties_model_instances = composed_info[2] self._additional_properties_model_instances = composed_info[2]
unused_args = composed_info[3]
{{#requiredVars}} {{#requiredVars}}
self.{{name}} = {{name}} self.{{name}} = {{name}}
{{/requiredVars}} {{/requiredVars}}
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -8,14 +8,14 @@
{{> python-experimental/model_templates/method_init_shared }} {{> 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}} {{#requiredVars}}
self.{{name}} = {{name}} self.{{name}} = {{name}}
{{/requiredVars}} {{/requiredVars}}
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -21,3 +21,9 @@
If omitted no type conversion is done.{{#optionalVars}} 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}} {{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

View File

@ -677,6 +677,7 @@ def attempt_convert_item(input_value, valid_classes, path_to_item,
if not valid_classes_coercible or key_type: if not valid_classes_coercible or key_type:
# we do not handle keytype errors, json will take care # we do not handle keytype errors, json will take care
# of this for us # of this for us
if configuration is None or not configuration.discard_unknown_keys:
raise get_type_error(input_value, path_to_item, valid_classes, raise get_type_error(input_value, path_to_item, valid_classes,
key_type=key_type) key_type=key_type)
for valid_class in valid_classes_coercible: for valid_class in valid_classes_coercible:
@ -1117,16 +1118,16 @@ def validate_get_composed_info(constant_args, model_args, self):
# set any remaining values # set any remaining values
unused_args = get_unused_args(self, composed_instances, model_args) unused_args = get_unused_args(self, composed_instances, model_args)
if len(unused_args) > 0: if len(unused_args) > 0 and \
if len(additional_properties_model_instances) == 0: len(additional_properties_model_instances) == 0 and \
(self._configuration is None or
not self._configuration.discard_unknown_keys):
raise ApiValueError( raise ApiValueError(
"Invalid input arguments input when making an instance of " "Invalid input arguments input when making an instance of "
"class %s. Not all inputs were used. The unused input data " "class %s. Not all inputs were used. The unused input data "
"is %s" % (self.__class__.__name__, unused_args) "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)
# no need to add additional_properties to var_name_to_model_instances here # no need to add additional_properties to var_name_to_model_instances here
# because additional_properties_model_instances will direct us to that # because additional_properties_model_instances will direct us to that
# instance when we use getattr or setattr # instance when we use getattr or setattr
@ -1135,5 +1136,6 @@ def validate_get_composed_info(constant_args, model_args, self):
return [ return [
composed_instances, composed_instances,
var_name_to_model_instances, var_name_to_model_instances,
additional_properties_model_instances additional_properties_model_instances,
unused_args
] ]

View File

@ -1362,10 +1362,15 @@ components:
Cat: Cat:
allOf: allOf:
- $ref: '#/components/schemas/Animal' - $ref: '#/components/schemas/Animal'
- $ref: '#/components/schemas/Address'
- type: object - type: object
properties: properties:
declawed: declawed:
type: boolean type: boolean
Address:
type: object
additionalProperties:
type: integer
Animal: Animal:
type: object type: object
discriminator: discriminator:

View File

@ -36,6 +36,17 @@ class Configuration(object):
The dict value is an API key prefix when generating the auth data. The dict value is an API key prefix when generating the auth data.
:param username: Username for HTTP basic authentication :param username: Username for HTTP basic authentication
:param password: Password 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: :Example:
@ -74,6 +85,7 @@ class Configuration(object):
def __init__(self, host="http://petstore.swagger.io:80/v2", def __init__(self, host="http://petstore.swagger.io:80/v2",
api_key=None, api_key_prefix=None, api_key=None, api_key_prefix=None,
username=None, password=None, username=None, password=None,
discard_unknown_keys=False,
): ):
"""Constructor """Constructor
""" """
@ -103,6 +115,7 @@ class Configuration(object):
self.password = password self.password = password
"""Password for HTTP basic authentication """Password for HTTP basic authentication
""" """
self.discard_unknown_keys = discard_unknown_keys
self.access_token = None self.access_token = None
"""access token for OAuth/Bearer """access token for OAuth/Bearer
""" """

View File

@ -37,6 +37,17 @@ class Configuration(object):
The dict value is an API key prefix when generating the auth data. The dict value is an API key prefix when generating the auth data.
:param username: Username for HTTP basic authentication :param username: Username for HTTP basic authentication
:param password: Password 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: :Example:
@ -75,6 +86,7 @@ class Configuration(object):
def __init__(self, host="http://petstore.swagger.io:80/v2", def __init__(self, host="http://petstore.swagger.io:80/v2",
api_key=None, api_key_prefix=None, api_key=None, api_key_prefix=None,
username=None, password=None, username=None, password=None,
discard_unknown_keys=False,
): ):
"""Constructor """Constructor
""" """
@ -104,6 +116,7 @@ class Configuration(object):
self.password = password self.password = password
"""Password for HTTP basic authentication """Password for HTTP basic authentication
""" """
self.discard_unknown_keys = discard_unknown_keys
self.access_token = None self.access_token = None
"""access token for OAuth/Bearer """access token for OAuth/Bearer
""" """

View File

@ -931,6 +931,7 @@ def attempt_convert_item(input_value, valid_classes, path_to_item,
if not valid_classes_coercible or key_type: if not valid_classes_coercible or key_type:
# we do not handle keytype errors, json will take care # we do not handle keytype errors, json will take care
# of this for us # of this for us
if configuration is None or not configuration.discard_unknown_keys:
raise get_type_error(input_value, path_to_item, valid_classes, raise get_type_error(input_value, path_to_item, valid_classes,
key_type=key_type) key_type=key_type)
for valid_class in valid_classes_coercible: for valid_class in valid_classes_coercible:
@ -1371,16 +1372,16 @@ def validate_get_composed_info(constant_args, model_args, self):
# set any remaining values # set any remaining values
unused_args = get_unused_args(self, composed_instances, model_args) unused_args = get_unused_args(self, composed_instances, model_args)
if len(unused_args) > 0: if len(unused_args) > 0 and \
if len(additional_properties_model_instances) == 0: len(additional_properties_model_instances) == 0 and \
(self._configuration is None or
not self._configuration.discard_unknown_keys):
raise ApiValueError( raise ApiValueError(
"Invalid input arguments input when making an instance of " "Invalid input arguments input when making an instance of "
"class %s. Not all inputs were used. The unused input data " "class %s. Not all inputs were used. The unused input data "
"is %s" % (self.__class__.__name__, unused_args) "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)
# no need to add additional_properties to var_name_to_model_instances here # no need to add additional_properties to var_name_to_model_instances here
# because additional_properties_model_instances will direct us to that # because additional_properties_model_instances will direct us to that
# instance when we use getattr or setattr # instance when we use getattr or setattr
@ -1389,5 +1390,6 @@ def validate_get_composed_info(constant_args, model_args, self):
return [ return [
composed_instances, composed_instances,
var_name_to_model_instances, var_name_to_model_instances,
additional_properties_model_instances additional_properties_model_instances,
unused_args
] ]

View File

@ -124,4 +124,10 @@ class AdditionalPropertiesAnyType(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -124,4 +124,10 @@ class AdditionalPropertiesArray(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -124,4 +124,10 @@ class AdditionalPropertiesBoolean(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -154,4 +154,10 @@ class AdditionalPropertiesClass(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -124,4 +124,10 @@ class AdditionalPropertiesInteger(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -124,4 +124,10 @@ class AdditionalPropertiesNumber(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -124,4 +124,10 @@ class AdditionalPropertiesObject(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -124,4 +124,10 @@ class AdditionalPropertiesString(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -144,6 +144,12 @@ class Animal(ModelNormal):
self.class_name = class_name self.class_name = class_name
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)
@classmethod @classmethod

View File

@ -130,4 +130,10 @@ class ApiResponse(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -124,4 +124,10 @@ class ArrayOfArrayOfNumberOnly(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -124,4 +124,10 @@ class ArrayOfNumberOnly(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -135,4 +135,10 @@ class ArrayTest(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -139,4 +139,10 @@ class Capitalization(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -154,9 +154,16 @@ class Cat(ModelComposed):
self._composed_instances = composed_info[0] self._composed_instances = composed_info[0]
self._var_name_to_model_instances = composed_info[1] self._var_name_to_model_instances = composed_info[1]
self._additional_properties_model_instances = composed_info[2] self._additional_properties_model_instances = composed_info[2]
unused_args = composed_info[3]
self.class_name = class_name self.class_name = class_name
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)
@staticmethod @staticmethod

View File

@ -124,4 +124,10 @@ class CatAllOf(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -129,4 +129,10 @@ class Category(ModelNormal):
self.name = name self.name = name
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -152,8 +152,15 @@ class Child(ModelComposed):
self._composed_instances = composed_info[0] self._composed_instances = composed_info[0]
self._var_name_to_model_instances = composed_info[1] self._var_name_to_model_instances = composed_info[1]
self._additional_properties_model_instances = composed_info[2] self._additional_properties_model_instances = composed_info[2]
unused_args = composed_info[3]
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)
@staticmethod @staticmethod

View File

@ -124,4 +124,10 @@ class ChildAllOf(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -151,9 +151,16 @@ class ChildCat(ModelComposed):
self._composed_instances = composed_info[0] self._composed_instances = composed_info[0]
self._var_name_to_model_instances = composed_info[1] self._var_name_to_model_instances = composed_info[1]
self._additional_properties_model_instances = composed_info[2] self._additional_properties_model_instances = composed_info[2]
unused_args = composed_info[3]
self.pet_type = pet_type self.pet_type = pet_type
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)
@staticmethod @staticmethod

View File

@ -124,4 +124,10 @@ class ChildCatAllOf(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -151,9 +151,16 @@ class ChildDog(ModelComposed):
self._composed_instances = composed_info[0] self._composed_instances = composed_info[0]
self._var_name_to_model_instances = composed_info[1] self._var_name_to_model_instances = composed_info[1]
self._additional_properties_model_instances = composed_info[2] self._additional_properties_model_instances = composed_info[2]
unused_args = composed_info[3]
self.pet_type = pet_type self.pet_type = pet_type
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)
@staticmethod @staticmethod

View File

@ -124,4 +124,10 @@ class ChildDogAllOf(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -151,9 +151,16 @@ class ChildLizard(ModelComposed):
self._composed_instances = composed_info[0] self._composed_instances = composed_info[0]
self._var_name_to_model_instances = composed_info[1] self._var_name_to_model_instances = composed_info[1]
self._additional_properties_model_instances = composed_info[2] self._additional_properties_model_instances = composed_info[2]
unused_args = composed_info[3]
self.pet_type = pet_type self.pet_type = pet_type
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)
@staticmethod @staticmethod

View File

@ -124,4 +124,10 @@ class ChildLizardAllOf(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -124,4 +124,10 @@ class ClassModel(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -124,4 +124,10 @@ class Client(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -154,9 +154,16 @@ class Dog(ModelComposed):
self._composed_instances = composed_info[0] self._composed_instances = composed_info[0]
self._var_name_to_model_instances = composed_info[1] self._var_name_to_model_instances = composed_info[1]
self._additional_properties_model_instances = composed_info[2] self._additional_properties_model_instances = composed_info[2]
unused_args = composed_info[3]
self.class_name = class_name self.class_name = class_name
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)
@staticmethod @staticmethod

View File

@ -124,4 +124,10 @@ class DogAllOf(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -135,4 +135,10 @@ class EnumArrays(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -123,4 +123,10 @@ class EnumClass(ModelSimple):
self.value = value self.value = value
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -161,4 +161,10 @@ class EnumTest(ModelNormal):
self.enum_string_required = enum_string_required self.enum_string_required = enum_string_required
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -124,4 +124,10 @@ class File(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -132,4 +132,10 @@ class FileSchemaTestClass(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -200,4 +200,10 @@ class FormatTest(ModelNormal):
self.date = date self.date = date
self.password = password self.password = password
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -124,4 +124,10 @@ class Grandparent(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -126,4 +126,10 @@ class GrandparentAnimal(ModelNormal):
self.pet_type = pet_type self.pet_type = pet_type
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -127,4 +127,10 @@ class HasOnlyReadOnly(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -124,4 +124,10 @@ class List(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -142,4 +142,10 @@ class MapTest(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -135,4 +135,10 @@ class MixedPropertiesAndAdditionalPropertiesClass(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -127,4 +127,10 @@ class Model200Response(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -124,4 +124,10 @@ class ModelReturn(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -135,4 +135,10 @@ class Name(ModelNormal):
self.name = name self.name = name
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -124,4 +124,10 @@ class NumberOnly(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -144,4 +144,10 @@ class Order(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -135,4 +135,10 @@ class OuterComposite(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -123,4 +123,10 @@ class OuterEnum(ModelSimple):
self.value = value self.value = value
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -122,4 +122,10 @@ class OuterNumber(ModelSimple):
self.value = value self.value = value
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -149,8 +149,15 @@ class Parent(ModelComposed):
self._composed_instances = composed_info[0] self._composed_instances = composed_info[0]
self._var_name_to_model_instances = composed_info[1] self._var_name_to_model_instances = composed_info[1]
self._additional_properties_model_instances = composed_info[2] self._additional_properties_model_instances = composed_info[2]
unused_args = composed_info[3]
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)
@staticmethod @staticmethod

View File

@ -124,4 +124,10 @@ class ParentAllOf(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -164,9 +164,16 @@ class ParentPet(ModelComposed):
self._composed_instances = composed_info[0] self._composed_instances = composed_info[0]
self._var_name_to_model_instances = composed_info[1] self._var_name_to_model_instances = composed_info[1]
self._additional_properties_model_instances = composed_info[2] self._additional_properties_model_instances = composed_info[2]
unused_args = composed_info[3]
self.pet_type = pet_type self.pet_type = pet_type
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)
@staticmethod @staticmethod

View File

@ -157,4 +157,10 @@ class Pet(ModelNormal):
self.name = name self.name = name
self.photo_urls = photo_urls self.photo_urls = photo_urls
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -129,4 +129,10 @@ class Player(ModelNormal):
self.name = name self.name = name
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -127,4 +127,10 @@ class ReadOnlyFirst(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -124,4 +124,10 @@ class SpecialModelName(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -121,4 +121,10 @@ class StringBooleanMap(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -130,4 +130,10 @@ class Tag(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -148,4 +148,10 @@ class TypeHolderDefault(ModelNormal):
self.bool_item = bool_item self.bool_item = bool_item
self.array_item = array_item self.array_item = array_item
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -151,4 +151,10 @@ class TypeHolderExample(ModelNormal):
self.bool_item = bool_item self.bool_item = bool_item
self.array_item = array_item self.array_item = array_item
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -145,4 +145,10 @@ class User(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -208,4 +208,10 @@ class XmlItem(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -37,6 +37,17 @@ class Configuration(object):
The dict value is an API key prefix when generating the auth data. The dict value is an API key prefix when generating the auth data.
:param username: Username for HTTP basic authentication :param username: Username for HTTP basic authentication
:param password: Password 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: :Example:
@ -75,6 +86,7 @@ class Configuration(object):
def __init__(self, host="http://petstore.swagger.io:80/v2", def __init__(self, host="http://petstore.swagger.io:80/v2",
api_key=None, api_key_prefix=None, api_key=None, api_key_prefix=None,
username=None, password=None, username=None, password=None,
discard_unknown_keys=False,
): ):
"""Constructor """Constructor
""" """
@ -104,6 +116,7 @@ class Configuration(object):
self.password = password self.password = password
"""Password for HTTP basic authentication """Password for HTTP basic authentication
""" """
self.discard_unknown_keys = discard_unknown_keys
self.access_token = None self.access_token = None
"""access token for OAuth/Bearer """access token for OAuth/Bearer
""" """

View File

@ -37,6 +37,17 @@ class Configuration(object):
The dict value is an API key prefix when generating the auth data. The dict value is an API key prefix when generating the auth data.
:param username: Username for HTTP basic authentication :param username: Username for HTTP basic authentication
:param password: Password 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: :Example:
@ -75,6 +86,7 @@ class Configuration(object):
def __init__(self, host="http://petstore.swagger.io:80/v2", def __init__(self, host="http://petstore.swagger.io:80/v2",
api_key=None, api_key_prefix=None, api_key=None, api_key_prefix=None,
username=None, password=None, username=None, password=None,
discard_unknown_keys=False,
): ):
"""Constructor """Constructor
""" """
@ -104,6 +116,7 @@ class Configuration(object):
self.password = password self.password = password
"""Password for HTTP basic authentication """Password for HTTP basic authentication
""" """
self.discard_unknown_keys = discard_unknown_keys
self.access_token = None self.access_token = None
"""access token for OAuth/Bearer """access token for OAuth/Bearer
""" """

View File

@ -1456,7 +1456,12 @@ components:
Cat: Cat:
allOf: allOf:
- $ref: '#/components/schemas/Animal' - $ref: '#/components/schemas/Animal'
- $ref: '#/components/schemas/Address'
- $ref: '#/components/schemas/Cat_allOf' - $ref: '#/components/schemas/Cat_allOf'
Address:
additionalProperties:
type: integer
type: object
Animal: Animal:
discriminator: discriminator:
propertyName: className propertyName: className

View File

@ -117,6 +117,7 @@ Class | Method | HTTP request | Description
## Documentation For Models ## Documentation For Models
- [additional_properties_class.AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md) - [additional_properties_class.AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
- [address.Address](docs/Address.md)
- [animal.Animal](docs/Animal.md) - [animal.Animal](docs/Animal.md)
- [api_response.ApiResponse](docs/ApiResponse.md) - [api_response.ApiResponse](docs/ApiResponse.md)
- [array_of_array_of_number_only.ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md) - [array_of_array_of_number_only.ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)

View File

@ -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)

View File

@ -41,6 +41,7 @@ from petstore_api.exceptions import ApiException
# import models into sdk package # import models into sdk package
from petstore_api.models.additional_properties_class import AdditionalPropertiesClass 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.animal import Animal
from petstore_api.models.api_response import ApiResponse from petstore_api.models.api_response import ApiResponse
from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly

View File

@ -37,6 +37,17 @@ class Configuration(object):
The dict value is an API key prefix when generating the auth data. The dict value is an API key prefix when generating the auth data.
:param username: Username for HTTP basic authentication :param username: Username for HTTP basic authentication
:param password: Password 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. :param signing_info: Configuration parameters for the HTTP signature security scheme.
Must be an instance of petstore_api.signing.HttpSigningConfiguration 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", def __init__(self, host="http://petstore.swagger.io:80/v2",
api_key=None, api_key_prefix=None, api_key=None, api_key_prefix=None,
username=None, password=None, username=None, password=None,
discard_unknown_keys=False,
signing_info=None, signing_info=None,
): ):
"""Constructor """Constructor
@ -146,6 +158,7 @@ class Configuration(object):
self.password = password self.password = password
"""Password for HTTP basic authentication """Password for HTTP basic authentication
""" """
self.discard_unknown_keys = discard_unknown_keys
if signing_info is not None: if signing_info is not None:
signing_info.host = host signing_info.host = host
self.signing_info = signing_info self.signing_info = signing_info

View File

@ -931,6 +931,7 @@ def attempt_convert_item(input_value, valid_classes, path_to_item,
if not valid_classes_coercible or key_type: if not valid_classes_coercible or key_type:
# we do not handle keytype errors, json will take care # we do not handle keytype errors, json will take care
# of this for us # of this for us
if configuration is None or not configuration.discard_unknown_keys:
raise get_type_error(input_value, path_to_item, valid_classes, raise get_type_error(input_value, path_to_item, valid_classes,
key_type=key_type) key_type=key_type)
for valid_class in valid_classes_coercible: for valid_class in valid_classes_coercible:
@ -1371,16 +1372,16 @@ def validate_get_composed_info(constant_args, model_args, self):
# set any remaining values # set any remaining values
unused_args = get_unused_args(self, composed_instances, model_args) unused_args = get_unused_args(self, composed_instances, model_args)
if len(unused_args) > 0: if len(unused_args) > 0 and \
if len(additional_properties_model_instances) == 0: len(additional_properties_model_instances) == 0 and \
(self._configuration is None or
not self._configuration.discard_unknown_keys):
raise ApiValueError( raise ApiValueError(
"Invalid input arguments input when making an instance of " "Invalid input arguments input when making an instance of "
"class %s. Not all inputs were used. The unused input data " "class %s. Not all inputs were used. The unused input data "
"is %s" % (self.__class__.__name__, unused_args) "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)
# no need to add additional_properties to var_name_to_model_instances here # no need to add additional_properties to var_name_to_model_instances here
# because additional_properties_model_instances will direct us to that # because additional_properties_model_instances will direct us to that
# instance when we use getattr or setattr # instance when we use getattr or setattr
@ -1389,5 +1390,6 @@ def validate_get_composed_info(constant_args, model_args, self):
return [ return [
composed_instances, composed_instances,
var_name_to_model_instances, var_name_to_model_instances,
additional_properties_model_instances additional_properties_model_instances,
unused_args
] ]

View File

@ -127,4 +127,10 @@ class AdditionalPropertiesClass(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -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)

View File

@ -144,6 +144,12 @@ class Animal(ModelNormal):
self.class_name = class_name self.class_name = class_name
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)
@classmethod @classmethod

View File

@ -130,4 +130,10 @@ class ApiResponse(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -124,4 +124,10 @@ class ArrayOfArrayOfNumberOnly(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -124,4 +124,10 @@ class ArrayOfNumberOnly(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -135,4 +135,10 @@ class ArrayTest(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -139,4 +139,10 @@ class Capitalization(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -28,6 +28,11 @@ from petstore_api.model_utils import ( # noqa: F401
str, str,
validate_get_composed_info, validate_get_composed_info,
) )
try:
from petstore_api.models import address
except ImportError:
address = sys.modules[
'petstore_api.models.address']
try: try:
from petstore_api.models import animal from petstore_api.models import animal
except ImportError: except ImportError:
@ -154,9 +159,16 @@ class Cat(ModelComposed):
self._composed_instances = composed_info[0] self._composed_instances = composed_info[0]
self._var_name_to_model_instances = composed_info[1] self._var_name_to_model_instances = composed_info[1]
self._additional_properties_model_instances = composed_info[2] self._additional_properties_model_instances = composed_info[2]
unused_args = composed_info[3]
self.class_name = class_name self.class_name = class_name
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)
@staticmethod @staticmethod
@ -172,6 +184,7 @@ class Cat(ModelComposed):
'anyOf': [ 'anyOf': [
], ],
'allOf': [ 'allOf': [
address.Address,
animal.Animal, animal.Animal,
cat_all_of.CatAllOf, cat_all_of.CatAllOf,
], ],

View File

@ -124,4 +124,10 @@ class CatAllOf(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -129,4 +129,10 @@ class Category(ModelNormal):
self.name = name self.name = name
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -124,4 +124,10 @@ class ClassModel(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -124,4 +124,10 @@ class Client(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -154,9 +154,16 @@ class Dog(ModelComposed):
self._composed_instances = composed_info[0] self._composed_instances = composed_info[0]
self._var_name_to_model_instances = composed_info[1] self._var_name_to_model_instances = composed_info[1]
self._additional_properties_model_instances = composed_info[2] self._additional_properties_model_instances = composed_info[2]
unused_args = composed_info[3]
self.class_name = class_name self.class_name = class_name
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)
@staticmethod @staticmethod

View File

@ -124,4 +124,10 @@ class DogAllOf(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -135,4 +135,10 @@ class EnumArrays(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -123,4 +123,10 @@ class EnumClass(ModelSimple):
self.value = value self.value = value
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -185,4 +185,10 @@ class EnumTest(ModelNormal):
self.enum_string_required = enum_string_required self.enum_string_required = enum_string_required
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -124,4 +124,10 @@ class File(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -132,4 +132,10 @@ class FileSchemaTestClass(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

View File

@ -124,4 +124,10 @@ class Foo(ModelNormal):
self._configuration = _configuration self._configuration = _configuration
for var_name, var_value in six.iteritems(kwargs): 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) setattr(self, var_name, var_value)

Some files were not shown because too many files have changed in this diff Show More