diff --git a/bin/openapi3/windows/python-experimental-petstore.bat b/bin/openapi3/windows/python-experimental-petstore.bat index 73c433de2784..29c097a55721 100644 --- a/bin/openapi3/windows/python-experimental-petstore.bat +++ b/bin/openapi3/windows/python-experimental-petstore.bat @@ -5,6 +5,6 @@ If Not Exist %executable% ( ) REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -set ags=generate -i modules\openapi-generator\src\test\resources\3_0\petstore-with-fake-endpoints-models-for-testing.yaml -g python-experimental -o samples\openapi3\client\petstore\python-experimental --additional-properties packageName=petstore_api +set ags=generate -i modules\openapi-generator\src\test\resources\3_0\petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml -g python-experimental -o samples\openapi3\client\petstore\python-experimental --additional-properties packageName=petstore_api java %JAVA_OPTS% -jar %executable% %ags% diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java index a9c57e3f07a0..3f6bfecddb50 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java @@ -706,6 +706,56 @@ public void postProcessParameter(CodegenParameter p) { } } + private void addNullDefaultToOneOfAnyOfReqProps(Schema schema, CodegenModel result){ + // for composed schema models, if the required properties are only from oneOf or anyOf models + // give them a nulltype.Null so the user can omit including them in python + ComposedSchema cs = (ComposedSchema) schema; + + // these are the properties that are from properties in self cs or cs allOf + Map selfProperties = new LinkedHashMap(); + List selfRequired = new ArrayList(); + + // these are the properties that are from properties in cs oneOf or cs anyOf + Map otherProperties = new LinkedHashMap(); + List otherRequired = new ArrayList(); + + List oneOfanyOfSchemas = new ArrayList<>(); + List oneOf = cs.getOneOf(); + if (oneOf != null) { + oneOfanyOfSchemas.addAll(oneOf); + } + List anyOf = cs.getAnyOf(); + if (anyOf != null) { + oneOfanyOfSchemas.addAll(anyOf); + } + for (Schema sc: oneOfanyOfSchemas) { + Schema refSchema = ModelUtils.getReferencedSchema(this.openAPI, sc); + addProperties(otherProperties, otherRequired, refSchema); + } + Set otherRequiredSet = new HashSet(otherRequired); + + List allOf = cs.getAllOf(); + if ((schema.getProperties() != null && !schema.getProperties().isEmpty()) || allOf != null) { + // NOTE: this function also adds the allOf propesrties inside schema + addProperties(selfProperties, selfRequired, schema); + } + if (result.discriminator != null) { + selfRequired.add(result.discriminator.getPropertyBaseName()); + } + Set selfRequiredSet = new HashSet(selfRequired); + + List reqVars = result.getRequiredVars(); + if (reqVars != null) { + for (CodegenProperty cp: reqVars) { + String propName = cp.baseName; + if (otherRequiredSet.contains(propName) && !selfRequiredSet.contains(propName)) { + // if var is in otherRequiredSet and is not in selfRequiredSet and is in result.requiredVars + // then set it to nullable because the user doesn't have to give a value for it + cp.setDefaultValue("nulltype.Null"); + } + } + } + } /** * Convert OAS Model object to Codegen Model object @@ -806,6 +856,11 @@ public CodegenModel fromModel(String name, Schema schema) { if (result.imports.contains(result.classname)) { result.imports.remove(result.classname); } + + if (result.requiredVars.size() > 0 && (result.oneOf.size() > 0 || result.anyOf.size() > 0)) { + addNullDefaultToOneOfAnyOfReqProps(schema, result); + } + return result; } diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model.mustache index 0ca198ddf96c..ef7da5728252 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/model.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model.mustache @@ -7,6 +7,7 @@ import re # noqa: F401 import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from {{packageName}}.model_utils import ( # noqa: F401 ModelComposed, diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_composed.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_composed.mustache index 5a1ece1f9266..e00bf129b247 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_composed.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_composed.mustache @@ -17,11 +17,18 @@ '_from_server': _from_server, '_configuration': _configuration, } - model_args = { + required_args = { {{#requiredVars}} '{{name}}': {{name}}, {{/requiredVars}} } + # remove args whose value is Null because they are unset + required_arg_names = list(required_args.keys()) + for required_arg_name in required_arg_names: + if required_args[required_arg_name] is nulltype.Null: + del required_args[required_arg_name] + model_args = {} + model_args.update(required_args) model_args.update(kwargs) composed_info = validate_get_composed_info( constant_args, model_args, self) @@ -30,9 +37,8 @@ self._additional_properties_model_instances = composed_info[2] unused_args = composed_info[3] -{{#requiredVars}} - self.{{name}} = {{name}} -{{/requiredVars}} + for var_name, var_value in required_args.items(): + setattr(self, var_name, var_value) for var_name, var_value in six.iteritems(kwargs): if var_name in unused_args and \ self._configuration is not None and \ diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_shared.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_shared.mustache index 318d693e15d0..9dd5bc2b6f3f 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_shared.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_shared.mustache @@ -1,11 +1,23 @@ def __init__(self{{#requiredVars}}{{^defaultValue}}, {{name}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{#defaultValue}}, {{name}}={{{defaultValue}}}{{/defaultValue}}{{/requiredVars}}, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """{{classname}} - a model defined in OpenAPI -{{#requiredVars}}{{^hasMore}} Args:{{/hasMore}}{{/requiredVars}}{{#requiredVars}}{{^defaultValue}} - {{name}} ({{{dataType}}}):{{#description}} {{description}}{{/description}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{^hasMore}} -{{/hasMore}}{{/requiredVars}} - Keyword Args:{{#requiredVars}}{{#defaultValue}} - {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}] # noqa: E501{{/defaultValue}}{{/requiredVars}} +{{#requiredVars}} +{{#-first}} + Args: +{{/-first}} +{{^defaultValue}} + {{name}} ({{{dataType}}}):{{#description}} {{description}}{{/description}} +{{/defaultValue}} +{{#-last}} + +{{/-last}} +{{/requiredVars}} + Keyword Args: +{{#requiredVars}} +{{#defaultValue}} + {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 +{{/defaultValue}} +{{/requiredVars}} _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. @@ -18,8 +30,10 @@ _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.{{#optionalVars}} - {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501{{/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}} """ self._data_store = {} diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/methods_setattr_getattr_composed.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/methods_setattr_getattr_composed.mustache index e5eee88a9608..9adb2a08a1fb 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/methods_setattr_getattr_composed.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/methods_setattr_getattr_composed.mustache @@ -41,21 +41,23 @@ if self._path_to_item: path_to_item.extend(self._path_to_item) path_to_item.append(name) + values = set() if model_instances: - values = set() for model_instance in model_instances: if name in model_instance._data_store: values.add(model_instance._data_store[name]) - if len(values) == 1: - return list(values)[0] + len_values = len(values) + if len_values == 0: + raise ApiKeyError( + "{0} has no key '{1}'".format(type(self).__name__, name), + path_to_item + ) + elif len_values == 1: + return list(values)[0] + elif len_values > 1: raise ApiValueError( "Values stored for property {0} in {1} difffer when looking " "at self and self's composed instances. All values must be " "the same".format(name, type(self).__name__), path_to_item - ) - - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) \ No newline at end of file + ) \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache index 8193d8a3b2a9..7f05f2dbe855 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache @@ -828,7 +828,7 @@ def model_to_dict(model_instance, serialize=True): model_instances = [model_instance] if model_instance._composed_schemas() is not None: - model_instances = model_instance._composed_instances + model_instances.extend(model_instance._composed_instances) for model_instance in model_instances: for attr, value in six.iteritems(model_instance._data_store): if serialize: @@ -951,12 +951,12 @@ def get_oneof_instance(self, model_args, constant_args): used to make instances Returns - oneof_instance (instance) + oneof_instance (instance/None) """ - oneof_instance = None if len(self._composed_schemas()['oneOf']) == 0: - return oneof_instance + return None + oneof_instances = [] for oneof_class in self._composed_schemas()['oneOf']: # transform js keys to python keys in fixed_model_args fixed_model_args = change_keys_js_to_python( @@ -969,20 +969,30 @@ def get_oneof_instance(self, model_args, constant_args): if var_name in fixed_model_args: kwargs[var_name] = fixed_model_args[var_name] + # do not try to make a model with no input args + if len(kwargs) == 0: + continue + # and use it to make the instance kwargs.update(constant_args) try: oneof_instance = oneof_class(**kwargs) - break + oneof_instances.append(oneof_instance) except Exception: pass - if oneof_instance is None: + if len(oneof_instances) == 0: raise ApiValueError( "Invalid inputs given to generate an instance of %s. Unable to " "make any instances of the classes in oneOf definition." % self.__class__.__name__ ) - return oneof_instance + elif len(oneof_instances) > 1: + raise ApiValueError( + "Invalid inputs given to generate an instance of %s. Multiple " + "oneOf instances were generated when a max of one is allowed." % + self.__class__.__name__ + ) + return oneof_instances[0] def get_anyof_instances(self, model_args, constant_args): @@ -1012,6 +1022,10 @@ def get_anyof_instances(self, model_args, constant_args): if var_name in fixed_model_args: kwargs[var_name] = fixed_model_args[var_name] + # do not try to make a model with no input args + if len(kwargs) == 0: + continue + # and use it to make the instance kwargs.update(constant_args) try: diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/requirements.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/requirements.mustache index eb358efd5bd3..a56bedffbf57 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/requirements.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/requirements.mustache @@ -1,3 +1,4 @@ +nulltype certifi >= 14.05.14 future; python_version<="2.7" six >= 1.10 diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/setup.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/setup.mustache index 2fe84efcee06..796475c45642 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/setup.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/setup.mustache @@ -21,6 +21,7 @@ REQUIRES = [ "six >= 1.10", "certifi", "python-dateutil", + "nulltype", {{#asyncio}} "aiohttp >= 3.0.0", {{/asyncio}} diff --git a/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml index ecc6f66f3b03..d9aedbba9c6d 100644 --- a/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml @@ -1779,3 +1779,82 @@ components: additionalProperties: type: object nullable: true + fruit: + properties: + color: + type: string + oneOf: + - $ref: '#/components/schemas/apple' + - $ref: '#/components/schemas/banana' + apple: + type: object + properties: + cultivar: + type: string + banana: + type: object + properties: + lengthCm: + type: number + mammal: + oneOf: + - $ref: '#/components/schemas/whale' + - $ref: '#/components/schemas/zebra' + discriminator: + propertyName: className + mapping: + whale: '#/components/schemas/whale' + zebra: '#/components/schemas/zebra' + whale: + type: object + properties: + hasBaleen: + type: boolean + hasTeeth: + type: boolean + className: + type: string + required: + - className + zebra: + type: object + properties: + type: + type: string + enum: + - plains + - mountain + - grevys + className: + type: string + required: + - className + gmFruit: + properties: + color: + type: string + anyOf: + - $ref: '#/components/schemas/apple' + - $ref: '#/components/schemas/banana' + fruitReq: + oneOf: + - $ref: '#/components/schemas/appleReq' + - $ref: '#/components/schemas/bananaReq' + appleReq: + type: object + properties: + cultivar: + type: string + mealy: + type: boolean + required: + - cultivar + bananaReq: + type: object + properties: + lengthCm: + type: number + sweet: + type: boolean + required: + - lengthCm diff --git a/samples/client/petstore/python-experimental/petstore_api/model_utils.py b/samples/client/petstore/python-experimental/petstore_api/model_utils.py index 074e597cbd22..eed501c84502 100644 --- a/samples/client/petstore/python-experimental/petstore_api/model_utils.py +++ b/samples/client/petstore/python-experimental/petstore_api/model_utils.py @@ -274,13 +274,20 @@ def __getattr__(self, name): if self._path_to_item: path_to_item.extend(self._path_to_item) path_to_item.append(name) + values = set() if model_instances: - values = set() for model_instance in model_instances: if name in model_instance._data_store: values.add(model_instance._data_store[name]) - if len(values) == 1: - return list(values)[0] + len_values = len(values) + if len_values == 0: + raise ApiKeyError( + "{0} has no key '{1}'".format(type(self).__name__, name), + path_to_item + ) + elif len_values == 1: + return list(values)[0] + elif len_values > 1: raise ApiValueError( "Values stored for property {0} in {1} difffer when looking " "at self and self's composed instances. All values must be " @@ -288,11 +295,6 @@ def __getattr__(self, name): path_to_item ) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - def to_dict(self): """Returns the model properties as a dict""" return model_to_dict(self, serialize=False) @@ -1082,7 +1084,7 @@ def model_to_dict(model_instance, serialize=True): model_instances = [model_instance] if model_instance._composed_schemas() is not None: - model_instances = model_instance._composed_instances + model_instances.extend(model_instance._composed_instances) for model_instance in model_instances: for attr, value in six.iteritems(model_instance._data_store): if serialize: @@ -1205,12 +1207,12 @@ def get_oneof_instance(self, model_args, constant_args): used to make instances Returns - oneof_instance (instance) + oneof_instance (instance/None) """ - oneof_instance = None if len(self._composed_schemas()['oneOf']) == 0: - return oneof_instance + return None + oneof_instances = [] for oneof_class in self._composed_schemas()['oneOf']: # transform js keys to python keys in fixed_model_args fixed_model_args = change_keys_js_to_python( @@ -1223,20 +1225,30 @@ def get_oneof_instance(self, model_args, constant_args): if var_name in fixed_model_args: kwargs[var_name] = fixed_model_args[var_name] + # do not try to make a model with no input args + if len(kwargs) == 0: + continue + # and use it to make the instance kwargs.update(constant_args) try: oneof_instance = oneof_class(**kwargs) - break + oneof_instances.append(oneof_instance) except Exception: pass - if oneof_instance is None: + if len(oneof_instances) == 0: raise ApiValueError( "Invalid inputs given to generate an instance of %s. Unable to " "make any instances of the classes in oneOf definition." % self.__class__.__name__ ) - return oneof_instance + elif len(oneof_instances) > 1: + raise ApiValueError( + "Invalid inputs given to generate an instance of %s. Multiple " + "oneOf instances were generated when a max of one is allowed." % + self.__class__.__name__ + ) + return oneof_instances[0] def get_anyof_instances(self, model_args, constant_args): @@ -1266,6 +1278,10 @@ def get_anyof_instances(self, model_args, constant_args): if var_name in fixed_model_args: kwargs[var_name] = fixed_model_args[var_name] + # do not try to make a model with no input args + if len(kwargs) == 0: + continue + # and use it to make the instance kwargs.update(constant_args) try: diff --git a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_any_type.py b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_any_type.py index 440ca3672749..d1a06123ea88 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_any_type.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_any_type.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """additional_properties_any_type.AdditionalPropertiesAnyType - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_array.py b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_array.py index 4c5054603ee0..bba4f0ed95f1 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_array.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_array.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """additional_properties_array.AdditionalPropertiesArray - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_boolean.py b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_boolean.py index 676c97d2915c..de012c132c90 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_boolean.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_boolean.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """additional_properties_boolean.AdditionalPropertiesBoolean - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_class.py b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_class.py index d0dcda0f193e..c37e9b5c73bf 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_class.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_class.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -119,7 +120,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """additional_properties_class.AdditionalPropertiesClass - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_integer.py b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_integer.py index e51a3ada19d8..649fbc485896 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_integer.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_integer.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """additional_properties_integer.AdditionalPropertiesInteger - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_number.py b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_number.py index c8cceb764404..ce12662a8ed0 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_number.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_number.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """additional_properties_number.AdditionalPropertiesNumber - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_object.py b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_object.py index 56d227c144d3..e5c60015a9e1 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_object.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_object.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """additional_properties_object.AdditionalPropertiesObject - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_string.py b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_string.py index c4a066f00422..24cef21ba90d 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_string.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_string.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """additional_properties_string.AdditionalPropertiesString - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/animal.py b/samples/client/petstore/python-experimental/petstore_api/models/animal.py index 4971ab17ab56..45058ec7612f 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/animal.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/animal.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, diff --git a/samples/client/petstore/python-experimental/petstore_api/models/api_response.py b/samples/client/petstore/python-experimental/petstore_api/models/api_response.py index 893024a80b99..f1680c87f67a 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/api_response.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/api_response.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -103,7 +104,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """api_response.ApiResponse - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/array_of_array_of_number_only.py b/samples/client/petstore/python-experimental/petstore_api/models/array_of_array_of_number_only.py index faa9b5c44ccd..bf6419e5c089 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/array_of_array_of_number_only.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """array_of_array_of_number_only.ArrayOfArrayOfNumberOnly - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/array_of_number_only.py b/samples/client/petstore/python-experimental/petstore_api/models/array_of_number_only.py index 2909708136de..f3bf89e27ba3 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/array_of_number_only.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/array_of_number_only.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """array_of_number_only.ArrayOfNumberOnly - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/array_test.py b/samples/client/petstore/python-experimental/petstore_api/models/array_test.py index 7f4f1090663a..0a01b3cad210 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/array_test.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/array_test.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -108,7 +109,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """array_test.ArrayTest - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/capitalization.py b/samples/client/petstore/python-experimental/petstore_api/models/capitalization.py index b4be4b15e71d..6011db39400c 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/capitalization.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/capitalization.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -109,7 +110,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """capitalization.Capitalization - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/cat.py b/samples/client/petstore/python-experimental/petstore_api/models/cat.py index 2683db835805..d40464eaf0e9 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/cat.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/cat.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -145,9 +146,16 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it '_from_server': _from_server, '_configuration': _configuration, } - model_args = { + required_args = { 'class_name': class_name, } + # remove args whose value is Null because they are unset + required_arg_names = list(required_args.keys()) + for required_arg_name in required_arg_names: + if required_args[required_arg_name] is nulltype.Null: + del required_args[required_arg_name] + model_args = {} + model_args.update(required_args) model_args.update(kwargs) composed_info = validate_get_composed_info( constant_args, model_args, self) @@ -156,7 +164,8 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it self._additional_properties_model_instances = composed_info[2] unused_args = composed_info[3] - self.class_name = class_name + for var_name, var_value in required_args.items(): + setattr(self, var_name, var_value) for var_name, var_value in six.iteritems(kwargs): if var_name in unused_args and \ self._configuration is not None and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/cat_all_of.py b/samples/client/petstore/python-experimental/petstore_api/models/cat_all_of.py index 1c3fe2578a46..75e856dcbcde 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/cat_all_of.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/cat_all_of.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """cat_all_of.CatAllOf - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/category.py b/samples/client/petstore/python-experimental/petstore_api/models/category.py index fcdb58cb9568..5d3e21ddd7e9 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/category.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/category.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -104,7 +105,7 @@ def __init__(self, name='default-name', _check_type=True, _from_server=False, _p Args: Keyword Args: - name (str): defaults to 'default-name', must be one of ['default-name'] # noqa: E501 + name (str): defaults to 'default-name' # noqa: E501 _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. diff --git a/samples/client/petstore/python-experimental/petstore_api/models/child.py b/samples/client/petstore/python-experimental/petstore_api/models/child.py index efbce35e8ba3..501c22427916 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/child.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/child.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -112,7 +113,6 @@ def discriminator(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """child.Child - 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 @@ -144,8 +144,15 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf '_from_server': _from_server, '_configuration': _configuration, } - model_args = { + required_args = { } + # remove args whose value is Null because they are unset + required_arg_names = list(required_args.keys()) + for required_arg_name in required_arg_names: + if required_args[required_arg_name] is nulltype.Null: + del required_args[required_arg_name] + model_args = {} + model_args.update(required_args) model_args.update(kwargs) composed_info = validate_get_composed_info( constant_args, model_args, self) @@ -154,6 +161,8 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._additional_properties_model_instances = composed_info[2] unused_args = composed_info[3] + for var_name, var_value in required_args.items(): + setattr(self, var_name, var_value) for var_name, var_value in six.iteritems(kwargs): if var_name in unused_args and \ self._configuration is not None and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/child_all_of.py b/samples/client/petstore/python-experimental/petstore_api/models/child_all_of.py index c4b55ed362b5..69f6b962f242 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/child_all_of.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/child_all_of.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """child_all_of.ChildAllOf - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/child_cat.py b/samples/client/petstore/python-experimental/petstore_api/models/child_cat.py index eab41ebbf11f..b83986bd68a8 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/child_cat.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/child_cat.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -142,9 +143,16 @@ def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item '_from_server': _from_server, '_configuration': _configuration, } - model_args = { + required_args = { 'pet_type': pet_type, } + # remove args whose value is Null because they are unset + required_arg_names = list(required_args.keys()) + for required_arg_name in required_arg_names: + if required_args[required_arg_name] is nulltype.Null: + del required_args[required_arg_name] + model_args = {} + model_args.update(required_args) model_args.update(kwargs) composed_info = validate_get_composed_info( constant_args, model_args, self) @@ -153,7 +161,8 @@ def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item self._additional_properties_model_instances = composed_info[2] unused_args = composed_info[3] - self.pet_type = pet_type + for var_name, var_value in required_args.items(): + setattr(self, var_name, var_value) for var_name, var_value in six.iteritems(kwargs): if var_name in unused_args and \ self._configuration is not None and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/child_cat_all_of.py b/samples/client/petstore/python-experimental/petstore_api/models/child_cat_all_of.py index 11b8c5d2c124..dbe4e88bcebc 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/child_cat_all_of.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/child_cat_all_of.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """child_cat_all_of.ChildCatAllOf - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/child_dog.py b/samples/client/petstore/python-experimental/petstore_api/models/child_dog.py index adbc33daf77c..da568bd7d271 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/child_dog.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/child_dog.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -142,9 +143,16 @@ def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item '_from_server': _from_server, '_configuration': _configuration, } - model_args = { + required_args = { 'pet_type': pet_type, } + # remove args whose value is Null because they are unset + required_arg_names = list(required_args.keys()) + for required_arg_name in required_arg_names: + if required_args[required_arg_name] is nulltype.Null: + del required_args[required_arg_name] + model_args = {} + model_args.update(required_args) model_args.update(kwargs) composed_info = validate_get_composed_info( constant_args, model_args, self) @@ -153,7 +161,8 @@ def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item self._additional_properties_model_instances = composed_info[2] unused_args = composed_info[3] - self.pet_type = pet_type + for var_name, var_value in required_args.items(): + setattr(self, var_name, var_value) for var_name, var_value in six.iteritems(kwargs): if var_name in unused_args and \ self._configuration is not None and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/child_dog_all_of.py b/samples/client/petstore/python-experimental/petstore_api/models/child_dog_all_of.py index 21fee1506a6f..f95f5ff8ae74 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/child_dog_all_of.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/child_dog_all_of.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """child_dog_all_of.ChildDogAllOf - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/child_lizard.py b/samples/client/petstore/python-experimental/petstore_api/models/child_lizard.py index 20c04d3f2fc1..62fa11f26e80 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/child_lizard.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/child_lizard.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -142,9 +143,16 @@ def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item '_from_server': _from_server, '_configuration': _configuration, } - model_args = { + required_args = { 'pet_type': pet_type, } + # remove args whose value is Null because they are unset + required_arg_names = list(required_args.keys()) + for required_arg_name in required_arg_names: + if required_args[required_arg_name] is nulltype.Null: + del required_args[required_arg_name] + model_args = {} + model_args.update(required_args) model_args.update(kwargs) composed_info = validate_get_composed_info( constant_args, model_args, self) @@ -153,7 +161,8 @@ def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item self._additional_properties_model_instances = composed_info[2] unused_args = composed_info[3] - self.pet_type = pet_type + for var_name, var_value in required_args.items(): + setattr(self, var_name, var_value) for var_name, var_value in six.iteritems(kwargs): if var_name in unused_args and \ self._configuration is not None and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/child_lizard_all_of.py b/samples/client/petstore/python-experimental/petstore_api/models/child_lizard_all_of.py index f429c864d5b8..27686379a890 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/child_lizard_all_of.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/child_lizard_all_of.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """child_lizard_all_of.ChildLizardAllOf - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/class_model.py b/samples/client/petstore/python-experimental/petstore_api/models/class_model.py index e4f1d63a264c..06c52dc8bee9 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/class_model.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/class_model.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """class_model.ClassModel - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/client.py b/samples/client/petstore/python-experimental/petstore_api/models/client.py index f3f645da3823..b7184b3f2b40 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/client.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/client.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """client.Client - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/dog.py b/samples/client/petstore/python-experimental/petstore_api/models/dog.py index 462869ffbd28..69af821b27e2 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/dog.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/dog.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -145,9 +146,16 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it '_from_server': _from_server, '_configuration': _configuration, } - model_args = { + required_args = { 'class_name': class_name, } + # remove args whose value is Null because they are unset + required_arg_names = list(required_args.keys()) + for required_arg_name in required_arg_names: + if required_args[required_arg_name] is nulltype.Null: + del required_args[required_arg_name] + model_args = {} + model_args.update(required_args) model_args.update(kwargs) composed_info = validate_get_composed_info( constant_args, model_args, self) @@ -156,7 +164,8 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it self._additional_properties_model_instances = composed_info[2] unused_args = composed_info[3] - self.class_name = class_name + for var_name, var_value in required_args.items(): + setattr(self, var_name, var_value) for var_name, var_value in six.iteritems(kwargs): if var_name in unused_args and \ self._configuration is not None and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/dog_all_of.py b/samples/client/petstore/python-experimental/petstore_api/models/dog_all_of.py index ec62d18e6376..0832f4b696cc 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/dog_all_of.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/dog_all_of.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """dog_all_of.DogAllOf - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/enum_arrays.py b/samples/client/petstore/python-experimental/petstore_api/models/enum_arrays.py index 59f73c8f1c9e..358e9f680e76 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/enum_arrays.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/enum_arrays.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -109,7 +110,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """enum_arrays.EnumArrays - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/enum_class.py b/samples/client/petstore/python-experimental/petstore_api/models/enum_class.py index 994d7723842e..5f3f1894de47 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/enum_class.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/enum_class.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,7 @@ def __init__(self, value='-efg', _check_type=True, _from_server=False, _path_to_ Args: Keyword Args: - value (str): defaults to '-efg', must be one of ['-efg'] # noqa: E501 + value (str): defaults to '-efg', must be one of ["_abc", "-efg", "(xyz)", ] # noqa: E501 _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. diff --git a/samples/client/petstore/python-experimental/petstore_api/models/enum_test.py b/samples/client/petstore/python-experimental/petstore_api/models/enum_test.py index 2d5efd84b263..4c35c7b8c2bb 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/enum_test.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/enum_test.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, diff --git a/samples/client/petstore/python-experimental/petstore_api/models/file.py b/samples/client/petstore/python-experimental/petstore_api/models/file.py index 46f02f4436cf..f71dc07b7ca8 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/file.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/file.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """file.File - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/file_schema_test_class.py b/samples/client/petstore/python-experimental/petstore_api/models/file_schema_test_class.py index 9c5cb0c63664..1260e8affda2 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/file_schema_test_class.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/file_schema_test_class.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -106,7 +107,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """file_schema_test_class.FileSchemaTestClass - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/format_test.py b/samples/client/petstore/python-experimental/petstore_api/models/format_test.py index 9325e5888e9b..823c3cb88d91 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/format_test.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/format_test.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, diff --git a/samples/client/petstore/python-experimental/petstore_api/models/grandparent.py b/samples/client/petstore/python-experimental/petstore_api/models/grandparent.py index dc71d92196fd..98d7934f472f 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/grandparent.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/grandparent.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """grandparent.Grandparent - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/grandparent_animal.py b/samples/client/petstore/python-experimental/petstore_api/models/grandparent_animal.py index 127de0d2e04d..af25951ed73a 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/grandparent_animal.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/grandparent_animal.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, diff --git a/samples/client/petstore/python-experimental/petstore_api/models/has_only_read_only.py b/samples/client/petstore/python-experimental/petstore_api/models/has_only_read_only.py index cf66f3fc02e8..c84cf0be3f2b 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/has_only_read_only.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/has_only_read_only.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -101,7 +102,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """has_only_read_only.HasOnlyReadOnly - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/list.py b/samples/client/petstore/python-experimental/petstore_api/models/list.py index d4cd4c4eb466..c7c80e8bd28b 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/list.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/list.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """list.List - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/map_test.py b/samples/client/petstore/python-experimental/petstore_api/models/map_test.py index 95d680e9ebdf..8cc47c0a6922 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/map_test.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/map_test.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -114,7 +115,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """map_test.MapTest - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/client/petstore/python-experimental/petstore_api/models/mixed_properties_and_additional_properties_class.py index 7eb5df3cc68f..143a79bfa266 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -108,7 +109,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """mixed_properties_and_additional_properties_class.MixedPropertiesAndAdditionalPropertiesClass - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/model200_response.py b/samples/client/petstore/python-experimental/petstore_api/models/model200_response.py index 4eb1672966ae..0c3885120210 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/model200_response.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/model200_response.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -101,7 +102,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """model200_response.Model200Response - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/model_return.py b/samples/client/petstore/python-experimental/petstore_api/models/model_return.py index 740c8e140563..75c3cea6318b 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/model_return.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/model_return.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """model_return.ModelReturn - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/name.py b/samples/client/petstore/python-experimental/petstore_api/models/name.py index c85f89a118c6..db81ae16916d 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/name.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/name.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, diff --git a/samples/client/petstore/python-experimental/petstore_api/models/number_only.py b/samples/client/petstore/python-experimental/petstore_api/models/number_only.py index a3f20cd4b4b3..0c91e2ae62d0 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/number_only.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/number_only.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """number_only.NumberOnly - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/order.py b/samples/client/petstore/python-experimental/petstore_api/models/order.py index 15c23366e433..673295a8610c 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/order.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/order.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -114,7 +115,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """order.Order - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/outer_composite.py b/samples/client/petstore/python-experimental/petstore_api/models/outer_composite.py index e643f6e73bd9..c654c51daffe 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/outer_composite.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/outer_composite.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -108,7 +109,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """outer_composite.OuterComposite - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/outer_enum.py b/samples/client/petstore/python-experimental/petstore_api/models/outer_enum.py index 8796d7d3f2b6..9a933b28169b 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/outer_enum.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/outer_enum.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, diff --git a/samples/client/petstore/python-experimental/petstore_api/models/outer_number.py b/samples/client/petstore/python-experimental/petstore_api/models/outer_number.py index faab717c987e..9f7b3de76d91 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/outer_number.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/outer_number.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, diff --git a/samples/client/petstore/python-experimental/petstore_api/models/parent.py b/samples/client/petstore/python-experimental/petstore_api/models/parent.py index e75f035ec764..f62abd94ceed 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/parent.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/parent.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -110,7 +111,6 @@ def discriminator(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """parent.Parent - 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 @@ -141,8 +141,15 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf '_from_server': _from_server, '_configuration': _configuration, } - model_args = { + required_args = { } + # remove args whose value is Null because they are unset + required_arg_names = list(required_args.keys()) + for required_arg_name in required_arg_names: + if required_args[required_arg_name] is nulltype.Null: + del required_args[required_arg_name] + model_args = {} + model_args.update(required_args) model_args.update(kwargs) composed_info = validate_get_composed_info( constant_args, model_args, self) @@ -151,6 +158,8 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._additional_properties_model_instances = composed_info[2] unused_args = composed_info[3] + for var_name, var_value in required_args.items(): + setattr(self, var_name, var_value) for var_name, var_value in six.iteritems(kwargs): if var_name in unused_args and \ self._configuration is not None and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/parent_all_of.py b/samples/client/petstore/python-experimental/petstore_api/models/parent_all_of.py index 49639b575660..f927649600bd 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/parent_all_of.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/parent_all_of.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """parent_all_of.ParentAllOf - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/parent_pet.py b/samples/client/petstore/python-experimental/petstore_api/models/parent_pet.py index 9ef05ab1a4a5..cdb96676c555 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/parent_pet.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/parent_pet.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -155,9 +156,16 @@ def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item '_from_server': _from_server, '_configuration': _configuration, } - model_args = { + required_args = { 'pet_type': pet_type, } + # remove args whose value is Null because they are unset + required_arg_names = list(required_args.keys()) + for required_arg_name in required_arg_names: + if required_args[required_arg_name] is nulltype.Null: + del required_args[required_arg_name] + model_args = {} + model_args.update(required_args) model_args.update(kwargs) composed_info = validate_get_composed_info( constant_args, model_args, self) @@ -166,7 +174,8 @@ def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item self._additional_properties_model_instances = composed_info[2] unused_args = composed_info[3] - self.pet_type = pet_type + for var_name, var_value in required_args.items(): + setattr(self, var_name, var_value) for var_name, var_value in six.iteritems(kwargs): if var_name in unused_args and \ self._configuration is not None and \ diff --git a/samples/client/petstore/python-experimental/petstore_api/models/pet.py b/samples/client/petstore/python-experimental/petstore_api/models/pet.py index 1682c3cb51b2..74cd8afef1af 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/pet.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/pet.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, diff --git a/samples/client/petstore/python-experimental/petstore_api/models/player.py b/samples/client/petstore/python-experimental/petstore_api/models/player.py index 4e2933ab4194..ea8d2a99456d 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/player.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/player.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, diff --git a/samples/client/petstore/python-experimental/petstore_api/models/read_only_first.py b/samples/client/petstore/python-experimental/petstore_api/models/read_only_first.py index 6a18e6331f61..329ec017d435 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/read_only_first.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/read_only_first.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -101,7 +102,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """read_only_first.ReadOnlyFirst - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/special_model_name.py b/samples/client/petstore/python-experimental/petstore_api/models/special_model_name.py index 006f9454b854..d4ffc608a579 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/special_model_name.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/special_model_name.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """special_model_name.SpecialModelName - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/string_boolean_map.py b/samples/client/petstore/python-experimental/petstore_api/models/string_boolean_map.py index d7b0b0a94501..7f797f5f1b5d 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/string_boolean_map.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/string_boolean_map.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -97,7 +98,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """string_boolean_map.StringBooleanMap - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/tag.py b/samples/client/petstore/python-experimental/petstore_api/models/tag.py index 6c529a5785dd..9af85413b39d 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/tag.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/tag.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -103,7 +104,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """tag.Tag - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/type_holder_default.py b/samples/client/petstore/python-experimental/petstore_api/models/type_holder_default.py index 8579bfc1a17b..acde27d37ab4 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/type_holder_default.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/type_holder_default.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -115,10 +116,10 @@ def __init__(self, array_item, string_item='what', number_item=1.234, integer_it array_item ([int]): Keyword Args: - string_item (str): defaults to 'what', must be one of ['what'] # noqa: E501 - number_item (float): defaults to 1.234, must be one of [1.234] # noqa: E501 - integer_item (int): defaults to -2, must be one of [-2] # noqa: E501 - bool_item (bool): defaults to True, must be one of [True] # noqa: E501 + string_item (str): defaults to 'what' # noqa: E501 + number_item (float): defaults to 1.234 # noqa: E501 + integer_item (int): defaults to -2 # noqa: E501 + bool_item (bool): defaults to True # noqa: E501 _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. diff --git a/samples/client/petstore/python-experimental/petstore_api/models/type_holder_example.py b/samples/client/petstore/python-experimental/petstore_api/models/type_holder_example.py index 8c78ff54a7d2..dc8b5116da09 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/type_holder_example.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/type_holder_example.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -121,9 +122,9 @@ def __init__(self, bool_item, array_item, string_item='what', number_item=1.234, array_item ([int]): Keyword Args: - string_item (str): defaults to 'what', must be one of ['what'] # noqa: E501 - number_item (float): defaults to 1.234, must be one of [1.234] # noqa: E501 - integer_item (int): defaults to -2, must be one of [-2] # noqa: E501 + string_item (str): defaults to 'what', must be one of ["what", ] # noqa: E501 + number_item (float): defaults to 1.234, must be one of [1.234, ] # noqa: E501 + integer_item (int): defaults to -2, must be one of [-2, ] # noqa: E501 _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. diff --git a/samples/client/petstore/python-experimental/petstore_api/models/user.py b/samples/client/petstore/python-experimental/petstore_api/models/user.py index 3776e7e7f3f8..3b2eeb54b3d9 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/user.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/user.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -113,7 +114,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """user.User - 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 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/xml_item.py b/samples/client/petstore/python-experimental/petstore_api/models/xml_item.py index 142c5ea2d6ff..3bcd62804dda 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/xml_item.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/xml_item.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -155,7 +156,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """xml_item.XmlItem - 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 diff --git a/samples/client/petstore/python-experimental/requirements.txt b/samples/client/petstore/python-experimental/requirements.txt index eb358efd5bd3..a56bedffbf57 100644 --- a/samples/client/petstore/python-experimental/requirements.txt +++ b/samples/client/petstore/python-experimental/requirements.txt @@ -1,3 +1,4 @@ +nulltype certifi >= 14.05.14 future; python_version<="2.7" six >= 1.10 diff --git a/samples/client/petstore/python-experimental/setup.py b/samples/client/petstore/python-experimental/setup.py index 7fef185a1a43..09b715bbccba 100644 --- a/samples/client/petstore/python-experimental/setup.py +++ b/samples/client/petstore/python-experimental/setup.py @@ -26,6 +26,7 @@ "six >= 1.10", "certifi", "python-dateutil", + "nulltype", ] EXTRAS = {':python_version <= "2.7"': ['future']} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/README.md b/samples/openapi3/client/petstore/go-experimental/go-petstore/README.md index a7fa78304046..1467a6316fc8 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/README.md +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/README.md @@ -117,9 +117,13 @@ Class | Method | HTTP request | Description - [AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md) - [Animal](docs/Animal.md) - [ApiResponse](docs/ApiResponse.md) + - [Apple](docs/Apple.md) + - [AppleReq](docs/AppleReq.md) - [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md) - [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) - [ArrayTest](docs/ArrayTest.md) + - [Banana](docs/Banana.md) + - [BananaReq](docs/BananaReq.md) - [Capitalization](docs/Capitalization.md) - [Cat](docs/Cat.md) - [CatAllOf](docs/CatAllOf.md) @@ -135,6 +139,9 @@ Class | Method | HTTP request | Description - [FileSchemaTestClass](docs/FileSchemaTestClass.md) - [Foo](docs/Foo.md) - [FormatTest](docs/FormatTest.md) + - [Fruit](docs/Fruit.md) + - [FruitReq](docs/FruitReq.md) + - [GmFruit](docs/GmFruit.md) - [HasOnlyReadOnly](docs/HasOnlyReadOnly.md) - [HealthCheckResult](docs/HealthCheckResult.md) - [InlineObject](docs/InlineObject.md) @@ -145,6 +152,7 @@ Class | Method | HTTP request | Description - [InlineObject5](docs/InlineObject5.md) - [InlineResponseDefault](docs/InlineResponseDefault.md) - [List](docs/List.md) + - [Mammal](docs/Mammal.md) - [MapTest](docs/MapTest.md) - [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) - [Model200Response](docs/Model200Response.md) @@ -163,6 +171,8 @@ Class | Method | HTTP request | Description - [SpecialModelName](docs/SpecialModelName.md) - [Tag](docs/Tag.md) - [User](docs/User.md) + - [Whale](docs/Whale.md) + - [Zebra](docs/Zebra.md) ## Documentation For Authorization diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/api/openapi.yaml b/samples/openapi3/client/petstore/go-experimental/go-petstore/api/openapi.yaml index b141d4d19b76..f27d7ff9c2d6 100644 --- a/samples/openapi3/client/petstore/go-experimental/go-petstore/api/openapi.yaml +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/api/openapi.yaml @@ -1892,6 +1892,88 @@ components: type: object type: object type: object + fruit: + oneOf: + - $ref: '#/components/schemas/apple' + - $ref: '#/components/schemas/banana' + properties: + color: + type: string + x-oneOf-name: Fruit + apple: + properties: + cultivar: + type: string + type: object + banana: + properties: + lengthCm: + type: number + type: object + mammal: + discriminator: + mapping: + whale: '#/components/schemas/whale' + zebra: '#/components/schemas/zebra' + propertyName: className + oneOf: + - $ref: '#/components/schemas/whale' + - $ref: '#/components/schemas/zebra' + x-oneOf-name: Mammal + whale: + properties: + hasBaleen: + type: boolean + hasTeeth: + type: boolean + className: + type: string + required: + - className + type: object + zebra: + properties: + type: + enum: + - plains + - mountain + - grevys + type: string + className: + type: string + required: + - className + type: object + gmFruit: + anyOf: + - $ref: '#/components/schemas/apple' + - $ref: '#/components/schemas/banana' + properties: + color: + type: string + fruitReq: + oneOf: + - $ref: '#/components/schemas/appleReq' + - $ref: '#/components/schemas/bananaReq' + x-oneOf-name: FruitReq + appleReq: + properties: + cultivar: + type: string + mealy: + type: boolean + required: + - cultivar + type: object + bananaReq: + properties: + lengthCm: + type: number + sweet: + type: boolean + required: + - lengthCm + type: object inline_response_default: example: string: diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/Apple.md b/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/Apple.md new file mode 100644 index 000000000000..6f0a8ad62b71 --- /dev/null +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/Apple.md @@ -0,0 +1,88 @@ +# Apple + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Cultivar** | Pointer to **string** | | [optional] +**Color** | Pointer to **string** | | [optional] + +## Methods + +### NewApple + +`func NewApple() *Apple` + +NewApple instantiates a new Apple object +This constructor will assign default values to properties that have it defined, +and makes sure properties required by API are set, but the set of arguments +will change when the set of required properties is changed + +### NewAppleWithDefaults + +`func NewAppleWithDefaults() *Apple` + +NewAppleWithDefaults instantiates a new Apple object +This constructor will only assign default values to properties that have it defined, +but it doesn't guarantee that properties required by API are set + +### GetCultivar + +`func (o *Apple) GetCultivar() string` + +GetCultivar returns the Cultivar field if non-nil, zero value otherwise. + +### GetCultivarOk + +`func (o *Apple) GetCultivarOk() (string, bool)` + +GetCultivarOk returns a tuple with the Cultivar field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### HasCultivar + +`func (o *Apple) HasCultivar() bool` + +HasCultivar returns a boolean if a field has been set. + +### SetCultivar + +`func (o *Apple) SetCultivar(v string)` + +SetCultivar gets a reference to the given string and assigns it to the Cultivar field. + +### GetColor + +`func (o *Apple) GetColor() string` + +GetColor returns the Color field if non-nil, zero value otherwise. + +### GetColorOk + +`func (o *Apple) GetColorOk() (string, bool)` + +GetColorOk returns a tuple with the Color field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### HasColor + +`func (o *Apple) HasColor() bool` + +HasColor returns a boolean if a field has been set. + +### SetColor + +`func (o *Apple) SetColor(v string)` + +SetColor gets a reference to the given string and assigns it to the Color field. + + +### AsFruit + +`func (s *Apple) AsFruit() Fruit` + +Convenience method to wrap this instance of Apple in Fruit + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/AppleReq.md b/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/AppleReq.md new file mode 100644 index 000000000000..53e41afbd080 --- /dev/null +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/AppleReq.md @@ -0,0 +1,88 @@ +# AppleReq + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Cultivar** | Pointer to **string** | | +**Mealy** | Pointer to **bool** | | [optional] + +## Methods + +### NewAppleReq + +`func NewAppleReq(cultivar string, ) *AppleReq` + +NewAppleReq instantiates a new AppleReq object +This constructor will assign default values to properties that have it defined, +and makes sure properties required by API are set, but the set of arguments +will change when the set of required properties is changed + +### NewAppleReqWithDefaults + +`func NewAppleReqWithDefaults() *AppleReq` + +NewAppleReqWithDefaults instantiates a new AppleReq object +This constructor will only assign default values to properties that have it defined, +but it doesn't guarantee that properties required by API are set + +### GetCultivar + +`func (o *AppleReq) GetCultivar() string` + +GetCultivar returns the Cultivar field if non-nil, zero value otherwise. + +### GetCultivarOk + +`func (o *AppleReq) GetCultivarOk() (string, bool)` + +GetCultivarOk returns a tuple with the Cultivar field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### HasCultivar + +`func (o *AppleReq) HasCultivar() bool` + +HasCultivar returns a boolean if a field has been set. + +### SetCultivar + +`func (o *AppleReq) SetCultivar(v string)` + +SetCultivar gets a reference to the given string and assigns it to the Cultivar field. + +### GetMealy + +`func (o *AppleReq) GetMealy() bool` + +GetMealy returns the Mealy field if non-nil, zero value otherwise. + +### GetMealyOk + +`func (o *AppleReq) GetMealyOk() (bool, bool)` + +GetMealyOk returns a tuple with the Mealy field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### HasMealy + +`func (o *AppleReq) HasMealy() bool` + +HasMealy returns a boolean if a field has been set. + +### SetMealy + +`func (o *AppleReq) SetMealy(v bool)` + +SetMealy gets a reference to the given bool and assigns it to the Mealy field. + + +### AsFruitReq + +`func (s *AppleReq) AsFruitReq() FruitReq` + +Convenience method to wrap this instance of AppleReq in FruitReq + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/Banana.md b/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/Banana.md new file mode 100644 index 000000000000..a20d3abbfd6e --- /dev/null +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/Banana.md @@ -0,0 +1,88 @@ +# Banana + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**LengthCm** | Pointer to **float32** | | [optional] +**Color** | Pointer to **string** | | [optional] + +## Methods + +### NewBanana + +`func NewBanana() *Banana` + +NewBanana instantiates a new Banana object +This constructor will assign default values to properties that have it defined, +and makes sure properties required by API are set, but the set of arguments +will change when the set of required properties is changed + +### NewBananaWithDefaults + +`func NewBananaWithDefaults() *Banana` + +NewBananaWithDefaults instantiates a new Banana object +This constructor will only assign default values to properties that have it defined, +but it doesn't guarantee that properties required by API are set + +### GetLengthCm + +`func (o *Banana) GetLengthCm() float32` + +GetLengthCm returns the LengthCm field if non-nil, zero value otherwise. + +### GetLengthCmOk + +`func (o *Banana) GetLengthCmOk() (float32, bool)` + +GetLengthCmOk returns a tuple with the LengthCm field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### HasLengthCm + +`func (o *Banana) HasLengthCm() bool` + +HasLengthCm returns a boolean if a field has been set. + +### SetLengthCm + +`func (o *Banana) SetLengthCm(v float32)` + +SetLengthCm gets a reference to the given float32 and assigns it to the LengthCm field. + +### GetColor + +`func (o *Banana) GetColor() string` + +GetColor returns the Color field if non-nil, zero value otherwise. + +### GetColorOk + +`func (o *Banana) GetColorOk() (string, bool)` + +GetColorOk returns a tuple with the Color field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### HasColor + +`func (o *Banana) HasColor() bool` + +HasColor returns a boolean if a field has been set. + +### SetColor + +`func (o *Banana) SetColor(v string)` + +SetColor gets a reference to the given string and assigns it to the Color field. + + +### AsFruit + +`func (s *Banana) AsFruit() Fruit` + +Convenience method to wrap this instance of Banana in Fruit + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/BananaReq.md b/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/BananaReq.md new file mode 100644 index 000000000000..e9ffa23a1142 --- /dev/null +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/BananaReq.md @@ -0,0 +1,88 @@ +# BananaReq + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**LengthCm** | Pointer to **float32** | | +**Sweet** | Pointer to **bool** | | [optional] + +## Methods + +### NewBananaReq + +`func NewBananaReq(lengthCm float32, ) *BananaReq` + +NewBananaReq instantiates a new BananaReq object +This constructor will assign default values to properties that have it defined, +and makes sure properties required by API are set, but the set of arguments +will change when the set of required properties is changed + +### NewBananaReqWithDefaults + +`func NewBananaReqWithDefaults() *BananaReq` + +NewBananaReqWithDefaults instantiates a new BananaReq object +This constructor will only assign default values to properties that have it defined, +but it doesn't guarantee that properties required by API are set + +### GetLengthCm + +`func (o *BananaReq) GetLengthCm() float32` + +GetLengthCm returns the LengthCm field if non-nil, zero value otherwise. + +### GetLengthCmOk + +`func (o *BananaReq) GetLengthCmOk() (float32, bool)` + +GetLengthCmOk returns a tuple with the LengthCm field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### HasLengthCm + +`func (o *BananaReq) HasLengthCm() bool` + +HasLengthCm returns a boolean if a field has been set. + +### SetLengthCm + +`func (o *BananaReq) SetLengthCm(v float32)` + +SetLengthCm gets a reference to the given float32 and assigns it to the LengthCm field. + +### GetSweet + +`func (o *BananaReq) GetSweet() bool` + +GetSweet returns the Sweet field if non-nil, zero value otherwise. + +### GetSweetOk + +`func (o *BananaReq) GetSweetOk() (bool, bool)` + +GetSweetOk returns a tuple with the Sweet field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### HasSweet + +`func (o *BananaReq) HasSweet() bool` + +HasSweet returns a boolean if a field has been set. + +### SetSweet + +`func (o *BananaReq) SetSweet(v bool)` + +SetSweet gets a reference to the given bool and assigns it to the Sweet field. + + +### AsFruitReq + +`func (s *BananaReq) AsFruitReq() FruitReq` + +Convenience method to wrap this instance of BananaReq in FruitReq + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/Fruit.md b/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/Fruit.md new file mode 100644 index 000000000000..fa033d3ef6f0 --- /dev/null +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/Fruit.md @@ -0,0 +1,14 @@ +# Fruit + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**FruitInterface** | **interface { }** | An interface that can hold any of the proper implementing types | + +## Methods + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/FruitReq.md b/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/FruitReq.md new file mode 100644 index 000000000000..c22de7800645 --- /dev/null +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/FruitReq.md @@ -0,0 +1,14 @@ +# FruitReq + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**FruitReqInterface** | **interface { }** | An interface that can hold any of the proper implementing types | + +## Methods + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/GmFruit.md b/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/GmFruit.md new file mode 100644 index 000000000000..fc71d4e30ec5 --- /dev/null +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/GmFruit.md @@ -0,0 +1,108 @@ +# GmFruit + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Color** | Pointer to **string** | | [optional] +**Cultivar** | Pointer to **string** | | [optional] +**LengthCm** | Pointer to **float32** | | [optional] + +## Methods + +### NewGmFruit + +`func NewGmFruit() *GmFruit` + +NewGmFruit instantiates a new GmFruit object +This constructor will assign default values to properties that have it defined, +and makes sure properties required by API are set, but the set of arguments +will change when the set of required properties is changed + +### NewGmFruitWithDefaults + +`func NewGmFruitWithDefaults() *GmFruit` + +NewGmFruitWithDefaults instantiates a new GmFruit object +This constructor will only assign default values to properties that have it defined, +but it doesn't guarantee that properties required by API are set + +### GetColor + +`func (o *GmFruit) GetColor() string` + +GetColor returns the Color field if non-nil, zero value otherwise. + +### GetColorOk + +`func (o *GmFruit) GetColorOk() (string, bool)` + +GetColorOk returns a tuple with the Color field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### HasColor + +`func (o *GmFruit) HasColor() bool` + +HasColor returns a boolean if a field has been set. + +### SetColor + +`func (o *GmFruit) SetColor(v string)` + +SetColor gets a reference to the given string and assigns it to the Color field. + +### GetCultivar + +`func (o *GmFruit) GetCultivar() string` + +GetCultivar returns the Cultivar field if non-nil, zero value otherwise. + +### GetCultivarOk + +`func (o *GmFruit) GetCultivarOk() (string, bool)` + +GetCultivarOk returns a tuple with the Cultivar field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### HasCultivar + +`func (o *GmFruit) HasCultivar() bool` + +HasCultivar returns a boolean if a field has been set. + +### SetCultivar + +`func (o *GmFruit) SetCultivar(v string)` + +SetCultivar gets a reference to the given string and assigns it to the Cultivar field. + +### GetLengthCm + +`func (o *GmFruit) GetLengthCm() float32` + +GetLengthCm returns the LengthCm field if non-nil, zero value otherwise. + +### GetLengthCmOk + +`func (o *GmFruit) GetLengthCmOk() (float32, bool)` + +GetLengthCmOk returns a tuple with the LengthCm field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### HasLengthCm + +`func (o *GmFruit) HasLengthCm() bool` + +HasLengthCm returns a boolean if a field has been set. + +### SetLengthCm + +`func (o *GmFruit) SetLengthCm(v float32)` + +SetLengthCm gets a reference to the given float32 and assigns it to the LengthCm field. + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/Mammal.md b/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/Mammal.md new file mode 100644 index 000000000000..7d3dfe04b15f --- /dev/null +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/Mammal.md @@ -0,0 +1,14 @@ +# Mammal + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**MammalInterface** | **interface { GetClassName() string }** | An interface that can hold any of the proper implementing types | + +## Methods + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/Whale.md b/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/Whale.md new file mode 100644 index 000000000000..301b91e4fd0c --- /dev/null +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/Whale.md @@ -0,0 +1,114 @@ +# Whale + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**HasBaleen** | Pointer to **bool** | | [optional] +**HasTeeth** | Pointer to **bool** | | [optional] +**ClassName** | Pointer to **string** | | + +## Methods + +### NewWhale + +`func NewWhale(className string, ) *Whale` + +NewWhale instantiates a new Whale object +This constructor will assign default values to properties that have it defined, +and makes sure properties required by API are set, but the set of arguments +will change when the set of required properties is changed + +### NewWhaleWithDefaults + +`func NewWhaleWithDefaults() *Whale` + +NewWhaleWithDefaults instantiates a new Whale object +This constructor will only assign default values to properties that have it defined, +but it doesn't guarantee that properties required by API are set + +### GetHasBaleen + +`func (o *Whale) GetHasBaleen() bool` + +GetHasBaleen returns the HasBaleen field if non-nil, zero value otherwise. + +### GetHasBaleenOk + +`func (o *Whale) GetHasBaleenOk() (bool, bool)` + +GetHasBaleenOk returns a tuple with the HasBaleen field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### HasHasBaleen + +`func (o *Whale) HasHasBaleen() bool` + +HasHasBaleen returns a boolean if a field has been set. + +### SetHasBaleen + +`func (o *Whale) SetHasBaleen(v bool)` + +SetHasBaleen gets a reference to the given bool and assigns it to the HasBaleen field. + +### GetHasTeeth + +`func (o *Whale) GetHasTeeth() bool` + +GetHasTeeth returns the HasTeeth field if non-nil, zero value otherwise. + +### GetHasTeethOk + +`func (o *Whale) GetHasTeethOk() (bool, bool)` + +GetHasTeethOk returns a tuple with the HasTeeth field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### HasHasTeeth + +`func (o *Whale) HasHasTeeth() bool` + +HasHasTeeth returns a boolean if a field has been set. + +### SetHasTeeth + +`func (o *Whale) SetHasTeeth(v bool)` + +SetHasTeeth gets a reference to the given bool and assigns it to the HasTeeth field. + +### GetClassName + +`func (o *Whale) GetClassName() string` + +GetClassName returns the ClassName field if non-nil, zero value otherwise. + +### GetClassNameOk + +`func (o *Whale) GetClassNameOk() (string, bool)` + +GetClassNameOk returns a tuple with the ClassName field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### HasClassName + +`func (o *Whale) HasClassName() bool` + +HasClassName returns a boolean if a field has been set. + +### SetClassName + +`func (o *Whale) SetClassName(v string)` + +SetClassName gets a reference to the given string and assigns it to the ClassName field. + + +### AsMammal + +`func (s *Whale) AsMammal() Mammal` + +Convenience method to wrap this instance of Whale in Mammal + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/Zebra.md b/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/Zebra.md new file mode 100644 index 000000000000..18147cffdf26 --- /dev/null +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/docs/Zebra.md @@ -0,0 +1,88 @@ +# Zebra + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Type** | Pointer to **string** | | [optional] +**ClassName** | Pointer to **string** | | + +## Methods + +### NewZebra + +`func NewZebra(className string, ) *Zebra` + +NewZebra instantiates a new Zebra object +This constructor will assign default values to properties that have it defined, +and makes sure properties required by API are set, but the set of arguments +will change when the set of required properties is changed + +### NewZebraWithDefaults + +`func NewZebraWithDefaults() *Zebra` + +NewZebraWithDefaults instantiates a new Zebra object +This constructor will only assign default values to properties that have it defined, +but it doesn't guarantee that properties required by API are set + +### GetType + +`func (o *Zebra) GetType() string` + +GetType returns the Type field if non-nil, zero value otherwise. + +### GetTypeOk + +`func (o *Zebra) GetTypeOk() (string, bool)` + +GetTypeOk returns a tuple with the Type field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### HasType + +`func (o *Zebra) HasType() bool` + +HasType returns a boolean if a field has been set. + +### SetType + +`func (o *Zebra) SetType(v string)` + +SetType gets a reference to the given string and assigns it to the Type field. + +### GetClassName + +`func (o *Zebra) GetClassName() string` + +GetClassName returns the ClassName field if non-nil, zero value otherwise. + +### GetClassNameOk + +`func (o *Zebra) GetClassNameOk() (string, bool)` + +GetClassNameOk returns a tuple with the ClassName field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### HasClassName + +`func (o *Zebra) HasClassName() bool` + +HasClassName returns a boolean if a field has been set. + +### SetClassName + +`func (o *Zebra) SetClassName(v string)` + +SetClassName gets a reference to the given string and assigns it to the ClassName field. + + +### AsMammal + +`func (s *Zebra) AsMammal() Mammal` + +Convenience method to wrap this instance of Zebra in Mammal + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_apple.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_apple.go new file mode 100644 index 000000000000..91603b510a7c --- /dev/null +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_apple.go @@ -0,0 +1,131 @@ +/* + * 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: \" \\ + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package petstore + +import ( + "bytes" + "encoding/json" +) + +// Apple struct for Apple +type Apple struct { + Cultivar *string `json:"cultivar,omitempty"` + Color *string `json:"color,omitempty"` +} + +// NewApple instantiates a new Apple object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewApple() *Apple { + this := Apple{} + return &this +} + +// NewAppleWithDefaults instantiates a new Apple object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewAppleWithDefaults() *Apple { + this := Apple{} + return &this +} + +// GetCultivar returns the Cultivar field value if set, zero value otherwise. +func (o *Apple) GetCultivar() string { + if o == nil || o.Cultivar == nil { + var ret string + return ret + } + return *o.Cultivar +} + +// GetCultivarOk returns a tuple with the Cultivar field value if set, zero value otherwise +// and a boolean to check if the value has been set. +func (o *Apple) GetCultivarOk() (string, bool) { + if o == nil || o.Cultivar == nil { + var ret string + return ret, false + } + return *o.Cultivar, true +} + +// HasCultivar returns a boolean if a field has been set. +func (o *Apple) HasCultivar() bool { + if o != nil && o.Cultivar != nil { + return true + } + + return false +} + +// SetCultivar gets a reference to the given string and assigns it to the Cultivar field. +func (o *Apple) SetCultivar(v string) { + o.Cultivar = &v +} + +// GetColor returns the Color field value if set, zero value otherwise. +func (o *Apple) GetColor() string { + if o == nil || o.Color == nil { + var ret string + return ret + } + return *o.Color +} + +// GetColorOk returns a tuple with the Color field value if set, zero value otherwise +// and a boolean to check if the value has been set. +func (o *Apple) GetColorOk() (string, bool) { + if o == nil || o.Color == nil { + var ret string + return ret, false + } + return *o.Color, true +} + +// HasColor returns a boolean if a field has been set. +func (o *Apple) HasColor() bool { + if o != nil && o.Color != nil { + return true + } + + return false +} + +// SetColor gets a reference to the given string and assigns it to the Color field. +func (o *Apple) SetColor(v string) { + o.Color = &v +} + +// AsFruit wraps this instance of Apple in Fruit +func (s *Apple) AsFruit() Fruit { + return Fruit{ FruitInterface: s } +} +type NullableApple struct { + Value Apple + ExplicitNull bool +} + +func (v NullableApple) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableApple) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_apple_req.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_apple_req.go new file mode 100644 index 000000000000..6db225a4afe4 --- /dev/null +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_apple_req.go @@ -0,0 +1,114 @@ +/* + * 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: \" \\ + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package petstore + +import ( + "bytes" + "encoding/json" +) + +// AppleReq struct for AppleReq +type AppleReq struct { + Cultivar string `json:"cultivar"` + Mealy *bool `json:"mealy,omitempty"` +} + +// NewAppleReq instantiates a new AppleReq object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewAppleReq(cultivar string, ) *AppleReq { + this := AppleReq{} + this.Cultivar = cultivar + return &this +} + +// NewAppleReqWithDefaults instantiates a new AppleReq object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewAppleReqWithDefaults() *AppleReq { + this := AppleReq{} + return &this +} + +// GetCultivar returns the Cultivar field value +func (o *AppleReq) GetCultivar() string { + if o == nil { + var ret string + return ret + } + + return o.Cultivar +} + +// SetCultivar sets field value +func (o *AppleReq) SetCultivar(v string) { + o.Cultivar = v +} + +// GetMealy returns the Mealy field value if set, zero value otherwise. +func (o *AppleReq) GetMealy() bool { + if o == nil || o.Mealy == nil { + var ret bool + return ret + } + return *o.Mealy +} + +// GetMealyOk returns a tuple with the Mealy field value if set, zero value otherwise +// and a boolean to check if the value has been set. +func (o *AppleReq) GetMealyOk() (bool, bool) { + if o == nil || o.Mealy == nil { + var ret bool + return ret, false + } + return *o.Mealy, true +} + +// HasMealy returns a boolean if a field has been set. +func (o *AppleReq) HasMealy() bool { + if o != nil && o.Mealy != nil { + return true + } + + return false +} + +// SetMealy gets a reference to the given bool and assigns it to the Mealy field. +func (o *AppleReq) SetMealy(v bool) { + o.Mealy = &v +} + +// AsFruitReq wraps this instance of AppleReq in FruitReq +func (s *AppleReq) AsFruitReq() FruitReq { + return FruitReq{ FruitReqInterface: s } +} +type NullableAppleReq struct { + Value AppleReq + ExplicitNull bool +} + +func (v NullableAppleReq) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableAppleReq) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_banana.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_banana.go new file mode 100644 index 000000000000..6d923f239595 --- /dev/null +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_banana.go @@ -0,0 +1,131 @@ +/* + * 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: \" \\ + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package petstore + +import ( + "bytes" + "encoding/json" +) + +// Banana struct for Banana +type Banana struct { + LengthCm *float32 `json:"lengthCm,omitempty"` + Color *string `json:"color,omitempty"` +} + +// NewBanana instantiates a new Banana object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewBanana() *Banana { + this := Banana{} + return &this +} + +// NewBananaWithDefaults instantiates a new Banana object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewBananaWithDefaults() *Banana { + this := Banana{} + return &this +} + +// GetLengthCm returns the LengthCm field value if set, zero value otherwise. +func (o *Banana) GetLengthCm() float32 { + if o == nil || o.LengthCm == nil { + var ret float32 + return ret + } + return *o.LengthCm +} + +// GetLengthCmOk returns a tuple with the LengthCm field value if set, zero value otherwise +// and a boolean to check if the value has been set. +func (o *Banana) GetLengthCmOk() (float32, bool) { + if o == nil || o.LengthCm == nil { + var ret float32 + return ret, false + } + return *o.LengthCm, true +} + +// HasLengthCm returns a boolean if a field has been set. +func (o *Banana) HasLengthCm() bool { + if o != nil && o.LengthCm != nil { + return true + } + + return false +} + +// SetLengthCm gets a reference to the given float32 and assigns it to the LengthCm field. +func (o *Banana) SetLengthCm(v float32) { + o.LengthCm = &v +} + +// GetColor returns the Color field value if set, zero value otherwise. +func (o *Banana) GetColor() string { + if o == nil || o.Color == nil { + var ret string + return ret + } + return *o.Color +} + +// GetColorOk returns a tuple with the Color field value if set, zero value otherwise +// and a boolean to check if the value has been set. +func (o *Banana) GetColorOk() (string, bool) { + if o == nil || o.Color == nil { + var ret string + return ret, false + } + return *o.Color, true +} + +// HasColor returns a boolean if a field has been set. +func (o *Banana) HasColor() bool { + if o != nil && o.Color != nil { + return true + } + + return false +} + +// SetColor gets a reference to the given string and assigns it to the Color field. +func (o *Banana) SetColor(v string) { + o.Color = &v +} + +// AsFruit wraps this instance of Banana in Fruit +func (s *Banana) AsFruit() Fruit { + return Fruit{ FruitInterface: s } +} +type NullableBanana struct { + Value Banana + ExplicitNull bool +} + +func (v NullableBanana) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableBanana) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_banana_req.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_banana_req.go new file mode 100644 index 000000000000..543d4476d688 --- /dev/null +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_banana_req.go @@ -0,0 +1,114 @@ +/* + * 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: \" \\ + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package petstore + +import ( + "bytes" + "encoding/json" +) + +// BananaReq struct for BananaReq +type BananaReq struct { + LengthCm float32 `json:"lengthCm"` + Sweet *bool `json:"sweet,omitempty"` +} + +// NewBananaReq instantiates a new BananaReq object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewBananaReq(lengthCm float32, ) *BananaReq { + this := BananaReq{} + this.LengthCm = lengthCm + return &this +} + +// NewBananaReqWithDefaults instantiates a new BananaReq object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewBananaReqWithDefaults() *BananaReq { + this := BananaReq{} + return &this +} + +// GetLengthCm returns the LengthCm field value +func (o *BananaReq) GetLengthCm() float32 { + if o == nil { + var ret float32 + return ret + } + + return o.LengthCm +} + +// SetLengthCm sets field value +func (o *BananaReq) SetLengthCm(v float32) { + o.LengthCm = v +} + +// GetSweet returns the Sweet field value if set, zero value otherwise. +func (o *BananaReq) GetSweet() bool { + if o == nil || o.Sweet == nil { + var ret bool + return ret + } + return *o.Sweet +} + +// GetSweetOk returns a tuple with the Sweet field value if set, zero value otherwise +// and a boolean to check if the value has been set. +func (o *BananaReq) GetSweetOk() (bool, bool) { + if o == nil || o.Sweet == nil { + var ret bool + return ret, false + } + return *o.Sweet, true +} + +// HasSweet returns a boolean if a field has been set. +func (o *BananaReq) HasSweet() bool { + if o != nil && o.Sweet != nil { + return true + } + + return false +} + +// SetSweet gets a reference to the given bool and assigns it to the Sweet field. +func (o *BananaReq) SetSweet(v bool) { + o.Sweet = &v +} + +// AsFruitReq wraps this instance of BananaReq in FruitReq +func (s *BananaReq) AsFruitReq() FruitReq { + return FruitReq{ FruitReqInterface: s } +} +type NullableBananaReq struct { + Value BananaReq + ExplicitNull bool +} + +func (v NullableBananaReq) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableBananaReq) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_fruit.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_fruit.go new file mode 100644 index 000000000000..c692b3e7eea9 --- /dev/null +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_fruit.go @@ -0,0 +1,64 @@ +/* + * 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: \" \\ + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package petstore + +import ( + "bytes" + "encoding/json" + "fmt" +) + +// Fruit struct for Fruit +type Fruit struct { + FruitInterface interface { } +} + +func (s *Fruit) MarshalJSON() ([]byte, error) { + return json.Marshal(s.FruitInterface) +} + +func (s *Fruit) UnmarshalJSON(src []byte) error { + var err error + var unmarshaledApple *Apple = &Apple{} + err = json.Unmarshal(src, unmarshaledApple) + if err == nil { + s.FruitInterface = unmarshaledApple + return nil + } + var unmarshaledBanana *Banana = &Banana{} + err = json.Unmarshal(src, unmarshaledBanana) + if err == nil { + s.FruitInterface = unmarshaledBanana + return nil + } + return fmt.Errorf("No oneOf model could be deserialized from payload: %s", string(src)) +} +type NullableFruit struct { + Value Fruit + ExplicitNull bool +} + +func (v NullableFruit) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableFruit) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_fruit_req.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_fruit_req.go new file mode 100644 index 000000000000..be4dd6864b49 --- /dev/null +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_fruit_req.go @@ -0,0 +1,64 @@ +/* + * 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: \" \\ + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package petstore + +import ( + "bytes" + "encoding/json" + "fmt" +) + +// FruitReq struct for FruitReq +type FruitReq struct { + FruitReqInterface interface { } +} + +func (s *FruitReq) MarshalJSON() ([]byte, error) { + return json.Marshal(s.FruitReqInterface) +} + +func (s *FruitReq) UnmarshalJSON(src []byte) error { + var err error + var unmarshaledAppleReq *AppleReq = &AppleReq{} + err = json.Unmarshal(src, unmarshaledAppleReq) + if err == nil { + s.FruitReqInterface = unmarshaledAppleReq + return nil + } + var unmarshaledBananaReq *BananaReq = &BananaReq{} + err = json.Unmarshal(src, unmarshaledBananaReq) + if err == nil { + s.FruitReqInterface = unmarshaledBananaReq + return nil + } + return fmt.Errorf("No oneOf model could be deserialized from payload: %s", string(src)) +} +type NullableFruitReq struct { + Value FruitReq + ExplicitNull bool +} + +func (v NullableFruitReq) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableFruitReq) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_gm_fruit.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_gm_fruit.go new file mode 100644 index 000000000000..c0350d87e064 --- /dev/null +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_gm_fruit.go @@ -0,0 +1,161 @@ +/* + * 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: \" \\ + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package petstore + +import ( + "bytes" + "encoding/json" +) + +// GmFruit struct for GmFruit +type GmFruit struct { + Color *string `json:"color,omitempty"` + Cultivar *string `json:"cultivar,omitempty"` + LengthCm *float32 `json:"lengthCm,omitempty"` +} + +// NewGmFruit instantiates a new GmFruit object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewGmFruit() *GmFruit { + this := GmFruit{} + return &this +} + +// NewGmFruitWithDefaults instantiates a new GmFruit object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewGmFruitWithDefaults() *GmFruit { + this := GmFruit{} + return &this +} + +// GetColor returns the Color field value if set, zero value otherwise. +func (o *GmFruit) GetColor() string { + if o == nil || o.Color == nil { + var ret string + return ret + } + return *o.Color +} + +// GetColorOk returns a tuple with the Color field value if set, zero value otherwise +// and a boolean to check if the value has been set. +func (o *GmFruit) GetColorOk() (string, bool) { + if o == nil || o.Color == nil { + var ret string + return ret, false + } + return *o.Color, true +} + +// HasColor returns a boolean if a field has been set. +func (o *GmFruit) HasColor() bool { + if o != nil && o.Color != nil { + return true + } + + return false +} + +// SetColor gets a reference to the given string and assigns it to the Color field. +func (o *GmFruit) SetColor(v string) { + o.Color = &v +} + +// GetCultivar returns the Cultivar field value if set, zero value otherwise. +func (o *GmFruit) GetCultivar() string { + if o == nil || o.Cultivar == nil { + var ret string + return ret + } + return *o.Cultivar +} + +// GetCultivarOk returns a tuple with the Cultivar field value if set, zero value otherwise +// and a boolean to check if the value has been set. +func (o *GmFruit) GetCultivarOk() (string, bool) { + if o == nil || o.Cultivar == nil { + var ret string + return ret, false + } + return *o.Cultivar, true +} + +// HasCultivar returns a boolean if a field has been set. +func (o *GmFruit) HasCultivar() bool { + if o != nil && o.Cultivar != nil { + return true + } + + return false +} + +// SetCultivar gets a reference to the given string and assigns it to the Cultivar field. +func (o *GmFruit) SetCultivar(v string) { + o.Cultivar = &v +} + +// GetLengthCm returns the LengthCm field value if set, zero value otherwise. +func (o *GmFruit) GetLengthCm() float32 { + if o == nil || o.LengthCm == nil { + var ret float32 + return ret + } + return *o.LengthCm +} + +// GetLengthCmOk returns a tuple with the LengthCm field value if set, zero value otherwise +// and a boolean to check if the value has been set. +func (o *GmFruit) GetLengthCmOk() (float32, bool) { + if o == nil || o.LengthCm == nil { + var ret float32 + return ret, false + } + return *o.LengthCm, true +} + +// HasLengthCm returns a boolean if a field has been set. +func (o *GmFruit) HasLengthCm() bool { + if o != nil && o.LengthCm != nil { + return true + } + + return false +} + +// SetLengthCm gets a reference to the given float32 and assigns it to the LengthCm field. +func (o *GmFruit) SetLengthCm(v float32) { + o.LengthCm = &v +} + +type NullableGmFruit struct { + Value GmFruit + ExplicitNull bool +} + +func (v NullableGmFruit) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableGmFruit) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_mammal.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_mammal.go new file mode 100644 index 000000000000..58095a07fab7 --- /dev/null +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_mammal.go @@ -0,0 +1,80 @@ +/* + * 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: \" \\ + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package petstore + +import ( + "bytes" + "encoding/json" + "fmt" +) + +// Mammal struct for Mammal +type Mammal struct { + MammalInterface interface { GetClassName() string } +} + +func (s *Mammal) MarshalJSON() ([]byte, error) { + return json.Marshal(s.MammalInterface) +} + +func (s *Mammal) UnmarshalJSON(src []byte) error { + var err error + var unmarshaled map[string]interface{} + err = json.Unmarshal(src, &unmarshaled) + if err != nil { + return err + } + if v, ok := unmarshaled["className"]; ok { + switch v { + case "whale": + var result *Whale = &Whale{} + err = json.Unmarshal(src, result) + if err != nil { + return err + } + s.MammalInterface = result + return nil + case "zebra": + var result *Zebra = &Zebra{} + err = json.Unmarshal(src, result) + if err != nil { + return err + } + s.MammalInterface = result + return nil + default: + return fmt.Errorf("No oneOf model has 'className' equal to %s", v) + } + } else { + return fmt.Errorf("Discriminator property 'className' not found in unmarshaled payload: %+v", unmarshaled) + } +} +type NullableMammal struct { + Value Mammal + ExplicitNull bool +} + +func (v NullableMammal) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableMammal) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_whale.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_whale.go new file mode 100644 index 000000000000..be28dd59d354 --- /dev/null +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_whale.go @@ -0,0 +1,148 @@ +/* + * 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: \" \\ + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package petstore + +import ( + "bytes" + "encoding/json" +) + +// Whale struct for Whale +type Whale struct { + HasBaleen *bool `json:"hasBaleen,omitempty"` + HasTeeth *bool `json:"hasTeeth,omitempty"` + ClassName string `json:"className"` +} + +// NewWhale instantiates a new Whale object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewWhale(className string, ) *Whale { + this := Whale{} + this.ClassName = className + return &this +} + +// NewWhaleWithDefaults instantiates a new Whale object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewWhaleWithDefaults() *Whale { + this := Whale{} + return &this +} + +// GetHasBaleen returns the HasBaleen field value if set, zero value otherwise. +func (o *Whale) GetHasBaleen() bool { + if o == nil || o.HasBaleen == nil { + var ret bool + return ret + } + return *o.HasBaleen +} + +// GetHasBaleenOk returns a tuple with the HasBaleen field value if set, zero value otherwise +// and a boolean to check if the value has been set. +func (o *Whale) GetHasBaleenOk() (bool, bool) { + if o == nil || o.HasBaleen == nil { + var ret bool + return ret, false + } + return *o.HasBaleen, true +} + +// HasHasBaleen returns a boolean if a field has been set. +func (o *Whale) HasHasBaleen() bool { + if o != nil && o.HasBaleen != nil { + return true + } + + return false +} + +// SetHasBaleen gets a reference to the given bool and assigns it to the HasBaleen field. +func (o *Whale) SetHasBaleen(v bool) { + o.HasBaleen = &v +} + +// GetHasTeeth returns the HasTeeth field value if set, zero value otherwise. +func (o *Whale) GetHasTeeth() bool { + if o == nil || o.HasTeeth == nil { + var ret bool + return ret + } + return *o.HasTeeth +} + +// GetHasTeethOk returns a tuple with the HasTeeth field value if set, zero value otherwise +// and a boolean to check if the value has been set. +func (o *Whale) GetHasTeethOk() (bool, bool) { + if o == nil || o.HasTeeth == nil { + var ret bool + return ret, false + } + return *o.HasTeeth, true +} + +// HasHasTeeth returns a boolean if a field has been set. +func (o *Whale) HasHasTeeth() bool { + if o != nil && o.HasTeeth != nil { + return true + } + + return false +} + +// SetHasTeeth gets a reference to the given bool and assigns it to the HasTeeth field. +func (o *Whale) SetHasTeeth(v bool) { + o.HasTeeth = &v +} + +// GetClassName returns the ClassName field value +func (o *Whale) GetClassName() string { + if o == nil { + var ret string + return ret + } + + return o.ClassName +} + +// SetClassName sets field value +func (o *Whale) SetClassName(v string) { + o.ClassName = v +} + +// AsMammal wraps this instance of Whale in Mammal +func (s *Whale) AsMammal() Mammal { + return Mammal{ MammalInterface: s } +} +type NullableWhale struct { + Value Whale + ExplicitNull bool +} + +func (v NullableWhale) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableWhale) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/go-experimental/go-petstore/model_zebra.go b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_zebra.go new file mode 100644 index 000000000000..bffa8eb7b851 --- /dev/null +++ b/samples/openapi3/client/petstore/go-experimental/go-petstore/model_zebra.go @@ -0,0 +1,114 @@ +/* + * 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: \" \\ + * + * API version: 1.0.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package petstore + +import ( + "bytes" + "encoding/json" +) + +// Zebra struct for Zebra +type Zebra struct { + Type *string `json:"type,omitempty"` + ClassName string `json:"className"` +} + +// NewZebra instantiates a new Zebra object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewZebra(className string, ) *Zebra { + this := Zebra{} + this.ClassName = className + return &this +} + +// NewZebraWithDefaults instantiates a new Zebra object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewZebraWithDefaults() *Zebra { + this := Zebra{} + return &this +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *Zebra) GetType() string { + if o == nil || o.Type == nil { + var ret string + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, zero value otherwise +// and a boolean to check if the value has been set. +func (o *Zebra) GetTypeOk() (string, bool) { + if o == nil || o.Type == nil { + var ret string + return ret, false + } + return *o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *Zebra) HasType() bool { + if o != nil && o.Type != nil { + return true + } + + return false +} + +// SetType gets a reference to the given string and assigns it to the Type field. +func (o *Zebra) SetType(v string) { + o.Type = &v +} + +// GetClassName returns the ClassName field value +func (o *Zebra) GetClassName() string { + if o == nil { + var ret string + return ret + } + + return o.ClassName +} + +// SetClassName sets field value +func (o *Zebra) SetClassName(v string) { + o.ClassName = v +} + +// AsMammal wraps this instance of Zebra in Mammal +func (s *Zebra) AsMammal() Mammal { + return Mammal{ MammalInterface: s } +} +type NullableZebra struct { + Value Zebra + ExplicitNull bool +} + +func (v NullableZebra) MarshalJSON() ([]byte, error) { + switch { + case v.ExplicitNull: + return []byte("null"), nil + default: + return json.Marshal(v.Value) + } +} + +func (v *NullableZebra) UnmarshalJSON(src []byte) error { + if bytes.Equal(src, []byte("null")) { + v.ExplicitNull = true + return nil + } + + return json.Unmarshal(src, &v.Value) +} diff --git a/samples/openapi3/client/petstore/python-experimental/README.md b/samples/openapi3/client/petstore/python-experimental/README.md index 7c1b27f95a4d..a0988878b947 100644 --- a/samples/openapi3/client/petstore/python-experimental/README.md +++ b/samples/openapi3/client/petstore/python-experimental/README.md @@ -120,9 +120,13 @@ Class | Method | HTTP request | Description - [address.Address](docs/Address.md) - [animal.Animal](docs/Animal.md) - [api_response.ApiResponse](docs/ApiResponse.md) + - [apple.Apple](docs/Apple.md) + - [apple_req.AppleReq](docs/AppleReq.md) - [array_of_array_of_number_only.ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md) - [array_of_number_only.ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) - [array_test.ArrayTest](docs/ArrayTest.md) + - [banana.Banana](docs/Banana.md) + - [banana_req.BananaReq](docs/BananaReq.md) - [capitalization.Capitalization](docs/Capitalization.md) - [cat.Cat](docs/Cat.md) - [cat_all_of.CatAllOf](docs/CatAllOf.md) @@ -138,6 +142,9 @@ Class | Method | HTTP request | Description - [file_schema_test_class.FileSchemaTestClass](docs/FileSchemaTestClass.md) - [foo.Foo](docs/Foo.md) - [format_test.FormatTest](docs/FormatTest.md) + - [fruit.Fruit](docs/Fruit.md) + - [fruit_req.FruitReq](docs/FruitReq.md) + - [gm_fruit.GmFruit](docs/GmFruit.md) - [has_only_read_only.HasOnlyReadOnly](docs/HasOnlyReadOnly.md) - [health_check_result.HealthCheckResult](docs/HealthCheckResult.md) - [inline_object.InlineObject](docs/InlineObject.md) @@ -148,6 +155,7 @@ Class | Method | HTTP request | Description - [inline_object5.InlineObject5](docs/InlineObject5.md) - [inline_response_default.InlineResponseDefault](docs/InlineResponseDefault.md) - [list.List](docs/List.md) + - [mammal.Mammal](docs/Mammal.md) - [map_test.MapTest](docs/MapTest.md) - [mixed_properties_and_additional_properties_class.MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) - [model200_response.Model200Response](docs/Model200Response.md) @@ -167,6 +175,8 @@ Class | Method | HTTP request | Description - [string_boolean_map.StringBooleanMap](docs/StringBooleanMap.md) - [tag.Tag](docs/Tag.md) - [user.User](docs/User.md) + - [whale.Whale](docs/Whale.md) + - [zebra.Zebra](docs/Zebra.md) ## Documentation For Authorization diff --git a/samples/openapi3/client/petstore/python-experimental/docs/Apple.md b/samples/openapi3/client/petstore/python-experimental/docs/Apple.md new file mode 100644 index 000000000000..0c62affcde4e --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/docs/Apple.md @@ -0,0 +1,10 @@ +# apple.Apple + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**cultivar** | **str** | | [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) + + diff --git a/samples/openapi3/client/petstore/python-experimental/docs/AppleReq.md b/samples/openapi3/client/petstore/python-experimental/docs/AppleReq.md new file mode 100644 index 000000000000..3d6717ebd60c --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/docs/AppleReq.md @@ -0,0 +1,11 @@ +# apple_req.AppleReq + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**cultivar** | **str** | | +**mealy** | **bool** | | [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) + + diff --git a/samples/openapi3/client/petstore/python-experimental/docs/Banana.md b/samples/openapi3/client/petstore/python-experimental/docs/Banana.md new file mode 100644 index 000000000000..ec8b3b902cc4 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/docs/Banana.md @@ -0,0 +1,10 @@ +# banana.Banana + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**length_cm** | **float** | | [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) + + diff --git a/samples/openapi3/client/petstore/python-experimental/docs/BananaReq.md b/samples/openapi3/client/petstore/python-experimental/docs/BananaReq.md new file mode 100644 index 000000000000..5cfe53ec741f --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/docs/BananaReq.md @@ -0,0 +1,11 @@ +# banana_req.BananaReq + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**length_cm** | **float** | | +**sweet** | **bool** | | [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) + + diff --git a/samples/openapi3/client/petstore/python-experimental/docs/Fruit.md b/samples/openapi3/client/petstore/python-experimental/docs/Fruit.md new file mode 100644 index 000000000000..24ea69546ff8 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/docs/Fruit.md @@ -0,0 +1,12 @@ +# fruit.Fruit + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**color** | **str** | | [optional] +**cultivar** | **str** | | [optional] +**length_cm** | **float** | | [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) + + diff --git a/samples/openapi3/client/petstore/python-experimental/docs/FruitReq.md b/samples/openapi3/client/petstore/python-experimental/docs/FruitReq.md new file mode 100644 index 000000000000..22eeb37f1cc3 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/docs/FruitReq.md @@ -0,0 +1,13 @@ +# fruit_req.FruitReq + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**cultivar** | **str** | | defaults to nulltype.Null +**length_cm** | **float** | | defaults to nulltype.Null +**mealy** | **bool** | | [optional] +**sweet** | **bool** | | [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) + + diff --git a/samples/openapi3/client/petstore/python-experimental/docs/GmFruit.md b/samples/openapi3/client/petstore/python-experimental/docs/GmFruit.md new file mode 100644 index 000000000000..4e0538c6c445 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/docs/GmFruit.md @@ -0,0 +1,12 @@ +# gm_fruit.GmFruit + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**color** | **str** | | [optional] +**cultivar** | **str** | | [optional] +**length_cm** | **float** | | [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) + + diff --git a/samples/openapi3/client/petstore/python-experimental/docs/Mammal.md b/samples/openapi3/client/petstore/python-experimental/docs/Mammal.md new file mode 100644 index 000000000000..b86f0b17ab99 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/docs/Mammal.md @@ -0,0 +1,13 @@ +# mammal.Mammal + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**class_name** | **str** | | +**has_baleen** | **bool** | | [optional] +**has_teeth** | **bool** | | [optional] +**type** | **str** | | [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) + + diff --git a/samples/openapi3/client/petstore/python-experimental/docs/Whale.md b/samples/openapi3/client/petstore/python-experimental/docs/Whale.md new file mode 100644 index 000000000000..4a19e88c5553 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/docs/Whale.md @@ -0,0 +1,12 @@ +# whale.Whale + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**class_name** | **str** | | +**has_baleen** | **bool** | | [optional] +**has_teeth** | **bool** | | [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) + + diff --git a/samples/openapi3/client/petstore/python-experimental/docs/Zebra.md b/samples/openapi3/client/petstore/python-experimental/docs/Zebra.md new file mode 100644 index 000000000000..779a8db51e9f --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/docs/Zebra.md @@ -0,0 +1,11 @@ +# zebra.Zebra + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**class_name** | **str** | | +**type** | **str** | | [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) + + diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/__init__.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/__init__.py index fbe114c91775..3aa279dd15d6 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/__init__.py @@ -44,9 +44,13 @@ 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.apple import Apple +from petstore_api.models.apple_req import AppleReq from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly from petstore_api.models.array_of_number_only import ArrayOfNumberOnly from petstore_api.models.array_test import ArrayTest +from petstore_api.models.banana import Banana +from petstore_api.models.banana_req import BananaReq from petstore_api.models.capitalization import Capitalization from petstore_api.models.cat import Cat from petstore_api.models.cat_all_of import CatAllOf @@ -62,6 +66,9 @@ from petstore_api.models.file_schema_test_class import FileSchemaTestClass from petstore_api.models.foo import Foo from petstore_api.models.format_test import FormatTest +from petstore_api.models.fruit import Fruit +from petstore_api.models.fruit_req import FruitReq +from petstore_api.models.gm_fruit import GmFruit from petstore_api.models.has_only_read_only import HasOnlyReadOnly from petstore_api.models.health_check_result import HealthCheckResult from petstore_api.models.inline_object import InlineObject @@ -72,6 +79,7 @@ from petstore_api.models.inline_object5 import InlineObject5 from petstore_api.models.inline_response_default import InlineResponseDefault from petstore_api.models.list import List +from petstore_api.models.mammal import Mammal from petstore_api.models.map_test import MapTest from petstore_api.models.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass from petstore_api.models.model200_response import Model200Response @@ -91,3 +99,5 @@ from petstore_api.models.string_boolean_map import StringBooleanMap from petstore_api.models.tag import Tag from petstore_api.models.user import User +from petstore_api.models.whale import Whale +from petstore_api.models.zebra import Zebra diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model_utils.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model_utils.py index 074e597cbd22..eed501c84502 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model_utils.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model_utils.py @@ -274,13 +274,20 @@ def __getattr__(self, name): if self._path_to_item: path_to_item.extend(self._path_to_item) path_to_item.append(name) + values = set() if model_instances: - values = set() for model_instance in model_instances: if name in model_instance._data_store: values.add(model_instance._data_store[name]) - if len(values) == 1: - return list(values)[0] + len_values = len(values) + if len_values == 0: + raise ApiKeyError( + "{0} has no key '{1}'".format(type(self).__name__, name), + path_to_item + ) + elif len_values == 1: + return list(values)[0] + elif len_values > 1: raise ApiValueError( "Values stored for property {0} in {1} difffer when looking " "at self and self's composed instances. All values must be " @@ -288,11 +295,6 @@ def __getattr__(self, name): path_to_item ) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - def to_dict(self): """Returns the model properties as a dict""" return model_to_dict(self, serialize=False) @@ -1082,7 +1084,7 @@ def model_to_dict(model_instance, serialize=True): model_instances = [model_instance] if model_instance._composed_schemas() is not None: - model_instances = model_instance._composed_instances + model_instances.extend(model_instance._composed_instances) for model_instance in model_instances: for attr, value in six.iteritems(model_instance._data_store): if serialize: @@ -1205,12 +1207,12 @@ def get_oneof_instance(self, model_args, constant_args): used to make instances Returns - oneof_instance (instance) + oneof_instance (instance/None) """ - oneof_instance = None if len(self._composed_schemas()['oneOf']) == 0: - return oneof_instance + return None + oneof_instances = [] for oneof_class in self._composed_schemas()['oneOf']: # transform js keys to python keys in fixed_model_args fixed_model_args = change_keys_js_to_python( @@ -1223,20 +1225,30 @@ def get_oneof_instance(self, model_args, constant_args): if var_name in fixed_model_args: kwargs[var_name] = fixed_model_args[var_name] + # do not try to make a model with no input args + if len(kwargs) == 0: + continue + # and use it to make the instance kwargs.update(constant_args) try: oneof_instance = oneof_class(**kwargs) - break + oneof_instances.append(oneof_instance) except Exception: pass - if oneof_instance is None: + if len(oneof_instances) == 0: raise ApiValueError( "Invalid inputs given to generate an instance of %s. Unable to " "make any instances of the classes in oneOf definition." % self.__class__.__name__ ) - return oneof_instance + elif len(oneof_instances) > 1: + raise ApiValueError( + "Invalid inputs given to generate an instance of %s. Multiple " + "oneOf instances were generated when a max of one is allowed." % + self.__class__.__name__ + ) + return oneof_instances[0] def get_anyof_instances(self, model_args, constant_args): @@ -1266,6 +1278,10 @@ def get_anyof_instances(self, model_args, constant_args): if var_name in fixed_model_args: kwargs[var_name] = fixed_model_args[var_name] + # do not try to make a model with no input args + if len(kwargs) == 0: + continue + # and use it to make the instance kwargs.update(constant_args) try: diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/additional_properties_class.py index 19b97e69b6af..30bc3cdce6f3 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/additional_properties_class.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -101,7 +102,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """additional_properties_class.AdditionalPropertiesClass - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/address.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/address.py index 39cec0750135..05a95d57fa99 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/address.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/address.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -97,7 +98,6 @@ def _composed_schemas(): 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/animal.py index 4971ab17ab56..45058ec7612f 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/animal.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/api_response.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/api_response.py index 893024a80b99..f1680c87f67a 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/api_response.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/api_response.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -103,7 +104,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """api_response.ApiResponse - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/apple.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/apple.py new file mode 100644 index 000000000000..03c502690d5d --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/apple.py @@ -0,0 +1,133 @@ +# 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 +import nulltype # 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 Apple(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 = None + + @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 { + 'cultivar': (str,), # noqa: E501 + } + + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'cultivar': 'cultivar', # noqa: E501 + } + + @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 + """apple.Apple - 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. + cultivar (str): [optional] # noqa: E501 + """ + + 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) diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/apple_req.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/apple_req.py new file mode 100644 index 000000000000..7aa81bf4c776 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/apple_req.py @@ -0,0 +1,139 @@ +# 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 +import nulltype # 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 AppleReq(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 = None + + @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 { + 'cultivar': (str,), # noqa: E501 + 'mealy': (bool,), # noqa: E501 + } + + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'cultivar': 'cultivar', # noqa: E501 + 'mealy': 'mealy', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) + + def __init__(self, cultivar, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + """apple_req.AppleReq - a model defined in OpenAPI + + Args: + cultivar (str): + + 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. + mealy (bool): [optional] # noqa: E501 + """ + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + + self.cultivar = cultivar + 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) diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/array_of_array_of_number_only.py index faa9b5c44ccd..bf6419e5c089 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/array_of_array_of_number_only.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """array_of_array_of_number_only.ArrayOfArrayOfNumberOnly - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/array_of_number_only.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/array_of_number_only.py index 2909708136de..f3bf89e27ba3 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/array_of_number_only.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """array_of_number_only.ArrayOfNumberOnly - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/array_test.py index 7f4f1090663a..0a01b3cad210 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/array_test.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -108,7 +109,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """array_test.ArrayTest - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/banana.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/banana.py new file mode 100644 index 000000000000..fda69a28a253 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/banana.py @@ -0,0 +1,133 @@ +# 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 +import nulltype # 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 Banana(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 = None + + @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 { + 'length_cm': (float,), # noqa: E501 + } + + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'length_cm': 'lengthCm', # noqa: E501 + } + + @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 + """banana.Banana - 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. + length_cm (float): [optional] # noqa: E501 + """ + + 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) diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/banana_req.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/banana_req.py new file mode 100644 index 000000000000..bf7d461c469c --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/banana_req.py @@ -0,0 +1,139 @@ +# 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 +import nulltype # 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 BananaReq(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 = None + + @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 { + 'length_cm': (float,), # noqa: E501 + 'sweet': (bool,), # noqa: E501 + } + + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'length_cm': 'lengthCm', # noqa: E501 + 'sweet': 'sweet', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) + + def __init__(self, length_cm, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + """banana_req.BananaReq - a model defined in OpenAPI + + Args: + length_cm (float): + + 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. + sweet (bool): [optional] # noqa: E501 + """ + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + + self.length_cm = length_cm + 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) diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/capitalization.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/capitalization.py index b4be4b15e71d..6011db39400c 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/capitalization.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/capitalization.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -109,7 +110,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """capitalization.Capitalization - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/cat.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/cat.py index 4106ff709bba..92076d35c068 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/cat.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/cat.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -150,9 +151,16 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it '_from_server': _from_server, '_configuration': _configuration, } - model_args = { + required_args = { 'class_name': class_name, } + # remove args whose value is Null because they are unset + required_arg_names = list(required_args.keys()) + for required_arg_name in required_arg_names: + if required_args[required_arg_name] is nulltype.Null: + del required_args[required_arg_name] + model_args = {} + model_args.update(required_args) model_args.update(kwargs) composed_info = validate_get_composed_info( constant_args, model_args, self) @@ -161,7 +169,8 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it self._additional_properties_model_instances = composed_info[2] unused_args = composed_info[3] - self.class_name = class_name + for var_name, var_value in required_args.items(): + setattr(self, var_name, var_value) for var_name, var_value in six.iteritems(kwargs): if var_name in unused_args and \ self._configuration is not None and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/cat_all_of.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/cat_all_of.py index 1c3fe2578a46..75e856dcbcde 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/cat_all_of.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/cat_all_of.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """cat_all_of.CatAllOf - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/category.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/category.py index fcdb58cb9568..5d3e21ddd7e9 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/category.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -104,7 +105,7 @@ def __init__(self, name='default-name', _check_type=True, _from_server=False, _p Args: Keyword Args: - name (str): defaults to 'default-name', must be one of ['default-name'] # noqa: E501 + name (str): defaults to 'default-name' # noqa: E501 _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. diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/class_model.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/class_model.py index e4f1d63a264c..06c52dc8bee9 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/class_model.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/class_model.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """class_model.ClassModel - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/client.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/client.py index f3f645da3823..b7184b3f2b40 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/client.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/client.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """client.Client - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/dog.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/dog.py index 462869ffbd28..69af821b27e2 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/dog.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/dog.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -145,9 +146,16 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it '_from_server': _from_server, '_configuration': _configuration, } - model_args = { + required_args = { 'class_name': class_name, } + # remove args whose value is Null because they are unset + required_arg_names = list(required_args.keys()) + for required_arg_name in required_arg_names: + if required_args[required_arg_name] is nulltype.Null: + del required_args[required_arg_name] + model_args = {} + model_args.update(required_args) model_args.update(kwargs) composed_info = validate_get_composed_info( constant_args, model_args, self) @@ -156,7 +164,8 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it self._additional_properties_model_instances = composed_info[2] unused_args = composed_info[3] - self.class_name = class_name + for var_name, var_value in required_args.items(): + setattr(self, var_name, var_value) for var_name, var_value in six.iteritems(kwargs): if var_name in unused_args and \ self._configuration is not None and \ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/dog_all_of.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/dog_all_of.py index ec62d18e6376..0832f4b696cc 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/dog_all_of.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/dog_all_of.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """dog_all_of.DogAllOf - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/enum_arrays.py index 59f73c8f1c9e..358e9f680e76 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/enum_arrays.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -109,7 +110,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """enum_arrays.EnumArrays - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/enum_class.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/enum_class.py index 994d7723842e..5f3f1894de47 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/enum_class.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/enum_class.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,7 @@ def __init__(self, value='-efg', _check_type=True, _from_server=False, _path_to_ Args: Keyword Args: - value (str): defaults to '-efg', must be one of ['-efg'] # noqa: E501 + value (str): defaults to '-efg', must be one of ["_abc", "-efg", "(xyz)", ] # noqa: E501 _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. diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/enum_test.py index bb39c26a8713..bcd601f04ed3 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/enum_test.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/file.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/file.py index 46f02f4436cf..f71dc07b7ca8 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/file.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/file.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """file.File - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/file_schema_test_class.py index 9c5cb0c63664..1260e8affda2 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/file_schema_test_class.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -106,7 +107,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """file_schema_test_class.FileSchemaTestClass - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/foo.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/foo.py index c9503266fc2e..7a71b34dc4de 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/foo.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/foo.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """foo.Foo - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/format_test.py index cd42a4b11ed4..2a7e08f4d737 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/format_test.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/fruit.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/fruit.py new file mode 100644 index 000000000000..d5e71abd700f --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/fruit.py @@ -0,0 +1,193 @@ +# 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 +import nulltype # 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, +) +try: + from petstore_api.models import apple +except ImportError: + apple = sys.modules[ + 'petstore_api.models.apple'] +try: + from petstore_api.models import banana +except ImportError: + banana = sys.modules[ + 'petstore_api.models.banana'] + + +class Fruit(ModelComposed): + """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 = None + + @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 { + 'color': (str,), # noqa: E501 + 'cultivar': (str,), # noqa: E501 + 'length_cm': (float,), # noqa: E501 + } + + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'color': 'color', # noqa: E501 + 'cultivar': 'cultivar', # noqa: E501 + 'length_cm': 'lengthCm', # noqa: E501 + } + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + """fruit.Fruit - 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. + color (str): [optional] # noqa: E501 + cultivar (str): [optional] # noqa: E501 + length_cm (float): [optional] # noqa: E501 + """ + + 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, + '_from_server': _from_server, + '_configuration': _configuration, + } + required_args = { + } + # remove args whose value is Null because they are unset + required_arg_names = list(required_args.keys()) + for required_arg_name in required_arg_names: + if required_args[required_arg_name] is nulltype.Null: + del required_args[required_arg_name] + model_args = {} + model_args.update(required_args) + model_args.update(kwargs) + composed_info = validate_get_composed_info( + constant_args, model_args, self) + 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 required_args.items(): + setattr(self, var_name, var_value) + 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 + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + return { + 'anyOf': [ + ], + 'allOf': [ + ], + 'oneOf': [ + apple.Apple, + banana.Banana, + ], + } diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/fruit_req.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/fruit_req.py new file mode 100644 index 000000000000..111326fcb4f6 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/fruit_req.py @@ -0,0 +1,200 @@ +# 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 +import nulltype # 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, +) +try: + from petstore_api.models import apple_req +except ImportError: + apple_req = sys.modules[ + 'petstore_api.models.apple_req'] +try: + from petstore_api.models import banana_req +except ImportError: + banana_req = sys.modules[ + 'petstore_api.models.banana_req'] + + +class FruitReq(ModelComposed): + """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 = None + + @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 { + 'cultivar': (str,), # noqa: E501 + 'length_cm': (float,), # noqa: E501 + 'mealy': (bool,), # noqa: E501 + 'sweet': (bool,), # noqa: E501 + } + + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'cultivar': 'cultivar', # noqa: E501 + 'length_cm': 'lengthCm', # noqa: E501 + 'mealy': 'mealy', # noqa: E501 + 'sweet': 'sweet', # noqa: E501 + } + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + + def __init__(self, cultivar=nulltype.Null, length_cm=nulltype.Null, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + """fruit_req.FruitReq - a model defined in OpenAPI + + Args: + + Keyword Args: + cultivar (str): defaults to nulltype.Null # noqa: E501 + length_cm (float): defaults to nulltype.Null # noqa: E501 + _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. + mealy (bool): [optional] # noqa: E501 + sweet (bool): [optional] # noqa: E501 + """ + + 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, + '_from_server': _from_server, + '_configuration': _configuration, + } + required_args = { + 'cultivar': cultivar, + 'length_cm': length_cm, + } + # remove args whose value is Null because they are unset + required_arg_names = list(required_args.keys()) + for required_arg_name in required_arg_names: + if required_args[required_arg_name] is nulltype.Null: + del required_args[required_arg_name] + model_args = {} + model_args.update(required_args) + model_args.update(kwargs) + composed_info = validate_get_composed_info( + constant_args, model_args, self) + 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 required_args.items(): + setattr(self, var_name, var_value) + 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 + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + return { + 'anyOf': [ + ], + 'allOf': [ + ], + 'oneOf': [ + apple_req.AppleReq, + banana_req.BananaReq, + ], + } diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/gm_fruit.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/gm_fruit.py new file mode 100644 index 000000000000..0888743b8ec8 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/gm_fruit.py @@ -0,0 +1,193 @@ +# 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 +import nulltype # 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, +) +try: + from petstore_api.models import apple +except ImportError: + apple = sys.modules[ + 'petstore_api.models.apple'] +try: + from petstore_api.models import banana +except ImportError: + banana = sys.modules[ + 'petstore_api.models.banana'] + + +class GmFruit(ModelComposed): + """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 = None + + @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 { + 'color': (str,), # noqa: E501 + 'cultivar': (str,), # noqa: E501 + 'length_cm': (float,), # noqa: E501 + } + + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'color': 'color', # noqa: E501 + 'cultivar': 'cultivar', # noqa: E501 + 'length_cm': 'lengthCm', # noqa: E501 + } + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + """gm_fruit.GmFruit - 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. + color (str): [optional] # noqa: E501 + cultivar (str): [optional] # noqa: E501 + length_cm (float): [optional] # noqa: E501 + """ + + 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, + '_from_server': _from_server, + '_configuration': _configuration, + } + required_args = { + } + # remove args whose value is Null because they are unset + required_arg_names = list(required_args.keys()) + for required_arg_name in required_arg_names: + if required_args[required_arg_name] is nulltype.Null: + del required_args[required_arg_name] + model_args = {} + model_args.update(required_args) + model_args.update(kwargs) + composed_info = validate_get_composed_info( + constant_args, model_args, self) + 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 required_args.items(): + setattr(self, var_name, var_value) + 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 + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + return { + 'anyOf': [ + apple.Apple, + banana.Banana, + ], + 'allOf': [ + ], + 'oneOf': [ + ], + } diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/gm_mammal.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/gm_mammal.py new file mode 100644 index 000000000000..83ef04f9707f --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/gm_mammal.py @@ -0,0 +1,212 @@ +# 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, +) +try: + from petstore_api.models import whale +except ImportError: + whale = sys.modules[ + 'petstore_api.models.whale'] +try: + from petstore_api.models import zebra +except ImportError: + zebra = sys.modules[ + 'petstore_api.models.zebra'] + + +class GmMammal(ModelComposed): + """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 = { + ('lungs',): { + '2': 2, + }, + ('type',): { + 'PLAINS': "plains", + 'MOUNTAIN': "mountain", + 'GREVYS': "grevys", + }, + } + + validations = { + } + + additional_properties_type = None + + @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 { + 'class_name': (str,), # noqa: E501 + 'lungs': (int,), # noqa: E501 + 'has_baleen': (bool,), # noqa: E501 + 'has_teeth': (bool,), # noqa: E501 + 'type': (str,), # noqa: E501 + } + + @staticmethod + def discriminator(): + return { + 'class_name': { + 'whale': whale.Whale, + 'zebra': zebra.Zebra, + }, + } + + attribute_map = { + 'class_name': 'className', # noqa: E501 + 'lungs': 'lungs', # noqa: E501 + 'has_baleen': 'hasBaleen', # noqa: E501 + 'has_teeth': 'hasTeeth', # noqa: E501 + 'type': 'type', # noqa: E501 + } + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + + def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + """gm_mammal.GmMammal - a model defined in OpenAPI + + Args: + class_name (str): + + 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. + lungs (int): [optional] if omitted the server will use the default value of 2 # noqa: E501 + has_baleen (bool): [optional] # noqa: E501 + has_teeth (bool): [optional] # noqa: E501 + type (str): [optional] # noqa: E501 + """ + + 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, + '_from_server': _from_server, + '_configuration': _configuration, + } + model_args = { + 'class_name': class_name, + } + model_args.update(kwargs) + composed_info = validate_get_composed_info( + constant_args, model_args, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + + self.class_name = class_name + for var_name, var_value in six.iteritems(kwargs): + setattr(self, var_name, var_value) + + @staticmethod + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + return { + 'anyOf': [ + whale.Whale, + zebra.Zebra, + ], + 'allOf': [ + ], + 'oneOf': [ + ], + } + + @classmethod + def get_discriminator_class(cls, from_server, data): + """Returns the child class specified by the discriminator""" + discriminator = cls.discriminator() + discr_propertyname_py = list(discriminator.keys())[0] + discr_propertyname_js = cls.attribute_map[discr_propertyname_py] + if from_server: + class_name = data[discr_propertyname_js] + else: + class_name = data[discr_propertyname_py] + class_name_to_discr_class = discriminator[discr_propertyname_py] + return class_name_to_discr_class.get(class_name) diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/has_only_read_only.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/has_only_read_only.py index cf66f3fc02e8..c84cf0be3f2b 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/has_only_read_only.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/has_only_read_only.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -101,7 +102,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """has_only_read_only.HasOnlyReadOnly - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/health_check_result.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/health_check_result.py index 84e6ba56231a..873bad5451fe 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/health_check_result.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/health_check_result.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """health_check_result.HealthCheckResult - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object.py index 0879d7cf296e..bba44a11c13d 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -101,7 +102,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """inline_object.InlineObject - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object1.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object1.py index bbdd1f9d3c02..4262d4165fdc 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object1.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object1.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -101,7 +102,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """inline_object1.InlineObject1 - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object2.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object2.py index 1e97636581dc..2fd4792709f5 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object2.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object2.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -110,7 +111,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """inline_object2.InlineObject2 - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object3.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object3.py index 210fe669dc7f..209e97de6e18 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object3.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object3.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object4.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object4.py index cb4720589438..67b14d2c64e5 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object4.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object4.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object5.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object5.py index feaa8525c6d8..ce5fc59a4aee 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object5.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_object5.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_response_default.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_response_default.py index f1649f46890e..ad0f356ab50b 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_response_default.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/inline_response_default.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -104,7 +105,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """inline_response_default.InlineResponseDefault - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/list.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/list.py index d4cd4c4eb466..c7c80e8bd28b 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/list.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/list.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """list.List - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/mammal.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/mammal.py new file mode 100644 index 000000000000..303838fd7d4b --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/mammal.py @@ -0,0 +1,222 @@ +# 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 +import nulltype # 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, +) +try: + from petstore_api.models import whale +except ImportError: + whale = sys.modules[ + 'petstore_api.models.whale'] +try: + from petstore_api.models import zebra +except ImportError: + zebra = sys.modules[ + 'petstore_api.models.zebra'] + + +class Mammal(ModelComposed): + """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 = { + ('type',): { + 'PLAINS': "plains", + 'MOUNTAIN': "mountain", + 'GREVYS': "grevys", + }, + } + + validations = { + } + + additional_properties_type = None + + @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 { + 'class_name': (str,), # noqa: E501 + 'has_baleen': (bool,), # noqa: E501 + 'has_teeth': (bool,), # noqa: E501 + 'type': (str,), # noqa: E501 + } + + @staticmethod + def discriminator(): + return { + 'class_name': { + 'whale': whale.Whale, + 'zebra': zebra.Zebra, + }, + } + + attribute_map = { + 'class_name': 'className', # noqa: E501 + 'has_baleen': 'hasBaleen', # noqa: E501 + 'has_teeth': 'hasTeeth', # noqa: E501 + 'type': 'type', # noqa: E501 + } + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + + def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + """mammal.Mammal - a model defined in OpenAPI + + Args: + class_name (str): + + 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. + has_baleen (bool): [optional] # noqa: E501 + has_teeth (bool): [optional] # noqa: E501 + type (str): [optional] # noqa: E501 + """ + + 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, + '_from_server': _from_server, + '_configuration': _configuration, + } + required_args = { + 'class_name': class_name, + } + # remove args whose value is Null because they are unset + required_arg_names = list(required_args.keys()) + for required_arg_name in required_arg_names: + if required_args[required_arg_name] is nulltype.Null: + del required_args[required_arg_name] + model_args = {} + model_args.update(required_args) + model_args.update(kwargs) + composed_info = validate_get_composed_info( + constant_args, model_args, self) + 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 required_args.items(): + setattr(self, var_name, var_value) + 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 + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + return { + 'anyOf': [ + ], + 'allOf': [ + ], + 'oneOf': [ + whale.Whale, + zebra.Zebra, + ], + } + + @classmethod + def get_discriminator_class(cls, from_server, data): + """Returns the child class specified by the discriminator""" + discriminator = cls.discriminator() + discr_propertyname_py = list(discriminator.keys())[0] + discr_propertyname_js = cls.attribute_map[discr_propertyname_py] + if from_server: + class_name = data[discr_propertyname_js] + else: + class_name = data[discr_propertyname_py] + class_name_to_discr_class = discriminator[discr_propertyname_py] + return class_name_to_discr_class.get(class_name) diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/map_test.py index 95d680e9ebdf..8cc47c0a6922 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/map_test.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -114,7 +115,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """map_test.MapTest - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/mixed_properties_and_additional_properties_class.py index 7eb5df3cc68f..143a79bfa266 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -108,7 +109,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """mixed_properties_and_additional_properties_class.MixedPropertiesAndAdditionalPropertiesClass - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/model200_response.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/model200_response.py index 4eb1672966ae..0c3885120210 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/model200_response.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/model200_response.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -101,7 +102,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """model200_response.Model200Response - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/model_return.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/model_return.py index 740c8e140563..75c3cea6318b 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/model_return.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/model_return.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """model_return.ModelReturn - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/name.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/name.py index c85f89a118c6..db81ae16916d 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/name.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/nullable_class.py index 1fad5bd94e72..c97b8227cde6 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/nullable_class.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -121,7 +122,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """nullable_class.NullableClass - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/number_only.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/number_only.py index a3f20cd4b4b3..0c91e2ae62d0 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/number_only.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/number_only.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """number_only.NumberOnly - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/order.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/order.py index 15c23366e433..673295a8610c 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/order.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -114,7 +115,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """order.Order - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_composite.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_composite.py index 382e84df2527..d797e2f7d07a 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_composite.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_composite.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -103,7 +104,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """outer_composite.OuterComposite - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum.py index 39e533a3ecf4..ad948db05274 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum_default_value.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum_default_value.py index 5a05e121f521..789bf4ae86fa 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum_default_value.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum_default_value.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,7 @@ def __init__(self, value='placed', _check_type=True, _from_server=False, _path_t Args: Keyword Args: - value (str): defaults to 'placed', must be one of ['placed'] # noqa: E501 + value (str): defaults to 'placed', must be one of ["placed", "approved", "delivered", ] # noqa: E501 _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. diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum_integer.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum_integer.py index b2d55e484b9c..a6323a7fc0ea 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum_integer.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum_integer.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum_integer_default_value.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum_integer_default_value.py index 7a3b77cb8240..1098c6494504 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum_integer_default_value.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/outer_enum_integer_default_value.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,7 @@ def __init__(self, value=0, _check_type=True, _from_server=False, _path_to_item= Args: Keyword Args: - value (int): defaults to 0, must be one of [0] # noqa: E501 + value (int): defaults to 0, must be one of [0, 1, 2, ] # noqa: E501 _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. diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/pet.py index 1682c3cb51b2..74cd8afef1af 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/pet.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/read_only_first.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/read_only_first.py index 6a18e6331f61..329ec017d435 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/read_only_first.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/read_only_first.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -101,7 +102,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """read_only_first.ReadOnlyFirst - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/special_model_name.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/special_model_name.py index 006f9454b854..d4ffc608a579 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/special_model_name.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/special_model_name.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -99,7 +100,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """special_model_name.SpecialModelName - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/string_boolean_map.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/string_boolean_map.py index d7b0b0a94501..7f797f5f1b5d 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/string_boolean_map.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/string_boolean_map.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -97,7 +98,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """string_boolean_map.StringBooleanMap - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/tag.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/tag.py index 8585d19c710b..8ffba1b13071 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/tag.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/tag.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -101,7 +102,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """tag.Tag - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/user.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/user.py index 3776e7e7f3f8..3b2eeb54b3d9 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/user.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/user.py @@ -15,6 +15,7 @@ import sys # noqa: F401 import six # noqa: F401 +import nulltype # noqa: F401 from petstore_api.model_utils import ( # noqa: F401 ModelComposed, @@ -113,7 +114,6 @@ def _composed_schemas(): def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 """user.User - 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 diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/whale.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/whale.py new file mode 100644 index 000000000000..0c166e663015 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/whale.py @@ -0,0 +1,142 @@ +# 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 +import nulltype # 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 Whale(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 = None + + @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 { + 'class_name': (str,), # noqa: E501 + 'has_baleen': (bool,), # noqa: E501 + 'has_teeth': (bool,), # noqa: E501 + } + + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'class_name': 'className', # noqa: E501 + 'has_baleen': 'hasBaleen', # noqa: E501 + 'has_teeth': 'hasTeeth', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) + + def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + """whale.Whale - a model defined in OpenAPI + + Args: + class_name (str): + + 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. + has_baleen (bool): [optional] # noqa: E501 + has_teeth (bool): [optional] # noqa: E501 + """ + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + + 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) diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/zebra.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/zebra.py new file mode 100644 index 000000000000..56c0b34c2672 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/zebra.py @@ -0,0 +1,144 @@ +# 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 +import nulltype # 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 Zebra(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 = { + ('type',): { + 'PLAINS': "plains", + 'MOUNTAIN': "mountain", + 'GREVYS': "grevys", + }, + } + + validations = { + } + + additional_properties_type = None + + @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 { + 'class_name': (str,), # noqa: E501 + 'type': (str,), # noqa: E501 + } + + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'class_name': 'className', # noqa: E501 + 'type': 'type', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) + + def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + """zebra.Zebra - a model defined in OpenAPI + + Args: + class_name (str): + + 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. + type (str): [optional] # noqa: E501 + """ + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + + 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) diff --git a/samples/openapi3/client/petstore/python-experimental/requirements.txt b/samples/openapi3/client/petstore/python-experimental/requirements.txt index eb358efd5bd3..a56bedffbf57 100644 --- a/samples/openapi3/client/petstore/python-experimental/requirements.txt +++ b/samples/openapi3/client/petstore/python-experimental/requirements.txt @@ -1,3 +1,4 @@ +nulltype certifi >= 14.05.14 future; python_version<="2.7" six >= 1.10 diff --git a/samples/openapi3/client/petstore/python-experimental/setup.py b/samples/openapi3/client/petstore/python-experimental/setup.py index 47c8b2787925..261bc12d34ba 100644 --- a/samples/openapi3/client/petstore/python-experimental/setup.py +++ b/samples/openapi3/client/petstore/python-experimental/setup.py @@ -26,6 +26,7 @@ "six >= 1.10", "certifi", "python-dateutil", + "nulltype", "pem>=19.3.0", "pycryptodome>=3.9.0", ] diff --git a/samples/openapi3/client/petstore/python-experimental/test/test_apple.py b/samples/openapi3/client/petstore/python-experimental/test/test_apple.py new file mode 100644 index 000000000000..100866918919 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/test/test_apple.py @@ -0,0 +1,37 @@ +# 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 unittest + +import petstore_api + + +class TestApple(unittest.TestCase): + """Apple unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testApple(self): + """Test Apple""" + # FIXME: construct object with mandatory attributes with example values + # model = petstore_api.Apple() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-experimental/test/test_apple_req.py b/samples/openapi3/client/petstore/python-experimental/test/test_apple_req.py new file mode 100644 index 000000000000..4cb5abcdede4 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/test/test_apple_req.py @@ -0,0 +1,37 @@ +# 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 unittest + +import petstore_api + + +class TestAppleReq(unittest.TestCase): + """AppleReq unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testAppleReq(self): + """Test AppleReq""" + # FIXME: construct object with mandatory attributes with example values + # model = petstore_api.AppleReq() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-experimental/test/test_banana.py b/samples/openapi3/client/petstore/python-experimental/test/test_banana.py new file mode 100644 index 000000000000..6efdcd07da1c --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/test/test_banana.py @@ -0,0 +1,37 @@ +# 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 unittest + +import petstore_api + + +class TestBanana(unittest.TestCase): + """Banana unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testBanana(self): + """Test Banana""" + # FIXME: construct object with mandatory attributes with example values + # model = petstore_api.Banana() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-experimental/test/test_banana_req.py b/samples/openapi3/client/petstore/python-experimental/test/test_banana_req.py new file mode 100644 index 000000000000..5eeb0bc57c21 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/test/test_banana_req.py @@ -0,0 +1,37 @@ +# 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 unittest + +import petstore_api + + +class TestBananaReq(unittest.TestCase): + """BananaReq unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testBananaReq(self): + """Test BananaReq""" + # FIXME: construct object with mandatory attributes with example values + # model = petstore_api.BananaReq() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-experimental/test/test_fruit.py b/samples/openapi3/client/petstore/python-experimental/test/test_fruit.py new file mode 100644 index 000000000000..ee32229a8bbd --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/test/test_fruit.py @@ -0,0 +1,175 @@ +# 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 unittest + +import petstore_api + + +class TestFruit(unittest.TestCase): + """Fruit unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testFruit(self): + """Test Fruit""" + + # make an instance of Fruit, a composed schema oneOf model + # banana test + length_cm = 20.3 + color = 'yellow' + fruit = petstore_api.Fruit(length_cm=length_cm, color=color) + # check its properties + self.assertEqual(fruit.length_cm, length_cm) + self.assertEqual(fruit['length_cm'], length_cm) + self.assertEqual(getattr(fruit, 'length_cm'), length_cm) + self.assertEqual(fruit.color, color) + self.assertEqual(fruit['color'], color) + self.assertEqual(getattr(fruit, 'color'), color) + # check the dict representation + self.assertEqual( + fruit.to_dict(), + { + 'length_cm': length_cm, + 'color': color + } + ) + # setting a value that doesn't exist raises an exception + # with a key + with self.assertRaises(petstore_api.ApiKeyError): + fruit['invalid_variable'] = 'some value' + # with setattr + with self.assertRaises(petstore_api.ApiKeyError): + setattr(fruit, 'invalid_variable', 'some value') + + # getting a value that doesn't exist raises an exception + # with a key + with self.assertRaises(petstore_api.ApiKeyError): + invalid_variable = fruit['cultivar'] + # with getattr + with self.assertRaises(petstore_api.ApiKeyError): + invalid_variable = getattr(fruit, 'cultivar', 'some value') + + # make sure that the ModelComposed class properties are correct + # model.composed_schemas() stores the anyOf/allOf/oneOf info + self.assertEqual( + fruit._composed_schemas(), + { + 'anyOf': [], + 'allOf': [], + 'oneOf': [ + petstore_api.Apple, + petstore_api.Banana, + ], + } + ) + # model._composed_instances is a list of the instances that were + # made from the anyOf/allOf/OneOf classes in model._composed_schemas() + for composed_instance in fruit._composed_instances: + if composed_instance.__class__ == petstore_api.Banana: + banana_instance = composed_instance + self.assertEqual( + fruit._composed_instances, + [banana_instance] + ) + # model._var_name_to_model_instances maps the variable name to the + # model instances which store that variable + self.assertEqual( + fruit._var_name_to_model_instances, + { + 'color': [fruit], + 'length_cm': [fruit, banana_instance], + 'cultivar': [fruit], + } + ) + # model._additional_properties_model_instances stores a list of + # models which have the property additional_properties_type != None + self.assertEqual( + fruit._additional_properties_model_instances, [] + ) + + # if we modify one of the properties owned by multiple + # model_instances we get an exception when we try to access that + # property because the retrieved values are not all the same + banana_instance.length_cm = 4.56 + with self.assertRaises(petstore_api.ApiValueError): + some_length_cm = fruit.length_cm + + # including extra parameters raises an exception + with self.assertRaises(petstore_api.ApiValueError): + fruit = petstore_api.Fruit( + color=color, + length_cm=length_cm, + unknown_property='some value' + ) + + # including input parameters for two oneOf instances raise an exception + with self.assertRaises(petstore_api.ApiValueError): + fruit = petstore_api.Fruit( + length_cm=length_cm, + cultivar='granny smith' + ) + + # make an instance of Fruit, a composed schema oneOf model + # apple test + color = 'red' + cultivar = 'golden delicious' + fruit = petstore_api.Fruit(color=color, cultivar=cultivar) + # check its properties + self.assertEqual(fruit.color, color) + self.assertEqual(fruit['color'], color) + self.assertEqual(getattr(fruit, 'color'), color) + self.assertEqual(fruit.cultivar, cultivar) + self.assertEqual(fruit['cultivar'], cultivar) + self.assertEqual(getattr(fruit, 'cultivar'), cultivar) + # check the dict representation + self.assertEqual( + fruit.to_dict(), + { + 'color': color, + 'cultivar': cultivar + } + ) + + # model._composed_instances is a list of the instances that were + # made from the anyOf/allOf/OneOf classes in model._composed_schemas() + for composed_instance in fruit._composed_instances: + if composed_instance.__class__ == petstore_api.Apple: + apple_instance = composed_instance + self.assertEqual( + fruit._composed_instances, + [apple_instance] + ) + # model._var_name_to_model_instances maps the variable name to the + # model instances which store that variable + self.assertEqual( + fruit._var_name_to_model_instances, + { + 'color': [fruit], + 'length_cm': [fruit], + 'cultivar': [fruit, apple_instance], + } + ) + # model._additional_properties_model_instances stores a list of + # models which have the property additional_properties_type != None + self.assertEqual( + fruit._additional_properties_model_instances, [] + ) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-experimental/test/test_fruit_req.py b/samples/openapi3/client/petstore/python-experimental/test/test_fruit_req.py new file mode 100644 index 000000000000..2fa26fac0aa5 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/test/test_fruit_req.py @@ -0,0 +1,166 @@ +# 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 unittest + +import petstore_api + + +class TestFruitReq(unittest.TestCase): + """FruitReq unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testFruitReq(self): + """Test FruitReq""" + + # make an instance of Fruit, a composed schema oneOf model + # banana test + length_cm = 20.3 + fruit = petstore_api.FruitReq(length_cm=length_cm) + # check its properties + self.assertEqual(fruit.length_cm, length_cm) + self.assertEqual(fruit['length_cm'], length_cm) + self.assertEqual(getattr(fruit, 'length_cm'), length_cm) + # check the dict representation + self.assertEqual( + fruit.to_dict(), + { + 'length_cm': length_cm, + } + ) + # setting a value that doesn't exist raises an exception + # with a key + with self.assertRaises(petstore_api.ApiKeyError): + fruit['invalid_variable'] = 'some value' + # with setattr + with self.assertRaises(petstore_api.ApiKeyError): + setattr(fruit, 'invalid_variable', 'some value') + + # getting a value that doesn't exist raises an exception + # with a key + with self.assertRaises(petstore_api.ApiKeyError): + invalid_variable = fruit['cultivar'] + # with getattr + with self.assertRaises(petstore_api.ApiKeyError): + invalid_variable = getattr(fruit, 'cultivar', 'some value') + + # make sure that the ModelComposed class properties are correct + # model.composed_schemas() stores the anyOf/allOf/oneOf info + self.assertEqual( + fruit._composed_schemas(), + { + 'anyOf': [], + 'allOf': [], + 'oneOf': [ + petstore_api.AppleReq, + petstore_api.BananaReq, + ], + } + ) + # model._composed_instances is a list of the instances that were + # made from the anyOf/allOf/OneOf classes in model._composed_schemas() + for composed_instance in fruit._composed_instances: + if composed_instance.__class__ == petstore_api.BananaReq: + banana_instance = composed_instance + self.assertEqual( + fruit._composed_instances, + [banana_instance] + ) + # model._var_name_to_model_instances maps the variable name to the + # model instances which store that variable + self.assertEqual( + fruit._var_name_to_model_instances, + { + 'length_cm': [fruit, banana_instance], + 'cultivar': [fruit], + 'mealy': [fruit], + 'sweet': [fruit, banana_instance], + } + ) + # model._additional_properties_model_instances stores a list of + # models which have the property additional_properties_type != None + self.assertEqual( + fruit._additional_properties_model_instances, [] + ) + + # if we modify one of the properties owned by multiple + # model_instances we get an exception when we try to access that + # property because the retrieved values are not all the same + banana_instance.length_cm = 4.56 + with self.assertRaises(petstore_api.ApiValueError): + some_length_cm = fruit.length_cm + + # including extra parameters raises an exception + with self.assertRaises(petstore_api.ApiValueError): + fruit = petstore_api.FruitReq( + length_cm=length_cm, + unknown_property='some value' + ) + + # including input parameters for two oneOf instances raise an exception + with self.assertRaises(petstore_api.ApiValueError): + fruit = petstore_api.FruitReq( + length_cm=length_cm, + cultivar='granny smith' + ) + + # make an instance of Fruit, a composed schema oneOf model + # apple test + cultivar = 'golden delicious' + fruit = petstore_api.FruitReq(cultivar=cultivar) + # check its properties + self.assertEqual(fruit.cultivar, cultivar) + self.assertEqual(fruit['cultivar'], cultivar) + self.assertEqual(getattr(fruit, 'cultivar'), cultivar) + # check the dict representation + self.assertEqual( + fruit.to_dict(), + { + 'cultivar': cultivar + } + ) + + # model._composed_instances is a list of the instances that were + # made from the anyOf/allOf/OneOf classes in model._composed_schemas() + for composed_instance in fruit._composed_instances: + if composed_instance.__class__ == petstore_api.AppleReq: + apple_instance = composed_instance + self.assertEqual( + fruit._composed_instances, + [apple_instance] + ) + # model._var_name_to_model_instances maps the variable name to the + # model instances which store that variable + self.assertEqual( + fruit._var_name_to_model_instances, + { + 'length_cm': [fruit], + 'cultivar': [fruit, apple_instance], + 'mealy': [fruit, apple_instance], + 'sweet': [fruit], + } + ) + # model._additional_properties_model_instances stores a list of + # models which have the property additional_properties_type != None + self.assertEqual( + fruit._additional_properties_model_instances, [] + ) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-experimental/test/test_gm_fruit.py b/samples/openapi3/client/petstore/python-experimental/test/test_gm_fruit.py new file mode 100644 index 000000000000..dd9605bd8a1b --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/test/test_gm_fruit.py @@ -0,0 +1,208 @@ +# 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 unittest + +import petstore_api + + +class TestGmFruit(unittest.TestCase): + """GmFruit unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testGmFruit(self): + """Test GmFruit""" + + # make an instance of GmFruit, a composed schema anyOf model + # banana test + length_cm = 20.3 + color = 'yellow' + fruit = petstore_api.GmFruit(length_cm=length_cm, color=color) + # check its properties + self.assertEqual(fruit.length_cm, length_cm) + self.assertEqual(fruit['length_cm'], length_cm) + self.assertEqual(getattr(fruit, 'length_cm'), length_cm) + self.assertEqual(fruit.color, color) + self.assertEqual(fruit['color'], color) + self.assertEqual(getattr(fruit, 'color'), color) + # check the dict representation + self.assertEqual( + fruit.to_dict(), + { + 'length_cm': length_cm, + 'color': color + } + ) + # setting a value that doesn't exist raises an exception + # with a key + with self.assertRaises(petstore_api.ApiKeyError): + fruit['invalid_variable'] = 'some value' + # with setattr + with self.assertRaises(petstore_api.ApiKeyError): + setattr(fruit, 'invalid_variable', 'some value') + + # getting a value that doesn't exist raises an exception + # with a key + with self.assertRaises(petstore_api.ApiKeyError): + invalid_variable = fruit['cultivar'] + # with getattr + with self.assertRaises(petstore_api.ApiKeyError): + invalid_variable = getattr(fruit, 'cultivar', 'some value') + + # make sure that the ModelComposed class properties are correct + # model.composed_schemas() stores the anyOf/allOf/oneOf info + self.assertEqual( + fruit._composed_schemas(), + { + 'anyOf': [ + petstore_api.Apple, + petstore_api.Banana, + ], + 'allOf': [], + 'oneOf': [], + } + ) + # model._composed_instances is a list of the instances that were + # made from the anyOf/allOf/OneOf classes in model._composed_schemas() + for composed_instance in fruit._composed_instances: + if composed_instance.__class__ == petstore_api.Banana: + banana_instance = composed_instance + self.assertEqual( + fruit._composed_instances, + [banana_instance] + ) + # model._var_name_to_model_instances maps the variable name to the + # model instances which store that variable + self.assertEqual( + fruit._var_name_to_model_instances, + { + 'color': [fruit], + 'length_cm': [fruit, banana_instance], + 'cultivar': [fruit], + } + ) + # model._additional_properties_model_instances stores a list of + # models which have the property additional_properties_type != None + self.assertEqual( + fruit._additional_properties_model_instances, [] + ) + + # if we modify one of the properties owned by multiple + # model_instances we get an exception when we try to access that + # property because the retrieved values are not all the same + banana_instance.length_cm = 4.56 + with self.assertRaises(petstore_api.ApiValueError): + some_length_cm = fruit.length_cm + + # including extra parameters raises an exception + with self.assertRaises(petstore_api.ApiValueError): + fruit = petstore_api.GmFruit( + color=color, + length_cm=length_cm, + unknown_property='some value' + ) + + # including input parameters for both anyOf instances works + cultivar = 'banaple' + color = 'orange' + fruit = petstore_api.GmFruit( + color=color, + cultivar=cultivar, + length_cm=length_cm + ) + self.assertEqual(fruit.color, color) + self.assertEqual(fruit['color'], color) + self.assertEqual(getattr(fruit, 'color'), color) + self.assertEqual(fruit.cultivar, cultivar) + self.assertEqual(fruit['cultivar'], cultivar) + self.assertEqual(getattr(fruit, 'cultivar'), cultivar) + self.assertEqual(fruit.length_cm, length_cm) + self.assertEqual(fruit['length_cm'], length_cm) + self.assertEqual(getattr(fruit, 'length_cm'), length_cm) + + # model._composed_instances is a list of the instances that were + # made from the anyOf/allOf/OneOf classes in model._composed_schemas() + for composed_instance in fruit._composed_instances: + if composed_instance.__class__ == petstore_api.Apple: + apple_instance = composed_instance + elif composed_instance.__class__ == petstore_api.Banana: + banana_instance = composed_instance + self.assertEqual( + fruit._composed_instances, + [apple_instance, banana_instance] + ) + # model._var_name_to_model_instances maps the variable name to the + # model instances which store that variable + self.assertEqual( + fruit._var_name_to_model_instances, + { + 'color': [fruit], + 'length_cm': [fruit, banana_instance], + 'cultivar': [fruit, apple_instance], + } + ) + + # make an instance of GmFruit, a composed schema anyOf model + # apple test + color = 'red' + cultivar = 'golden delicious' + fruit = petstore_api.GmFruit(color=color, cultivar=cultivar) + # check its properties + self.assertEqual(fruit.color, color) + self.assertEqual(fruit['color'], color) + self.assertEqual(getattr(fruit, 'color'), color) + self.assertEqual(fruit.cultivar, cultivar) + self.assertEqual(fruit['cultivar'], cultivar) + self.assertEqual(getattr(fruit, 'cultivar'), cultivar) + # check the dict representation + self.assertEqual( + fruit.to_dict(), + { + 'color': color, + 'cultivar': cultivar + } + ) + + # model._composed_instances is a list of the instances that were + # made from the anyOf/allOf/OneOf classes in model._composed_schemas() + for composed_instance in fruit._composed_instances: + if composed_instance.__class__ == petstore_api.Apple: + apple_instance = composed_instance + self.assertEqual( + fruit._composed_instances, + [apple_instance] + ) + # model._var_name_to_model_instances maps the variable name to the + # model instances which store that variable + self.assertEqual( + fruit._var_name_to_model_instances, + { + 'color': [fruit], + 'length_cm': [fruit], + 'cultivar': [fruit, apple_instance], + } + ) + # model._additional_properties_model_instances stores a list of + # models which have the property additional_properties_type != None + self.assertEqual( + fruit._additional_properties_model_instances, [] + ) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-experimental/test/test_mammal.py b/samples/openapi3/client/petstore/python-experimental/test/test_mammal.py new file mode 100644 index 000000000000..1b4f161196e7 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/test/test_mammal.py @@ -0,0 +1,37 @@ +# 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 unittest + +import petstore_api + + +class TestMammal(unittest.TestCase): + """Mammal unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testMammal(self): + """Test Mammal""" + # FIXME: construct object with mandatory attributes with example values + # model = petstore_api.Mammal() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-experimental/test/test_whale.py b/samples/openapi3/client/petstore/python-experimental/test/test_whale.py new file mode 100644 index 000000000000..35d68f0cda02 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/test/test_whale.py @@ -0,0 +1,37 @@ +# 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 unittest + +import petstore_api + + +class TestWhale(unittest.TestCase): + """Whale unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testWhale(self): + """Test Whale""" + # FIXME: construct object with mandatory attributes with example values + # model = petstore_api.Whale() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-experimental/test/test_zebra.py b/samples/openapi3/client/petstore/python-experimental/test/test_zebra.py new file mode 100644 index 000000000000..6013bd9a9a20 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/test/test_zebra.py @@ -0,0 +1,37 @@ +# 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 unittest + +import petstore_api + + +class TestZebra(unittest.TestCase): + """Zebra unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testZebra(self): + """Test Zebra""" + # FIXME: construct object with mandatory attributes with example values + # model = petstore_api.Zebra() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-experimental/tests/test_deserialization.py b/samples/openapi3/client/petstore/python-experimental/tests/test_deserialization.py new file mode 100644 index 000000000000..f1a71a67378b --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/tests/test_deserialization.py @@ -0,0 +1,86 @@ +# coding: utf-8 + +# flake8: noqa + +""" +Run the tests. +$ pip install nose (optional) +$ cd OpenAPIPetstore-python +$ nosetests -v +""" +from collections import namedtuple +import json +import os +import time +import unittest +import datetime + +import petstore_api + + +MockResponse = namedtuple('MockResponse', 'data') + + +class DeserializationTests(unittest.TestCase): + + def setUp(self): + self.api_client = petstore_api.ApiClient() + self.deserialize = self.api_client.deserialize + + def test_deserialize_animal(self): + """ + deserialize Animal to a Dog instance + Animal uses a discriminator which has a map built of child classes + that inherrit from Animal + This is the swagger (v2) way of doing something like oneOf composition + """ + class_name = 'Dog' + color = 'white' + breed = 'Jack Russel Terrier' + data = { + 'className': class_name, + 'color': color, + 'breed': breed + } + response = MockResponse(data=json.dumps(data)) + + deserialized = self.deserialize(response, (petstore_api.Animal,), True) + self.assertTrue(isinstance(deserialized, petstore_api.Dog)) + self.assertEqual(deserialized.class_name, class_name) + self.assertEqual(deserialized.color, color) + self.assertEqual(deserialized.breed, breed) + + def test_deserialize_mammal(self): + """ + deserialize mammal + mammal is a oneOf composed schema model with discriminator + """ + + # whale test + has_baleen = True + has_teeth = False + class_name = 'whale' + data = { + 'hasBaleen': has_baleen, + 'hasTeeth': has_teeth, + 'className': class_name + } + response = MockResponse(data=json.dumps(data)) + deserialized = self.deserialize(response, (petstore_api.Mammal,), True) + self.assertTrue(isinstance(deserialized, petstore_api.Whale)) + self.assertEqual(deserialized.has_baleen, has_baleen) + self.assertEqual(deserialized.has_teeth, has_teeth) + self.assertEqual(deserialized.class_name, class_name) + + # zebra test + zebra_type = 'plains' + class_name = 'zebra' + data = { + 'type': zebra_type, + 'className': class_name + } + response = MockResponse(data=json.dumps(data)) + deserialized = self.deserialize(response, (petstore_api.Mammal,), True) + self.assertTrue(isinstance(deserialized, petstore_api.Zebra)) + self.assertEqual(deserialized.type, zebra_type) + self.assertEqual(deserialized.class_name, class_name) \ No newline at end of file diff --git a/samples/openapi3/client/petstore/python-experimental/tests/test_http_signature.py b/samples/openapi3/client/petstore/python-experimental/tests/test_http_signature.py index c6c7c5e9bc11..0ef089cfff51 100644 --- a/samples/openapi3/client/petstore/python-experimental/tests/test_http_signature.py +++ b/samples/openapi3/client/petstore/python-experimental/tests/test_http_signature.py @@ -192,57 +192,73 @@ def _validate_authorization_header(self, request_target, actual_headers, authori class PetApiTests(unittest.TestCase): - def setUp(self): - self.setUpModels() - self.setUpFiles() - - - def setUpModels(self): - self.category = petstore_api.Category() - self.category.id = id_gen() - self.category.name = "dog" - self.tag = petstore_api.Tag() - self.tag.id = id_gen() - self.tag.name = "python-pet-tag" - self.pet = petstore_api.Pet(name="hello kity", photo_urls=["http://foo.bar.com/1", "http://foo.bar.com/2"]) - self.pet.id = id_gen() - self.pet.status = "sold" - self.pet.category = self.category - self.pet.tags = [self.tag] - - def setUpFiles(self): - self.test_file_dir = os.path.join(os.path.dirname(__file__), "..", "testfiles") - self.test_file_dir = os.path.realpath(self.test_file_dir) - if not os.path.exists(self.test_file_dir): - os.mkdir(self.test_file_dir) - - self.private_key_passphrase = 'test-passphrase' - self.rsa_key_path = os.path.join(self.test_file_dir, 'rsa.pem') - self.rsa4096_key_path = os.path.join(self.test_file_dir, 'rsa4096.pem') - self.ec_p521_key_path = os.path.join(self.test_file_dir, 'ecP521.pem') - - if not os.path.exists(self.rsa_key_path): - with open(self.rsa_key_path, 'w') as f: + @classmethod + def setUpClass(cls): + cls.setUpModels() + cls.setUpFiles() + + @classmethod + def tearDownClass(cls): + file_paths = [ + cls.rsa_key_path, + cls.rsa4096_key_path, + cls.ec_p521_key_path, + ] + for file_path in file_paths: + os.unlink(file_path) + + @classmethod + def setUpModels(cls): + cls.category = petstore_api.Category() + cls.category.id = id_gen() + cls.category.name = "dog" + cls.tag = petstore_api.Tag() + cls.tag.id = id_gen() + cls.tag.name = "python-pet-tag" + cls.pet = petstore_api.Pet( + name="hello kity", + photo_urls=["http://foo.bar.com/1", "http://foo.bar.com/2"] + ) + cls.pet.id = id_gen() + cls.pet.status = "sold" + cls.pet.category = cls.category + cls.pet.tags = [cls.tag] + + @classmethod + def setUpFiles(cls): + cls.test_file_dir = os.path.join( + os.path.dirname(__file__), "..", "testfiles") + cls.test_file_dir = os.path.realpath(cls.test_file_dir) + if not os.path.exists(cls.test_file_dir): + os.mkdir(cls.test_file_dir) + + cls.private_key_passphrase = 'test-passphrase' + cls.rsa_key_path = os.path.join(cls.test_file_dir, 'rsa.pem') + cls.rsa4096_key_path = os.path.join(cls.test_file_dir, 'rsa4096.pem') + cls.ec_p521_key_path = os.path.join(cls.test_file_dir, 'ecP521.pem') + + if not os.path.exists(cls.rsa_key_path): + with open(cls.rsa_key_path, 'w') as f: f.write(RSA_TEST_PRIVATE_KEY) - if not os.path.exists(self.rsa4096_key_path): + if not os.path.exists(cls.rsa4096_key_path): key = RSA.generate(4096) private_key = key.export_key( - passphrase=self.private_key_passphrase, + passphrase=cls.private_key_passphrase, protection='PEM' ) - with open(self.rsa4096_key_path, "wb") as f: + with open(cls.rsa4096_key_path, "wb") as f: f.write(private_key) - if not os.path.exists(self.ec_p521_key_path): + if not os.path.exists(cls.ec_p521_key_path): key = ECC.generate(curve='P-521') private_key = key.export_key( format='PEM', - passphrase=self.private_key_passphrase, + passphrase=cls.private_key_passphrase, use_pkcs8=True, protection='PBKDF2WithHMAC-SHA1AndAES128-CBC' ) - with open(self.ec_p521_key_path, "wt") as f: + with open(cls.ec_p521_key_path, "wt") as f: f.write(private_key) def test_valid_http_signature(self):