From e43db8b8bf2931cf846f2bc7ae46841f4f399852 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Mon, 3 Feb 2020 10:20:23 -0800 Subject: [PATCH 1/7] Adds oneOf + anyOf schemas, models and tests to python-experimental --- bin/openapi3/python-experimental-petstore.sh | 2 +- .../windows/python-experimental-petstore.bat | 2 +- .../PythonClientExperimentalCodegen.java | 55 + .../python/python-experimental/model.mustache | 1 + .../method_init_composed.mustache | 14 +- .../method_init_shared.mustache | 30 +- .../methods_setattr_getattr_composed.mustache | 20 +- .../python-experimental/model_utils.mustache | 28 +- .../python-experimental/requirements.mustache | 1 + .../python/python-experimental/setup.mustache | 1 + ...dels-for-testing-httpsig-cmpsdschemas.yaml | 1855 +++++++++++++++++ .../petstore_api/model_utils.py | 46 +- .../models/additional_properties_any_type.py | 2 +- .../models/additional_properties_array.py | 2 +- .../models/additional_properties_boolean.py | 2 +- .../models/additional_properties_class.py | 2 +- .../models/additional_properties_integer.py | 2 +- .../models/additional_properties_number.py | 2 +- .../models/additional_properties_object.py | 2 +- .../models/additional_properties_string.py | 2 +- .../petstore_api/models/animal.py | 1 + .../petstore_api/models/api_response.py | 2 +- .../models/array_of_array_of_number_only.py | 2 +- .../models/array_of_number_only.py | 2 +- .../petstore_api/models/array_test.py | 2 +- .../petstore_api/models/capitalization.py | 2 +- .../petstore_api/models/cat.py | 13 +- .../petstore_api/models/cat_all_of.py | 2 +- .../petstore_api/models/category.py | 3 +- .../petstore_api/models/child.py | 13 +- .../petstore_api/models/child_all_of.py | 2 +- .../petstore_api/models/child_cat.py | 13 +- .../petstore_api/models/child_cat_all_of.py | 2 +- .../petstore_api/models/child_dog.py | 13 +- .../petstore_api/models/child_dog_all_of.py | 2 +- .../petstore_api/models/child_lizard.py | 13 +- .../models/child_lizard_all_of.py | 2 +- .../petstore_api/models/class_model.py | 2 +- .../petstore_api/models/client.py | 2 +- .../petstore_api/models/dog.py | 13 +- .../petstore_api/models/dog_all_of.py | 2 +- .../petstore_api/models/enum_arrays.py | 2 +- .../petstore_api/models/enum_class.py | 3 +- .../petstore_api/models/enum_test.py | 1 + .../petstore_api/models/file.py | 2 +- .../models/file_schema_test_class.py | 2 +- .../petstore_api/models/format_test.py | 1 + .../petstore_api/models/grandparent.py | 2 +- .../petstore_api/models/grandparent_animal.py | 1 + .../petstore_api/models/has_only_read_only.py | 2 +- .../petstore_api/models/list.py | 2 +- .../petstore_api/models/map_test.py | 2 +- ...perties_and_additional_properties_class.py | 2 +- .../petstore_api/models/model200_response.py | 2 +- .../petstore_api/models/model_return.py | 2 +- .../petstore_api/models/name.py | 1 + .../petstore_api/models/number_only.py | 2 +- .../petstore_api/models/order.py | 2 +- .../petstore_api/models/outer_composite.py | 2 +- .../petstore_api/models/outer_enum.py | 1 + .../petstore_api/models/outer_number.py | 1 + .../petstore_api/models/parent.py | 13 +- .../petstore_api/models/parent_all_of.py | 2 +- .../petstore_api/models/parent_pet.py | 13 +- .../petstore_api/models/pet.py | 1 + .../petstore_api/models/player.py | 1 + .../petstore_api/models/read_only_first.py | 2 +- .../petstore_api/models/special_model_name.py | 2 +- .../petstore_api/models/string_boolean_map.py | 2 +- .../petstore_api/models/tag.py | 2 +- .../models/type_holder_default.py | 9 +- .../models/type_holder_example.py | 7 +- .../petstore_api/models/user.py | 2 +- .../petstore_api/models/xml_item.py | 2 +- .../python-experimental/requirements.txt | 1 + .../petstore/python-experimental/setup.py | 1 + .../petstore/python-experimental/README.md | 10 + .../python-experimental/docs/Apple.md | 10 + .../python-experimental/docs/AppleReq.md | 11 + .../python-experimental/docs/Banana.md | 10 + .../python-experimental/docs/BananaReq.md | 11 + .../python-experimental/docs/Fruit.md | 12 + .../python-experimental/docs/FruitReq.md | 13 + .../python-experimental/docs/GmFruit.md | 12 + .../python-experimental/docs/Mammal.md | 13 + .../python-experimental/docs/Whale.md | 12 + .../python-experimental/docs/Zebra.md | 11 + .../petstore_api/__init__.py | 10 + .../petstore_api/model_utils.py | 46 +- .../models/additional_properties_class.py | 2 +- .../petstore_api/models/animal.py | 1 + .../petstore_api/models/api_response.py | 2 +- .../petstore_api/models/apple.py | 127 ++ .../petstore_api/models/apple_req.py | 133 ++ .../models/array_of_array_of_number_only.py | 2 +- .../models/array_of_number_only.py | 2 +- .../petstore_api/models/array_test.py | 2 +- .../petstore_api/models/banana.py | 127 ++ .../petstore_api/models/banana_req.py | 133 ++ .../petstore_api/models/capitalization.py | 2 +- .../petstore_api/models/cat.py | 13 +- .../petstore_api/models/cat_all_of.py | 2 +- .../petstore_api/models/category.py | 3 +- .../petstore_api/models/class_model.py | 2 +- .../petstore_api/models/client.py | 2 +- .../petstore_api/models/dog.py | 13 +- .../petstore_api/models/dog_all_of.py | 2 +- .../petstore_api/models/enum_arrays.py | 2 +- .../petstore_api/models/enum_class.py | 3 +- .../petstore_api/models/enum_test.py | 1 + .../petstore_api/models/file.py | 2 +- .../models/file_schema_test_class.py | 2 +- .../petstore_api/models/foo.py | 2 +- .../petstore_api/models/format_test.py | 1 + .../petstore_api/models/fruit.py | 186 ++ .../petstore_api/models/fruit_req.py | 193 ++ .../petstore_api/models/gm_fruit.py | 186 ++ .../petstore_api/models/gm_mammal.py | 212 ++ .../petstore_api/models/has_only_read_only.py | 2 +- .../models/health_check_result.py | 2 +- .../petstore_api/models/inline_object.py | 2 +- .../petstore_api/models/inline_object1.py | 2 +- .../petstore_api/models/inline_object2.py | 2 +- .../petstore_api/models/inline_object3.py | 1 + .../petstore_api/models/inline_object4.py | 1 + .../petstore_api/models/inline_object5.py | 1 + .../models/inline_response_default.py | 2 +- .../petstore_api/models/list.py | 2 +- .../petstore_api/models/mammal.py | 215 ++ .../petstore_api/models/map_test.py | 2 +- ...perties_and_additional_properties_class.py | 2 +- .../petstore_api/models/model200_response.py | 2 +- .../petstore_api/models/model_return.py | 2 +- .../petstore_api/models/name.py | 1 + .../petstore_api/models/nullable_class.py | 2 +- .../petstore_api/models/number_only.py | 2 +- .../petstore_api/models/order.py | 2 +- .../petstore_api/models/outer_composite.py | 2 +- .../petstore_api/models/outer_enum.py | 1 + .../models/outer_enum_default_value.py | 3 +- .../petstore_api/models/outer_enum_integer.py | 1 + .../outer_enum_integer_default_value.py | 3 +- .../petstore_api/models/pet.py | 1 + .../petstore_api/models/read_only_first.py | 2 +- .../petstore_api/models/special_model_name.py | 2 +- .../petstore_api/models/string_boolean_map.py | 2 +- .../petstore_api/models/tag.py | 2 +- .../petstore_api/models/user.py | 2 +- .../petstore_api/models/whale.py | 136 ++ .../petstore_api/models/zebra.py | 138 ++ .../python-experimental/requirements.txt | 1 + .../petstore/python-experimental/setup.py | 1 + .../python-experimental/test/test_apple.py | 37 + .../test/test_apple_req.py | 37 + .../python-experimental/test/test_banana.py | 37 + .../test/test_banana_req.py | 37 + .../python-experimental/test/test_fruit.py | 175 ++ .../test/test_fruit_req.py | 166 ++ .../python-experimental/test/test_gm_fruit.py | 208 ++ .../python-experimental/test/test_mammal.py | 37 + .../python-experimental/test/test_whale.py | 37 + .../python-experimental/test/test_zebra.py | 37 + .../python-experimental/testfiles/ecP521.pem | 10 + .../python-experimental/testfiles/rsa.pem | 15 + .../python-experimental/testfiles/rsa4096.pem | 54 + .../tests/test_deserialization.py | 86 + 166 files changed, 5164 insertions(+), 168 deletions(-) create mode 100644 modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-httpsig-cmpsdschemas.yaml create mode 100644 samples/openapi3/client/petstore/python-experimental/docs/Apple.md create mode 100644 samples/openapi3/client/petstore/python-experimental/docs/AppleReq.md create mode 100644 samples/openapi3/client/petstore/python-experimental/docs/Banana.md create mode 100644 samples/openapi3/client/petstore/python-experimental/docs/BananaReq.md create mode 100644 samples/openapi3/client/petstore/python-experimental/docs/Fruit.md create mode 100644 samples/openapi3/client/petstore/python-experimental/docs/FruitReq.md create mode 100644 samples/openapi3/client/petstore/python-experimental/docs/GmFruit.md create mode 100644 samples/openapi3/client/petstore/python-experimental/docs/Mammal.md create mode 100644 samples/openapi3/client/petstore/python-experimental/docs/Whale.md create mode 100644 samples/openapi3/client/petstore/python-experimental/docs/Zebra.md create mode 100644 samples/openapi3/client/petstore/python-experimental/petstore_api/models/apple.py create mode 100644 samples/openapi3/client/petstore/python-experimental/petstore_api/models/apple_req.py create mode 100644 samples/openapi3/client/petstore/python-experimental/petstore_api/models/banana.py create mode 100644 samples/openapi3/client/petstore/python-experimental/petstore_api/models/banana_req.py create mode 100644 samples/openapi3/client/petstore/python-experimental/petstore_api/models/fruit.py create mode 100644 samples/openapi3/client/petstore/python-experimental/petstore_api/models/fruit_req.py create mode 100644 samples/openapi3/client/petstore/python-experimental/petstore_api/models/gm_fruit.py create mode 100644 samples/openapi3/client/petstore/python-experimental/petstore_api/models/gm_mammal.py create mode 100644 samples/openapi3/client/petstore/python-experimental/petstore_api/models/mammal.py create mode 100644 samples/openapi3/client/petstore/python-experimental/petstore_api/models/whale.py create mode 100644 samples/openapi3/client/petstore/python-experimental/petstore_api/models/zebra.py create mode 100644 samples/openapi3/client/petstore/python-experimental/test/test_apple.py create mode 100644 samples/openapi3/client/petstore/python-experimental/test/test_apple_req.py create mode 100644 samples/openapi3/client/petstore/python-experimental/test/test_banana.py create mode 100644 samples/openapi3/client/petstore/python-experimental/test/test_banana_req.py create mode 100644 samples/openapi3/client/petstore/python-experimental/test/test_fruit.py create mode 100644 samples/openapi3/client/petstore/python-experimental/test/test_fruit_req.py create mode 100644 samples/openapi3/client/petstore/python-experimental/test/test_gm_fruit.py create mode 100644 samples/openapi3/client/petstore/python-experimental/test/test_mammal.py create mode 100644 samples/openapi3/client/petstore/python-experimental/test/test_whale.py create mode 100644 samples/openapi3/client/petstore/python-experimental/test/test_zebra.py create mode 100644 samples/openapi3/client/petstore/python-experimental/testfiles/ecP521.pem create mode 100644 samples/openapi3/client/petstore/python-experimental/testfiles/rsa.pem create mode 100644 samples/openapi3/client/petstore/python-experimental/testfiles/rsa4096.pem create mode 100644 samples/openapi3/client/petstore/python-experimental/tests/test_deserialization.py diff --git a/bin/openapi3/python-experimental-petstore.sh b/bin/openapi3/python-experimental-petstore.sh index 71cd902dee57..188b45f15cbd 100755 --- a/bin/openapi3/python-experimental-petstore.sh +++ b/bin/openapi3/python-experimental-petstore.sh @@ -28,7 +28,7 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties" #yaml="modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml" -yaml="modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml" +yaml="modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-httpsig-cmpsdschemas.yaml" ags="generate -t modules/openapi-generator/src/main/resources/python -i $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/bin/openapi3/windows/python-experimental-petstore.bat b/bin/openapi3/windows/python-experimental-petstore.bat index 73c433de2784..5043ea878750 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-httpsig-cmpsdschemas.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..c6bcdf747f35 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,12 +30,14 @@ _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 = {} self._check_type = _check_type self._from_server = _from_server self._path_to_item = _path_to_item - self._configuration = _configuration \ No newline at end of file + self._configuration = _configuration 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-httpsig-cmpsdschemas.yaml b/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-httpsig-cmpsdschemas.yaml new file mode 100644 index 000000000000..31b4e2e1dd60 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-httpsig-cmpsdschemas.yaml @@ -0,0 +1,1855 @@ +openapi: 3.0.0 +info: + description: >- + This spec is mainly for testing Petstore server and contains fake endpoints, + models. Please do not use this for any other purpose. Special characters: " + \ + version: 1.0.0 + title: OpenAPI Petstore + license: + name: Apache-2.0 + url: 'https://www.apache.org/licenses/LICENSE-2.0.html' +tags: + - name: pet + description: Everything about your Pets + - name: store + description: Access to Petstore orders + - name: user + description: Operations about user +paths: + /foo: + get: + responses: + default: + description: response + content: + application/json: + schema: + type: object + properties: + string: + $ref: '#/components/schemas/Foo' + /pet: + servers: + - url: 'http://petstore.swagger.io/v2' + - url: 'http://path-server-test.petstore.local/v2' + post: + tags: + - pet + summary: Add a new pet to the store + description: '' + operationId: addPet + responses: + '405': + description: Invalid input + security: + - http_signature_test: [] + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + $ref: '#/components/requestBodies/Pet' + put: + tags: + - pet + summary: Update an existing pet + description: '' + operationId: updatePet + responses: + '400': + description: Invalid ID supplied + '404': + description: Pet not found + '405': + description: Validation exception + security: + - http_signature_test: [] + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + $ref: '#/components/requestBodies/Pet' + /pet/findByStatus: + get: + tags: + - pet + summary: Finds Pets by status + description: Multiple status values can be provided with comma separated strings + operationId: findPetsByStatus + parameters: + - name: status + in: query + description: Status values that need to be considered for filter + required: true + style: form + explode: false + schema: + type: array + items: + type: string + enum: + - available + - pending + - sold + default: available + responses: + '200': + description: successful operation + content: + application/xml: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + '400': + description: Invalid status value + security: + - http_signature_test: [] + - petstore_auth: + - 'write:pets' + - 'read:pets' + /pet/findByTags: + get: + tags: + - pet + summary: Finds Pets by tags + description: >- + Multiple tags can be provided with comma separated strings. Use tag1, + tag2, tag3 for testing. + operationId: findPetsByTags + parameters: + - name: tags + in: query + description: Tags to filter by + required: true + style: form + explode: false + schema: + type: array + items: + type: string + responses: + '200': + description: successful operation + content: + application/xml: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + '400': + description: Invalid tag value + security: + - http_signature_test: [] + - petstore_auth: + - 'write:pets' + - 'read:pets' + deprecated: true + '/pet/{petId}': + get: + tags: + - pet + summary: Find pet by ID + description: Returns a single pet + operationId: getPetById + parameters: + - name: petId + in: path + description: ID of pet to return + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Pet' + application/json: + schema: + $ref: '#/components/schemas/Pet' + '400': + description: Invalid ID supplied + '404': + description: Pet not found + security: + - api_key: [] + post: + tags: + - pet + summary: Updates a pet in the store with form data + description: '' + operationId: updatePetWithForm + parameters: + - name: petId + in: path + description: ID of pet that needs to be updated + required: true + schema: + type: integer + format: int64 + responses: + '405': + description: Invalid input + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string + delete: + tags: + - pet + summary: Deletes a pet + description: '' + operationId: deletePet + parameters: + - name: api_key + in: header + required: false + schema: + type: string + - name: petId + in: path + description: Pet id to delete + required: true + schema: + type: integer + format: int64 + responses: + '400': + description: Invalid pet value + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + '/pet/{petId}/uploadImage': + post: + tags: + - pet + summary: uploads an image + description: '' + operationId: uploadFile + parameters: + - name: petId + in: path + description: ID of pet to update + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + content: + multipart/form-data: + schema: + type: object + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + type: string + format: binary + /store/inventory: + get: + tags: + - store + summary: Returns pet inventories by status + description: Returns a map of status codes to quantities + operationId: getInventory + responses: + '200': + description: successful operation + content: + application/json: + schema: + type: object + additionalProperties: + type: integer + format: int32 + security: + - api_key: [] + /store/order: + post: + tags: + - store + summary: Place an order for a pet + description: '' + operationId: placeOrder + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Order' + application/json: + schema: + $ref: '#/components/schemas/Order' + '400': + description: Invalid Order + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Order' + description: order placed for purchasing the pet + required: true + '/store/order/{order_id}': + get: + tags: + - store + summary: Find purchase order by ID + description: >- + For valid response try integer IDs with value <= 5 or > 10. Other values + will generated exceptions + operationId: getOrderById + parameters: + - name: order_id + in: path + description: ID of pet that needs to be fetched + required: true + schema: + type: integer + format: int64 + minimum: 1 + maximum: 5 + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Order' + application/json: + schema: + $ref: '#/components/schemas/Order' + '400': + description: Invalid ID supplied + '404': + description: Order not found + delete: + tags: + - store + summary: Delete purchase order by ID + description: >- + For valid response try integer IDs with value < 1000. Anything above + 1000 or nonintegers will generate API errors + operationId: deleteOrder + parameters: + - name: order_id + in: path + description: ID of the order that needs to be deleted + required: true + schema: + type: string + responses: + '400': + description: Invalid ID supplied + '404': + description: Order not found + /user: + post: + tags: + - user + summary: Create user + description: This can only be done by the logged in user. + operationId: createUser + responses: + default: + description: successful operation + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + description: Created user object + required: true + /user/createWithArray: + post: + tags: + - user + summary: Creates list of users with given input array + description: '' + operationId: createUsersWithArrayInput + responses: + default: + description: successful operation + requestBody: + $ref: '#/components/requestBodies/UserArray' + /user/createWithList: + post: + tags: + - user + summary: Creates list of users with given input array + description: '' + operationId: createUsersWithListInput + responses: + default: + description: successful operation + requestBody: + $ref: '#/components/requestBodies/UserArray' + /user/login: + get: + tags: + - user + summary: Logs user into the system + description: '' + operationId: loginUser + parameters: + - name: username + in: query + description: The user name for login + required: true + schema: + type: string + - name: password + in: query + description: The password for login in clear text + required: true + schema: + type: string + responses: + '200': + description: successful operation + headers: + X-Rate-Limit: + description: calls per hour allowed by the user + schema: + type: integer + format: int32 + X-Expires-After: + description: date in UTC when token expires + schema: + type: string + format: date-time + content: + application/xml: + schema: + type: string + application/json: + schema: + type: string + '400': + description: Invalid username/password supplied + /user/logout: + get: + tags: + - user + summary: Logs out current logged in user session + description: '' + operationId: logoutUser + responses: + default: + description: successful operation + '/user/{username}': + get: + tags: + - user + summary: Get user by user name + description: '' + operationId: getUserByName + parameters: + - name: username + in: path + description: The name that needs to be fetched. Use user1 for testing. + required: true + schema: + type: string + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/User' + application/json: + schema: + $ref: '#/components/schemas/User' + '400': + description: Invalid username supplied + '404': + description: User not found + put: + tags: + - user + summary: Updated user + description: This can only be done by the logged in user. + operationId: updateUser + parameters: + - name: username + in: path + description: name that need to be deleted + required: true + schema: + type: string + responses: + '400': + description: Invalid user supplied + '404': + description: User not found + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + description: Updated user object + required: true + delete: + tags: + - user + summary: Delete user + description: This can only be done by the logged in user. + operationId: deleteUser + parameters: + - name: username + in: path + description: The name that needs to be deleted + required: true + schema: + type: string + responses: + '400': + description: Invalid username supplied + '404': + description: User not found + /fake_classname_test: + patch: + tags: + - 'fake_classname_tags 123#$%^' + summary: To test class name in snake case + description: To test class name in snake case + operationId: testClassname + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + security: + - api_key_query: [] + requestBody: + $ref: '#/components/requestBodies/Client' + /fake: + patch: + tags: + - fake + summary: To test "client" model + description: To test "client" model + operationId: testClientModel + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + requestBody: + $ref: '#/components/requestBodies/Client' + get: + tags: + - fake + summary: To test enum parameters + description: To test enum parameters + operationId: testEnumParameters + parameters: + - name: enum_header_string_array + in: header + description: Header parameter enum test (string array) + schema: + type: array + items: + type: string + default: $ + enum: + - '>' + - $ + - name: enum_header_string + in: header + description: Header parameter enum test (string) + schema: + type: string + enum: + - _abc + - '-efg' + - (xyz) + default: '-efg' + - name: enum_query_string_array + in: query + description: Query parameter enum test (string array) + schema: + type: array + items: + type: string + default: $ + enum: + - '>' + - $ + - name: enum_query_string + in: query + description: Query parameter enum test (string) + schema: + type: string + enum: + - _abc + - '-efg' + - (xyz) + default: '-efg' + - name: enum_query_integer + in: query + description: Query parameter enum test (double) + schema: + type: integer + format: int32 + enum: + - 1 + - -2 + - name: enum_query_double + in: query + description: Query parameter enum test (double) + schema: + type: number + format: double + enum: + - 1.1 + - -1.2 + responses: + '400': + description: Invalid request + '404': + description: Not found + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + enum_form_string_array: + description: Form parameter enum test (string array) + type: array + items: + type: string + default: $ + enum: + - '>' + - $ + enum_form_string: + description: Form parameter enum test (string) + type: string + enum: + - _abc + - '-efg' + - (xyz) + default: '-efg' + post: + tags: + - fake + summary: | + Fake endpoint for testing various parameters + 假端點 + 偽のエンドポイント + 가짜 엔드 포인트 + description: | + Fake endpoint for testing various parameters + 假端點 + 偽のエンドポイント + 가짜 엔드 포인트 + operationId: testEndpointParameters + responses: + '400': + description: Invalid username supplied + '404': + description: User not found + security: + - http_basic_test: [] + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + integer: + description: None + type: integer + minimum: 10 + maximum: 100 + int32: + description: None + type: integer + format: int32 + minimum: 20 + maximum: 200 + int64: + description: None + type: integer + format: int64 + number: + description: None + type: number + minimum: 32.1 + maximum: 543.2 + float: + description: None + type: number + format: float + maximum: 987.6 + double: + description: None + type: number + format: double + minimum: 67.8 + maximum: 123.4 + string: + description: None + type: string + pattern: '/[a-z]/i' + pattern_without_delimiter: + description: None + type: string + pattern: '^[A-Z].*' + byte: + description: None + type: string + format: byte + binary: + description: None + type: string + format: binary + date: + description: None + type: string + format: date + dateTime: + description: None + type: string + format: date-time + password: + description: None + type: string + format: password + minLength: 10 + maxLength: 64 + callback: + description: None + type: string + required: + - number + - double + - pattern_without_delimiter + - byte + delete: + tags: + - fake + security: + - bearer_test: [] + summary: Fake endpoint to test group parameters (optional) + description: Fake endpoint to test group parameters (optional) + operationId: testGroupParameters + x-group-parameters: true + parameters: + - name: required_string_group + in: query + description: Required String in group parameters + required: true + schema: + type: integer + - name: required_boolean_group + in: header + description: Required Boolean in group parameters + required: true + schema: + type: boolean + - name: required_int64_group + in: query + description: Required Integer in group parameters + required: true + schema: + type: integer + format: int64 + - name: string_group + in: query + description: String in group parameters + schema: + type: integer + - name: boolean_group + in: header + description: Boolean in group parameters + schema: + type: boolean + - name: int64_group + in: query + description: Integer in group parameters + schema: + type: integer + format: int64 + responses: + '400': + description: Someting wrong + /fake/outer/number: + post: + tags: + - fake + description: Test serialization of outer number types + operationId: fakeOuterNumberSerialize + responses: + '200': + description: Output number + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterNumber' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterNumber' + description: Input number as post body + /fake/outer/string: + post: + tags: + - fake + description: Test serialization of outer string types + operationId: fakeOuterStringSerialize + responses: + '200': + description: Output string + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterString' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterString' + description: Input string as post body + /fake/outer/boolean: + post: + tags: + - fake + description: Test serialization of outer boolean types + operationId: fakeOuterBooleanSerialize + responses: + '200': + description: Output boolean + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterBoolean' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterBoolean' + description: Input boolean as post body + /fake/outer/composite: + post: + tags: + - fake + description: Test serialization of object with outer number type + operationId: fakeOuterCompositeSerialize + responses: + '200': + description: Output composite + content: + '*/*': + schema: + $ref: '#/components/schemas/OuterComposite' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/OuterComposite' + description: Input composite as post body + /fake/jsonFormData: + get: + tags: + - fake + summary: test json serialization of form data + description: '' + operationId: testJsonFormData + responses: + '200': + description: successful operation + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + param: + description: field1 + type: string + param2: + description: field2 + type: string + required: + - param + - param2 + /fake/inline-additionalProperties: + post: + tags: + - fake + summary: test inline additionalProperties + description: '' + operationId: testInlineAdditionalProperties + responses: + '200': + description: successful operation + requestBody: + content: + application/json: + schema: + type: object + additionalProperties: + type: string + description: request body + required: true + /fake/body-with-query-params: + put: + tags: + - fake + operationId: testBodyWithQueryParams + parameters: + - name: query + in: query + required: true + schema: + type: string + responses: + '200': + description: Success + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + required: true + /another-fake/dummy: + patch: + tags: + - $another-fake? + summary: To test special tags + description: To test special tags and operation ID starting with number + operationId: '123_test_@#$%_special_tags' + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + requestBody: + $ref: '#/components/requestBodies/Client' + /fake/body-with-file-schema: + put: + tags: + - fake + description: >- + For this test, the body for this request much reference a schema named + `File`. + operationId: testBodyWithFileSchema + responses: + '200': + description: Success + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/FileSchemaTestClass' + required: true + /fake/test-query-paramters: + put: + tags: + - fake + description: To test the collection format in query parameters + operationId: testQueryParameterCollectionFormat + parameters: + - name: pipe + in: query + required: true + schema: + type: array + items: + type: string + - name: ioutil + in: query + required: true + style: form + explode: false + schema: + type: array + items: + type: string + - name: http + in: query + required: true + style: spaceDelimited + schema: + type: array + items: + type: string + - name: url + in: query + required: true + style: form + explode: false + schema: + type: array + items: + type: string + - name: context + in: query + required: true + explode: true + schema: + type: array + items: + type: string + responses: + "200": + description: Success + '/fake/{petId}/uploadImageWithRequiredFile': + post: + tags: + - pet + summary: uploads an image (required) + description: '' + operationId: uploadFileWithRequiredFile + parameters: + - name: petId + in: path + description: ID of pet to update + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + content: + multipart/form-data: + schema: + type: object + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + requiredFile: + description: file to upload + type: string + format: binary + required: + - requiredFile + /fake/health: + get: + tags: + - fake + summary: Health check endpoint + responses: + 200: + description: The instance started successfully + content: + application/json: + schema: + $ref: '#/components/schemas/HealthCheckResult' +servers: + - url: 'http://{server}.swagger.io:{port}/v2' + description: petstore server + variables: + server: + enum: + - 'petstore' + - 'qa-petstore' + - 'dev-petstore' + default: 'petstore' + port: + enum: + - 80 + - 8080 + default: 80 + - url: https://localhost:8080/{version} + description: The local server + variables: + version: + enum: + - 'v1' + - 'v2' + default: 'v2' +components: + requestBodies: + UserArray: + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/User' + description: List of user object + required: true + Client: + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: client model + required: true + Pet: + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + application/xml: + schema: + $ref: '#/components/schemas/Pet' + description: Pet object that needs to be added to the store + required: true + securitySchemes: + petstore_auth: + type: oauth2 + flows: + implicit: + authorizationUrl: 'http://petstore.swagger.io/api/oauth/dialog' + scopes: + 'write:pets': modify pets in your account + 'read:pets': read your pets + api_key: + type: apiKey + name: api_key + in: header + api_key_query: + type: apiKey + name: api_key_query + in: query + http_basic_test: + type: http + scheme: basic + bearer_test: + type: http + scheme: bearer + bearerFormat: JWT + http_signature_test: + # Test the 'HTTP signature' security scheme. + # Each HTTP request is cryptographically signed as specified + # in https://datatracker.ietf.org/doc/draft-cavage-http-signatures/ + type: http + scheme: signature + schemas: + Foo: + type: object + properties: + bar: + $ref: '#/components/schemas/Bar' + Bar: + type: string + default: bar + Order: + type: object + properties: + id: + type: integer + format: int64 + petId: + type: integer + format: int64 + quantity: + type: integer + format: int32 + shipDate: + type: string + format: date-time + status: + type: string + description: Order Status + enum: + - placed + - approved + - delivered + complete: + type: boolean + default: false + xml: + name: Order + Category: + type: object + required: + - name + properties: + id: + type: integer + format: int64 + name: + type: string + default: default-name + xml: + name: Category + User: + type: object + properties: + id: + type: integer + format: int64 + x-is-unique: true + username: + type: string + firstName: + type: string + lastName: + type: string + email: + type: string + password: + type: string + phone: + type: string + userStatus: + type: integer + format: int32 + description: User Status + xml: + name: User + Tag: + type: object + properties: + id: + type: integer + format: int64 + name: + type: string + xml: + name: Tag + Pet: + type: object + required: + - name + - photoUrls + properties: + id: + type: integer + format: int64 + x-is-unique: true + category: + $ref: '#/components/schemas/Category' + name: + type: string + example: doggie + photoUrls: + type: array + xml: + name: photoUrl + wrapped: true + items: + type: string + tags: + type: array + xml: + name: tag + wrapped: true + items: + $ref: '#/components/schemas/Tag' + status: + type: string + description: pet status in the store + enum: + - available + - pending + - sold + xml: + name: Pet + ApiResponse: + type: object + properties: + code: + type: integer + format: int32 + type: + type: string + message: + type: string + Return: + description: Model for testing reserved words + properties: + return: + type: integer + format: int32 + xml: + name: Return + Name: + description: Model for testing model name same as property name + required: + - name + properties: + name: + type: integer + format: int32 + snake_case: + readOnly: true + type: integer + format: int32 + property: + type: string + 123Number: + type: integer + readOnly: true + xml: + name: Name + 200_response: + description: Model for testing model name starting with number + properties: + name: + type: integer + format: int32 + class: + type: string + xml: + name: Name + ClassModel: + description: Model for testing model with "_class" property + properties: + _class: + type: string + Dog: + allOf: + - $ref: '#/components/schemas/Animal' + - type: object + properties: + breed: + type: string + Cat: + allOf: + - $ref: '#/components/schemas/Animal' + - type: object + properties: + declawed: + type: boolean + Animal: + type: object + discriminator: + propertyName: className + required: + - className + properties: + className: + type: string + color: + type: string + default: red + AnimalFarm: + type: array + items: + $ref: '#/components/schemas/Animal' + format_test: + type: object + required: + - number + - byte + - date + - password + properties: + integer: + type: integer + maximum: 100 + minimum: 10 + int32: + type: integer + format: int32 + maximum: 200 + minimum: 20 + int64: + type: integer + format: int64 + number: + maximum: 543.2 + minimum: 32.1 + type: number + float: + type: number + format: float + maximum: 987.6 + minimum: 54.3 + double: + type: number + format: double + maximum: 123.4 + minimum: 67.8 + string: + type: string + pattern: '/[a-z]/i' + byte: + type: string + format: byte + binary: + type: string + format: binary + date: + type: string + format: date + dateTime: + type: string + format: date-time + uuid: + type: string + format: uuid + example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + password: + type: string + format: password + maxLength: 64 + minLength: 10 + pattern_with_digits: + description: A string that is a 10 digit number. Can have leading zeros. + type: string + pattern: '^\d{10}$' + pattern_with_digits_and_delimiter: + description: A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. + type: string + pattern: '/^image_\d{1,3}$/i' + EnumClass: + type: string + default: '-efg' + enum: + - _abc + - '-efg' + - (xyz) + Enum_Test: + type: object + required: + - enum_string_required + properties: + enum_string: + type: string + enum: + - UPPER + - lower + - '' + enum_string_required: + type: string + enum: + - UPPER + - lower + - '' + enum_integer: + type: integer + format: int32 + enum: + - 1 + - -1 + enum_number: + type: number + format: double + enum: + - 1.1 + - -1.2 + outerEnum: + $ref: '#/components/schemas/OuterEnum' + outerEnumInteger: + $ref: '#/components/schemas/OuterEnumInteger' + outerEnumDefaultValue: + $ref: '#/components/schemas/OuterEnumDefaultValue' + outerEnumIntegerDefaultValue: + $ref: '#/components/schemas/OuterEnumIntegerDefaultValue' + AdditionalPropertiesClass: + type: object + properties: + map_property: + type: object + additionalProperties: + type: string + map_of_map_property: + type: object + additionalProperties: + type: object + additionalProperties: + type: string + MixedPropertiesAndAdditionalPropertiesClass: + type: object + properties: + uuid: + type: string + format: uuid + dateTime: + type: string + format: date-time + map: + type: object + additionalProperties: + $ref: '#/components/schemas/Animal' + List: + type: object + properties: + 123-list: + type: string + Client: + type: object + properties: + client: + type: string + ReadOnlyFirst: + type: object + properties: + bar: + type: string + readOnly: true + baz: + type: string + hasOnlyReadOnly: + type: object + properties: + bar: + type: string + readOnly: true + foo: + type: string + readOnly: true + Capitalization: + type: object + properties: + smallCamel: + type: string + CapitalCamel: + type: string + small_Snake: + type: string + Capital_Snake: + type: string + SCA_ETH_Flow_Points: + type: string + ATT_NAME: + description: | + Name of the pet + type: string + MapTest: + type: object + properties: + map_map_of_string: + type: object + additionalProperties: + type: object + additionalProperties: + type: string + map_of_enum_string: + type: object + additionalProperties: + type: string + enum: + - UPPER + - lower + direct_map: + type: object + additionalProperties: + type: boolean + indirect_map: + $ref: '#/components/schemas/StringBooleanMap' + ArrayTest: + type: object + properties: + array_of_string: + type: array + items: + type: string + array_array_of_integer: + type: array + items: + type: array + items: + type: integer + format: int64 + array_array_of_model: + type: array + items: + type: array + items: + $ref: '#/components/schemas/ReadOnlyFirst' + NumberOnly: + type: object + properties: + JustNumber: + type: number + ArrayOfNumberOnly: + type: object + properties: + ArrayNumber: + type: array + items: + type: number + ArrayOfArrayOfNumberOnly: + type: object + properties: + ArrayArrayNumber: + type: array + items: + type: array + items: + type: number + EnumArrays: + type: object + properties: + just_symbol: + type: string + enum: + - '>=' + - $ + array_enum: + type: array + items: + type: string + enum: + - fish + - crab + OuterEnum: + nullable: true + type: string + enum: + - placed + - approved + - delivered + OuterEnumInteger: + type: integer + enum: + - 0 + - 1 + - 2 + OuterEnumDefaultValue: + type: string + enum: + - placed + - approved + - delivered + default: placed + OuterEnumIntegerDefaultValue: + type: integer + enum: + - 0 + - 1 + - 2 + default: 0 + OuterComposite: + type: object + properties: + my_number: + $ref: '#/components/schemas/OuterNumber' + my_string: + $ref: '#/components/schemas/OuterString' + my_boolean: + $ref: '#/components/schemas/OuterBoolean' + OuterNumber: + type: number + OuterString: + type: string + OuterBoolean: + type: boolean + x-codegen-body-parameter-name: boolean_post_body + StringBooleanMap: + additionalProperties: + type: boolean + FileSchemaTestClass: + type: object + properties: + file: + $ref: '#/components/schemas/File' + files: + type: array + items: + $ref: '#/components/schemas/File' + File: + type: object + description: Must be named `File` for test. + properties: + sourceURI: + description: Test capitalization + type: string + _special_model.name_: + properties: + '$special[property.name]': + type: integer + format: int64 + xml: + name: '$special[model.name]' + HealthCheckResult: + type: object + properties: + NullableMessage: + nullable: true + type: string + description: Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. + NullableClass: + type: object + properties: + integer_prop: + type: integer + nullable: true + number_prop: + type: number + nullable: true + boolean_prop: + type: boolean + nullable: true + string_prop: + type: string + nullable: true + date_prop: + type: string + format: date + nullable: true + datetime_prop: + type: string + format: date-time + nullable: true + array_nullable_prop: + type: array + nullable: true + items: + type: object + array_and_items_nullable_prop: + type: array + nullable: true + items: + type: object + nullable: true + array_items_nullable: + type: array + items: + type: object + nullable: true + object_nullable_prop: + type: object + nullable: true + additionalProperties: + type: object + object_and_items_nullable_prop: + type: object + nullable: true + additionalProperties: + type: object + nullable: true + object_items_nullable: + type: object + additionalProperties: + type: object + nullable: true + 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/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/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..705a2106947e --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/apple.py @@ -0,0 +1,127 @@ +# 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): + 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..5b64900184ad --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/apple_req.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 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): + 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..e9c8ad97e777 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/banana.py @@ -0,0 +1,127 @@ +# 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): + 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..1096e36e9599 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/banana_req.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 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): + 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..e87a9a9fca44 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/fruit.py @@ -0,0 +1,186 @@ +# 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] + + for var_name, var_value in required_args.items(): + setattr(self, var_name, var_value) + 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': [ + ], + '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..97d1e86cbcd0 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/fruit_req.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_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] + + for var_name, var_value in required_args.items(): + setattr(self, var_name, var_value) + 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': [ + ], + '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..575639697617 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/gm_fruit.py @@ -0,0 +1,186 @@ +# 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] + + for var_name, var_value in required_args.items(): + setattr(self, var_name, var_value) + 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': [ + 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..1a6895646d2d --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/mammal.py @@ -0,0 +1,215 @@ +# 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] + + for var_name, var_value in required_args.items(): + setattr(self, var_name, var_value) + 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': [ + ], + '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..cc751da3aada --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/whale.py @@ -0,0 +1,136 @@ +# 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): + 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..8dddf56064c5 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/zebra.py @@ -0,0 +1,138 @@ +# 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): + 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/testfiles/ecP521.pem b/samples/openapi3/client/petstore/python-experimental/testfiles/ecP521.pem new file mode 100644 index 000000000000..dbf639c32029 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/testfiles/ecP521.pem @@ -0,0 +1,10 @@ +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIBTzBJBgkqhkiG9w0BBQ0wPDAbBgkqhkiG9w0BBQwwDgQIl5fhsgDB0BICAgPo +MB0GCWCGSAFlAwQBAgQQEprktYMTqB+wmvDAipQDigSCAQACy7C5dcYGK7d+fvm9 +QbjAfdNkqb1lTk21ni53ApJdY2sHF9+Aw/bz7DmuJVx5KS0hRPX8F3dy1u0V+DIA +3dxjlj6zmUmh/emLgRWz84cWYBzVCt80B5H29gx4ti6JQeXZfc4TXUVApLov0WX0 +D9ShtEjzg14SEqtQsTgmA5jqkzAYNkGbEsWr0yyr/eqArTbrJblXWNhlWk1AodOz +JLXyypDx+Df10updwHfntWegu3UY8W+3cVjSi2K9QAwyMe2RKzEcsCFrd3OiH5ys +SrDExnhsdYLH5x4mdrw4+DSqMT4r7/J8hLHxjMPPTr6nGbd3pU2Q0ZN6CMfLd77S +IQuN +-----END ENCRYPTED PRIVATE KEY----- \ No newline at end of file diff --git a/samples/openapi3/client/petstore/python-experimental/testfiles/rsa.pem b/samples/openapi3/client/petstore/python-experimental/testfiles/rsa.pem new file mode 100644 index 000000000000..ddc2c9767c4e --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/testfiles/rsa.pem @@ -0,0 +1,15 @@ +-----BEGIN RSA PRIVATE KEY----- +MIICXgIBAAKBgQDCFENGw33yGihy92pDjZQhl0C36rPJj+CvfSC8+q28hxA161QF +NUd13wuCTUcq0Qd2qsBe/2hFyc2DCJJg0h1L78+6Z4UMR7EOcpfdUE9Hf3m/hs+F +UR45uBJeDK1HSFHD8bHKD6kv8FPGfJTotc+2xjJwoYi+1hqp1fIekaxsyQIDAQAB +AoGBAJR8ZkCUvx5kzv+utdl7T5MnordT1TvoXXJGXK7ZZ+UuvMNUCdN2QPc4sBiA +QWvLw1cSKt5DsKZ8UETpYPy8pPYnnDEz2dDYiaew9+xEpubyeW2oH4Zx71wqBtOK +kqwrXa/pzdpiucRRjk6vE6YY7EBBs/g7uanVpGibOVAEsqH1AkEA7DkjVH28WDUg +f1nqvfn2Kj6CT7nIcE3jGJsZZ7zlZmBmHFDONMLUrXR/Zm3pR5m0tCmBqa5RK95u +412jt1dPIwJBANJT3v8pnkth48bQo/fKel6uEYyboRtA5/uHuHkZ6FQF7OUkGogc +mSJluOdc5t6hI1VsLn0QZEjQZMEOWr+wKSMCQQCC4kXJEsHAve77oP6HtG/IiEn7 +kpyUXRNvFsDE0czpJJBvL/aRFUJxuRK91jhjC68sA7NsKMGg5OXb5I5Jj36xAkEA +gIT7aFOYBFwGgQAQkWNKLvySgKbAZRTeLBacpHMuQdl1DfdntvAyqpAZ0lY0RKmW +G6aFKaqQfOXKCyWoUiVknQJAXrlgySFci/2ueKlIE1QqIiLSZ8V8OlpFLRnb1pzI +7U1yQXnTAEFYM560yJlzUpOb1V4cScGd365tiSMvxLOvTA== +-----END RSA PRIVATE KEY----- \ No newline at end of file diff --git a/samples/openapi3/client/petstore/python-experimental/testfiles/rsa4096.pem b/samples/openapi3/client/petstore/python-experimental/testfiles/rsa4096.pem new file mode 100644 index 000000000000..7feddb4c9fb6 --- /dev/null +++ b/samples/openapi3/client/petstore/python-experimental/testfiles/rsa4096.pem @@ -0,0 +1,54 @@ +-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: DES-EDE3-CBC,C7F43A1C51AB0CE8 + +151UAfs+/dwcTVpHkOWuE64YQ4XfB041P1XZEfKD/UAyzxh3ntxcNKSzKcexN1hg +F7CqVWIAsbbeP6lZlFuggNnHZe5Pk/nlK68e3kNFqkUpkpyN275ClTEiFVGR8yMb +TznCg+4GQ0BFFi+Zjoy5+M/6r6z+UOHrV2yAE9N9jWnoazuQUAszmYhqG4D79y82 +EqusKN8rDQIscXc/L6TqY9Zs19ahkh5UzsW1Y7AKLwXVyhmxX487cnSA7xRQlyX4 +laJGqELR6oNic2l7ISx4ZXuzrdD6L7FORQVmWcT9HR5KDrKVgAdzi7rH0vpFe4Xr +iZBHGAEThm9eTgJmSUuPfXp/bSUAnXSzaiPueCPH5YYs+nY0SIba0AA8e7kqe3rL +YnzLMgP1s07MAgdKCZYK2Pb2cvazPh+fNL6HV4cIhPHHX7ckfO2a3zgyl4FEdu4Q +cfTSO3l/eVkg5GntCZ96VaN5ifZtbCfm2+drSbI2xcTLv1NcplqbUquQcb6p8zLS +J8phnKDsQYXth3JbF1DvsGUk4EdkDOYyuY700pIKEGeRGsfWVrSIAkmxch9e3pZQ +i/h8EcXBCx1wkNEGQZuFLUduH/e0nSi5qDg/8rYyS2no3vnI9cjFvTFvVDZgA4RJ +8B2XIemj/cHox7WeLTOHDkybrE3DJCLzL+FlihCcIwms/v4tUdB7vjlag+iwgesB +OD8p7eTz43JZeHLGWQqelQeqYcZ5djhUtm8EzE4svn17E1X8/BRjN+dYIOOn0ND0 +HkgVle/1uthxr2SAWeeyRJTV85JR5eDLOdOj7wkcoZ5/wgjPPBIvQ5Yf7EWFcyg8 +448FFOnmi7trfybNAxczz0RXKnjKjqJa6sJTczyfs8pA1h91IohsaWIk1ceKwVCT +yNbwRgTXkjqqSVmuwCDdjgu/SbT/dWpJUFLwHdxasY6ShFxpVrLAfKIR/i/GM5BM +0CzsOePCJXD5jVmzGFPX8l2Mv7kPzzgmu0Jb8hq5VpLu8DFdVGZhyK0i77gX0MSs +8aOb+Q+Ezal2tEGFNccYE3jM+jWWts1WIL/IIg5h+ee2XIRusfFqFVO0jiE4y1Ut +xuOlrR6TE2yWDUmnKdnUj2/zF7VFa3ZUq3+x8dy3DHMV/KdaRiXdxOXJz96ZJ7gu +SI3nw0b48Sh0YXcr7B55CSaJ8klg2v8WLNE0e/UCCz8UK6YRlC1azAnpP1AgQU1o +0NJ4sCJEFqT1HzPUI/0fKhA+pJ3JFUYqtUCXewzk4hMWWA733W3Av89wwt8xbYOg +/LiFUSovjxh+PMxhq0hgH7IMnU73jHbobB3pQDKN9zlavvcOuzf3buMWplXm+CQ1 +7ZM3pYDIKGFpYXb6CjrdvhdqY4Q2VVo9SJ3AWZaE6IDOnPEBsqu1B/WkxP3nmcYD +sG03it2xAFd+NkZq8aW5kKaWglmwLf1HLzvyQpNLjbjF64luwRYOJaXVXK4csC49 +DOgGP8h4YvBQn9SoFIgNznDfCUdJvtkzb0OBBs2YKPA81xQIXoE6pjfa3ztiN8sZ +G1L70+wU4fZ9itNx8K9D9xu/xUM7LCBP86SMJvaVpIV5S5PL0xcetLsfPzj5qQwK +RzggWIym5wGvoTrcVn1HPc5Pvt1jUEIIg6kNIxfxTVdPZjNCB/vK8xgUfn5l5sRT +Ot9RfsTgzGe0rH/L7JeDmxVk39Z0GnZF/qfMS+rdEZT9+jHT7q7XKAiCgSUHWFgp +e9Sqt8L5Xr25UQpIAHlmnNwOM595dMfzJzO1guG1zQEsMgdf/RESk4tmSia37Fly +dW5KltyTY1uIQxfb3rJT0wUUaFAatVx3wnEtO5r6qbsn8i8PErwinuFVOij6kDAs +1nir3ZG4t2pOJGRe7pPXfeM7MSllMDGelf4aGxCSKU3KnXnQ+pPpRrkMYG978JRg +kBdwW25J17QgYeiVSJR21Y6KevK8rfhxV+Mq8mxoTxiX7xR5dBwF8Earn4NMcqyt +rIZANDN2qDfI5Ese7PG+WeCbSysWDwXlgfVWkx0ebJsw+e05NHcdpfuR+R65iAkn +5fwLoic6MzIM4nuEN3qXh7onrsJ0x9rVul18LLVcNATVXkXXiGDEZPRkABJ2Wvwu +PXxn5nioylS8grC+Wg2GS0LY833ohr/10Ps2rXAlI7LCRcbBeQT/W+6gaLsqOnyj +k2Tl1SBBqEn3quKDNGpTzr5GaTTcFOTycFuFrYalcrLplQaihwE2zZiQJ+A/93C5 +gdHxayUuEwvJ226/U3P8ouiw0c3WmIiHeQUzJjnUMUHZP0lFOe96jP+51h6fomxp +rMWQdMQ+iH8k0tyeHB0xrvemK1ILOo0r2x6NwhBTmUgzFnngm8SxvHd3BCY/Gpye +wXRsVkkpeLStZL+qB0VQzW6G2eLrhUb3rZ0douFqyS0wGhbYEovO+2wU2DY6A5Og +W/TUtrOLtvXYvzTGVbfeU9ZXum1U5htqM8Dwfdo4b8A10QF2jL2Nbi4iElm33twN +R78f+SG8EgjZ15FiN8RUM+J2UAF6yKC84MLjXAqQ1riH2ZdlAGawV608biUYTV/K +GvUtG+BaFAcX5N1DI+1NVUQ+c9EOfi5hAmKZ/92r37kKHM7AaSsxDxZmE33lYVRR +M4/NoJkW3TNUbV4FMw1Ui8tm2nuB7qPCO9spGKxzXU+CNFyUjqDojHCIi5KzoEgH +JrP1KWKuzY0lZTsyDATOT8j9O349jK/Mk0ecqP0sxWqP+szniFVEa7+xM/GTTL05 +7R7/mADc982WhHKrzAFpocb4xvY+9Vs6LnAnIo4rQWBzpdJh7EMPRM6vroLcvaNX +XS3Hq6NmR/xvfVpuzEQzMCxmXJMT8OrwF/uJNoJ+un7DzJYUwF8oPLWKDBSy6NS5 +EP8JN8g7A2pIBzpcWoVm/16zXP8vh68fYXRj+i4uksd1aVkXjzbPigHyCgO8z7l/ +ohzOgHwNgC4ZMjysumO9LukOGUTV3Yj75iYYYD/N3/Qm8P0NOJ2hMi1oOKHW6/pj +0uVN5vluiigbrI9kifxTwur0JB7WZ5yznFxKGnLJcu9QTzy/KzMQZDnTkoEuPIlh +kG/RXjZNm3GfuKZxNWy0u403NiUVuRLsYN6KrOlxViNpoEIC92StfQnPWefyQQSl +-----END RSA PRIVATE KEY----- \ No newline at end of file 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 From 9690af91b5c4f68d0244364d8b891571f8d93238 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Tue, 18 Feb 2020 23:27:22 -0800 Subject: [PATCH 2/7] Adds setUpClass and tearDownClass --- .../python-experimental/testfiles/ecP521.pem | 10 --- .../python-experimental/testfiles/rsa.pem | 15 ---- .../python-experimental/testfiles/rsa4096.pem | 54 ----------- .../tests/test_http_signature.py | 90 +++++++++++-------- 4 files changed, 53 insertions(+), 116 deletions(-) delete mode 100644 samples/openapi3/client/petstore/python-experimental/testfiles/ecP521.pem delete mode 100644 samples/openapi3/client/petstore/python-experimental/testfiles/rsa.pem delete mode 100644 samples/openapi3/client/petstore/python-experimental/testfiles/rsa4096.pem diff --git a/samples/openapi3/client/petstore/python-experimental/testfiles/ecP521.pem b/samples/openapi3/client/petstore/python-experimental/testfiles/ecP521.pem deleted file mode 100644 index dbf639c32029..000000000000 --- a/samples/openapi3/client/petstore/python-experimental/testfiles/ecP521.pem +++ /dev/null @@ -1,10 +0,0 @@ ------BEGIN ENCRYPTED PRIVATE KEY----- -MIIBTzBJBgkqhkiG9w0BBQ0wPDAbBgkqhkiG9w0BBQwwDgQIl5fhsgDB0BICAgPo -MB0GCWCGSAFlAwQBAgQQEprktYMTqB+wmvDAipQDigSCAQACy7C5dcYGK7d+fvm9 -QbjAfdNkqb1lTk21ni53ApJdY2sHF9+Aw/bz7DmuJVx5KS0hRPX8F3dy1u0V+DIA -3dxjlj6zmUmh/emLgRWz84cWYBzVCt80B5H29gx4ti6JQeXZfc4TXUVApLov0WX0 -D9ShtEjzg14SEqtQsTgmA5jqkzAYNkGbEsWr0yyr/eqArTbrJblXWNhlWk1AodOz -JLXyypDx+Df10updwHfntWegu3UY8W+3cVjSi2K9QAwyMe2RKzEcsCFrd3OiH5ys -SrDExnhsdYLH5x4mdrw4+DSqMT4r7/J8hLHxjMPPTr6nGbd3pU2Q0ZN6CMfLd77S -IQuN ------END ENCRYPTED PRIVATE KEY----- \ No newline at end of file diff --git a/samples/openapi3/client/petstore/python-experimental/testfiles/rsa.pem b/samples/openapi3/client/petstore/python-experimental/testfiles/rsa.pem deleted file mode 100644 index ddc2c9767c4e..000000000000 --- a/samples/openapi3/client/petstore/python-experimental/testfiles/rsa.pem +++ /dev/null @@ -1,15 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIICXgIBAAKBgQDCFENGw33yGihy92pDjZQhl0C36rPJj+CvfSC8+q28hxA161QF -NUd13wuCTUcq0Qd2qsBe/2hFyc2DCJJg0h1L78+6Z4UMR7EOcpfdUE9Hf3m/hs+F -UR45uBJeDK1HSFHD8bHKD6kv8FPGfJTotc+2xjJwoYi+1hqp1fIekaxsyQIDAQAB -AoGBAJR8ZkCUvx5kzv+utdl7T5MnordT1TvoXXJGXK7ZZ+UuvMNUCdN2QPc4sBiA -QWvLw1cSKt5DsKZ8UETpYPy8pPYnnDEz2dDYiaew9+xEpubyeW2oH4Zx71wqBtOK -kqwrXa/pzdpiucRRjk6vE6YY7EBBs/g7uanVpGibOVAEsqH1AkEA7DkjVH28WDUg -f1nqvfn2Kj6CT7nIcE3jGJsZZ7zlZmBmHFDONMLUrXR/Zm3pR5m0tCmBqa5RK95u -412jt1dPIwJBANJT3v8pnkth48bQo/fKel6uEYyboRtA5/uHuHkZ6FQF7OUkGogc -mSJluOdc5t6hI1VsLn0QZEjQZMEOWr+wKSMCQQCC4kXJEsHAve77oP6HtG/IiEn7 -kpyUXRNvFsDE0czpJJBvL/aRFUJxuRK91jhjC68sA7NsKMGg5OXb5I5Jj36xAkEA -gIT7aFOYBFwGgQAQkWNKLvySgKbAZRTeLBacpHMuQdl1DfdntvAyqpAZ0lY0RKmW -G6aFKaqQfOXKCyWoUiVknQJAXrlgySFci/2ueKlIE1QqIiLSZ8V8OlpFLRnb1pzI -7U1yQXnTAEFYM560yJlzUpOb1V4cScGd365tiSMvxLOvTA== ------END RSA PRIVATE KEY----- \ No newline at end of file diff --git a/samples/openapi3/client/petstore/python-experimental/testfiles/rsa4096.pem b/samples/openapi3/client/petstore/python-experimental/testfiles/rsa4096.pem deleted file mode 100644 index 7feddb4c9fb6..000000000000 --- a/samples/openapi3/client/petstore/python-experimental/testfiles/rsa4096.pem +++ /dev/null @@ -1,54 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -Proc-Type: 4,ENCRYPTED -DEK-Info: DES-EDE3-CBC,C7F43A1C51AB0CE8 - -151UAfs+/dwcTVpHkOWuE64YQ4XfB041P1XZEfKD/UAyzxh3ntxcNKSzKcexN1hg -F7CqVWIAsbbeP6lZlFuggNnHZe5Pk/nlK68e3kNFqkUpkpyN275ClTEiFVGR8yMb -TznCg+4GQ0BFFi+Zjoy5+M/6r6z+UOHrV2yAE9N9jWnoazuQUAszmYhqG4D79y82 -EqusKN8rDQIscXc/L6TqY9Zs19ahkh5UzsW1Y7AKLwXVyhmxX487cnSA7xRQlyX4 -laJGqELR6oNic2l7ISx4ZXuzrdD6L7FORQVmWcT9HR5KDrKVgAdzi7rH0vpFe4Xr -iZBHGAEThm9eTgJmSUuPfXp/bSUAnXSzaiPueCPH5YYs+nY0SIba0AA8e7kqe3rL -YnzLMgP1s07MAgdKCZYK2Pb2cvazPh+fNL6HV4cIhPHHX7ckfO2a3zgyl4FEdu4Q -cfTSO3l/eVkg5GntCZ96VaN5ifZtbCfm2+drSbI2xcTLv1NcplqbUquQcb6p8zLS -J8phnKDsQYXth3JbF1DvsGUk4EdkDOYyuY700pIKEGeRGsfWVrSIAkmxch9e3pZQ -i/h8EcXBCx1wkNEGQZuFLUduH/e0nSi5qDg/8rYyS2no3vnI9cjFvTFvVDZgA4RJ -8B2XIemj/cHox7WeLTOHDkybrE3DJCLzL+FlihCcIwms/v4tUdB7vjlag+iwgesB -OD8p7eTz43JZeHLGWQqelQeqYcZ5djhUtm8EzE4svn17E1X8/BRjN+dYIOOn0ND0 -HkgVle/1uthxr2SAWeeyRJTV85JR5eDLOdOj7wkcoZ5/wgjPPBIvQ5Yf7EWFcyg8 -448FFOnmi7trfybNAxczz0RXKnjKjqJa6sJTczyfs8pA1h91IohsaWIk1ceKwVCT -yNbwRgTXkjqqSVmuwCDdjgu/SbT/dWpJUFLwHdxasY6ShFxpVrLAfKIR/i/GM5BM -0CzsOePCJXD5jVmzGFPX8l2Mv7kPzzgmu0Jb8hq5VpLu8DFdVGZhyK0i77gX0MSs -8aOb+Q+Ezal2tEGFNccYE3jM+jWWts1WIL/IIg5h+ee2XIRusfFqFVO0jiE4y1Ut -xuOlrR6TE2yWDUmnKdnUj2/zF7VFa3ZUq3+x8dy3DHMV/KdaRiXdxOXJz96ZJ7gu -SI3nw0b48Sh0YXcr7B55CSaJ8klg2v8WLNE0e/UCCz8UK6YRlC1azAnpP1AgQU1o -0NJ4sCJEFqT1HzPUI/0fKhA+pJ3JFUYqtUCXewzk4hMWWA733W3Av89wwt8xbYOg -/LiFUSovjxh+PMxhq0hgH7IMnU73jHbobB3pQDKN9zlavvcOuzf3buMWplXm+CQ1 -7ZM3pYDIKGFpYXb6CjrdvhdqY4Q2VVo9SJ3AWZaE6IDOnPEBsqu1B/WkxP3nmcYD -sG03it2xAFd+NkZq8aW5kKaWglmwLf1HLzvyQpNLjbjF64luwRYOJaXVXK4csC49 -DOgGP8h4YvBQn9SoFIgNznDfCUdJvtkzb0OBBs2YKPA81xQIXoE6pjfa3ztiN8sZ -G1L70+wU4fZ9itNx8K9D9xu/xUM7LCBP86SMJvaVpIV5S5PL0xcetLsfPzj5qQwK -RzggWIym5wGvoTrcVn1HPc5Pvt1jUEIIg6kNIxfxTVdPZjNCB/vK8xgUfn5l5sRT -Ot9RfsTgzGe0rH/L7JeDmxVk39Z0GnZF/qfMS+rdEZT9+jHT7q7XKAiCgSUHWFgp -e9Sqt8L5Xr25UQpIAHlmnNwOM595dMfzJzO1guG1zQEsMgdf/RESk4tmSia37Fly -dW5KltyTY1uIQxfb3rJT0wUUaFAatVx3wnEtO5r6qbsn8i8PErwinuFVOij6kDAs -1nir3ZG4t2pOJGRe7pPXfeM7MSllMDGelf4aGxCSKU3KnXnQ+pPpRrkMYG978JRg -kBdwW25J17QgYeiVSJR21Y6KevK8rfhxV+Mq8mxoTxiX7xR5dBwF8Earn4NMcqyt -rIZANDN2qDfI5Ese7PG+WeCbSysWDwXlgfVWkx0ebJsw+e05NHcdpfuR+R65iAkn -5fwLoic6MzIM4nuEN3qXh7onrsJ0x9rVul18LLVcNATVXkXXiGDEZPRkABJ2Wvwu -PXxn5nioylS8grC+Wg2GS0LY833ohr/10Ps2rXAlI7LCRcbBeQT/W+6gaLsqOnyj -k2Tl1SBBqEn3quKDNGpTzr5GaTTcFOTycFuFrYalcrLplQaihwE2zZiQJ+A/93C5 -gdHxayUuEwvJ226/U3P8ouiw0c3WmIiHeQUzJjnUMUHZP0lFOe96jP+51h6fomxp -rMWQdMQ+iH8k0tyeHB0xrvemK1ILOo0r2x6NwhBTmUgzFnngm8SxvHd3BCY/Gpye -wXRsVkkpeLStZL+qB0VQzW6G2eLrhUb3rZ0douFqyS0wGhbYEovO+2wU2DY6A5Og -W/TUtrOLtvXYvzTGVbfeU9ZXum1U5htqM8Dwfdo4b8A10QF2jL2Nbi4iElm33twN -R78f+SG8EgjZ15FiN8RUM+J2UAF6yKC84MLjXAqQ1riH2ZdlAGawV608biUYTV/K -GvUtG+BaFAcX5N1DI+1NVUQ+c9EOfi5hAmKZ/92r37kKHM7AaSsxDxZmE33lYVRR -M4/NoJkW3TNUbV4FMw1Ui8tm2nuB7qPCO9spGKxzXU+CNFyUjqDojHCIi5KzoEgH -JrP1KWKuzY0lZTsyDATOT8j9O349jK/Mk0ecqP0sxWqP+szniFVEa7+xM/GTTL05 -7R7/mADc982WhHKrzAFpocb4xvY+9Vs6LnAnIo4rQWBzpdJh7EMPRM6vroLcvaNX -XS3Hq6NmR/xvfVpuzEQzMCxmXJMT8OrwF/uJNoJ+un7DzJYUwF8oPLWKDBSy6NS5 -EP8JN8g7A2pIBzpcWoVm/16zXP8vh68fYXRj+i4uksd1aVkXjzbPigHyCgO8z7l/ -ohzOgHwNgC4ZMjysumO9LukOGUTV3Yj75iYYYD/N3/Qm8P0NOJ2hMi1oOKHW6/pj -0uVN5vluiigbrI9kifxTwur0JB7WZ5yznFxKGnLJcu9QTzy/KzMQZDnTkoEuPIlh -kG/RXjZNm3GfuKZxNWy0u403NiUVuRLsYN6KrOlxViNpoEIC92StfQnPWefyQQSl ------END RSA PRIVATE KEY----- \ 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): From 231e7b902ec8e2a643f865df2fec8508179d30ea Mon Sep 17 00:00:00 2001 From: Justin Black Date: Sun, 23 Feb 2020 22:44:14 -0800 Subject: [PATCH 3/7] Removes newline in method_init_shared.mustache --- .../model_templates/method_init_shared.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 c6bcdf747f35..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 @@ -40,4 +40,4 @@ self._check_type = _check_type self._from_server = _from_server self._path_to_item = _path_to_item - self._configuration = _configuration + self._configuration = _configuration \ No newline at end of file From 9ebaa4a43371a00403449c1ca0df05a91dc68ba6 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Sun, 23 Feb 2020 23:36:29 -0800 Subject: [PATCH 4/7] Regenerated v3 spec sample for python-experimental --- .../openapi3/client/petstore/python-experimental/README.md | 1 - .../petstore/python-experimental/petstore_api/__init__.py | 1 - .../python-experimental/petstore_api/models/apple.py | 6 ++++++ .../python-experimental/petstore_api/models/apple_req.py | 6 ++++++ .../python-experimental/petstore_api/models/banana.py | 6 ++++++ .../python-experimental/petstore_api/models/banana_req.py | 6 ++++++ .../python-experimental/petstore_api/models/cat.py | 6 ------ .../python-experimental/petstore_api/models/fruit.py | 7 +++++++ .../python-experimental/petstore_api/models/fruit_req.py | 7 +++++++ .../python-experimental/petstore_api/models/gm_fruit.py | 7 +++++++ .../python-experimental/petstore_api/models/mammal.py | 7 +++++++ .../python-experimental/petstore_api/models/whale.py | 6 ++++++ .../python-experimental/petstore_api/models/zebra.py | 6 ++++++ 13 files changed, 64 insertions(+), 8 deletions(-) diff --git a/samples/openapi3/client/petstore/python-experimental/README.md b/samples/openapi3/client/petstore/python-experimental/README.md index a0988878b947..3c89436d8f69 100644 --- a/samples/openapi3/client/petstore/python-experimental/README.md +++ b/samples/openapi3/client/petstore/python-experimental/README.md @@ -117,7 +117,6 @@ Class | Method | HTTP request | Description ## Documentation For Models - [additional_properties_class.AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md) - - [address.Address](docs/Address.md) - [animal.Animal](docs/Animal.md) - [api_response.ApiResponse](docs/ApiResponse.md) - [apple.Apple](docs/Apple.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 3aa279dd15d6..b508d6519abc 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/__init__.py @@ -41,7 +41,6 @@ # import models into sdk package from petstore_api.models.additional_properties_class import AdditionalPropertiesClass -from petstore_api.models.address import Address from petstore_api.models.animal import Animal from petstore_api.models.api_response import ApiResponse from petstore_api.models.apple import Apple 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 index 705a2106947e..03c502690d5d 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/apple.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/apple.py @@ -124,4 +124,10 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf 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 index 5b64900184ad..7aa81bf4c776 100644 --- 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 @@ -130,4 +130,10 @@ def __init__(self, cultivar, _check_type=True, _from_server=False, _path_to_item 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/banana.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/banana.py index e9c8ad97e777..fda69a28a253 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/banana.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/banana.py @@ -124,4 +124,10 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf 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 index 1096e36e9599..bf7d461c469c 100644 --- 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 @@ -130,4 +130,10 @@ def __init__(self, length_cm, _check_type=True, _from_server=False, _path_to_ite 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/cat.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/cat.py index 92076d35c068..d40464eaf0e9 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 @@ -29,11 +29,6 @@ str, validate_get_composed_info, ) -try: - from petstore_api.models import address -except ImportError: - address = sys.modules[ - 'petstore_api.models.address'] try: from petstore_api.models import animal except ImportError: @@ -193,7 +188,6 @@ def _composed_schemas(): 'anyOf': [ ], 'allOf': [ - address.Address, animal.Animal, cat_all_of.CatAllOf, ], 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 index e87a9a9fca44..d5e71abd700f 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/fruit.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/fruit.py @@ -159,10 +159,17 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf 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 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 index 97d1e86cbcd0..111326fcb4f6 100644 --- 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 @@ -166,10 +166,17 @@ def __init__(self, cultivar=nulltype.Null, length_cm=nulltype.Null, _check_type= 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 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 index 575639697617..0888743b8ec8 100644 --- 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 @@ -159,10 +159,17 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf 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 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 index 1a6895646d2d..303838fd7d4b 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/mammal.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/mammal.py @@ -175,10 +175,17 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it 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 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 index cc751da3aada..0c166e663015 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/whale.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/whale.py @@ -133,4 +133,10 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it 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 index 8dddf56064c5..56c0b34c2672 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/models/zebra.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/zebra.py @@ -135,4 +135,10 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it 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) From fb64c4091c7c1bb433636a64a20aee7ba724263a Mon Sep 17 00:00:00 2001 From: Justin Black Date: Mon, 24 Feb 2020 00:05:44 -0800 Subject: [PATCH 5/7] Fxes test for discard_unknown_keys --- ...e-endpoints-models-for-testing-httpsig-cmpsdschemas.yaml | 5 +++++ .../openapi3/client/petstore/python-experimental/README.md | 1 + .../petstore/python-experimental/petstore_api/__init__.py | 1 + .../python-experimental/petstore_api/models/address.py | 2 +- .../petstore/python-experimental/petstore_api/models/cat.py | 6 ++++++ 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-httpsig-cmpsdschemas.yaml b/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-httpsig-cmpsdschemas.yaml index 31b4e2e1dd60..d9aedbba9c6d 100644 --- a/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-httpsig-cmpsdschemas.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-httpsig-cmpsdschemas.yaml @@ -1362,10 +1362,15 @@ components: Cat: allOf: - $ref: '#/components/schemas/Animal' + - $ref: '#/components/schemas/Address' - type: object properties: declawed: type: boolean + Address: + type: object + additionalProperties: + type: integer Animal: type: object discriminator: diff --git a/samples/openapi3/client/petstore/python-experimental/README.md b/samples/openapi3/client/petstore/python-experimental/README.md index 3c89436d8f69..a0988878b947 100644 --- a/samples/openapi3/client/petstore/python-experimental/README.md +++ b/samples/openapi3/client/petstore/python-experimental/README.md @@ -117,6 +117,7 @@ Class | Method | HTTP request | Description ## Documentation For Models - [additional_properties_class.AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md) + - [address.Address](docs/Address.md) - [animal.Animal](docs/Animal.md) - [api_response.ApiResponse](docs/ApiResponse.md) - [apple.Apple](docs/Apple.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 b508d6519abc..3aa279dd15d6 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/__init__.py @@ -41,6 +41,7 @@ # import models into sdk package from petstore_api.models.additional_properties_class import AdditionalPropertiesClass +from petstore_api.models.address import Address from petstore_api.models.animal import Animal from petstore_api.models.api_response import ApiResponse from petstore_api.models.apple import Apple 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/cat.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/models/cat.py index d40464eaf0e9..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 @@ -29,6 +29,11 @@ str, validate_get_composed_info, ) +try: + from petstore_api.models import address +except ImportError: + address = sys.modules[ + 'petstore_api.models.address'] try: from petstore_api.models import animal except ImportError: @@ -188,6 +193,7 @@ def _composed_schemas(): 'anyOf': [ ], 'allOf': [ + address.Address, animal.Animal, cat_all_of.CatAllOf, ], From 68e41a330e3b1e1c56c67de8690703793b4dec24 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Fri, 28 Feb 2020 10:00:07 -0800 Subject: [PATCH 6/7] Moves new models into existing spec, regen python-exp and go-exp --- bin/openapi3/python-experimental-petstore.sh | 2 +- ...dels-for-testing-httpsig-cmpsdschemas.yaml | 1860 ----------------- ...odels-for-testing-with-http-signature.yaml | 79 + .../go-experimental/go-petstore/README.md | 10 + .../go-petstore/api/openapi.yaml | 82 + .../go-experimental/go-petstore/docs/Apple.md | 88 + .../go-petstore/docs/AppleReq.md | 88 + .../go-petstore/docs/Banana.md | 88 + .../go-petstore/docs/BananaReq.md | 88 + .../go-experimental/go-petstore/docs/Fruit.md | 14 + .../go-petstore/docs/FruitReq.md | 14 + .../go-petstore/docs/GmFruit.md | 108 + .../go-petstore/docs/Mammal.md | 14 + .../go-experimental/go-petstore/docs/Whale.md | 114 + .../go-experimental/go-petstore/docs/Zebra.md | 88 + .../go-petstore/model_apple.go | 131 ++ .../go-petstore/model_apple_req.go | 114 + .../go-petstore/model_banana.go | 131 ++ .../go-petstore/model_banana_req.go | 114 + .../go-petstore/model_fruit.go | 64 + .../go-petstore/model_fruit_req.go | 64 + .../go-petstore/model_gm_fruit.go | 161 ++ .../go-petstore/model_mammal.go | 80 + .../go-petstore/model_whale.go | 148 ++ .../go-petstore/model_zebra.go | 114 + 25 files changed, 1997 insertions(+), 1861 deletions(-) delete mode 100644 modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-httpsig-cmpsdschemas.yaml create mode 100644 samples/openapi3/client/petstore/go-experimental/go-petstore/docs/Apple.md create mode 100644 samples/openapi3/client/petstore/go-experimental/go-petstore/docs/AppleReq.md create mode 100644 samples/openapi3/client/petstore/go-experimental/go-petstore/docs/Banana.md create mode 100644 samples/openapi3/client/petstore/go-experimental/go-petstore/docs/BananaReq.md create mode 100644 samples/openapi3/client/petstore/go-experimental/go-petstore/docs/Fruit.md create mode 100644 samples/openapi3/client/petstore/go-experimental/go-petstore/docs/FruitReq.md create mode 100644 samples/openapi3/client/petstore/go-experimental/go-petstore/docs/GmFruit.md create mode 100644 samples/openapi3/client/petstore/go-experimental/go-petstore/docs/Mammal.md create mode 100644 samples/openapi3/client/petstore/go-experimental/go-petstore/docs/Whale.md create mode 100644 samples/openapi3/client/petstore/go-experimental/go-petstore/docs/Zebra.md create mode 100644 samples/openapi3/client/petstore/go-experimental/go-petstore/model_apple.go create mode 100644 samples/openapi3/client/petstore/go-experimental/go-petstore/model_apple_req.go create mode 100644 samples/openapi3/client/petstore/go-experimental/go-petstore/model_banana.go create mode 100644 samples/openapi3/client/petstore/go-experimental/go-petstore/model_banana_req.go create mode 100644 samples/openapi3/client/petstore/go-experimental/go-petstore/model_fruit.go create mode 100644 samples/openapi3/client/petstore/go-experimental/go-petstore/model_fruit_req.go create mode 100644 samples/openapi3/client/petstore/go-experimental/go-petstore/model_gm_fruit.go create mode 100644 samples/openapi3/client/petstore/go-experimental/go-petstore/model_mammal.go create mode 100644 samples/openapi3/client/petstore/go-experimental/go-petstore/model_whale.go create mode 100644 samples/openapi3/client/petstore/go-experimental/go-petstore/model_zebra.go diff --git a/bin/openapi3/python-experimental-petstore.sh b/bin/openapi3/python-experimental-petstore.sh index 188b45f15cbd..71cd902dee57 100755 --- a/bin/openapi3/python-experimental-petstore.sh +++ b/bin/openapi3/python-experimental-petstore.sh @@ -28,7 +28,7 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties" #yaml="modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml" -yaml="modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-httpsig-cmpsdschemas.yaml" +yaml="modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml" ags="generate -t modules/openapi-generator/src/main/resources/python -i $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/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-httpsig-cmpsdschemas.yaml b/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-httpsig-cmpsdschemas.yaml deleted file mode 100644 index d9aedbba9c6d..000000000000 --- a/modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-httpsig-cmpsdschemas.yaml +++ /dev/null @@ -1,1860 +0,0 @@ -openapi: 3.0.0 -info: - description: >- - This spec is mainly for testing Petstore server and contains fake endpoints, - models. Please do not use this for any other purpose. Special characters: " - \ - version: 1.0.0 - title: OpenAPI Petstore - license: - name: Apache-2.0 - url: 'https://www.apache.org/licenses/LICENSE-2.0.html' -tags: - - name: pet - description: Everything about your Pets - - name: store - description: Access to Petstore orders - - name: user - description: Operations about user -paths: - /foo: - get: - responses: - default: - description: response - content: - application/json: - schema: - type: object - properties: - string: - $ref: '#/components/schemas/Foo' - /pet: - servers: - - url: 'http://petstore.swagger.io/v2' - - url: 'http://path-server-test.petstore.local/v2' - post: - tags: - - pet - summary: Add a new pet to the store - description: '' - operationId: addPet - responses: - '405': - description: Invalid input - security: - - http_signature_test: [] - - petstore_auth: - - 'write:pets' - - 'read:pets' - requestBody: - $ref: '#/components/requestBodies/Pet' - put: - tags: - - pet - summary: Update an existing pet - description: '' - operationId: updatePet - responses: - '400': - description: Invalid ID supplied - '404': - description: Pet not found - '405': - description: Validation exception - security: - - http_signature_test: [] - - petstore_auth: - - 'write:pets' - - 'read:pets' - requestBody: - $ref: '#/components/requestBodies/Pet' - /pet/findByStatus: - get: - tags: - - pet - summary: Finds Pets by status - description: Multiple status values can be provided with comma separated strings - operationId: findPetsByStatus - parameters: - - name: status - in: query - description: Status values that need to be considered for filter - required: true - style: form - explode: false - schema: - type: array - items: - type: string - enum: - - available - - pending - - sold - default: available - responses: - '200': - description: successful operation - content: - application/xml: - schema: - type: array - items: - $ref: '#/components/schemas/Pet' - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Pet' - '400': - description: Invalid status value - security: - - http_signature_test: [] - - petstore_auth: - - 'write:pets' - - 'read:pets' - /pet/findByTags: - get: - tags: - - pet - summary: Finds Pets by tags - description: >- - Multiple tags can be provided with comma separated strings. Use tag1, - tag2, tag3 for testing. - operationId: findPetsByTags - parameters: - - name: tags - in: query - description: Tags to filter by - required: true - style: form - explode: false - schema: - type: array - items: - type: string - responses: - '200': - description: successful operation - content: - application/xml: - schema: - type: array - items: - $ref: '#/components/schemas/Pet' - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Pet' - '400': - description: Invalid tag value - security: - - http_signature_test: [] - - petstore_auth: - - 'write:pets' - - 'read:pets' - deprecated: true - '/pet/{petId}': - get: - tags: - - pet - summary: Find pet by ID - description: Returns a single pet - operationId: getPetById - parameters: - - name: petId - in: path - description: ID of pet to return - required: true - schema: - type: integer - format: int64 - responses: - '200': - description: successful operation - content: - application/xml: - schema: - $ref: '#/components/schemas/Pet' - application/json: - schema: - $ref: '#/components/schemas/Pet' - '400': - description: Invalid ID supplied - '404': - description: Pet not found - security: - - api_key: [] - post: - tags: - - pet - summary: Updates a pet in the store with form data - description: '' - operationId: updatePetWithForm - parameters: - - name: petId - in: path - description: ID of pet that needs to be updated - required: true - schema: - type: integer - format: int64 - responses: - '405': - description: Invalid input - security: - - petstore_auth: - - 'write:pets' - - 'read:pets' - requestBody: - content: - application/x-www-form-urlencoded: - schema: - type: object - properties: - name: - description: Updated name of the pet - type: string - status: - description: Updated status of the pet - type: string - delete: - tags: - - pet - summary: Deletes a pet - description: '' - operationId: deletePet - parameters: - - name: api_key - in: header - required: false - schema: - type: string - - name: petId - in: path - description: Pet id to delete - required: true - schema: - type: integer - format: int64 - responses: - '400': - description: Invalid pet value - security: - - petstore_auth: - - 'write:pets' - - 'read:pets' - '/pet/{petId}/uploadImage': - post: - tags: - - pet - summary: uploads an image - description: '' - operationId: uploadFile - parameters: - - name: petId - in: path - description: ID of pet to update - required: true - schema: - type: integer - format: int64 - responses: - '200': - description: successful operation - content: - application/json: - schema: - $ref: '#/components/schemas/ApiResponse' - security: - - petstore_auth: - - 'write:pets' - - 'read:pets' - requestBody: - content: - multipart/form-data: - schema: - type: object - properties: - additionalMetadata: - description: Additional data to pass to server - type: string - file: - description: file to upload - type: string - format: binary - /store/inventory: - get: - tags: - - store - summary: Returns pet inventories by status - description: Returns a map of status codes to quantities - operationId: getInventory - responses: - '200': - description: successful operation - content: - application/json: - schema: - type: object - additionalProperties: - type: integer - format: int32 - security: - - api_key: [] - /store/order: - post: - tags: - - store - summary: Place an order for a pet - description: '' - operationId: placeOrder - responses: - '200': - description: successful operation - content: - application/xml: - schema: - $ref: '#/components/schemas/Order' - application/json: - schema: - $ref: '#/components/schemas/Order' - '400': - description: Invalid Order - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Order' - description: order placed for purchasing the pet - required: true - '/store/order/{order_id}': - get: - tags: - - store - summary: Find purchase order by ID - description: >- - For valid response try integer IDs with value <= 5 or > 10. Other values - will generated exceptions - operationId: getOrderById - parameters: - - name: order_id - in: path - description: ID of pet that needs to be fetched - required: true - schema: - type: integer - format: int64 - minimum: 1 - maximum: 5 - responses: - '200': - description: successful operation - content: - application/xml: - schema: - $ref: '#/components/schemas/Order' - application/json: - schema: - $ref: '#/components/schemas/Order' - '400': - description: Invalid ID supplied - '404': - description: Order not found - delete: - tags: - - store - summary: Delete purchase order by ID - description: >- - For valid response try integer IDs with value < 1000. Anything above - 1000 or nonintegers will generate API errors - operationId: deleteOrder - parameters: - - name: order_id - in: path - description: ID of the order that needs to be deleted - required: true - schema: - type: string - responses: - '400': - description: Invalid ID supplied - '404': - description: Order not found - /user: - post: - tags: - - user - summary: Create user - description: This can only be done by the logged in user. - operationId: createUser - responses: - default: - description: successful operation - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/User' - description: Created user object - required: true - /user/createWithArray: - post: - tags: - - user - summary: Creates list of users with given input array - description: '' - operationId: createUsersWithArrayInput - responses: - default: - description: successful operation - requestBody: - $ref: '#/components/requestBodies/UserArray' - /user/createWithList: - post: - tags: - - user - summary: Creates list of users with given input array - description: '' - operationId: createUsersWithListInput - responses: - default: - description: successful operation - requestBody: - $ref: '#/components/requestBodies/UserArray' - /user/login: - get: - tags: - - user - summary: Logs user into the system - description: '' - operationId: loginUser - parameters: - - name: username - in: query - description: The user name for login - required: true - schema: - type: string - - name: password - in: query - description: The password for login in clear text - required: true - schema: - type: string - responses: - '200': - description: successful operation - headers: - X-Rate-Limit: - description: calls per hour allowed by the user - schema: - type: integer - format: int32 - X-Expires-After: - description: date in UTC when token expires - schema: - type: string - format: date-time - content: - application/xml: - schema: - type: string - application/json: - schema: - type: string - '400': - description: Invalid username/password supplied - /user/logout: - get: - tags: - - user - summary: Logs out current logged in user session - description: '' - operationId: logoutUser - responses: - default: - description: successful operation - '/user/{username}': - get: - tags: - - user - summary: Get user by user name - description: '' - operationId: getUserByName - parameters: - - name: username - in: path - description: The name that needs to be fetched. Use user1 for testing. - required: true - schema: - type: string - responses: - '200': - description: successful operation - content: - application/xml: - schema: - $ref: '#/components/schemas/User' - application/json: - schema: - $ref: '#/components/schemas/User' - '400': - description: Invalid username supplied - '404': - description: User not found - put: - tags: - - user - summary: Updated user - description: This can only be done by the logged in user. - operationId: updateUser - parameters: - - name: username - in: path - description: name that need to be deleted - required: true - schema: - type: string - responses: - '400': - description: Invalid user supplied - '404': - description: User not found - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/User' - description: Updated user object - required: true - delete: - tags: - - user - summary: Delete user - description: This can only be done by the logged in user. - operationId: deleteUser - parameters: - - name: username - in: path - description: The name that needs to be deleted - required: true - schema: - type: string - responses: - '400': - description: Invalid username supplied - '404': - description: User not found - /fake_classname_test: - patch: - tags: - - 'fake_classname_tags 123#$%^' - summary: To test class name in snake case - description: To test class name in snake case - operationId: testClassname - responses: - '200': - description: successful operation - content: - application/json: - schema: - $ref: '#/components/schemas/Client' - security: - - api_key_query: [] - requestBody: - $ref: '#/components/requestBodies/Client' - /fake: - patch: - tags: - - fake - summary: To test "client" model - description: To test "client" model - operationId: testClientModel - responses: - '200': - description: successful operation - content: - application/json: - schema: - $ref: '#/components/schemas/Client' - requestBody: - $ref: '#/components/requestBodies/Client' - get: - tags: - - fake - summary: To test enum parameters - description: To test enum parameters - operationId: testEnumParameters - parameters: - - name: enum_header_string_array - in: header - description: Header parameter enum test (string array) - schema: - type: array - items: - type: string - default: $ - enum: - - '>' - - $ - - name: enum_header_string - in: header - description: Header parameter enum test (string) - schema: - type: string - enum: - - _abc - - '-efg' - - (xyz) - default: '-efg' - - name: enum_query_string_array - in: query - description: Query parameter enum test (string array) - schema: - type: array - items: - type: string - default: $ - enum: - - '>' - - $ - - name: enum_query_string - in: query - description: Query parameter enum test (string) - schema: - type: string - enum: - - _abc - - '-efg' - - (xyz) - default: '-efg' - - name: enum_query_integer - in: query - description: Query parameter enum test (double) - schema: - type: integer - format: int32 - enum: - - 1 - - -2 - - name: enum_query_double - in: query - description: Query parameter enum test (double) - schema: - type: number - format: double - enum: - - 1.1 - - -1.2 - responses: - '400': - description: Invalid request - '404': - description: Not found - requestBody: - content: - application/x-www-form-urlencoded: - schema: - type: object - properties: - enum_form_string_array: - description: Form parameter enum test (string array) - type: array - items: - type: string - default: $ - enum: - - '>' - - $ - enum_form_string: - description: Form parameter enum test (string) - type: string - enum: - - _abc - - '-efg' - - (xyz) - default: '-efg' - post: - tags: - - fake - summary: | - Fake endpoint for testing various parameters - 假端點 - 偽のエンドポイント - 가짜 엔드 포인트 - description: | - Fake endpoint for testing various parameters - 假端點 - 偽のエンドポイント - 가짜 엔드 포인트 - operationId: testEndpointParameters - responses: - '400': - description: Invalid username supplied - '404': - description: User not found - security: - - http_basic_test: [] - requestBody: - content: - application/x-www-form-urlencoded: - schema: - type: object - properties: - integer: - description: None - type: integer - minimum: 10 - maximum: 100 - int32: - description: None - type: integer - format: int32 - minimum: 20 - maximum: 200 - int64: - description: None - type: integer - format: int64 - number: - description: None - type: number - minimum: 32.1 - maximum: 543.2 - float: - description: None - type: number - format: float - maximum: 987.6 - double: - description: None - type: number - format: double - minimum: 67.8 - maximum: 123.4 - string: - description: None - type: string - pattern: '/[a-z]/i' - pattern_without_delimiter: - description: None - type: string - pattern: '^[A-Z].*' - byte: - description: None - type: string - format: byte - binary: - description: None - type: string - format: binary - date: - description: None - type: string - format: date - dateTime: - description: None - type: string - format: date-time - password: - description: None - type: string - format: password - minLength: 10 - maxLength: 64 - callback: - description: None - type: string - required: - - number - - double - - pattern_without_delimiter - - byte - delete: - tags: - - fake - security: - - bearer_test: [] - summary: Fake endpoint to test group parameters (optional) - description: Fake endpoint to test group parameters (optional) - operationId: testGroupParameters - x-group-parameters: true - parameters: - - name: required_string_group - in: query - description: Required String in group parameters - required: true - schema: - type: integer - - name: required_boolean_group - in: header - description: Required Boolean in group parameters - required: true - schema: - type: boolean - - name: required_int64_group - in: query - description: Required Integer in group parameters - required: true - schema: - type: integer - format: int64 - - name: string_group - in: query - description: String in group parameters - schema: - type: integer - - name: boolean_group - in: header - description: Boolean in group parameters - schema: - type: boolean - - name: int64_group - in: query - description: Integer in group parameters - schema: - type: integer - format: int64 - responses: - '400': - description: Someting wrong - /fake/outer/number: - post: - tags: - - fake - description: Test serialization of outer number types - operationId: fakeOuterNumberSerialize - responses: - '200': - description: Output number - content: - '*/*': - schema: - $ref: '#/components/schemas/OuterNumber' - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/OuterNumber' - description: Input number as post body - /fake/outer/string: - post: - tags: - - fake - description: Test serialization of outer string types - operationId: fakeOuterStringSerialize - responses: - '200': - description: Output string - content: - '*/*': - schema: - $ref: '#/components/schemas/OuterString' - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/OuterString' - description: Input string as post body - /fake/outer/boolean: - post: - tags: - - fake - description: Test serialization of outer boolean types - operationId: fakeOuterBooleanSerialize - responses: - '200': - description: Output boolean - content: - '*/*': - schema: - $ref: '#/components/schemas/OuterBoolean' - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/OuterBoolean' - description: Input boolean as post body - /fake/outer/composite: - post: - tags: - - fake - description: Test serialization of object with outer number type - operationId: fakeOuterCompositeSerialize - responses: - '200': - description: Output composite - content: - '*/*': - schema: - $ref: '#/components/schemas/OuterComposite' - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/OuterComposite' - description: Input composite as post body - /fake/jsonFormData: - get: - tags: - - fake - summary: test json serialization of form data - description: '' - operationId: testJsonFormData - responses: - '200': - description: successful operation - requestBody: - content: - application/x-www-form-urlencoded: - schema: - type: object - properties: - param: - description: field1 - type: string - param2: - description: field2 - type: string - required: - - param - - param2 - /fake/inline-additionalProperties: - post: - tags: - - fake - summary: test inline additionalProperties - description: '' - operationId: testInlineAdditionalProperties - responses: - '200': - description: successful operation - requestBody: - content: - application/json: - schema: - type: object - additionalProperties: - type: string - description: request body - required: true - /fake/body-with-query-params: - put: - tags: - - fake - operationId: testBodyWithQueryParams - parameters: - - name: query - in: query - required: true - schema: - type: string - responses: - '200': - description: Success - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/User' - required: true - /another-fake/dummy: - patch: - tags: - - $another-fake? - summary: To test special tags - description: To test special tags and operation ID starting with number - operationId: '123_test_@#$%_special_tags' - responses: - '200': - description: successful operation - content: - application/json: - schema: - $ref: '#/components/schemas/Client' - requestBody: - $ref: '#/components/requestBodies/Client' - /fake/body-with-file-schema: - put: - tags: - - fake - description: >- - For this test, the body for this request much reference a schema named - `File`. - operationId: testBodyWithFileSchema - responses: - '200': - description: Success - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/FileSchemaTestClass' - required: true - /fake/test-query-paramters: - put: - tags: - - fake - description: To test the collection format in query parameters - operationId: testQueryParameterCollectionFormat - parameters: - - name: pipe - in: query - required: true - schema: - type: array - items: - type: string - - name: ioutil - in: query - required: true - style: form - explode: false - schema: - type: array - items: - type: string - - name: http - in: query - required: true - style: spaceDelimited - schema: - type: array - items: - type: string - - name: url - in: query - required: true - style: form - explode: false - schema: - type: array - items: - type: string - - name: context - in: query - required: true - explode: true - schema: - type: array - items: - type: string - responses: - "200": - description: Success - '/fake/{petId}/uploadImageWithRequiredFile': - post: - tags: - - pet - summary: uploads an image (required) - description: '' - operationId: uploadFileWithRequiredFile - parameters: - - name: petId - in: path - description: ID of pet to update - required: true - schema: - type: integer - format: int64 - responses: - '200': - description: successful operation - content: - application/json: - schema: - $ref: '#/components/schemas/ApiResponse' - security: - - petstore_auth: - - 'write:pets' - - 'read:pets' - requestBody: - content: - multipart/form-data: - schema: - type: object - properties: - additionalMetadata: - description: Additional data to pass to server - type: string - requiredFile: - description: file to upload - type: string - format: binary - required: - - requiredFile - /fake/health: - get: - tags: - - fake - summary: Health check endpoint - responses: - 200: - description: The instance started successfully - content: - application/json: - schema: - $ref: '#/components/schemas/HealthCheckResult' -servers: - - url: 'http://{server}.swagger.io:{port}/v2' - description: petstore server - variables: - server: - enum: - - 'petstore' - - 'qa-petstore' - - 'dev-petstore' - default: 'petstore' - port: - enum: - - 80 - - 8080 - default: 80 - - url: https://localhost:8080/{version} - description: The local server - variables: - version: - enum: - - 'v1' - - 'v2' - default: 'v2' -components: - requestBodies: - UserArray: - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/User' - description: List of user object - required: true - Client: - content: - application/json: - schema: - $ref: '#/components/schemas/Client' - description: client model - required: true - Pet: - content: - application/json: - schema: - $ref: '#/components/schemas/Pet' - application/xml: - schema: - $ref: '#/components/schemas/Pet' - description: Pet object that needs to be added to the store - required: true - securitySchemes: - petstore_auth: - type: oauth2 - flows: - implicit: - authorizationUrl: 'http://petstore.swagger.io/api/oauth/dialog' - scopes: - 'write:pets': modify pets in your account - 'read:pets': read your pets - api_key: - type: apiKey - name: api_key - in: header - api_key_query: - type: apiKey - name: api_key_query - in: query - http_basic_test: - type: http - scheme: basic - bearer_test: - type: http - scheme: bearer - bearerFormat: JWT - http_signature_test: - # Test the 'HTTP signature' security scheme. - # Each HTTP request is cryptographically signed as specified - # in https://datatracker.ietf.org/doc/draft-cavage-http-signatures/ - type: http - scheme: signature - schemas: - Foo: - type: object - properties: - bar: - $ref: '#/components/schemas/Bar' - Bar: - type: string - default: bar - Order: - type: object - properties: - id: - type: integer - format: int64 - petId: - type: integer - format: int64 - quantity: - type: integer - format: int32 - shipDate: - type: string - format: date-time - status: - type: string - description: Order Status - enum: - - placed - - approved - - delivered - complete: - type: boolean - default: false - xml: - name: Order - Category: - type: object - required: - - name - properties: - id: - type: integer - format: int64 - name: - type: string - default: default-name - xml: - name: Category - User: - type: object - properties: - id: - type: integer - format: int64 - x-is-unique: true - username: - type: string - firstName: - type: string - lastName: - type: string - email: - type: string - password: - type: string - phone: - type: string - userStatus: - type: integer - format: int32 - description: User Status - xml: - name: User - Tag: - type: object - properties: - id: - type: integer - format: int64 - name: - type: string - xml: - name: Tag - Pet: - type: object - required: - - name - - photoUrls - properties: - id: - type: integer - format: int64 - x-is-unique: true - category: - $ref: '#/components/schemas/Category' - name: - type: string - example: doggie - photoUrls: - type: array - xml: - name: photoUrl - wrapped: true - items: - type: string - tags: - type: array - xml: - name: tag - wrapped: true - items: - $ref: '#/components/schemas/Tag' - status: - type: string - description: pet status in the store - enum: - - available - - pending - - sold - xml: - name: Pet - ApiResponse: - type: object - properties: - code: - type: integer - format: int32 - type: - type: string - message: - type: string - Return: - description: Model for testing reserved words - properties: - return: - type: integer - format: int32 - xml: - name: Return - Name: - description: Model for testing model name same as property name - required: - - name - properties: - name: - type: integer - format: int32 - snake_case: - readOnly: true - type: integer - format: int32 - property: - type: string - 123Number: - type: integer - readOnly: true - xml: - name: Name - 200_response: - description: Model for testing model name starting with number - properties: - name: - type: integer - format: int32 - class: - type: string - xml: - name: Name - ClassModel: - description: Model for testing model with "_class" property - properties: - _class: - type: string - Dog: - allOf: - - $ref: '#/components/schemas/Animal' - - type: object - properties: - breed: - type: string - Cat: - allOf: - - $ref: '#/components/schemas/Animal' - - $ref: '#/components/schemas/Address' - - type: object - properties: - declawed: - type: boolean - Address: - type: object - additionalProperties: - type: integer - Animal: - type: object - discriminator: - propertyName: className - required: - - className - properties: - className: - type: string - color: - type: string - default: red - AnimalFarm: - type: array - items: - $ref: '#/components/schemas/Animal' - format_test: - type: object - required: - - number - - byte - - date - - password - properties: - integer: - type: integer - maximum: 100 - minimum: 10 - int32: - type: integer - format: int32 - maximum: 200 - minimum: 20 - int64: - type: integer - format: int64 - number: - maximum: 543.2 - minimum: 32.1 - type: number - float: - type: number - format: float - maximum: 987.6 - minimum: 54.3 - double: - type: number - format: double - maximum: 123.4 - minimum: 67.8 - string: - type: string - pattern: '/[a-z]/i' - byte: - type: string - format: byte - binary: - type: string - format: binary - date: - type: string - format: date - dateTime: - type: string - format: date-time - uuid: - type: string - format: uuid - example: 72f98069-206d-4f12-9f12-3d1e525a8e84 - password: - type: string - format: password - maxLength: 64 - minLength: 10 - pattern_with_digits: - description: A string that is a 10 digit number. Can have leading zeros. - type: string - pattern: '^\d{10}$' - pattern_with_digits_and_delimiter: - description: A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. - type: string - pattern: '/^image_\d{1,3}$/i' - EnumClass: - type: string - default: '-efg' - enum: - - _abc - - '-efg' - - (xyz) - Enum_Test: - type: object - required: - - enum_string_required - properties: - enum_string: - type: string - enum: - - UPPER - - lower - - '' - enum_string_required: - type: string - enum: - - UPPER - - lower - - '' - enum_integer: - type: integer - format: int32 - enum: - - 1 - - -1 - enum_number: - type: number - format: double - enum: - - 1.1 - - -1.2 - outerEnum: - $ref: '#/components/schemas/OuterEnum' - outerEnumInteger: - $ref: '#/components/schemas/OuterEnumInteger' - outerEnumDefaultValue: - $ref: '#/components/schemas/OuterEnumDefaultValue' - outerEnumIntegerDefaultValue: - $ref: '#/components/schemas/OuterEnumIntegerDefaultValue' - AdditionalPropertiesClass: - type: object - properties: - map_property: - type: object - additionalProperties: - type: string - map_of_map_property: - type: object - additionalProperties: - type: object - additionalProperties: - type: string - MixedPropertiesAndAdditionalPropertiesClass: - type: object - properties: - uuid: - type: string - format: uuid - dateTime: - type: string - format: date-time - map: - type: object - additionalProperties: - $ref: '#/components/schemas/Animal' - List: - type: object - properties: - 123-list: - type: string - Client: - type: object - properties: - client: - type: string - ReadOnlyFirst: - type: object - properties: - bar: - type: string - readOnly: true - baz: - type: string - hasOnlyReadOnly: - type: object - properties: - bar: - type: string - readOnly: true - foo: - type: string - readOnly: true - Capitalization: - type: object - properties: - smallCamel: - type: string - CapitalCamel: - type: string - small_Snake: - type: string - Capital_Snake: - type: string - SCA_ETH_Flow_Points: - type: string - ATT_NAME: - description: | - Name of the pet - type: string - MapTest: - type: object - properties: - map_map_of_string: - type: object - additionalProperties: - type: object - additionalProperties: - type: string - map_of_enum_string: - type: object - additionalProperties: - type: string - enum: - - UPPER - - lower - direct_map: - type: object - additionalProperties: - type: boolean - indirect_map: - $ref: '#/components/schemas/StringBooleanMap' - ArrayTest: - type: object - properties: - array_of_string: - type: array - items: - type: string - array_array_of_integer: - type: array - items: - type: array - items: - type: integer - format: int64 - array_array_of_model: - type: array - items: - type: array - items: - $ref: '#/components/schemas/ReadOnlyFirst' - NumberOnly: - type: object - properties: - JustNumber: - type: number - ArrayOfNumberOnly: - type: object - properties: - ArrayNumber: - type: array - items: - type: number - ArrayOfArrayOfNumberOnly: - type: object - properties: - ArrayArrayNumber: - type: array - items: - type: array - items: - type: number - EnumArrays: - type: object - properties: - just_symbol: - type: string - enum: - - '>=' - - $ - array_enum: - type: array - items: - type: string - enum: - - fish - - crab - OuterEnum: - nullable: true - type: string - enum: - - placed - - approved - - delivered - OuterEnumInteger: - type: integer - enum: - - 0 - - 1 - - 2 - OuterEnumDefaultValue: - type: string - enum: - - placed - - approved - - delivered - default: placed - OuterEnumIntegerDefaultValue: - type: integer - enum: - - 0 - - 1 - - 2 - default: 0 - OuterComposite: - type: object - properties: - my_number: - $ref: '#/components/schemas/OuterNumber' - my_string: - $ref: '#/components/schemas/OuterString' - my_boolean: - $ref: '#/components/schemas/OuterBoolean' - OuterNumber: - type: number - OuterString: - type: string - OuterBoolean: - type: boolean - x-codegen-body-parameter-name: boolean_post_body - StringBooleanMap: - additionalProperties: - type: boolean - FileSchemaTestClass: - type: object - properties: - file: - $ref: '#/components/schemas/File' - files: - type: array - items: - $ref: '#/components/schemas/File' - File: - type: object - description: Must be named `File` for test. - properties: - sourceURI: - description: Test capitalization - type: string - _special_model.name_: - properties: - '$special[property.name]': - type: integer - format: int64 - xml: - name: '$special[model.name]' - HealthCheckResult: - type: object - properties: - NullableMessage: - nullable: true - type: string - description: Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. - NullableClass: - type: object - properties: - integer_prop: - type: integer - nullable: true - number_prop: - type: number - nullable: true - boolean_prop: - type: boolean - nullable: true - string_prop: - type: string - nullable: true - date_prop: - type: string - format: date - nullable: true - datetime_prop: - type: string - format: date-time - nullable: true - array_nullable_prop: - type: array - nullable: true - items: - type: object - array_and_items_nullable_prop: - type: array - nullable: true - items: - type: object - nullable: true - array_items_nullable: - type: array - items: - type: object - nullable: true - object_nullable_prop: - type: object - nullable: true - additionalProperties: - type: object - object_and_items_nullable_prop: - type: object - nullable: true - additionalProperties: - type: object - nullable: true - object_items_nullable: - type: object - additionalProperties: - type: object - nullable: true - 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/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/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) +} From 0bda2211dc1b280962d6762856eb446eea63f342 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Fri, 28 Feb 2020 10:01:12 -0800 Subject: [PATCH 7/7] Also fix python-exp windows file --- bin/openapi3/windows/python-experimental-petstore.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/openapi3/windows/python-experimental-petstore.bat b/bin/openapi3/windows/python-experimental-petstore.bat index 5043ea878750..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-httpsig-cmpsdschemas.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%