From 9feb1e45ab1160473c60dfa220b69d4c503d693e Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Thu, 16 Jun 2022 14:30:33 -0700 Subject: [PATCH 01/43] Adds draft6 tests and python file reader --- CI/circle_parallel.sh | 1 + .../python-experimental_3_0_3_unit_test.yaml | 6 + .../openapitools/codegen/DefaultCodegen.java | 32 + .../codegen/ObjectWithTypeBooleans.java | 54 + .../openapitools/codegen/SchemaTestCase.java | 14 + .../PythonExperimentalClientCodegen.java | 5 + .../payload_renderer.handlebars | 33 + .../python-experimental/model_test.handlebars | 33 +- .../python-experimental/schemas.handlebars | 5 +- .../resources/3_0/unit_test_spec/.gitignore | 1 + .../draft6/additionalItems.json | 149 ++ .../draft6/additionalProperties.json | 133 + .../3_0/unit_test_spec/draft6/allOf.json | 294 +++ .../3_0/unit_test_spec/draft6/anyOf.json | 215 ++ .../unit_test_spec/draft6/boolean_schema.json | 104 + .../3_0/unit_test_spec/draft6/const.json | 342 +++ .../3_0/unit_test_spec/draft6/contains.json | 129 + .../3_0/unit_test_spec/draft6/default.json | 79 + .../unit_test_spec/draft6/definitions.json | 26 + .../unit_test_spec/draft6/dependencies.json | 248 ++ .../3_0/unit_test_spec/draft6/enum.json | 236 ++ .../draft6/exclusiveMaximum.json | 30 + .../draft6/exclusiveMinimum.json | 30 + .../3_0/unit_test_spec/draft6/format.json | 326 +++ .../3_0/unit_test_spec/draft6/id.json | 53 + .../draft6/infinite-loop-detection.json | 36 + .../3_0/unit_test_spec/draft6/items.json | 250 ++ .../3_0/unit_test_spec/draft6/maxItems.json | 28 + .../3_0/unit_test_spec/draft6/maxLength.json | 33 + .../unit_test_spec/draft6/maxProperties.json | 54 + .../3_0/unit_test_spec/draft6/maximum.json | 54 + .../3_0/unit_test_spec/draft6/minItems.json | 28 + .../3_0/unit_test_spec/draft6/minLength.json | 33 + .../unit_test_spec/draft6/minProperties.json | 38 + .../3_0/unit_test_spec/draft6/minimum.json | 69 + .../3_0/unit_test_spec/draft6/multipleOf.json | 71 + .../3_0/unit_test_spec/draft6/not.json | 117 + .../3_0/unit_test_spec/draft6/oneOf.json | 274 ++ .../draft6/optional/bignum.json | 93 + .../draft6/optional/ecmascript-regex.json | 552 +++++ .../draft6/optional/float-overflow.json | 13 + .../draft6/optional/format/date-time.json | 133 + .../draft6/optional/format/email.json | 83 + .../draft6/optional/format/hostname.json | 98 + .../draft6/optional/format/ipv4.json | 84 + .../draft6/optional/format/ipv6.json | 208 ++ .../draft6/optional/format/json-pointer.json | 198 ++ .../draft6/optional/format/unknown.json | 43 + .../draft6/optional/format/uri-reference.json | 73 + .../draft6/optional/format/uri-template.json | 58 + .../draft6/optional/format/uri.json | 108 + .../draft6/optional/future-keywords.json | 465 ++++ .../draft6/optional/non-bmp-regex.json | 82 + .../3_0/unit_test_spec/draft6/pattern.json | 59 + .../draft6/patternProperties.json | 156 ++ .../3_0/unit_test_spec/draft6/properties.json | 167 ++ .../unit_test_spec/draft6/propertyNames.json | 107 + .../3_0/unit_test_spec/draft6/ref.json | 612 +++++ .../3_0/unit_test_spec/draft6/refRemote.json | 196 ++ .../3_0/unit_test_spec/draft6/required.json | 105 + .../3_0/unit_test_spec/draft6/type.json | 474 ++++ .../unit_test_spec/draft6/uniqueItems.json | 404 +++ .../unit_test_spec/draft6/unknownKeyword.json | 56 + .../openapi_additions/type.json | 43 + .../3_0/unit_test_spec/spec_writer.py | 189 ++ .../resources/3_0/unit_test_spec/type.yaml | 275 ++ .../python-experimental/.gitignore | 67 + .../python-experimental/.gitlab-ci.yml | 24 + .../.openapi-generator-ignore | 23 + .../.openapi-generator/FILES | 33 + .../.openapi-generator/VERSION | 1 + .../python-experimental/.travis.yml | 13 + .../python-experimental/Makefile | 16 + .../python-experimental/README.md | 96 + .../python-experimental/dev-requirements.txt | 2 + .../docs/ArrayTypeMatchesArrays.md | 8 + .../docs/BooleanTypeMatchesBooleans.md | 8 + .../docs/IntegerTypeMatchesIntegers.md | 8 + .../docs/NullTypeMatchesOnlyTheNullObject.md | 8 + .../docs/NumberTypeMatchesNumbers.md | 8 + .../docs/StringTypeMatchesStrings.md | 8 + .../python-experimental/git_push.sh | 58 + .../python-experimental/pom.xml | 46 + .../python-experimental/requirements.txt | 5 + .../python-experimental/setup.cfg | 2 + .../python-experimental/setup.py | 45 + .../python-experimental/test-requirements.txt | 3 + .../python-experimental/test/__init__.py | 0 .../test/test_array_type_matches_arrays.py | 73 + .../test_boolean_type_matches_booleans.py | 93 + .../test_integer_type_matches_integers.py | 86 + ..._null_type_matches_only_the_null_object.py | 94 + .../test/test_number_type_matches_numbers.py | 85 + .../test/test_string_type_matches_strings.py | 85 + .../python-experimental/test_python.sh | 33 + .../python-experimental/tox.ini | 9 + .../unit_test_api/__init__.py | 28 + .../unit_test_api/api/__init__.py | 0 .../unit_test_api/api_client.py | 1420 +++++++++++ .../unit_test_api/apis/__init__.py | 0 .../unit_test_api/configuration.py | 440 ++++ .../unit_test_api/exceptions.py | 136 + .../unit_test_api/model/__init__.py | 5 + .../model/array_type_matches_arrays.py | 77 + .../model/boolean_type_matches_booleans.py | 67 + .../model/integer_type_matches_integers.py | 67 + .../null_type_matches_only_the_null_object.py | 67 + .../model/number_type_matches_numbers.py | 67 + .../model/string_type_matches_strings.py | 67 + .../unit_test_api/models/__init__.py | 19 + .../python-experimental/unit_test_api/rest.py | 253 ++ .../unit_test_api/schemas.py | 2201 +++++++++++++++++ 112 files changed, 14738 insertions(+), 13 deletions(-) create mode 100644 bin/configs/python-experimental_3_0_3_unit_test.yaml create mode 100644 modules/openapi-generator/src/main/java/org/openapitools/codegen/ObjectWithTypeBooleans.java create mode 100644 modules/openapi-generator/src/main/java/org/openapitools/codegen/SchemaTestCase.java create mode 100644 modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars create mode 100644 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/.gitignore create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/additionalItems.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/additionalProperties.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/allOf.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/anyOf.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/boolean_schema.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/const.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/contains.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/default.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/definitions.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/dependencies.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/enum.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/exclusiveMaximum.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/exclusiveMinimum.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/format.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/id.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/infinite-loop-detection.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/items.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/maxItems.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/maxLength.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/maxProperties.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/maximum.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/minItems.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/minLength.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/minProperties.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/minimum.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/multipleOf.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/not.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/oneOf.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/bignum.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/ecmascript-regex.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/float-overflow.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/date-time.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/email.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/hostname.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/ipv4.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/ipv6.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/json-pointer.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/unknown.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/uri-reference.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/uri-template.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/uri.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/future-keywords.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/non-bmp-regex.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/pattern.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/patternProperties.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/properties.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/propertyNames.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/ref.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/refRemote.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/required.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/type.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/uniqueItems.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/unknownKeyword.json create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/openapi_additions/type.json create mode 100644 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py create mode 100644 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/.gitignore create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/.gitlab-ci.yml create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator-ignore create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/VERSION create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/.travis.yml create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/Makefile create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/dev-requirements.txt create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ArrayTypeMatchesArrays.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/BooleanTypeMatchesBooleans.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/IntegerTypeMatchesIntegers.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NullTypeMatchesOnlyTheNullObject.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NumberTypeMatchesNumbers.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/StringTypeMatchesStrings.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/git_push.sh create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/pom.xml create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/requirements.txt create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/setup.cfg create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/setup.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test-requirements.txt create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/__init__.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py create mode 100755 samples/openapi3/client/3_0_3_unit_test/python-experimental/test_python.sh create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/tox.ini create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/__init__.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/api/__init__.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/api_client.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/__init__.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/configuration.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/exceptions.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/__init__.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/array_type_matches_arrays.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/boolean_type_matches_booleans.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/integer_type_matches_integers.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/null_type_matches_only_the_null_object.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/number_type_matches_numbers.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/string_type_matches_strings.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/rest.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/schemas.py diff --git a/CI/circle_parallel.sh b/CI/circle_parallel.sh index 183c77c8c62..1d96dae7b13 100755 --- a/CI/circle_parallel.sh +++ b/CI/circle_parallel.sh @@ -80,6 +80,7 @@ elif [ "$NODE_INDEX" = "4" ]; then #mvn --no-snapshot-updates --quiet verify -Psamples.circleci.node4 -Dorg.slf4j.simpleLogger.defaultLogLevel=error (cd samples/openapi3/client/petstore/python && make test) (cd samples/openapi3/client/petstore/python-experimental && make test) + (cd samples/openapi3/client/3_0_3_unit_test/python-experimental && make test) else echo "Running node $NODE_INDEX to test 'samples.circleci.others' defined in pom.xml ..." diff --git a/bin/configs/python-experimental_3_0_3_unit_test.yaml b/bin/configs/python-experimental_3_0_3_unit_test.yaml new file mode 100644 index 00000000000..3169f0804e1 --- /dev/null +++ b/bin/configs/python-experimental_3_0_3_unit_test.yaml @@ -0,0 +1,6 @@ +generatorName: python-experimental +outputDir: samples/openapi3/client/3_0_3_unit_test/python-experimental +inputSpec: modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml +templateDir: modules/openapi-generator/src/main/resources/python-experimental +additionalProperties: + packageName: unit_test_api diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index b20c1131114..2c9d261162b 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -2696,6 +2696,35 @@ public class DefaultCodegen implements CodegenConfig { setAddProps(schema, m); } + protected String toTesCaseName(String specTestCaseName) { + return specTestCaseName; + } + + /** + * Processes any test cases if they exist in the vendor extensions + * If they exist then cast them to java class instances and assign them back as the value + * in the x-test-examples vendor extension + * @param vendorExtensions + */ + private void processTestCases(HashMap<String, Object> vendorExtensions) { + String testExamplesKey = "x-test-examples"; + HashMap<String, SchemaTestCase> testCases = new HashMap<>(); + if (vendorExtensions.containsKey(testExamplesKey)) { + LinkedHashMap<String, Object> testExamples = (LinkedHashMap<String, Object>) vendorExtensions.get(testExamplesKey); + for(Map.Entry<String, Object> testExampleEntry: testExamples.entrySet()) { + String exampleName = testExampleEntry.getKey(); + LinkedHashMap<String, Object> testExample = (LinkedHashMap<String, Object>) testExampleEntry.getValue(); + String nameInSnakeCase = toTesCaseName(exampleName); + SchemaTestCase testCase = new SchemaTestCase( + (String) testExample.getOrDefault("description", ""), + new ObjectWithTypeBooleans(testExample.get("data")), + (boolean) testExample.get("valid") + ); + testCases.put(nameInSnakeCase, testCase); + } + vendorExtensions.put(testExamplesKey, testCases); + } + } /** * Convert OAS Model object to Codegen Model object. @@ -2706,6 +2735,9 @@ public class DefaultCodegen implements CodegenConfig { */ @Override public CodegenModel fromModel(String name, Schema schema) { + HashMap<String, Object> vendorExtensions = (HashMap<String, Object>) schema.getExtensions(); + processTestCases(vendorExtensions); + Map<String, Schema> allDefinitions = ModelUtils.getSchemas(this.openAPI); if (typeAliases == null) { // Only do this once during first call diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/ObjectWithTypeBooleans.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/ObjectWithTypeBooleans.java new file mode 100644 index 00000000000..7f450b51c2f --- /dev/null +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/ObjectWithTypeBooleans.java @@ -0,0 +1,54 @@ +package org.openapitools.codegen; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.Map; + +public class ObjectWithTypeBooleans { + public boolean isUnboundedInteger; + public boolean isNumber; + public boolean isString; + public boolean isMap; + public boolean isArray; + public boolean isBoolean; + public boolean isNull; + public Object value; + + public ObjectWithTypeBooleans(Object value) { + Object usedValue = null; + if (value instanceof Integer){ + this.isUnboundedInteger = true; + this.value = value; + } else if (value instanceof Double || value instanceof Float){ + this.isNumber = true; + this.value = value; + } else if (value instanceof String) { + this.isString = true; + this.value = value; + } else if (value instanceof LinkedHashMap) { + LinkedHashMap<String, Object> castValue = (LinkedHashMap<String, Object>) value; + LinkedHashMap<String, ObjectWithTypeBooleans> castMap = new LinkedHashMap<>(); + for (Map.Entry entry: castValue.entrySet()) { + String entryKey = (String) entry.getKey(); + ObjectWithTypeBooleans entryValue = new ObjectWithTypeBooleans(entry.getValue()); + castMap.put(entryKey, entryValue); + } + this.value = castMap; + this.isMap = true; + } else if (value instanceof ArrayList) { + ArrayList<ObjectWithTypeBooleans> castList = new ArrayList<>(); + for (Object item: (ArrayList<Object>) value) { + castList.add(new ObjectWithTypeBooleans(item)); + } + this.value = castList; + this.isArray = true; + } else if (value instanceof Boolean) { + this.isBoolean = true; + this.value = value; + } else if (value == null) { + this.isNull = true; + this.value = value; + } + } +} + diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/SchemaTestCase.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/SchemaTestCase.java new file mode 100644 index 00000000000..c377fe704e2 --- /dev/null +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/SchemaTestCase.java @@ -0,0 +1,14 @@ +package org.openapitools.codegen; + +public class SchemaTestCase { + public String description; + public ObjectWithTypeBooleans data; + // true means the test case should pass, false means it should fail + public boolean valid; + + public SchemaTestCase(String description, ObjectWithTypeBooleans data, boolean valid) { + this.description = description; + this.data = data; + this.valid = valid; + } +} diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java index 8657494678a..7a2a9099e23 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java @@ -19,6 +19,7 @@ package org.openapitools.codegen.languages; import com.github.curiousoddman.rgxgen.RgxGen; import com.github.curiousoddman.rgxgen.config.RgxGenOption; import com.github.curiousoddman.rgxgen.config.RgxGenProperties; +import com.google.common.base.CaseFormat; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.servers.Server; @@ -1152,6 +1153,10 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen { model.dataType = getTypeString(schema, "", "", referencedModelNames); } + protected String toTesCaseName(String specTestCaseName) { + return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, specTestCaseName); + } + /** * Convert OAS Model object to Codegen Model object * We have a custom version of this method so we can: diff --git a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars new file mode 100644 index 00000000000..12d9c8c77bc --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars @@ -0,0 +1,33 @@ +{{#or isNumber isUnboundedInteger}} + {{value}} +{{/or}} +{{#if isBoolean}} + {{#if value}} + True + {{else}} + False + {{/if}} +{{/if}} +{{#if isNull}} + None +{{/if}} +{{#if isString}} + "{{value}}" +{{/if}} +{{#if isArray}} + [ + {{#each value}} + {{> model_templates/payload_renderer }} + {{/each}} + ] +{{/if}} +{{#if isMap}} + { + {{#each value}} + "{{@key}}": + {{#with this}} + {{> model_templates/payload_renderer }}, + {{/with}} + {{/each}} + } +{{/if}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python-experimental/model_test.handlebars b/modules/openapi-generator/src/main/resources/python-experimental/model_test.handlebars index 48a4a7c85a1..4f4ab258434 100644 --- a/modules/openapi-generator/src/main/resources/python-experimental/model_test.handlebars +++ b/modules/openapi-generator/src/main/resources/python-experimental/model_test.handlebars @@ -13,18 +13,29 @@ from {{packageName}}.{{modelPackage}}.{{classFilename}} import {{classname}} class Test{{classname}}(unittest.TestCase): """{{classname}} unit test stubs""" - def setUp(self): - pass - - def tearDown(self): - pass - - def test_{{classname}}(self): - """Test {{classname}}""" - # FIXME: construct object with mandatory attributes with example values - # model = {{classname}}() # noqa: E501 - pass +{{#each vendorExtensions}} +{{#if @key eq "x-test-examples" }} +{{#each this }} + def test_{{@key}}_{{#if valid}}passes{{else}}fails{{/if}}(self): + # {{description}} +{{#if valid}} + {{classname}}( +{{#with data}} + {{>model_templates/payload_renderer}} +{{/with}} + ) +{{else}} + with self.assertRaises(({{packageName}}.ApiValueError, {{packageName}}.ApiTypeError)): + {{classname}}( +{{#with data}} + {{>model_templates/payload_renderer}} +{{/with}} + ) +{{/if}} +{{/each}} +{{/if}} +{{/each}} {{/with}} {{/each}} diff --git a/modules/openapi-generator/src/main/resources/python-experimental/schemas.handlebars b/modules/openapi-generator/src/main/resources/python-experimental/schemas.handlebars index f9a69ff2b75..d7eb0accba2 100644 --- a/modules/openapi-generator/src/main/resources/python-experimental/schemas.handlebars +++ b/modules/openapi-generator/src/main/resources/python-experimental/schemas.handlebars @@ -1865,8 +1865,9 @@ class IntBase(NumberBase): @classmethod def _validate_format(cls, arg: typing.Optional[decimal.Decimal], validation_metadata: ValidationMetadata): if isinstance(arg, decimal.Decimal): - exponent = arg.as_tuple().exponent - if exponent != 0: + + denominator = arg.as_integer_ratio()[-1] + if denominator != 1: raise ApiValueError( "Invalid value '{}' for type integer at {}".format(arg, validation_metadata.path_to_item) ) diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/.gitignore b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/.gitignore new file mode 100644 index 00000000000..f5e96dbfaec --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/.gitignore @@ -0,0 +1 @@ +venv \ No newline at end of file diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/additionalItems.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/additionalItems.json new file mode 100755 index 00000000000..784bc846105 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/additionalItems.json @@ -0,0 +1,149 @@ +[ + { + "description": "additionalItems as schema", + "schema": { + "items": [{}], + "additionalItems": {"type": "integer"} + }, + "tests": [ + { + "description": "additional items match schema", + "data": [ null, 2, 3, 4 ], + "valid": true + }, + { + "description": "additional items do not match schema", + "data": [ null, 2, 3, "foo" ], + "valid": false + } + ] + }, + { + "description": "when items is schema, additionalItems does nothing", + "schema": { + "items": {}, + "additionalItems": false + }, + "tests": [ + { + "description": "all items match schema", + "data": [ 1, 2, 3, 4, 5 ], + "valid": true + } + ] + }, + { + "description": "array of items with no additionalItems permitted", + "schema": { + "items": [{}, {}, {}], + "additionalItems": false + }, + "tests": [ + { + "description": "empty array", + "data": [ ], + "valid": true + }, + { + "description": "fewer number of items present (1)", + "data": [ 1 ], + "valid": true + }, + { + "description": "fewer number of items present (2)", + "data": [ 1, 2 ], + "valid": true + }, + { + "description": "equal number of items present", + "data": [ 1, 2, 3 ], + "valid": true + }, + { + "description": "additional items are not permitted", + "data": [ 1, 2, 3, 4 ], + "valid": false + } + ] + }, + { + "description": "additionalItems as false without items", + "schema": {"additionalItems": false}, + "tests": [ + { + "description": + "items defaults to empty schema so everything is valid", + "data": [ 1, 2, 3, 4, 5 ], + "valid": true + }, + { + "description": "ignores non-arrays", + "data": {"foo" : "bar"}, + "valid": true + } + ] + }, + { + "description": "additionalItems are allowed by default", + "schema": {"items": [{"type": "integer"}]}, + "tests": [ + { + "description": "only the first item is validated", + "data": [1, "foo", false], + "valid": true + } + ] + }, + { + "description": "additionalItems should not look in applicators, valid case", + "schema": { + "allOf": [ + { "items": [ { "type": "integer" } ] } + ], + "additionalItems": { "type": "boolean" } + }, + "tests": [ + { + "description": "items defined in allOf are not examined", + "data": [ 1, null ], + "valid": true + } + ] + }, + { + "description": "additionalItems should not look in applicators, invalid case", + "schema": { + "allOf": [ + { "items": [ { "type": "integer" }, { "type": "string" } ] } + ], + "items": [ {"type": "integer" } ], + "additionalItems": { "type": "boolean" } + }, + "tests": [ + { + "description": "items defined in allOf are not examined", + "data": [ 1, "hello" ], + "valid": false + } + ] + }, + { + "description": "items validation adjusts the starting index for additionalItems", + "schema": { + "items": [ { "type": "string" } ], + "additionalItems": { "type": "integer" } + }, + "tests": [ + { + "description": "valid items", + "data": [ "x", 2, 3 ], + "valid": true + }, + { + "description": "wrong type of second item", + "data": [ "x", "y" ], + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/additionalProperties.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/additionalProperties.json new file mode 100755 index 00000000000..381275a596a --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/additionalProperties.json @@ -0,0 +1,133 @@ +[ + { + "description": + "additionalProperties being false does not allow other properties", + "schema": { + "properties": {"foo": {}, "bar": {}}, + "patternProperties": { "^v": {} }, + "additionalProperties": false + }, + "tests": [ + { + "description": "no additional properties is valid", + "data": {"foo": 1}, + "valid": true + }, + { + "description": "an additional property is invalid", + "data": {"foo" : 1, "bar" : 2, "quux" : "boom"}, + "valid": false + }, + { + "description": "ignores arrays", + "data": [1, 2, 3], + "valid": true + }, + { + "description": "ignores strings", + "data": "foobarbaz", + "valid": true + }, + { + "description": "ignores other non-objects", + "data": 12, + "valid": true + }, + { + "description": "patternProperties are not additional properties", + "data": {"foo":1, "vroom": 2}, + "valid": true + } + ] + }, + { + "description": "non-ASCII pattern with additionalProperties", + "schema": { + "patternProperties": {"^á": {}}, + "additionalProperties": false + }, + "tests": [ + { + "description": "matching the pattern is valid", + "data": {"ármányos": 2}, + "valid": true + }, + { + "description": "not matching the pattern is invalid", + "data": {"élmény": 2}, + "valid": false + } + ] + }, + { + "description": + "additionalProperties allows a schema which should validate", + "schema": { + "properties": {"foo": {}, "bar": {}}, + "additionalProperties": {"type": "boolean"} + }, + "tests": [ + { + "description": "no additional properties is valid", + "data": {"foo": 1}, + "valid": true + }, + { + "description": "an additional valid property is valid", + "data": {"foo" : 1, "bar" : 2, "quux" : true}, + "valid": true + }, + { + "description": "an additional invalid property is invalid", + "data": {"foo" : 1, "bar" : 2, "quux" : 12}, + "valid": false + } + ] + }, + { + "description": + "additionalProperties can exist by itself", + "schema": { + "additionalProperties": {"type": "boolean"} + }, + "tests": [ + { + "description": "an additional valid property is valid", + "data": {"foo" : true}, + "valid": true + }, + { + "description": "an additional invalid property is invalid", + "data": {"foo" : 1}, + "valid": false + } + ] + }, + { + "description": "additionalProperties are allowed by default", + "schema": {"properties": {"foo": {}, "bar": {}}}, + "tests": [ + { + "description": "additional properties are allowed", + "data": {"foo": 1, "bar": 2, "quux": true}, + "valid": true + } + ] + }, + { + "description": "additionalProperties should not look in applicators", + "schema": { + "allOf": [ + {"properties": {"foo": {}}} + ], + "additionalProperties": {"type": "boolean"} + }, + "tests": [ + { + "description": "properties defined in allOf are not examined", + "data": {"foo": 1, "bar": true}, + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/allOf.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/allOf.json new file mode 100755 index 00000000000..ec9319e1436 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/allOf.json @@ -0,0 +1,294 @@ +[ + { + "description": "allOf", + "schema": { + "allOf": [ + { + "properties": { + "bar": {"type": "integer"} + }, + "required": ["bar"] + }, + { + "properties": { + "foo": {"type": "string"} + }, + "required": ["foo"] + } + ] + }, + "tests": [ + { + "description": "allOf", + "data": {"foo": "baz", "bar": 2}, + "valid": true + }, + { + "description": "mismatch second", + "data": {"foo": "baz"}, + "valid": false + }, + { + "description": "mismatch first", + "data": {"bar": 2}, + "valid": false + }, + { + "description": "wrong type", + "data": {"foo": "baz", "bar": "quux"}, + "valid": false + } + ] + }, + { + "description": "allOf with base schema", + "schema": { + "properties": {"bar": {"type": "integer"}}, + "required": ["bar"], + "allOf" : [ + { + "properties": { + "foo": {"type": "string"} + }, + "required": ["foo"] + }, + { + "properties": { + "baz": {"type": "null"} + }, + "required": ["baz"] + } + ] + }, + "tests": [ + { + "description": "valid", + "data": {"foo": "quux", "bar": 2, "baz": null}, + "valid": true + }, + { + "description": "mismatch base schema", + "data": {"foo": "quux", "baz": null}, + "valid": false + }, + { + "description": "mismatch first allOf", + "data": {"bar": 2, "baz": null}, + "valid": false + }, + { + "description": "mismatch second allOf", + "data": {"foo": "quux", "bar": 2}, + "valid": false + }, + { + "description": "mismatch both", + "data": {"bar": 2}, + "valid": false + } + ] + }, + { + "description": "allOf simple types", + "schema": { + "allOf": [ + {"maximum": 30}, + {"minimum": 20} + ] + }, + "tests": [ + { + "description": "valid", + "data": 25, + "valid": true + }, + { + "description": "mismatch one", + "data": 35, + "valid": false + } + ] + }, + { + "description": "allOf with boolean schemas, all true", + "schema": {"allOf": [true, true]}, + "tests": [ + { + "description": "any value is valid", + "data": "foo", + "valid": true + } + ] + }, + { + "description": "allOf with boolean schemas, some false", + "schema": {"allOf": [true, false]}, + "tests": [ + { + "description": "any value is invalid", + "data": "foo", + "valid": false + } + ] + }, + { + "description": "allOf with boolean schemas, all false", + "schema": {"allOf": [false, false]}, + "tests": [ + { + "description": "any value is invalid", + "data": "foo", + "valid": false + } + ] + }, + { + "description": "allOf with one empty schema", + "schema": { + "allOf": [ + {} + ] + }, + "tests": [ + { + "description": "any data is valid", + "data": 1, + "valid": true + } + ] + }, + { + "description": "allOf with two empty schemas", + "schema": { + "allOf": [ + {}, + {} + ] + }, + "tests": [ + { + "description": "any data is valid", + "data": 1, + "valid": true + } + ] + }, + { + "description": "allOf with the first empty schema", + "schema": { + "allOf": [ + {}, + { "type": "number" } + ] + }, + "tests": [ + { + "description": "number is valid", + "data": 1, + "valid": true + }, + { + "description": "string is invalid", + "data": "foo", + "valid": false + } + ] + }, + { + "description": "allOf with the last empty schema", + "schema": { + "allOf": [ + { "type": "number" }, + {} + ] + }, + "tests": [ + { + "description": "number is valid", + "data": 1, + "valid": true + }, + { + "description": "string is invalid", + "data": "foo", + "valid": false + } + ] + }, + { + "description": "nested allOf, to check validation semantics", + "schema": { + "allOf": [ + { + "allOf": [ + { + "type": "null" + } + ] + } + ] + }, + "tests": [ + { + "description": "null is valid", + "data": null, + "valid": true + }, + { + "description": "anything non-null is invalid", + "data": 123, + "valid": false + } + ] + }, + { + "description": "allOf combined with anyOf, oneOf", + "schema": { + "allOf": [ { "multipleOf": 2 } ], + "anyOf": [ { "multipleOf": 3 } ], + "oneOf": [ { "multipleOf": 5 } ] + }, + "tests": [ + { + "description": "allOf: false, anyOf: false, oneOf: false", + "data": 1, + "valid": false + }, + { + "description": "allOf: false, anyOf: false, oneOf: true", + "data": 5, + "valid": false + }, + { + "description": "allOf: false, anyOf: true, oneOf: false", + "data": 3, + "valid": false + }, + { + "description": "allOf: false, anyOf: true, oneOf: true", + "data": 15, + "valid": false + }, + { + "description": "allOf: true, anyOf: false, oneOf: false", + "data": 2, + "valid": false + }, + { + "description": "allOf: true, anyOf: false, oneOf: true", + "data": 10, + "valid": false + }, + { + "description": "allOf: true, anyOf: true, oneOf: false", + "data": 6, + "valid": false + }, + { + "description": "allOf: true, anyOf: true, oneOf: true", + "data": 30, + "valid": true + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/anyOf.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/anyOf.json new file mode 100755 index 00000000000..b720afa8de3 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/anyOf.json @@ -0,0 +1,215 @@ +[ + { + "description": "anyOf", + "schema": { + "anyOf": [ + { + "type": "integer" + }, + { + "minimum": 2 + } + ] + }, + "tests": [ + { + "description": "first anyOf valid", + "data": 1, + "valid": true + }, + { + "description": "second anyOf valid", + "data": 2.5, + "valid": true + }, + { + "description": "both anyOf valid", + "data": 3, + "valid": true + }, + { + "description": "neither anyOf valid", + "data": 1.5, + "valid": false + } + ] + }, + { + "description": "anyOf with base schema", + "schema": { + "type": "string", + "anyOf" : [ + { + "maxLength": 2 + }, + { + "minLength": 4 + } + ] + }, + "tests": [ + { + "description": "mismatch base schema", + "data": 3, + "valid": false + }, + { + "description": "one anyOf valid", + "data": "foobar", + "valid": true + }, + { + "description": "both anyOf invalid", + "data": "foo", + "valid": false + } + ] + }, + { + "description": "anyOf with boolean schemas, all true", + "schema": {"anyOf": [true, true]}, + "tests": [ + { + "description": "any value is valid", + "data": "foo", + "valid": true + } + ] + }, + { + "description": "anyOf with boolean schemas, some true", + "schema": {"anyOf": [true, false]}, + "tests": [ + { + "description": "any value is valid", + "data": "foo", + "valid": true + } + ] + }, + { + "description": "anyOf with boolean schemas, all false", + "schema": {"anyOf": [false, false]}, + "tests": [ + { + "description": "any value is invalid", + "data": "foo", + "valid": false + } + ] + }, + { + "description": "anyOf complex types", + "schema": { + "anyOf": [ + { + "properties": { + "bar": {"type": "integer"} + }, + "required": ["bar"] + }, + { + "properties": { + "foo": {"type": "string"} + }, + "required": ["foo"] + } + ] + }, + "tests": [ + { + "description": "first anyOf valid (complex)", + "data": {"bar": 2}, + "valid": true + }, + { + "description": "second anyOf valid (complex)", + "data": {"foo": "baz"}, + "valid": true + }, + { + "description": "both anyOf valid (complex)", + "data": {"foo": "baz", "bar": 2}, + "valid": true + }, + { + "description": "neither anyOf valid (complex)", + "data": {"foo": 2, "bar": "quux"}, + "valid": false + } + ] + }, + { + "description": "anyOf with one empty schema", + "schema": { + "anyOf": [ + { "type": "number" }, + {} + ] + }, + "tests": [ + { + "description": "string is valid", + "data": "foo", + "valid": true + }, + { + "description": "number is valid", + "data": 123, + "valid": true + } + ] + }, + { + "description": "nested anyOf, to check validation semantics", + "schema": { + "anyOf": [ + { + "anyOf": [ + { + "type": "null" + } + ] + } + ] + }, + "tests": [ + { + "description": "null is valid", + "data": null, + "valid": true + }, + { + "description": "anything non-null is invalid", + "data": 123, + "valid": false + } + ] + }, + { + "description": "nested anyOf, to check validation semantics", + "schema": { + "anyOf": [ + { + "anyOf": [ + { + "type": "null" + } + ] + } + ] + }, + "tests": [ + { + "description": "null is valid", + "data": null, + "valid": true + }, + { + "description": "anything non-null is invalid", + "data": 123, + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/boolean_schema.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/boolean_schema.json new file mode 100755 index 00000000000..6d40f23f262 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/boolean_schema.json @@ -0,0 +1,104 @@ +[ + { + "description": "boolean schema 'true'", + "schema": true, + "tests": [ + { + "description": "number is valid", + "data": 1, + "valid": true + }, + { + "description": "string is valid", + "data": "foo", + "valid": true + }, + { + "description": "boolean true is valid", + "data": true, + "valid": true + }, + { + "description": "boolean false is valid", + "data": false, + "valid": true + }, + { + "description": "null is valid", + "data": null, + "valid": true + }, + { + "description": "object is valid", + "data": {"foo": "bar"}, + "valid": true + }, + { + "description": "empty object is valid", + "data": {}, + "valid": true + }, + { + "description": "array is valid", + "data": ["foo"], + "valid": true + }, + { + "description": "empty array is valid", + "data": [], + "valid": true + } + ] + }, + { + "description": "boolean schema 'false'", + "schema": false, + "tests": [ + { + "description": "number is invalid", + "data": 1, + "valid": false + }, + { + "description": "string is invalid", + "data": "foo", + "valid": false + }, + { + "description": "boolean true is invalid", + "data": true, + "valid": false + }, + { + "description": "boolean false is invalid", + "data": false, + "valid": false + }, + { + "description": "null is invalid", + "data": null, + "valid": false + }, + { + "description": "object is invalid", + "data": {"foo": "bar"}, + "valid": false + }, + { + "description": "empty object is invalid", + "data": {}, + "valid": false + }, + { + "description": "array is invalid", + "data": ["foo"], + "valid": false + }, + { + "description": "empty array is invalid", + "data": [], + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/const.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/const.json new file mode 100755 index 00000000000..1c2cafcc19b --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/const.json @@ -0,0 +1,342 @@ +[ + { + "description": "const validation", + "schema": {"const": 2}, + "tests": [ + { + "description": "same value is valid", + "data": 2, + "valid": true + }, + { + "description": "another value is invalid", + "data": 5, + "valid": false + }, + { + "description": "another type is invalid", + "data": "a", + "valid": false + } + ] + }, + { + "description": "const with object", + "schema": {"const": {"foo": "bar", "baz": "bax"}}, + "tests": [ + { + "description": "same object is valid", + "data": {"foo": "bar", "baz": "bax"}, + "valid": true + }, + { + "description": "same object with different property order is valid", + "data": {"baz": "bax", "foo": "bar"}, + "valid": true + }, + { + "description": "another object is invalid", + "data": {"foo": "bar"}, + "valid": false + }, + { + "description": "another type is invalid", + "data": [1, 2], + "valid": false + } + ] + }, + { + "description": "const with array", + "schema": {"const": [{ "foo": "bar" }]}, + "tests": [ + { + "description": "same array is valid", + "data": [{"foo": "bar"}], + "valid": true + }, + { + "description": "another array item is invalid", + "data": [2], + "valid": false + }, + { + "description": "array with additional items is invalid", + "data": [1, 2, 3], + "valid": false + } + ] + }, + { + "description": "const with null", + "schema": {"const": null}, + "tests": [ + { + "description": "null is valid", + "data": null, + "valid": true + }, + { + "description": "not null is invalid", + "data": 0, + "valid": false + } + ] + }, + { + "description": "const with false does not match 0", + "schema": {"const": false}, + "tests": [ + { + "description": "false is valid", + "data": false, + "valid": true + }, + { + "description": "integer zero is invalid", + "data": 0, + "valid": false + }, + { + "description": "float zero is invalid", + "data": 0.0, + "valid": false + } + ] + }, + { + "description": "const with true does not match 1", + "schema": {"const": true}, + "tests": [ + { + "description": "true is valid", + "data": true, + "valid": true + }, + { + "description": "integer one is invalid", + "data": 1, + "valid": false + }, + { + "description": "float one is invalid", + "data": 1.0, + "valid": false + } + ] + }, + { + "description": "const with [false] does not match [0]", + "schema": {"const": [false]}, + "tests": [ + { + "description": "[false] is valid", + "data": [false], + "valid": true + }, + { + "description": "[0] is invalid", + "data": [0], + "valid": false + }, + { + "description": "[0.0] is invalid", + "data": [0.0], + "valid": false + } + ] + }, + { + "description": "const with [true] does not match [1]", + "schema": {"const": [true]}, + "tests": [ + { + "description": "[true] is valid", + "data": [true], + "valid": true + }, + { + "description": "[1] is invalid", + "data": [1], + "valid": false + }, + { + "description": "[1.0] is invalid", + "data": [1.0], + "valid": false + } + ] + }, + { + "description": "const with {\"a\": false} does not match {\"a\": 0}", + "schema": {"const": {"a": false}}, + "tests": [ + { + "description": "{\"a\": false} is valid", + "data": {"a": false}, + "valid": true + }, + { + "description": "{\"a\": 0} is invalid", + "data": {"a": 0}, + "valid": false + }, + { + "description": "{\"a\": 0.0} is invalid", + "data": {"a": 0.0}, + "valid": false + } + ] + }, + { + "description": "const with {\"a\": true} does not match {\"a\": 1}", + "schema": {"const": {"a": true}}, + "tests": [ + { + "description": "{\"a\": true} is valid", + "data": {"a": true}, + "valid": true + }, + { + "description": "{\"a\": 1} is invalid", + "data": {"a": 1}, + "valid": false + }, + { + "description": "{\"a\": 1.0} is invalid", + "data": {"a": 1.0}, + "valid": false + } + ] + }, + { + "description": "const with 0 does not match other zero-like types", + "schema": {"const": 0}, + "tests": [ + { + "description": "false is invalid", + "data": false, + "valid": false + }, + { + "description": "integer zero is valid", + "data": 0, + "valid": true + }, + { + "description": "float zero is valid", + "data": 0.0, + "valid": true + }, + { + "description": "empty object is invalid", + "data": {}, + "valid": false + }, + { + "description": "empty array is invalid", + "data": [], + "valid": false + }, + { + "description": "empty string is invalid", + "data": "", + "valid": false + } + ] + }, + { + "description": "const with 1 does not match true", + "schema": {"const": 1}, + "tests": [ + { + "description": "true is invalid", + "data": true, + "valid": false + }, + { + "description": "integer one is valid", + "data": 1, + "valid": true + }, + { + "description": "float one is valid", + "data": 1.0, + "valid": true + } + ] + }, + { + "description": "const with -2.0 matches integer and float types", + "schema": {"const": -2.0}, + "tests": [ + { + "description": "integer -2 is valid", + "data": -2, + "valid": true + }, + { + "description": "integer 2 is invalid", + "data": 2, + "valid": false + }, + { + "description": "float -2.0 is valid", + "data": -2.0, + "valid": true + }, + { + "description": "float 2.0 is invalid", + "data": 2.0, + "valid": false + }, + { + "description": "float -2.00001 is invalid", + "data": -2.00001, + "valid": false + } + ] + }, + { + "description": "float and integers are equal up to 64-bit representation limits", + "schema": {"const": 9007199254740992}, + "tests": [ + { + "description": "integer is valid", + "data": 9007199254740992, + "valid": true + }, + { + "description": "integer minus one is invalid", + "data": 9007199254740991, + "valid": false + }, + { + "description": "float is valid", + "data": 9007199254740992.0, + "valid": true + }, + { + "description": "float minus one is invalid", + "data": 9007199254740991.0, + "valid": false + } + ] + }, + { + "description": "nul characters in strings", + "schema": { "const": "hello\u0000there" }, + "tests": [ + { + "description": "match string with nul", + "data": "hello\u0000there", + "valid": true + }, + { + "description": "do not match string lacking nul", + "data": "hellothere", + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/contains.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/contains.json new file mode 100755 index 00000000000..c5471cc0210 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/contains.json @@ -0,0 +1,129 @@ +[ + { + "description": "contains keyword validation", + "schema": { + "contains": {"minimum": 5} + }, + "tests": [ + { + "description": "array with item matching schema (5) is valid", + "data": [3, 4, 5], + "valid": true + }, + { + "description": "array with item matching schema (6) is valid", + "data": [3, 4, 6], + "valid": true + }, + { + "description": "array with two items matching schema (5, 6) is valid", + "data": [3, 4, 5, 6], + "valid": true + }, + { + "description": "array without items matching schema is invalid", + "data": [2, 3, 4], + "valid": false + }, + { + "description": "empty array is invalid", + "data": [], + "valid": false + }, + { + "description": "not array is valid", + "data": {}, + "valid": true + } + ] + }, + { + "description": "contains keyword with const keyword", + "schema": { + "contains": { "const": 5 } + }, + "tests": [ + { + "description": "array with item 5 is valid", + "data": [3, 4, 5], + "valid": true + }, + { + "description": "array with two items 5 is valid", + "data": [3, 4, 5, 5], + "valid": true + }, + { + "description": "array without item 5 is invalid", + "data": [1, 2, 3, 4], + "valid": false + } + ] + }, + { + "description": "contains keyword with boolean schema true", + "schema": {"contains": true}, + "tests": [ + { + "description": "any non-empty array is valid", + "data": ["foo"], + "valid": true + }, + { + "description": "empty array is invalid", + "data": [], + "valid": false + } + ] + }, + { + "description": "contains keyword with boolean schema false", + "schema": {"contains": false}, + "tests": [ + { + "description": "any non-empty array is invalid", + "data": ["foo"], + "valid": false + }, + { + "description": "empty array is invalid", + "data": [], + "valid": false + }, + { + "description": "non-arrays are valid", + "data": "contains does not apply to strings", + "valid": true + } + ] + }, + { + "description": "items + contains", + "schema": { + "items": { "multipleOf": 2 }, + "contains": { "multipleOf": 3 } + }, + "tests": [ + { + "description": "matches items, does not match contains", + "data": [ 2, 4, 8 ], + "valid": false + }, + { + "description": "does not match items, matches contains", + "data": [ 3, 6, 9 ], + "valid": false + }, + { + "description": "matches both items and contains", + "data": [ 6, 12 ], + "valid": true + }, + { + "description": "matches neither items nor contains", + "data": [ 1, 5 ], + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/default.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/default.json new file mode 100755 index 00000000000..289a9b66c13 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/default.json @@ -0,0 +1,79 @@ +[ + { + "description": "invalid type for default", + "schema": { + "properties": { + "foo": { + "type": "integer", + "default": [] + } + } + }, + "tests": [ + { + "description": "valid when property is specified", + "data": {"foo": 13}, + "valid": true + }, + { + "description": "still valid when the invalid default is used", + "data": {}, + "valid": true + } + ] + }, + { + "description": "invalid string value for default", + "schema": { + "properties": { + "bar": { + "type": "string", + "minLength": 4, + "default": "bad" + } + } + }, + "tests": [ + { + "description": "valid when property is specified", + "data": {"bar": "good"}, + "valid": true + }, + { + "description": "still valid when the invalid default is used", + "data": {}, + "valid": true + } + ] + }, + { + "description": "the default keyword does not do anything if the property is missing", + "schema": { + "type": "object", + "properties": { + "alpha": { + "type": "number", + "maximum": 3, + "default": 5 + } + } + }, + "tests": [ + { + "description": "an explicit property value is checked against maximum (passing)", + "data": { "alpha": 1 }, + "valid": true + }, + { + "description": "an explicit property value is checked against maximum (failing)", + "data": { "alpha": 5 }, + "valid": false + }, + { + "description": "missing properties are not filled in with the default", + "data": {}, + "valid": true + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/definitions.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/definitions.json new file mode 100755 index 00000000000..d772fde3ec5 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/definitions.json @@ -0,0 +1,26 @@ +[ + { + "description": "validate definition against metaschema", + "schema": {"$ref": "http://json-schema.org/draft-06/schema#"}, + "tests": [ + { + "description": "valid definition schema", + "data": { + "definitions": { + "foo": {"type": "integer"} + } + }, + "valid": true + }, + { + "description": "invalid definition schema", + "data": { + "definitions": { + "foo": {"type": 1} + } + }, + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/dependencies.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/dependencies.json new file mode 100755 index 00000000000..a5e54282ccc --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/dependencies.json @@ -0,0 +1,248 @@ +[ + { + "description": "dependencies", + "schema": { + "dependencies": {"bar": ["foo"]} + }, + "tests": [ + { + "description": "neither", + "data": {}, + "valid": true + }, + { + "description": "nondependant", + "data": {"foo": 1}, + "valid": true + }, + { + "description": "with dependency", + "data": {"foo": 1, "bar": 2}, + "valid": true + }, + { + "description": "missing dependency", + "data": {"bar": 2}, + "valid": false + }, + { + "description": "ignores arrays", + "data": ["bar"], + "valid": true + }, + { + "description": "ignores strings", + "data": "foobar", + "valid": true + }, + { + "description": "ignores other non-objects", + "data": 12, + "valid": true + } + ] + }, + { + "description": "dependencies with empty array", + "schema": { + "dependencies": {"bar": []} + }, + "tests": [ + { + "description": "empty object", + "data": {}, + "valid": true + }, + { + "description": "object with one property", + "data": {"bar": 2}, + "valid": true + }, + { + "description": "non-object is valid", + "data": 1, + "valid": true + } + ] + }, + { + "description": "multiple dependencies", + "schema": { + "dependencies": {"quux": ["foo", "bar"]} + }, + "tests": [ + { + "description": "neither", + "data": {}, + "valid": true + }, + { + "description": "nondependants", + "data": {"foo": 1, "bar": 2}, + "valid": true + }, + { + "description": "with dependencies", + "data": {"foo": 1, "bar": 2, "quux": 3}, + "valid": true + }, + { + "description": "missing dependency", + "data": {"foo": 1, "quux": 2}, + "valid": false + }, + { + "description": "missing other dependency", + "data": {"bar": 1, "quux": 2}, + "valid": false + }, + { + "description": "missing both dependencies", + "data": {"quux": 1}, + "valid": false + } + ] + }, + { + "description": "multiple dependencies subschema", + "schema": { + "dependencies": { + "bar": { + "properties": { + "foo": {"type": "integer"}, + "bar": {"type": "integer"} + } + } + } + }, + "tests": [ + { + "description": "valid", + "data": {"foo": 1, "bar": 2}, + "valid": true + }, + { + "description": "no dependency", + "data": {"foo": "quux"}, + "valid": true + }, + { + "description": "wrong type", + "data": {"foo": "quux", "bar": 2}, + "valid": false + }, + { + "description": "wrong type other", + "data": {"foo": 2, "bar": "quux"}, + "valid": false + }, + { + "description": "wrong type both", + "data": {"foo": "quux", "bar": "quux"}, + "valid": false + } + ] + }, + { + "description": "dependencies with boolean subschemas", + "schema": { + "dependencies": { + "foo": true, + "bar": false + } + }, + "tests": [ + { + "description": "object with property having schema true is valid", + "data": {"foo": 1}, + "valid": true + }, + { + "description": "object with property having schema false is invalid", + "data": {"bar": 2}, + "valid": false + }, + { + "description": "object with both properties is invalid", + "data": {"foo": 1, "bar": 2}, + "valid": false + }, + { + "description": "empty object is valid", + "data": {}, + "valid": true + } + ] + }, + { + "description": "dependencies with escaped characters", + "schema": { + "dependencies": { + "foo\nbar": ["foo\rbar"], + "foo\tbar": { + "minProperties": 4 + }, + "foo'bar": {"required": ["foo\"bar"]}, + "foo\"bar": ["foo'bar"] + } + }, + "tests": [ + { + "description": "valid object 1", + "data": { + "foo\nbar": 1, + "foo\rbar": 2 + }, + "valid": true + }, + { + "description": "valid object 2", + "data": { + "foo\tbar": 1, + "a": 2, + "b": 3, + "c": 4 + }, + "valid": true + }, + { + "description": "valid object 3", + "data": { + "foo'bar": 1, + "foo\"bar": 2 + }, + "valid": true + }, + { + "description": "invalid object 1", + "data": { + "foo\nbar": 1, + "foo": 2 + }, + "valid": false + }, + { + "description": "invalid object 2", + "data": { + "foo\tbar": 1, + "a": 2 + }, + "valid": false + }, + { + "description": "invalid object 3", + "data": { + "foo'bar": 1 + }, + "valid": false + }, + { + "description": "invalid object 4", + "data": { + "foo\"bar": 2 + }, + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/enum.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/enum.json new file mode 100755 index 00000000000..f085097be77 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/enum.json @@ -0,0 +1,236 @@ +[ + { + "description": "simple enum validation", + "schema": {"enum": [1, 2, 3]}, + "tests": [ + { + "description": "one of the enum is valid", + "data": 1, + "valid": true + }, + { + "description": "something else is invalid", + "data": 4, + "valid": false + } + ] + }, + { + "description": "heterogeneous enum validation", + "schema": {"enum": [6, "foo", [], true, {"foo": 12}]}, + "tests": [ + { + "description": "one of the enum is valid", + "data": [], + "valid": true + }, + { + "description": "something else is invalid", + "data": null, + "valid": false + }, + { + "description": "objects are deep compared", + "data": {"foo": false}, + "valid": false + }, + { + "description": "valid object matches", + "data": {"foo": 12}, + "valid": true + }, + { + "description": "extra properties in object is invalid", + "data": {"foo": 12, "boo": 42}, + "valid": false + } + ] + }, + { + "description": "heterogeneous enum-with-null validation", + "schema": { "enum": [6, null] }, + "tests": [ + { + "description": "null is valid", + "data": null, + "valid": true + }, + { + "description": "number is valid", + "data": 6, + "valid": true + }, + { + "description": "something else is invalid", + "data": "test", + "valid": false + } + ] + }, + { + "description": "enums in properties", + "schema": { + "type":"object", + "properties": { + "foo": {"enum":["foo"]}, + "bar": {"enum":["bar"]} + }, + "required": ["bar"] + }, + "tests": [ + { + "description": "both properties are valid", + "data": {"foo":"foo", "bar":"bar"}, + "valid": true + }, + { + "description": "wrong foo value", + "data": {"foo":"foot", "bar":"bar"}, + "valid": false + }, + { + "description": "wrong bar value", + "data": {"foo":"foo", "bar":"bart"}, + "valid": false + }, + { + "description": "missing optional property is valid", + "data": {"bar":"bar"}, + "valid": true + }, + { + "description": "missing required property is invalid", + "data": {"foo":"foo"}, + "valid": false + }, + { + "description": "missing all properties is invalid", + "data": {}, + "valid": false + } + ] + }, + { + "description": "enum with escaped characters", + "schema": { + "enum": ["foo\nbar", "foo\rbar"] + }, + "tests": [ + { + "description": "member 1 is valid", + "data": "foo\nbar", + "valid": true + }, + { + "description": "member 2 is valid", + "data": "foo\rbar", + "valid": true + }, + { + "description": "another string is invalid", + "data": "abc", + "valid": false + } + ] + }, + { + "description": "enum with false does not match 0", + "schema": {"enum": [false]}, + "tests": [ + { + "description": "false is valid", + "data": false, + "valid": true + }, + { + "description": "integer zero is invalid", + "data": 0, + "valid": false + }, + { + "description": "float zero is invalid", + "data": 0.0, + "valid": false + } + ] + }, + { + "description": "enum with true does not match 1", + "schema": {"enum": [true]}, + "tests": [ + { + "description": "true is valid", + "data": true, + "valid": true + }, + { + "description": "integer one is invalid", + "data": 1, + "valid": false + }, + { + "description": "float one is invalid", + "data": 1.0, + "valid": false + } + ] + }, + { + "description": "enum with 0 does not match false", + "schema": {"enum": [0]}, + "tests": [ + { + "description": "false is invalid", + "data": false, + "valid": false + }, + { + "description": "integer zero is valid", + "data": 0, + "valid": true + }, + { + "description": "float zero is valid", + "data": 0.0, + "valid": true + } + ] + }, + { + "description": "enum with 1 does not match true", + "schema": {"enum": [1]}, + "tests": [ + { + "description": "true is invalid", + "data": true, + "valid": false + }, + { + "description": "integer one is valid", + "data": 1, + "valid": true + }, + { + "description": "float one is valid", + "data": 1.0, + "valid": true + } + ] + }, + { + "description": "nul characters in strings", + "schema": { "enum": [ "hello\u0000there" ] }, + "tests": [ + { + "description": "match string with nul", + "data": "hello\u0000there", + "valid": true + }, + { + "description": "do not match string lacking nul", + "data": "hellothere", + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/exclusiveMaximum.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/exclusiveMaximum.json new file mode 100755 index 00000000000..dc3cd709d31 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/exclusiveMaximum.json @@ -0,0 +1,30 @@ +[ + { + "description": "exclusiveMaximum validation", + "schema": { + "exclusiveMaximum": 3.0 + }, + "tests": [ + { + "description": "below the exclusiveMaximum is valid", + "data": 2.2, + "valid": true + }, + { + "description": "boundary point is invalid", + "data": 3.0, + "valid": false + }, + { + "description": "above the exclusiveMaximum is invalid", + "data": 3.5, + "valid": false + }, + { + "description": "ignores non-numbers", + "data": "x", + "valid": true + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/exclusiveMinimum.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/exclusiveMinimum.json new file mode 100755 index 00000000000..b38d7ecec63 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/exclusiveMinimum.json @@ -0,0 +1,30 @@ +[ + { + "description": "exclusiveMinimum validation", + "schema": { + "exclusiveMinimum": 1.1 + }, + "tests": [ + { + "description": "above the exclusiveMinimum is valid", + "data": 1.2, + "valid": true + }, + { + "description": "boundary point is invalid", + "data": 1.1, + "valid": false + }, + { + "description": "below the exclusiveMinimum is invalid", + "data": 0.6, + "valid": false + }, + { + "description": "ignores non-numbers", + "data": "x", + "valid": true + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/format.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/format.json new file mode 100755 index 00000000000..2df2a9f0a55 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/format.json @@ -0,0 +1,326 @@ +[ + { + "description": "email format", + "schema": { "format": "email" }, + "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + } + ] + }, + { + "description": "ipv4 format", + "schema": { "format": "ipv4" }, + "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + } + ] + }, + { + "description": "ipv6 format", + "schema": { "format": "ipv6" }, + "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + } + ] + }, + { + "description": "hostname format", + "schema": { "format": "hostname" }, + "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + } + ] + }, + { + "description": "date-time format", + "schema": { "format": "date-time" }, + "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + } + ] + }, + { + "description": "json-pointer format", + "schema": { "format": "json-pointer" }, + "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + } + ] + }, + { + "description": "uri format", + "schema": { "format": "uri" }, + "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + } + ] + }, + { + "description": "uri-reference format", + "schema": { "format": "uri-reference" }, + "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + } + ] + }, + { + "description": "uri-template format", + "schema": { "format": "uri-template" }, + "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/id.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/id.json new file mode 100755 index 00000000000..b58e0d0071d --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/id.json @@ -0,0 +1,53 @@ +[ + { + "description": "id inside an enum is not a real identifier", + "comment": "the implementation must not be confused by an id buried in the enum", + "schema": { + "definitions": { + "id_in_enum": { + "enum": [ + { + "$id": "https://localhost:1234/id/my_identifier.json", + "type": "null" + } + ] + }, + "real_id_in_schema": { + "$id": "https://localhost:1234/id/my_identifier.json", + "type": "string" + }, + "zzz_id_in_const": { + "const": { + "$id": "https://localhost:1234/id/my_identifier.json", + "type": "null" + } + } + }, + "anyOf": [ + { "$ref": "#/definitions/id_in_enum" }, + { "$ref": "https://localhost:1234/id/my_identifier.json" } + ] + }, + "tests": [ + { + "description": "exact match to enum, and type matches", + "data": { + "$id": "https://localhost:1234/id/my_identifier.json", + "type": "null" + }, + "valid": true + }, + { + "description": "match $ref to id", + "data": "a string to match #/definitions/id_in_enum", + "valid": true + }, + { + "description": "no match on enum or $ref to id", + "data": 1, + "valid": false + } + ] + } + +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/infinite-loop-detection.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/infinite-loop-detection.json new file mode 100755 index 00000000000..f98c74fc640 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/infinite-loop-detection.json @@ -0,0 +1,36 @@ +[ + { + "description": "evaluating the same schema location against the same data location twice is not a sign of an infinite loop", + "schema": { + "definitions": { + "int": { "type": "integer" } + }, + "allOf": [ + { + "properties": { + "foo": { + "$ref": "#/definitions/int" + } + } + }, + { + "additionalProperties": { + "$ref": "#/definitions/int" + } + } + ] + }, + "tests": [ + { + "description": "passing case", + "data": { "foo": 1 }, + "valid": true + }, + { + "description": "failing case", + "data": { "foo": "a string" }, + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/items.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/items.json new file mode 100755 index 00000000000..67f11840a24 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/items.json @@ -0,0 +1,250 @@ +[ + { + "description": "a schema given for items", + "schema": { + "items": {"type": "integer"} + }, + "tests": [ + { + "description": "valid items", + "data": [ 1, 2, 3 ], + "valid": true + }, + { + "description": "wrong type of items", + "data": [1, "x"], + "valid": false + }, + { + "description": "ignores non-arrays", + "data": {"foo" : "bar"}, + "valid": true + }, + { + "description": "JavaScript pseudo-array is valid", + "data": { + "0": "invalid", + "length": 1 + }, + "valid": true + } + ] + }, + { + "description": "an array of schemas for items", + "schema": { + "items": [ + {"type": "integer"}, + {"type": "string"} + ] + }, + "tests": [ + { + "description": "correct types", + "data": [ 1, "foo" ], + "valid": true + }, + { + "description": "wrong types", + "data": [ "foo", 1 ], + "valid": false + }, + { + "description": "incomplete array of items", + "data": [ 1 ], + "valid": true + }, + { + "description": "array with additional items", + "data": [ 1, "foo", true ], + "valid": true + }, + { + "description": "empty array", + "data": [ ], + "valid": true + }, + { + "description": "JavaScript pseudo-array is valid", + "data": { + "0": "invalid", + "1": "valid", + "length": 2 + }, + "valid": true + } + ] + }, + { + "description": "items with boolean schema (true)", + "schema": {"items": true}, + "tests": [ + { + "description": "any array is valid", + "data": [ 1, "foo", true ], + "valid": true + }, + { + "description": "empty array is valid", + "data": [], + "valid": true + } + ] + }, + { + "description": "items with boolean schema (false)", + "schema": {"items": false}, + "tests": [ + { + "description": "any non-empty array is invalid", + "data": [ 1, "foo", true ], + "valid": false + }, + { + "description": "empty array is valid", + "data": [], + "valid": true + } + ] + }, + { + "description": "items with boolean schemas", + "schema": { + "items": [true, false] + }, + "tests": [ + { + "description": "array with one item is valid", + "data": [ 1 ], + "valid": true + }, + { + "description": "array with two items is invalid", + "data": [ 1, "foo" ], + "valid": false + }, + { + "description": "empty array is valid", + "data": [], + "valid": true + } + ] + }, + { + "description": "items and subitems", + "schema": { + "definitions": { + "item": { + "type": "array", + "additionalItems": false, + "items": [ + { "$ref": "#/definitions/sub-item" }, + { "$ref": "#/definitions/sub-item" } + ] + }, + "sub-item": { + "type": "object", + "required": ["foo"] + } + }, + "type": "array", + "additionalItems": false, + "items": [ + { "$ref": "#/definitions/item" }, + { "$ref": "#/definitions/item" }, + { "$ref": "#/definitions/item" } + ] + }, + "tests": [ + { + "description": "valid items", + "data": [ + [ {"foo": null}, {"foo": null} ], + [ {"foo": null}, {"foo": null} ], + [ {"foo": null}, {"foo": null} ] + ], + "valid": true + }, + { + "description": "too many items", + "data": [ + [ {"foo": null}, {"foo": null} ], + [ {"foo": null}, {"foo": null} ], + [ {"foo": null}, {"foo": null} ], + [ {"foo": null}, {"foo": null} ] + ], + "valid": false + }, + { + "description": "too many sub-items", + "data": [ + [ {"foo": null}, {"foo": null}, {"foo": null} ], + [ {"foo": null}, {"foo": null} ], + [ {"foo": null}, {"foo": null} ] + ], + "valid": false + }, + { + "description": "wrong item", + "data": [ + {"foo": null}, + [ {"foo": null}, {"foo": null} ], + [ {"foo": null}, {"foo": null} ] + ], + "valid": false + }, + { + "description": "wrong sub-item", + "data": [ + [ {}, {"foo": null} ], + [ {"foo": null}, {"foo": null} ], + [ {"foo": null}, {"foo": null} ] + ], + "valid": false + }, + { + "description": "fewer items is valid", + "data": [ + [ {"foo": null} ], + [ {"foo": null} ] + ], + "valid": true + } + ] + }, + { + "description": "nested items", + "schema": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "number" + } + } + } + } + }, + "tests": [ + { + "description": "valid nested array", + "data": [[[[1]], [[2],[3]]], [[[4], [5], [6]]]], + "valid": true + }, + { + "description": "nested array with invalid type", + "data": [[[["1"]], [[2],[3]]], [[[4], [5], [6]]]], + "valid": false + }, + { + "description": "not deep enough", + "data": [[[1], [2],[3]], [[4], [5], [6]]], + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/maxItems.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/maxItems.json new file mode 100755 index 00000000000..3b53a6b371a --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/maxItems.json @@ -0,0 +1,28 @@ +[ + { + "description": "maxItems validation", + "schema": {"maxItems": 2}, + "tests": [ + { + "description": "shorter is valid", + "data": [1], + "valid": true + }, + { + "description": "exact length is valid", + "data": [1, 2], + "valid": true + }, + { + "description": "too long is invalid", + "data": [1, 2, 3], + "valid": false + }, + { + "description": "ignores non-arrays", + "data": "foobar", + "valid": true + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/maxLength.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/maxLength.json new file mode 100755 index 00000000000..811d35b253c --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/maxLength.json @@ -0,0 +1,33 @@ +[ + { + "description": "maxLength validation", + "schema": {"maxLength": 2}, + "tests": [ + { + "description": "shorter is valid", + "data": "f", + "valid": true + }, + { + "description": "exact length is valid", + "data": "fo", + "valid": true + }, + { + "description": "too long is invalid", + "data": "foo", + "valid": false + }, + { + "description": "ignores non-strings", + "data": 100, + "valid": true + }, + { + "description": "two supplementary Unicode code points is long enough", + "data": "\uD83D\uDCA9\uD83D\uDCA9", + "valid": true + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/maxProperties.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/maxProperties.json new file mode 100755 index 00000000000..aa7209f537c --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/maxProperties.json @@ -0,0 +1,54 @@ +[ + { + "description": "maxProperties validation", + "schema": {"maxProperties": 2}, + "tests": [ + { + "description": "shorter is valid", + "data": {"foo": 1}, + "valid": true + }, + { + "description": "exact length is valid", + "data": {"foo": 1, "bar": 2}, + "valid": true + }, + { + "description": "too long is invalid", + "data": {"foo": 1, "bar": 2, "baz": 3}, + "valid": false + }, + { + "description": "ignores arrays", + "data": [1, 2, 3], + "valid": true + }, + { + "description": "ignores strings", + "data": "foobar", + "valid": true + }, + { + "description": "ignores other non-objects", + "data": 12, + "valid": true + } + ] + }, + { + "description": "maxProperties = 0 means the object is empty", + "schema": { "maxProperties": 0 }, + "tests": [ + { + "description": "no properties is valid", + "data": {}, + "valid": true + }, + { + "description": "one property is invalid", + "data": { "foo": 1 }, + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/maximum.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/maximum.json new file mode 100755 index 00000000000..6844a39eee0 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/maximum.json @@ -0,0 +1,54 @@ +[ + { + "description": "maximum validation", + "schema": {"maximum": 3.0}, + "tests": [ + { + "description": "below the maximum is valid", + "data": 2.6, + "valid": true + }, + { + "description": "boundary point is valid", + "data": 3.0, + "valid": true + }, + { + "description": "above the maximum is invalid", + "data": 3.5, + "valid": false + }, + { + "description": "ignores non-numbers", + "data": "x", + "valid": true + } + ] + }, + { + "description": "maximum validation with unsigned integer", + "schema": {"maximum": 300}, + "tests": [ + { + "description": "below the maximum is invalid", + "data": 299.97, + "valid": true + }, + { + "description": "boundary point integer is valid", + "data": 300, + "valid": true + }, + { + "description": "boundary point float is valid", + "data": 300.00, + "valid": true + }, + { + "description": "above the maximum is invalid", + "data": 300.5, + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/minItems.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/minItems.json new file mode 100755 index 00000000000..ed5118815ee --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/minItems.json @@ -0,0 +1,28 @@ +[ + { + "description": "minItems validation", + "schema": {"minItems": 1}, + "tests": [ + { + "description": "longer is valid", + "data": [1, 2], + "valid": true + }, + { + "description": "exact length is valid", + "data": [1], + "valid": true + }, + { + "description": "too short is invalid", + "data": [], + "valid": false + }, + { + "description": "ignores non-arrays", + "data": "", + "valid": true + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/minLength.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/minLength.json new file mode 100755 index 00000000000..3f09158deef --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/minLength.json @@ -0,0 +1,33 @@ +[ + { + "description": "minLength validation", + "schema": {"minLength": 2}, + "tests": [ + { + "description": "longer is valid", + "data": "foo", + "valid": true + }, + { + "description": "exact length is valid", + "data": "fo", + "valid": true + }, + { + "description": "too short is invalid", + "data": "f", + "valid": false + }, + { + "description": "ignores non-strings", + "data": 1, + "valid": true + }, + { + "description": "one supplementary Unicode code point is not long enough", + "data": "\uD83D\uDCA9", + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/minProperties.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/minProperties.json new file mode 100755 index 00000000000..49a0726e01c --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/minProperties.json @@ -0,0 +1,38 @@ +[ + { + "description": "minProperties validation", + "schema": {"minProperties": 1}, + "tests": [ + { + "description": "longer is valid", + "data": {"foo": 1, "bar": 2}, + "valid": true + }, + { + "description": "exact length is valid", + "data": {"foo": 1}, + "valid": true + }, + { + "description": "too short is invalid", + "data": {}, + "valid": false + }, + { + "description": "ignores arrays", + "data": [], + "valid": true + }, + { + "description": "ignores strings", + "data": "", + "valid": true + }, + { + "description": "ignores other non-objects", + "data": 12, + "valid": true + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/minimum.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/minimum.json new file mode 100755 index 00000000000..21ae50e0ed7 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/minimum.json @@ -0,0 +1,69 @@ +[ + { + "description": "minimum validation", + "schema": {"minimum": 1.1}, + "tests": [ + { + "description": "above the minimum is valid", + "data": 2.6, + "valid": true + }, + { + "description": "boundary point is valid", + "data": 1.1, + "valid": true + }, + { + "description": "below the minimum is invalid", + "data": 0.6, + "valid": false + }, + { + "description": "ignores non-numbers", + "data": "x", + "valid": true + } + ] + }, + { + "description": "minimum validation with signed integer", + "schema": {"minimum": -2}, + "tests": [ + { + "description": "negative above the minimum is valid", + "data": -1, + "valid": true + }, + { + "description": "positive above the minimum is valid", + "data": 0, + "valid": true + }, + { + "description": "boundary point is valid", + "data": -2, + "valid": true + }, + { + "description": "boundary point with float is valid", + "data": -2.0, + "valid": true + }, + { + "description": "float below the minimum is invalid", + "data": -2.0001, + "valid": false + }, + { + "description": "int below the minimum is invalid", + "data": -3, + "valid": false + }, + { + "description": "ignores non-numbers", + "data": "x", + "valid": true + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/multipleOf.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/multipleOf.json new file mode 100755 index 00000000000..faa87cff590 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/multipleOf.json @@ -0,0 +1,71 @@ +[ + { + "description": "by int", + "schema": {"multipleOf": 2}, + "tests": [ + { + "description": "int by int", + "data": 10, + "valid": true + }, + { + "description": "int by int fail", + "data": 7, + "valid": false + }, + { + "description": "ignores non-numbers", + "data": "foo", + "valid": true + } + ] + }, + { + "description": "by number", + "schema": {"multipleOf": 1.5}, + "tests": [ + { + "description": "zero is multiple of anything", + "data": 0, + "valid": true + }, + { + "description": "4.5 is multiple of 1.5", + "data": 4.5, + "valid": true + }, + { + "description": "35 is not multiple of 1.5", + "data": 35, + "valid": false + } + ] + }, + { + "description": "by small number", + "schema": {"multipleOf": 0.0001}, + "tests": [ + { + "description": "0.0075 is multiple of 0.0001", + "data": 0.0075, + "valid": true + }, + { + "description": "0.00751 is not multiple of 0.0001", + "data": 0.00751, + "valid": false + } + ] + }, + { + "description": "invalid instance should not raise error when float division = inf", + "schema": {"type": "integer", "multipleOf": 0.123456789}, + "tests": [ + { + "description": "always invalid, but naive implementations may raise an overflow error", + "data": 1e308, + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/not.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/not.json new file mode 100755 index 00000000000..98de0eda8dd --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/not.json @@ -0,0 +1,117 @@ +[ + { + "description": "not", + "schema": { + "not": {"type": "integer"} + }, + "tests": [ + { + "description": "allowed", + "data": "foo", + "valid": true + }, + { + "description": "disallowed", + "data": 1, + "valid": false + } + ] + }, + { + "description": "not multiple types", + "schema": { + "not": {"type": ["integer", "boolean"]} + }, + "tests": [ + { + "description": "valid", + "data": "foo", + "valid": true + }, + { + "description": "mismatch", + "data": 1, + "valid": false + }, + { + "description": "other mismatch", + "data": true, + "valid": false + } + ] + }, + { + "description": "not more complex schema", + "schema": { + "not": { + "type": "object", + "properties": { + "foo": { + "type": "string" + } + } + } + }, + "tests": [ + { + "description": "match", + "data": 1, + "valid": true + }, + { + "description": "other match", + "data": {"foo": 1}, + "valid": true + }, + { + "description": "mismatch", + "data": {"foo": "bar"}, + "valid": false + } + ] + }, + { + "description": "forbidden property", + "schema": { + "properties": { + "foo": { + "not": {} + } + } + }, + "tests": [ + { + "description": "property present", + "data": {"foo": 1, "bar": 2}, + "valid": false + }, + { + "description": "property absent", + "data": {"bar": 1, "baz": 2}, + "valid": true + } + ] + }, + { + "description": "not with boolean schema true", + "schema": {"not": true}, + "tests": [ + { + "description": "any value is invalid", + "data": "foo", + "valid": false + } + ] + }, + { + "description": "not with boolean schema false", + "schema": {"not": false}, + "tests": [ + { + "description": "any value is valid", + "data": "foo", + "valid": true + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/oneOf.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/oneOf.json new file mode 100755 index 00000000000..eeb7ae866ad --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/oneOf.json @@ -0,0 +1,274 @@ +[ + { + "description": "oneOf", + "schema": { + "oneOf": [ + { + "type": "integer" + }, + { + "minimum": 2 + } + ] + }, + "tests": [ + { + "description": "first oneOf valid", + "data": 1, + "valid": true + }, + { + "description": "second oneOf valid", + "data": 2.5, + "valid": true + }, + { + "description": "both oneOf valid", + "data": 3, + "valid": false + }, + { + "description": "neither oneOf valid", + "data": 1.5, + "valid": false + } + ] + }, + { + "description": "oneOf with base schema", + "schema": { + "type": "string", + "oneOf" : [ + { + "minLength": 2 + }, + { + "maxLength": 4 + } + ] + }, + "tests": [ + { + "description": "mismatch base schema", + "data": 3, + "valid": false + }, + { + "description": "one oneOf valid", + "data": "foobar", + "valid": true + }, + { + "description": "both oneOf valid", + "data": "foo", + "valid": false + } + ] + }, + { + "description": "oneOf with boolean schemas, all true", + "schema": {"oneOf": [true, true, true]}, + "tests": [ + { + "description": "any value is invalid", + "data": "foo", + "valid": false + } + ] + }, + { + "description": "oneOf with boolean schemas, one true", + "schema": {"oneOf": [true, false, false]}, + "tests": [ + { + "description": "any value is valid", + "data": "foo", + "valid": true + } + ] + }, + { + "description": "oneOf with boolean schemas, more than one true", + "schema": {"oneOf": [true, true, false]}, + "tests": [ + { + "description": "any value is invalid", + "data": "foo", + "valid": false + } + ] + }, + { + "description": "oneOf with boolean schemas, all false", + "schema": {"oneOf": [false, false, false]}, + "tests": [ + { + "description": "any value is invalid", + "data": "foo", + "valid": false + } + ] + }, + { + "description": "oneOf complex types", + "schema": { + "oneOf": [ + { + "properties": { + "bar": {"type": "integer"} + }, + "required": ["bar"] + }, + { + "properties": { + "foo": {"type": "string"} + }, + "required": ["foo"] + } + ] + }, + "tests": [ + { + "description": "first oneOf valid (complex)", + "data": {"bar": 2}, + "valid": true + }, + { + "description": "second oneOf valid (complex)", + "data": {"foo": "baz"}, + "valid": true + }, + { + "description": "both oneOf valid (complex)", + "data": {"foo": "baz", "bar": 2}, + "valid": false + }, + { + "description": "neither oneOf valid (complex)", + "data": {"foo": 2, "bar": "quux"}, + "valid": false + } + ] + }, + { + "description": "oneOf with empty schema", + "schema": { + "oneOf": [ + { "type": "number" }, + {} + ] + }, + "tests": [ + { + "description": "one valid - valid", + "data": "foo", + "valid": true + }, + { + "description": "both valid - invalid", + "data": 123, + "valid": false + } + ] + }, + { + "description": "oneOf with required", + "schema": { + "type": "object", + "oneOf": [ + { "required": ["foo", "bar"] }, + { "required": ["foo", "baz"] } + ] + }, + "tests": [ + { + "description": "both invalid - invalid", + "data": {"bar": 2}, + "valid": false + }, + { + "description": "first valid - valid", + "data": {"foo": 1, "bar": 2}, + "valid": true + }, + { + "description": "second valid - valid", + "data": {"foo": 1, "baz": 3}, + "valid": true + }, + { + "description": "both valid - invalid", + "data": {"foo": 1, "bar": 2, "baz" : 3}, + "valid": false + } + ] + }, + { + "description": "oneOf with missing optional property", + "schema": { + "oneOf": [ + { + "properties": { + "bar": true, + "baz": true + }, + "required": ["bar"] + }, + { + "properties": { + "foo": true + }, + "required": ["foo"] + } + ] + }, + "tests": [ + { + "description": "first oneOf valid", + "data": {"bar": 8}, + "valid": true + }, + { + "description": "second oneOf valid", + "data": {"foo": "foo"}, + "valid": true + }, + { + "description": "both oneOf valid", + "data": {"foo": "foo", "bar": 8}, + "valid": false + }, + { + "description": "neither oneOf valid", + "data": {"baz": "quux"}, + "valid": false + } + ] + }, + { + "description": "nested oneOf, to check validation semantics", + "schema": { + "oneOf": [ + { + "oneOf": [ + { + "type": "null" + } + ] + } + ] + }, + "tests": [ + { + "description": "null is valid", + "data": null, + "valid": true + }, + { + "description": "anything non-null is invalid", + "data": 123, + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/bignum.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/bignum.json new file mode 100755 index 00000000000..3f49226ac39 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/bignum.json @@ -0,0 +1,93 @@ +[ + { + "description": "integer", + "schema": { "type": "integer" }, + "tests": [ + { + "description": "a bignum is an integer", + "data": 12345678910111213141516171819202122232425262728293031, + "valid": true + }, + { + "description": "a negative bignum is an integer", + "data": -12345678910111213141516171819202122232425262728293031, + "valid": true + } + ] + }, + { + "description": "number", + "schema": { "type": "number" }, + "tests": [ + { + "description": "a bignum is a number", + "data": 98249283749234923498293171823948729348710298301928331, + "valid": true + }, + { + "description": "a negative bignum is a number", + "data": -98249283749234923498293171823948729348710298301928331, + "valid": true + } + ] + }, + { + "description": "string", + "schema": { "type": "string" }, + "tests": [ + { + "description": "a bignum is not a string", + "data": 98249283749234923498293171823948729348710298301928331, + "valid": false + } + ] + }, + { + "description": "integer comparison", + "schema": { "maximum": 18446744073709551615 }, + "tests": [ + { + "description": "comparison works for high numbers", + "data": 18446744073709551600, + "valid": true + } + ] + }, + { + "description": "float comparison with high precision", + "schema": { + "exclusiveMaximum": 972783798187987123879878123.18878137 + }, + "tests": [ + { + "description": "comparison works for high numbers", + "data": 972783798187987123879878123.188781371, + "valid": false + } + ] + }, + { + "description": "integer comparison", + "schema": { "minimum": -18446744073709551615 }, + "tests": [ + { + "description": "comparison works for very negative numbers", + "data": -18446744073709551600, + "valid": true + } + ] + }, + { + "description": "float comparison with high precision on negative numbers", + "schema": { + "exclusiveMinimum": -972783798187987123879878123.18878137 + }, + "tests": [ + { + "description": "comparison works for very negative numbers", + "data": -972783798187987123879878123.188781371, + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/ecmascript-regex.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/ecmascript-regex.json new file mode 100755 index 00000000000..1beb0b3a661 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/ecmascript-regex.json @@ -0,0 +1,552 @@ +[ + { + "description": "ECMA 262 regex $ does not match trailing newline", + "schema": { + "type": "string", + "pattern": "^abc$" + }, + "tests": [ + { + "description": "matches in Python, but should not in jsonschema", + "data": "abc\\n", + "valid": false + }, + { + "description": "should match", + "data": "abc", + "valid": true + } + ] + }, + { + "description": "ECMA 262 regex converts \\t to horizontal tab", + "schema": { + "type": "string", + "pattern": "^\\t$" + }, + "tests": [ + { + "description": "does not match", + "data": "\\t", + "valid": false + }, + { + "description": "matches", + "data": "\u0009", + "valid": true + } + ] + }, + { + "description": "ECMA 262 regex escapes control codes with \\c and upper letter", + "schema": { + "type": "string", + "pattern": "^\\cC$" + }, + "tests": [ + { + "description": "does not match", + "data": "\\cC", + "valid": false + }, + { + "description": "matches", + "data": "\u0003", + "valid": true + } + ] + }, + { + "description": "ECMA 262 regex escapes control codes with \\c and lower letter", + "schema": { + "type": "string", + "pattern": "^\\cc$" + }, + "tests": [ + { + "description": "does not match", + "data": "\\cc", + "valid": false + }, + { + "description": "matches", + "data": "\u0003", + "valid": true + } + ] + }, + { + "description": "ECMA 262 \\d matches ascii digits only", + "schema": { + "type": "string", + "pattern": "^\\d$" + }, + "tests": [ + { + "description": "ASCII zero matches", + "data": "0", + "valid": true + }, + { + "description": "NKO DIGIT ZERO does not match (unlike e.g. Python)", + "data": "߀", + "valid": false + }, + { + "description": "NKO DIGIT ZERO (as \\u escape) does not match", + "data": "\u07c0", + "valid": false + } + ] + }, + { + "description": "ECMA 262 \\D matches everything but ascii digits", + "schema": { + "type": "string", + "pattern": "^\\D$" + }, + "tests": [ + { + "description": "ASCII zero does not match", + "data": "0", + "valid": false + }, + { + "description": "NKO DIGIT ZERO matches (unlike e.g. Python)", + "data": "߀", + "valid": true + }, + { + "description": "NKO DIGIT ZERO (as \\u escape) matches", + "data": "\u07c0", + "valid": true + } + ] + }, + { + "description": "ECMA 262 \\w matches ascii letters only", + "schema": { + "type": "string", + "pattern": "^\\w$" + }, + "tests": [ + { + "description": "ASCII 'a' matches", + "data": "a", + "valid": true + }, + { + "description": "latin-1 e-acute does not match (unlike e.g. Python)", + "data": "é", + "valid": false + } + ] + }, + { + "description": "ECMA 262 \\W matches everything but ascii letters", + "schema": { + "type": "string", + "pattern": "^\\W$" + }, + "tests": [ + { + "description": "ASCII 'a' does not match", + "data": "a", + "valid": false + }, + { + "description": "latin-1 e-acute matches (unlike e.g. Python)", + "data": "é", + "valid": true + } + ] + }, + { + "description": "ECMA 262 \\s matches whitespace", + "schema": { + "type": "string", + "pattern": "^\\s$" + }, + "tests": [ + { + "description": "ASCII space matches", + "data": " ", + "valid": true + }, + { + "description": "Character tabulation matches", + "data": "\t", + "valid": true + }, + { + "description": "Line tabulation matches", + "data": "\u000b", + "valid": true + }, + { + "description": "Form feed matches", + "data": "\u000c", + "valid": true + }, + { + "description": "latin-1 non-breaking-space matches", + "data": "\u00a0", + "valid": true + }, + { + "description": "zero-width whitespace matches", + "data": "\ufeff", + "valid": true + }, + { + "description": "line feed matches (line terminator)", + "data": "\u000a", + "valid": true + }, + { + "description": "paragraph separator matches (line terminator)", + "data": "\u2029", + "valid": true + }, + { + "description": "EM SPACE matches (Space_Separator)", + "data": "\u2003", + "valid": true + }, + { + "description": "Non-whitespace control does not match", + "data": "\u0001", + "valid": false + }, + { + "description": "Non-whitespace does not match", + "data": "\u2013", + "valid": false + } + ] + }, + { + "description": "ECMA 262 \\S matches everything but whitespace", + "schema": { + "type": "string", + "pattern": "^\\S$" + }, + "tests": [ + { + "description": "ASCII space does not match", + "data": " ", + "valid": false + }, + { + "description": "Character tabulation does not match", + "data": "\t", + "valid": false + }, + { + "description": "Line tabulation does not match", + "data": "\u000b", + "valid": false + }, + { + "description": "Form feed does not match", + "data": "\u000c", + "valid": false + }, + { + "description": "latin-1 non-breaking-space does not match", + "data": "\u00a0", + "valid": false + }, + { + "description": "zero-width whitespace does not match", + "data": "\ufeff", + "valid": false + }, + { + "description": "line feed does not match (line terminator)", + "data": "\u000a", + "valid": false + }, + { + "description": "paragraph separator does not match (line terminator)", + "data": "\u2029", + "valid": false + }, + { + "description": "EM SPACE does not match (Space_Separator)", + "data": "\u2003", + "valid": false + }, + { + "description": "Non-whitespace control matches", + "data": "\u0001", + "valid": true + }, + { + "description": "Non-whitespace matches", + "data": "\u2013", + "valid": true + } + ] + }, + { + "description": "unicode semantics should be used for all pattern matching", + "schema": { "pattern": "\\p{Letter}cole" }, + "tests": [ + { + "description": "ascii character in json string", + "data": "Les hivers de mon enfance etaient des saisons longues, longues. Nous vivions en trois lieux: l'ecole, l'eglise et la patinoire; mais la vraie vie etait sur la patinoire.", + "valid": true + }, + { + "description": "literal unicode character in json string", + "data": "Les hivers de mon enfance étaient des saisons longues, longues. Nous vivions en trois lieux: l'école, l'église et la patinoire; mais la vraie vie était sur la patinoire.", + "valid": true + }, + { + "description": "unicode character in hex format in string", + "data": "Les hivers de mon enfance étaient des saisons longues, longues. Nous vivions en trois lieux: l'\u00e9cole, l'église et la patinoire; mais la vraie vie était sur la patinoire.", + "valid": true + }, + { + "description": "unicode matching is case-sensitive", + "data": "LES HIVERS DE MON ENFANCE ÉTAIENT DES SAISONS LONGUES, LONGUES. NOUS VIVIONS EN TROIS LIEUX: L'ÉCOLE, L'ÉGLISE ET LA PATINOIRE; MAIS LA VRAIE VIE ÉTAIT SUR LA PATINOIRE.", + "valid": false + } + ] + }, + { + "description": "\\w in patterns matches [A-Za-z0-9_], not unicode letters", + "schema": { "pattern": "\\wcole" }, + "tests": [ + { + "description": "ascii character in json string", + "data": "Les hivers de mon enfance etaient des saisons longues, longues. Nous vivions en trois lieux: l'ecole, l'eglise et la patinoire; mais la vraie vie etait sur la patinoire.", + "valid": true + }, + { + "description": "literal unicode character in json string", + "data": "Les hivers de mon enfance étaient des saisons longues, longues. Nous vivions en trois lieux: l'école, l'église et la patinoire; mais la vraie vie était sur la patinoire.", + "valid": false + }, + { + "description": "unicode character in hex format in string", + "data": "Les hivers de mon enfance étaient des saisons longues, longues. Nous vivions en trois lieux: l'\u00e9cole, l'église et la patinoire; mais la vraie vie était sur la patinoire.", + "valid": false + }, + { + "description": "unicode matching is case-sensitive", + "data": "LES HIVERS DE MON ENFANCE ÉTAIENT DES SAISONS LONGUES, LONGUES. NOUS VIVIONS EN TROIS LIEUX: L'ÉCOLE, L'ÉGLISE ET LA PATINOIRE; MAIS LA VRAIE VIE ÉTAIT SUR LA PATINOIRE.", + "valid": false + } + ] + }, + { + "description": "unicode characters do not match ascii ranges", + "schema": { "pattern": "[a-z]cole" }, + "tests": [ + { + "description": "literal unicode character in json string", + "data": "Les hivers de mon enfance étaient des saisons longues, longues. Nous vivions en trois lieux: l'école, l'église et la patinoire; mais la vraie vie était sur la patinoire.", + "valid": false + }, + { + "description": "unicode character in hex format in string", + "data": "Les hivers de mon enfance étaient des saisons longues, longues. Nous vivions en trois lieux: l'\u00e9cole, l'église et la patinoire; mais la vraie vie était sur la patinoire.", + "valid": false + }, + { + "description": "ascii characters match", + "data": "Les hivers de mon enfance etaient des saisons longues, longues. Nous vivions en trois lieux: l'ecole, l'eglise et la patinoire; mais la vraie vie etait sur la patinoire.", + "valid": true + } + ] + }, + { + "description": "\\d in pattern matches [0-9], not unicode digits", + "schema": { "pattern": "^\\d+$" }, + "tests": [ + { + "description": "ascii digits", + "data": "42", + "valid": true + }, + { + "description": "ascii non-digits", + "data": "-%#", + "valid": false + }, + { + "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", + "data": "৪২", + "valid": false + } + ] + }, + { + "description": "unicode digits are more than 0 through 9", + "schema": { "pattern": "^\\p{digit}+$" }, + "tests": [ + { + "description": "ascii digits", + "data": "42", + "valid": true + }, + { + "description": "ascii non-digits", + "data": "-%#", + "valid": false + }, + { + "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", + "data": "৪২", + "valid": true + } + ] + }, + { + "description": "unicode semantics should be used for all patternProperties matching", + "schema": { + "type": "object", + "patternProperties": { + "\\p{Letter}cole": true + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "ascii character in json string", + "data": { "l'ecole": "pas de vraie vie" }, + "valid": true + }, + { + "description": "literal unicode character in json string", + "data": { "l'école": "pas de vraie vie" }, + "valid": true + }, + { + "description": "unicode character in hex format in string", + "data": { "l'\u00e9cole": "pas de vraie vie" }, + "valid": true + }, + { + "description": "unicode matching is case-sensitive", + "data": { "L'ÉCOLE": "PAS DE VRAIE VIE" }, + "valid": false + } + ] + }, + { + "description": "\\w in patternProperties matches [A-Za-z0-9_], not unicode letters", + "schema": { + "type": "object", + "patternProperties": { + "\\wcole": true + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "ascii character in json string", + "data": { "l'ecole": "pas de vraie vie" }, + "valid": true + }, + { + "description": "literal unicode character in json string", + "data": { "l'école": "pas de vraie vie" }, + "valid": false + }, + { + "description": "unicode character in hex format in string", + "data": { "l'\u00e9cole": "pas de vraie vie" }, + "valid": false + }, + { + "description": "unicode matching is case-sensitive", + "data": { "L'ÉCOLE": "PAS DE VRAIE VIE" }, + "valid": false + } + ] + }, + { + "description": "unicode characters do not match ascii ranges", + "schema": { + "type": "object", + "patternProperties": { + "[a-z]cole": true + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "literal unicode character in json string", + "data": { "l'école": "pas de vraie vie" }, + "valid": false + }, + { + "description": "unicode character in hex format in string", + "data": { "l'\u00e9cole": "pas de vraie vie" }, + "valid": false + }, + { + "description": "ascii characters match", + "data": { "l'ecole": "pas de vraie vie" }, + "valid": true + } + ] + }, + { + "description": "\\d in patternProperties matches [0-9], not unicode digits", + "schema": { + "type": "object", + "patternProperties": { + "^\\d+$": true + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "ascii digits", + "data": { "42": "life, the universe, and everything" }, + "valid": true + }, + { + "description": "ascii non-digits", + "data": { "-%#": "spending the year dead for tax reasons" }, + "valid": false + }, + { + "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", + "data": { "৪২": "khajit has wares if you have coin" }, + "valid": false + } + ] + }, + { + "description": "unicode digits are more than 0 through 9", + "schema": { + "type": "object", + "patternProperties": { + "^\\p{digit}+$": true + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "ascii digits", + "data": { "42": "life, the universe, and everything" }, + "valid": true + }, + { + "description": "ascii non-digits", + "data": { "-%#": "spending the year dead for tax reasons" }, + "valid": false + }, + { + "description": "non-ascii digits (BENGALI DIGIT FOUR, BENGALI DIGIT TWO)", + "data": { "৪২": "khajit has wares if you have coin" }, + "valid": true + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/float-overflow.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/float-overflow.json new file mode 100755 index 00000000000..52ff9827cf7 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/float-overflow.json @@ -0,0 +1,13 @@ +[ + { + "description": "all integers are multiples of 0.5, if overflow is handled", + "schema": {"type": "integer", "multipleOf": 0.5}, + "tests": [ + { + "description": "valid if optional overflow handling is implemented", + "data": 1e308, + "valid": true + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/date-time.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/date-time.json new file mode 100755 index 00000000000..f4f99335558 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/date-time.json @@ -0,0 +1,133 @@ +[ + { + "description": "validation of date-time strings", + "schema": { "format": "date-time" }, + "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, + { + "description": "a valid date-time string", + "data": "1963-06-19T08:30:06.283185Z", + "valid": true + }, + { + "description": "a valid date-time string without second fraction", + "data": "1963-06-19T08:30:06Z", + "valid": true + }, + { + "description": "a valid date-time string with plus offset", + "data": "1937-01-01T12:00:27.87+00:20", + "valid": true + }, + { + "description": "a valid date-time string with minus offset", + "data": "1990-12-31T15:59:50.123-08:00", + "valid": true + }, + { + "description": "a valid date-time with a leap second, UTC", + "data": "1998-12-31T23:59:60Z", + "valid": true + }, + { + "description": "a valid date-time with a leap second, with minus offset", + "data": "1998-12-31T15:59:60.123-08:00", + "valid": true + }, + { + "description": "an invalid date-time past leap second, UTC", + "data": "1998-12-31T23:59:61Z", + "valid": false + }, + { + "description": "an invalid date-time with leap second on a wrong minute, UTC", + "data": "1998-12-31T23:58:60Z", + "valid": false + }, + { + "description": "an invalid date-time with leap second on a wrong hour, UTC", + "data": "1998-12-31T22:59:60Z", + "valid": false + }, + { + "description": "an invalid day in date-time string", + "data": "1990-02-31T15:59:59.123-08:00", + "valid": false + }, + { + "description": "an invalid offset in date-time string", + "data": "1990-12-31T15:59:59-24:00", + "valid": false + }, + { + "description": "an invalid closing Z after time-zone offset", + "data": "1963-06-19T08:30:06.28123+01:00Z", + "valid": false + }, + { + "description": "an invalid date-time string", + "data": "06/19/1963 08:30:06 PST", + "valid": false + }, + { + "description": "case-insensitive T and Z", + "data": "1963-06-19t08:30:06.283185z", + "valid": true + }, + { + "description": "only RFC3339 not all of ISO 8601 are valid", + "data": "2013-350T01:01:01", + "valid": false + }, + { + "description": "invalid non-padded month dates", + "data": "1963-6-19T08:30:06.283185Z", + "valid": false + }, + { + "description": "invalid non-padded day dates", + "data": "1963-06-1T08:30:06.283185Z", + "valid": false + }, + { + "description": "non-ascii digits should be rejected in the date portion", + "data": "1963-06-1৪T00:00:00Z", + "valid": false + }, + { + "description": "non-ascii digits should be rejected in the time portion", + "data": "1963-06-11T0৪:00:00Z", + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/email.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/email.json new file mode 100755 index 00000000000..d6761a46bab --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/email.json @@ -0,0 +1,83 @@ +[ + { + "description": "validation of e-mail addresses", + "schema": { "format": "email" }, + "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, + { + "description": "a valid e-mail address", + "data": "joe.bloggs@example.com", + "valid": true + }, + { + "description": "an invalid e-mail address", + "data": "2962", + "valid": false + }, + { + "description": "tilde in local part is valid", + "data": "te~st@example.com", + "valid": true + }, + { + "description": "tilde before local part is valid", + "data": "~test@example.com", + "valid": true + }, + { + "description": "tilde after local part is valid", + "data": "test~@example.com", + "valid": true + }, + { + "description": "dot before local part is not valid", + "data": ".test@example.com", + "valid": false + }, + { + "description": "dot after local part is not valid", + "data": "test.@example.com", + "valid": false + }, + { + "description": "two separated dots inside local part are valid", + "data": "te.s.t@example.com", + "valid": true + }, + { + "description": "two subsequent dots inside local part are not valid", + "data": "te..st@example.com", + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/hostname.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/hostname.json new file mode 100755 index 00000000000..8a67fda8807 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/hostname.json @@ -0,0 +1,98 @@ +[ + { + "description": "validation of host names", + "schema": { "format": "hostname" }, + "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, + { + "description": "a valid host name", + "data": "www.example.com", + "valid": true + }, + { + "description": "a valid punycoded IDN hostname", + "data": "xn--4gbwdl.xn--wgbh1c", + "valid": true + }, + { + "description": "a host name starting with an illegal character", + "data": "-a-host-name-that-starts-with--", + "valid": false + }, + { + "description": "a host name containing illegal characters", + "data": "not_a_valid_host_name", + "valid": false + }, + { + "description": "a host name with a component too long", + "data": "a-vvvvvvvvvvvvvvvveeeeeeeeeeeeeeeerrrrrrrrrrrrrrrryyyyyyyyyyyyyyyy-long-host-name-component", + "valid": false + }, + { + "description": "starts with hyphen", + "data": "-hostname", + "valid": false + }, + { + "description": "ends with hyphen", + "data": "hostname-", + "valid": false + }, + { + "description": "starts with underscore", + "data": "_hostname", + "valid": false + }, + { + "description": "ends with underscore", + "data": "hostname_", + "valid": false + }, + { + "description": "contains underscore", + "data": "host_name", + "valid": false + }, + { + "description": "maximum label length", + "data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk.com", + "valid": true + }, + { + "description": "exceeds maximum label length", + "data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl.com", + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/ipv4.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/ipv4.json new file mode 100755 index 00000000000..6b166c70cda --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/ipv4.json @@ -0,0 +1,84 @@ +[ + { + "description": "validation of IP addresses", + "schema": { "format": "ipv4" }, + "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, + { + "description": "a valid IP address", + "data": "192.168.0.1", + "valid": true + }, + { + "description": "an IP address with too many components", + "data": "127.0.0.0.1", + "valid": false + }, + { + "description": "an IP address with out-of-range values", + "data": "256.256.256.256", + "valid": false + }, + { + "description": "an IP address without 4 components", + "data": "127.0", + "valid": false + }, + { + "description": "an IP address as an integer", + "data": "0x7f000001", + "valid": false + }, + { + "description": "an IP address as an integer (decimal)", + "data": "2130706433", + "valid": false + }, + { + "description": "leading zeroes should be rejected, as they are treated as octals", + "comment": "see https://sick.codes/universal-netmask-npm-package-used-by-270000-projects-vulnerable-to-octal-input-data-server-side-request-forgery-remote-file-inclusion-local-file-inclusion-and-more-cve-2021-28918/", + "data": "087.10.0.1", + "valid": false + }, + { + "description": "value without leading zero is valid", + "data": "87.10.0.1", + "valid": true + }, + { + "description": "non-ascii digits should be rejected", + "data": "1২7.0.0.1", + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/ipv6.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/ipv6.json new file mode 100755 index 00000000000..6379927b3e8 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/ipv6.json @@ -0,0 +1,208 @@ +[ + { + "description": "validation of IPv6 addresses", + "schema": { "format": "ipv6" }, + "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, + { + "description": "a valid IPv6 address", + "data": "::1", + "valid": true + }, + { + "description": "an IPv6 address with out-of-range values", + "data": "12345::", + "valid": false + }, + { + "description": "trailing 4 hex symbols is valid", + "data": "::abef", + "valid": true + }, + { + "description": "trailing 5 hex symbols is invalid", + "data": "::abcef", + "valid": false + }, + { + "description": "an IPv6 address with too many components", + "data": "1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1", + "valid": false + }, + { + "description": "an IPv6 address containing illegal characters", + "data": "::laptop", + "valid": false + }, + { + "description": "no digits is valid", + "data": "::", + "valid": true + }, + { + "description": "leading colons is valid", + "data": "::42:ff:1", + "valid": true + }, + { + "description": "trailing colons is valid", + "data": "d6::", + "valid": true + }, + { + "description": "missing leading octet is invalid", + "data": ":2:3:4:5:6:7:8", + "valid": false + }, + { + "description": "missing trailing octet is invalid", + "data": "1:2:3:4:5:6:7:", + "valid": false + }, + { + "description": "missing leading octet with omitted octets later", + "data": ":2:3:4::8", + "valid": false + }, + { + "description": "single set of double colons in the middle is valid", + "data": "1:d6::42", + "valid": true + }, + { + "description": "two sets of double colons is invalid", + "data": "1::d6::42", + "valid": false + }, + { + "description": "mixed format with the ipv4 section as decimal octets", + "data": "1::d6:192.168.0.1", + "valid": true + }, + { + "description": "mixed format with double colons between the sections", + "data": "1:2::192.168.0.1", + "valid": true + }, + { + "description": "mixed format with ipv4 section with octet out of range", + "data": "1::2:192.168.256.1", + "valid": false + }, + { + "description": "mixed format with ipv4 section with a hex octet", + "data": "1::2:192.168.ff.1", + "valid": false + }, + { + "description": "mixed format with leading double colons (ipv4-mapped ipv6 address)", + "data": "::ffff:192.168.0.1", + "valid": true + }, + { + "description": "triple colons is invalid", + "data": "1:2:3:4:5:::8", + "valid": false + }, + { + "description": "8 octets", + "data": "1:2:3:4:5:6:7:8", + "valid": true + }, + { + "description": "insufficient octets without double colons", + "data": "1:2:3:4:5:6:7", + "valid": false + }, + { + "description": "no colons is invalid", + "data": "1", + "valid": false + }, + { + "description": "ipv4 is not ipv6", + "data": "127.0.0.1", + "valid": false + }, + { + "description": "ipv4 segment must have 4 octets", + "data": "1:2:3:4:1.2.3", + "valid": false + }, + { + "description": "leading whitespace is invalid", + "data": " ::1", + "valid": false + }, + { + "description": "trailing whitespace is invalid", + "data": "::1 ", + "valid": false + }, + { + "description": "netmask is not a part of ipv6 address", + "data": "fe80::/64", + "valid": false + }, + { + "description": "zone id is not a part of ipv6 address", + "data": "fe80::a%eth1", + "valid": false + }, + { + "description": "a long valid ipv6", + "data": "1000:1000:1000:1000:1000:1000:255.255.255.255", + "valid": true + }, + { + "description": "a long invalid ipv6, below length limit, first", + "data": "100:100:100:100:100:100:255.255.255.255.255", + "valid": false + }, + { + "description": "a long invalid ipv6, below length limit, second", + "data": "100:100:100:100:100:100:100:255.255.255.255", + "valid": false + }, + { + "description": "non-ascii digits should be rejected", + "data": "1:2:3:4:5:6:7:৪", + "valid": false + }, + { + "description": "non-ascii digits should be rejected in the ipv4 portion also", + "data": "1:2::192.16৪.0.1", + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/json-pointer.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/json-pointer.json new file mode 100755 index 00000000000..a0346b57522 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/json-pointer.json @@ -0,0 +1,198 @@ +[ + { + "description": "validation of JSON-pointers (JSON String Representation)", + "schema": { "format": "json-pointer" }, + "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, + { + "description": "a valid JSON-pointer", + "data": "/foo/bar~0/baz~1/%a", + "valid": true + }, + { + "description": "not a valid JSON-pointer (~ not escaped)", + "data": "/foo/bar~", + "valid": false + }, + { + "description": "valid JSON-pointer with empty segment", + "data": "/foo//bar", + "valid": true + }, + { + "description": "valid JSON-pointer with the last empty segment", + "data": "/foo/bar/", + "valid": true + }, + { + "description": "valid JSON-pointer as stated in RFC 6901 #1", + "data": "", + "valid": true + }, + { + "description": "valid JSON-pointer as stated in RFC 6901 #2", + "data": "/foo", + "valid": true + }, + { + "description": "valid JSON-pointer as stated in RFC 6901 #3", + "data": "/foo/0", + "valid": true + }, + { + "description": "valid JSON-pointer as stated in RFC 6901 #4", + "data": "/", + "valid": true + }, + { + "description": "valid JSON-pointer as stated in RFC 6901 #5", + "data": "/a~1b", + "valid": true + }, + { + "description": "valid JSON-pointer as stated in RFC 6901 #6", + "data": "/c%d", + "valid": true + }, + { + "description": "valid JSON-pointer as stated in RFC 6901 #7", + "data": "/e^f", + "valid": true + }, + { + "description": "valid JSON-pointer as stated in RFC 6901 #8", + "data": "/g|h", + "valid": true + }, + { + "description": "valid JSON-pointer as stated in RFC 6901 #9", + "data": "/i\\j", + "valid": true + }, + { + "description": "valid JSON-pointer as stated in RFC 6901 #10", + "data": "/k\"l", + "valid": true + }, + { + "description": "valid JSON-pointer as stated in RFC 6901 #11", + "data": "/ ", + "valid": true + }, + { + "description": "valid JSON-pointer as stated in RFC 6901 #12", + "data": "/m~0n", + "valid": true + }, + { + "description": "valid JSON-pointer used adding to the last array position", + "data": "/foo/-", + "valid": true + }, + { + "description": "valid JSON-pointer (- used as object member name)", + "data": "/foo/-/bar", + "valid": true + }, + { + "description": "valid JSON-pointer (multiple escaped characters)", + "data": "/~1~0~0~1~1", + "valid": true + }, + { + "description": "valid JSON-pointer (escaped with fraction part) #1", + "data": "/~1.1", + "valid": true + }, + { + "description": "valid JSON-pointer (escaped with fraction part) #2", + "data": "/~0.1", + "valid": true + }, + { + "description": "not a valid JSON-pointer (URI Fragment Identifier) #1", + "data": "#", + "valid": false + }, + { + "description": "not a valid JSON-pointer (URI Fragment Identifier) #2", + "data": "#/", + "valid": false + }, + { + "description": "not a valid JSON-pointer (URI Fragment Identifier) #3", + "data": "#a", + "valid": false + }, + { + "description": "not a valid JSON-pointer (some escaped, but not all) #1", + "data": "/~0~", + "valid": false + }, + { + "description": "not a valid JSON-pointer (some escaped, but not all) #2", + "data": "/~0/~", + "valid": false + }, + { + "description": "not a valid JSON-pointer (wrong escape character) #1", + "data": "/~2", + "valid": false + }, + { + "description": "not a valid JSON-pointer (wrong escape character) #2", + "data": "/~-1", + "valid": false + }, + { + "description": "not a valid JSON-pointer (multiple characters not escaped)", + "data": "/~~", + "valid": false + }, + { + "description": "not a valid JSON-pointer (isn't empty nor starts with /) #1", + "data": "a", + "valid": false + }, + { + "description": "not a valid JSON-pointer (isn't empty nor starts with /) #2", + "data": "0", + "valid": false + }, + { + "description": "not a valid JSON-pointer (isn't empty nor starts with /) #3", + "data": "a/a", + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/unknown.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/unknown.json new file mode 100755 index 00000000000..12339ae57df --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/unknown.json @@ -0,0 +1,43 @@ +[ + { + "description": "unknown format", + "schema": { "format": "unknown" }, + "tests": [ + { + "description": "unknown formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "unknown formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "unknown formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "unknown formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "unknown formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "unknown formats ignore nulls", + "data": null, + "valid": true + }, + { + "description": "unknown formats ignore strings", + "data": "string", + "valid": true + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/uri-reference.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/uri-reference.json new file mode 100755 index 00000000000..7cdf228d8b1 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/uri-reference.json @@ -0,0 +1,73 @@ +[ + { + "description": "validation of URI References", + "schema": { "format": "uri-reference" }, + "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, + { + "description": "a valid URI", + "data": "http://foo.bar/?baz=qux#quux", + "valid": true + }, + { + "description": "a valid protocol-relative URI Reference", + "data": "//foo.bar/?baz=qux#quux", + "valid": true + }, + { + "description": "a valid relative URI Reference", + "data": "/abc", + "valid": true + }, + { + "description": "an invalid URI Reference", + "data": "\\\\WINDOWS\\fileshare", + "valid": false + }, + { + "description": "a valid URI Reference", + "data": "abc", + "valid": true + }, + { + "description": "a valid URI fragment", + "data": "#fragment", + "valid": true + }, + { + "description": "an invalid URI fragment", + "data": "#frag\\ment", + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/uri-template.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/uri-template.json new file mode 100755 index 00000000000..df355c55aa3 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/uri-template.json @@ -0,0 +1,58 @@ +[ + { + "description": "format: uri-template", + "schema": { "format": "uri-template" }, + "tests": [ + { + "description": "all string formats ignore integers", + "data": 12, + "valid": true + }, + { + "description": "all string formats ignore floats", + "data": 13.7, + "valid": true + }, + { + "description": "all string formats ignore objects", + "data": {}, + "valid": true + }, + { + "description": "all string formats ignore arrays", + "data": [], + "valid": true + }, + { + "description": "all string formats ignore booleans", + "data": false, + "valid": true + }, + { + "description": "all string formats ignore nulls", + "data": null, + "valid": true + }, + { + "description": "a valid uri-template", + "data": "http://example.com/dictionary/{term:1}/{term}", + "valid": true + }, + { + "description": "an invalid uri-template", + "data": "http://example.com/dictionary/{term:1}/{term", + "valid": false + }, + { + "description": "a valid uri-template without variables", + "data": "http://example.com/dictionary", + "valid": true + }, + { + "description": "a valid relative uri-template", + "data": "dictionary/{term:1}/{term}", + "valid": true + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/uri.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/uri.json new file mode 100755 index 00000000000..792d71a0583 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/format/uri.json @@ -0,0 +1,108 @@ +[ + { + "description": "validation of URIs", + "schema": { "format": "uri" }, + "tests": [ + { + "description": "a valid URL with anchor tag", + "data": "http://foo.bar/?baz=qux#quux", + "valid": true + }, + { + "description": "a valid URL with anchor tag and parentheses", + "data": "http://foo.com/blah_(wikipedia)_blah#cite-1", + "valid": true + }, + { + "description": "a valid URL with URL-encoded stuff", + "data": "http://foo.bar/?q=Test%20URL-encoded%20stuff", + "valid": true + }, + { + "description": "a valid puny-coded URL ", + "data": "http://xn--nw2a.xn--j6w193g/", + "valid": true + }, + { + "description": "a valid URL with many special characters", + "data": "http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com", + "valid": true + }, + { + "description": "a valid URL based on IPv4", + "data": "http://223.255.255.254", + "valid": true + }, + { + "description": "a valid URL with ftp scheme", + "data": "ftp://ftp.is.co.za/rfc/rfc1808.txt", + "valid": true + }, + { + "description": "a valid URL for a simple text file", + "data": "http://www.ietf.org/rfc/rfc2396.txt", + "valid": true + }, + { + "description": "a valid URL ", + "data": "ldap://[2001:db8::7]/c=GB?objectClass?one", + "valid": true + }, + { + "description": "a valid mailto URI", + "data": "mailto:John.Doe@example.com", + "valid": true + }, + { + "description": "a valid newsgroup URI", + "data": "news:comp.infosystems.www.servers.unix", + "valid": true + }, + { + "description": "a valid tel URI", + "data": "tel:+1-816-555-1212", + "valid": true + }, + { + "description": "a valid URN", + "data": "urn:oasis:names:specification:docbook:dtd:xml:4.1.2", + "valid": true + }, + { + "description": "an invalid protocol-relative URI Reference", + "data": "//foo.bar/?baz=qux#quux", + "valid": false + }, + { + "description": "an invalid relative URI Reference", + "data": "/abc", + "valid": false + }, + { + "description": "an invalid URI", + "data": "\\\\WINDOWS\\fileshare", + "valid": false + }, + { + "description": "an invalid URI though valid URI reference", + "data": "abc", + "valid": false + }, + { + "description": "an invalid URI with spaces", + "data": "http:// shouldfail.com", + "valid": false + }, + { + "description": "an invalid URI with spaces and missing scheme", + "data": ":// should fail", + "valid": false + }, + { + "description": "an invalid URI with comma in scheme", + "data": "bar,baz:foo", + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/future-keywords.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/future-keywords.json new file mode 100755 index 00000000000..af2f791321a --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/future-keywords.json @@ -0,0 +1,465 @@ +[ + { + "description": "$dynamicRef without $dynamicAnchor works like $ref", + "schema": { + "properties": { + "foo": {"$dynamicRef": "#"} + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "match", + "data": {"foo": false}, + "valid": true + }, + { + "description": "recursive match", + "data": {"foo": {"foo": false}}, + "valid": true + }, + { + "description": "mismatch", + "data": {"bar": false}, + "valid": false + }, + { + "description": "recursive mismatch (but $dynamicRef is ignored)", + "data": {"foo": {"bar": false}}, + "valid": true + } + ] + }, + { + "description": "prefixItems: an array of schemas for items", + "schema": { + "prefixItems": [ + {"type": "integer"}, + {"type": "string"} + ] + }, + "tests": [ + { + "description": "correct types", + "data": [ 1, "foo" ], + "valid": true + }, + { + "description": "wrong types", + "data": [ "foo", 1 ], + "valid": true + }, + { + "description": "incomplete array of items", + "data": [ 1 ], + "valid": true + }, + { + "description": "array with additional items", + "data": [ 1, "foo", true ], + "valid": true + }, + { + "description": "empty array", + "data": [ ], + "valid": true + }, + { + "description": "JavaScript pseudo-array is valid", + "data": { + "0": "invalid", + "1": "valid", + "length": 2 + }, + "valid": true + } + ] + }, + { + "description": "dependentSchemas: single dependency", + "schema": { + "dependentSchemas": { + "bar": { + "properties": { + "foo": {"type": "integer"}, + "bar": {"type": "integer"} + } + } + } + }, + "tests": [ + { + "description": "valid", + "data": {"foo": 1, "bar": 2}, + "valid": true + }, + { + "description": "no dependency", + "data": {"foo": "quux"}, + "valid": true + }, + { + "description": "wrong type", + "data": {"foo": "quux", "bar": 2}, + "valid": true + }, + { + "description": "wrong type other", + "data": {"foo": 2, "bar": "quux"}, + "valid": true + }, + { + "description": "wrong type both", + "data": {"foo": "quux", "bar": "quux"}, + "valid": true + } + ] + }, + { + "description": "dependentRequired: single dependency", + "schema": {"dependentRequired": {"bar": ["foo"]}}, + "tests": [ + { + "description": "neither", + "data": {}, + "valid": true + }, + { + "description": "nondependant", + "data": {"foo": 1}, + "valid": true + }, + { + "description": "with dependency", + "data": {"foo": 1, "bar": 2}, + "valid": true + }, + { + "description": "missing dependency", + "data": {"bar": 2}, + "valid": true + }, + { + "description": "ignores arrays", + "data": ["bar"], + "valid": true + }, + { + "description": "ignores strings", + "data": "foobar", + "valid": true + }, + { + "description": "ignores other non-objects", + "data": 12, + "valid": true + } + ] + }, + { + "description": "unevaluatedItems false", + "schema": { + "type": "array", + "unevaluatedItems": false + }, + "tests": [ + { + "description": "with no unevaluated items", + "data": [], + "valid": true + }, + { + "description": "with unevaluated items", + "data": ["foo"], + "valid": true + } + ] + }, + { + "description": "unevaluatedProperties schema", + "schema": { + "type": "object", + "unevaluatedProperties": { + "type": "string", + "minLength": 3 + } + }, + "tests": [ + { + "description": "with no unevaluated properties", + "data": {}, + "valid": true + }, + { + "description": "with valid unevaluated properties", + "data": { + "foo": "foo" + }, + "valid": true + }, + { + "description": "with invalid unevaluated properties", + "data": { + "foo": "fo" + }, + "valid": true + } + ] + }, + { + "description": "maxContains with contains", + "schema": { + "contains": {"const": 1}, + "maxContains": 1 + }, + "tests": [ + { + "description": "empty data", + "data": [ ], + "valid": false + }, + { + "description": "all elements match, valid maxContains", + "data": [ 1 ], + "valid": true + }, + { + "description": "all elements match, invalid maxContains", + "data": [ 1, 1 ], + "valid": true + }, + { + "description": "some elements match, valid maxContains", + "data": [ 1, 2 ], + "valid": true + }, + { + "description": "some elements match, invalid maxContains", + "data": [ 1, 2, 1 ], + "valid": true + } + ] + }, + { + "description": "minContains=2 with contains", + "schema": { + "contains": {"const": 1}, + "minContains": 2 + }, + "tests": [ + { + "description": "empty data", + "data": [ ], + "valid": false + }, + { + "description": "all elements match, invalid minContains", + "data": [ 1 ], + "valid": true + }, + { + "description": "some elements match, invalid minContains", + "data": [ 1, 2 ], + "valid": true + }, + { + "description": "all elements match, valid minContains (exactly as needed)", + "data": [ 1, 1 ], + "valid": true + }, + { + "description": "all elements match, valid minContains (more than needed)", + "data": [ 1, 1, 1 ], + "valid": true + }, + { + "description": "some elements match, valid minContains", + "data": [ 1, 2, 1 ], + "valid": true + } + ] + }, + { + "description": "minContains = 0", + "schema": { + "contains": {"const": 1}, + "minContains": 0 + }, + "tests": [ + { + "description": "empty array is valid with minContains=0", + "data": [ ], + "valid": false + }, + { + "description": "minContains = 0 would make contains always pass", + "data": [ 2 ], + "valid": false + } + ] + }, + { + "description": "if with boolean schema true", + "schema": { "if": true, "then": { "const": "then" }, "else": { "const": "else" } }, + "tests": [ + { + "description": "boolean schema true in if (invalid when supported)", + "data": "then", + "valid": true + }, + { + "description": "boolean schema true in if (valid when supported)", + "data": "else", + "valid": true + } + ] + }, + { + "description": "if with boolean schema false", + "schema": { "if": false, "then": { "const": "then" }, "else": { "const": "else" } }, + "tests": [ + { + "description": "boolean schema false in if (invalid when supported)", + "data": "then", + "valid": true + }, + { + "description": "boolean schema false in if (valid when supported)", + "data": "else", + "valid": true + } + ] + }, + { + "description": "$recursiveRef without $recursiveAnchor works like $ref", + "schema": { + "properties": { + "foo": { "$recursiveRef": "#" } + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "match", + "data": {"foo": false}, + "valid": true + }, + { + "description": "recursive match", + "data": { "foo": { "foo": false } }, + "valid": true + }, + { + "description": "mismatch", + "data": { "bar": false }, + "valid": false + }, + { + "description": "recursive mismatch", + "data": { "foo": { "bar": false } }, + "valid": true + } + ] + }, + { + "description": "$recursiveRef without using nesting", + "schema": { + "$id": "http://localhost:4242", + "definitions": { + "myobject": { + "$id": "myobject.json", + "$recursiveAnchor": true, + "anyOf": [ + { "type": "string" }, + { + "type": "object", + "additionalProperties": { "$recursiveRef": "#" } + } + ] + } + }, + "anyOf": [ + { "type": "integer" }, + { "$ref": "#/definitions/myobject" } + ] + }, + "tests": [ + { + "description": "integer matches at the outer level", + "data": 1, + "valid": true + }, + { + "description": "single level match", + "data": { "foo": "hi" }, + "valid": true + }, + { + "description": "integer does not match as a property value", + "data": { "foo": 1 }, + "valid": true + }, + { + "description": "two levels, additionalProperties always matches, 1", + "data": { "foo": { "bar": "hi" } }, + "valid": true + }, + { + "description": "two levels, additionalProperties always matches, 2", + "data": { "foo": { "bar": 1 } }, + "valid": true + } + ] + }, + { + "description": "$recursiveRef with nesting", + "schema": { + "$id": "http://localhost:4242", + "$recursiveAnchor": true, + "definitions": { + "myobject": { + "$id": "myobject.json", + "$recursiveAnchor": true, + "anyOf": [ + { "type": "string" }, + { + "type": "object", + "additionalProperties": { "$recursiveRef": "#" } + } + ] + } + }, + "anyOf": [ + { "type": "integer" }, + { "$ref": "#/definitions/myobject" } + ] + }, + "tests": [ + { + "description": "integer matches at the outer level", + "data": 1, + "valid": true + }, + { + "description": "single level match", + "data": { "foo": "hi" }, + "valid": true + }, + { + "description": "integer now matches as a property value", + "data": { "foo": 1 }, + "valid": true + }, + { + "description": "two levels, properties match with inner definition", + "data": { "foo": { "bar": "hi" } }, + "valid": true + }, + { + "description": "two levels, properties match with $recursiveRef", + "data": { "foo": { "bar": 1 } }, + "valid": true + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/non-bmp-regex.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/non-bmp-regex.json new file mode 100755 index 00000000000..dd67af2b2ad --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/optional/non-bmp-regex.json @@ -0,0 +1,82 @@ +[ + { + "description": "Proper UTF-16 surrogate pair handling: pattern", + "comment": "Optional because .Net doesn't correctly handle 32-bit Unicode characters", + "schema": { "pattern": "^ðŸ²*$" }, + "tests": [ + { + "description": "matches empty", + "data": "", + "valid": true + }, + { + "description": "matches single", + "data": "ðŸ²", + "valid": true + }, + { + "description": "matches two", + "data": "ðŸ²ðŸ²", + "valid": true + }, + { + "description": "doesn't match one", + "data": "ðŸ‰", + "valid": false + }, + { + "description": "doesn't match two", + "data": "ðŸ‰ðŸ‰", + "valid": false + }, + { + "description": "doesn't match one ASCII", + "data": "D", + "valid": false + }, + { + "description": "doesn't match two ASCII", + "data": "DD", + "valid": false + } + ] + }, + { + "description": "Proper UTF-16 surrogate pair handling: patternProperties", + "comment": "Optional because .Net doesn't correctly handle 32-bit Unicode characters", + "schema": { + "patternProperties": { + "^ðŸ²*$": { + "type": "integer" + } + } + }, + "tests": [ + { + "description": "matches empty", + "data": { "": 1 }, + "valid": true + }, + { + "description": "matches single", + "data": { "ðŸ²": 1 }, + "valid": true + }, + { + "description": "matches two", + "data": { "ðŸ²ðŸ²": 1 }, + "valid": true + }, + { + "description": "doesn't match one", + "data": { "ðŸ²": "hello" }, + "valid": false + }, + { + "description": "doesn't match two", + "data": { "ðŸ²ðŸ²": "hello" }, + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/pattern.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/pattern.json new file mode 100755 index 00000000000..92db0f971c7 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/pattern.json @@ -0,0 +1,59 @@ +[ + { + "description": "pattern validation", + "schema": {"pattern": "^a*$"}, + "tests": [ + { + "description": "a matching pattern is valid", + "data": "aaa", + "valid": true + }, + { + "description": "a non-matching pattern is invalid", + "data": "abc", + "valid": false + }, + { + "description": "ignores booleans", + "data": true, + "valid": true + }, + { + "description": "ignores integers", + "data": 123, + "valid": true + }, + { + "description": "ignores floats", + "data": 1.0, + "valid": true + }, + { + "description": "ignores objects", + "data": {}, + "valid": true + }, + { + "description": "ignores arrays", + "data": [], + "valid": true + }, + { + "description": "ignores null", + "data": null, + "valid": true + } + ] + }, + { + "description": "pattern is not anchored", + "schema": {"pattern": "a+"}, + "tests": [ + { + "description": "matches a substring", + "data": "xxaayy", + "valid": true + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/patternProperties.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/patternProperties.json new file mode 100755 index 00000000000..c10ffcc05da --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/patternProperties.json @@ -0,0 +1,156 @@ +[ + { + "description": + "patternProperties validates properties matching a regex", + "schema": { + "patternProperties": { + "f.*o": {"type": "integer"} + } + }, + "tests": [ + { + "description": "a single valid match is valid", + "data": {"foo": 1}, + "valid": true + }, + { + "description": "multiple valid matches is valid", + "data": {"foo": 1, "foooooo" : 2}, + "valid": true + }, + { + "description": "a single invalid match is invalid", + "data": {"foo": "bar", "fooooo": 2}, + "valid": false + }, + { + "description": "multiple invalid matches is invalid", + "data": {"foo": "bar", "foooooo" : "baz"}, + "valid": false + }, + { + "description": "ignores arrays", + "data": ["foo"], + "valid": true + }, + { + "description": "ignores strings", + "data": "foo", + "valid": true + }, + { + "description": "ignores other non-objects", + "data": 12, + "valid": true + } + ] + }, + { + "description": "multiple simultaneous patternProperties are validated", + "schema": { + "patternProperties": { + "a*": {"type": "integer"}, + "aaa*": {"maximum": 20} + } + }, + "tests": [ + { + "description": "a single valid match is valid", + "data": {"a": 21}, + "valid": true + }, + { + "description": "a simultaneous match is valid", + "data": {"aaaa": 18}, + "valid": true + }, + { + "description": "multiple matches is valid", + "data": {"a": 21, "aaaa": 18}, + "valid": true + }, + { + "description": "an invalid due to one is invalid", + "data": {"a": "bar"}, + "valid": false + }, + { + "description": "an invalid due to the other is invalid", + "data": {"aaaa": 31}, + "valid": false + }, + { + "description": "an invalid due to both is invalid", + "data": {"aaa": "foo", "aaaa": 31}, + "valid": false + } + ] + }, + { + "description": "regexes are not anchored by default and are case sensitive", + "schema": { + "patternProperties": { + "[0-9]{2,}": { "type": "boolean" }, + "X_": { "type": "string" } + } + }, + "tests": [ + { + "description": "non recognized members are ignored", + "data": { "answer 1": "42" }, + "valid": true + }, + { + "description": "recognized members are accounted for", + "data": { "a31b": null }, + "valid": false + }, + { + "description": "regexes are case sensitive", + "data": { "a_x_3": 3 }, + "valid": true + }, + { + "description": "regexes are case sensitive, 2", + "data": { "a_X_3": 3 }, + "valid": false + } + ] + }, + { + "description": "patternProperties with boolean schemas", + "schema": { + "patternProperties": { + "f.*": true, + "b.*": false + } + }, + "tests": [ + { + "description": "object with property matching schema true is valid", + "data": {"foo": 1}, + "valid": true + }, + { + "description": "object with property matching schema false is invalid", + "data": {"bar": 2}, + "valid": false + }, + { + "description": "object with both properties is invalid", + "data": {"foo": 1, "bar": 2}, + "valid": false + }, + { + "description": "object with a property matching both true and false is invalid", + "data": {"foobar":1}, + "valid": false + }, + { + "description": "empty object is valid", + "data": {}, + "valid": true + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/properties.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/properties.json new file mode 100755 index 00000000000..b86c1819828 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/properties.json @@ -0,0 +1,167 @@ +[ + { + "description": "object properties validation", + "schema": { + "properties": { + "foo": {"type": "integer"}, + "bar": {"type": "string"} + } + }, + "tests": [ + { + "description": "both properties present and valid is valid", + "data": {"foo": 1, "bar": "baz"}, + "valid": true + }, + { + "description": "one property invalid is invalid", + "data": {"foo": 1, "bar": {}}, + "valid": false + }, + { + "description": "both properties invalid is invalid", + "data": {"foo": [], "bar": {}}, + "valid": false + }, + { + "description": "doesn't invalidate other properties", + "data": {"quux": []}, + "valid": true + }, + { + "description": "ignores arrays", + "data": [], + "valid": true + }, + { + "description": "ignores other non-objects", + "data": 12, + "valid": true + } + ] + }, + { + "description": + "properties, patternProperties, additionalProperties interaction", + "schema": { + "properties": { + "foo": {"type": "array", "maxItems": 3}, + "bar": {"type": "array"} + }, + "patternProperties": {"f.o": {"minItems": 2}}, + "additionalProperties": {"type": "integer"} + }, + "tests": [ + { + "description": "property validates property", + "data": {"foo": [1, 2]}, + "valid": true + }, + { + "description": "property invalidates property", + "data": {"foo": [1, 2, 3, 4]}, + "valid": false + }, + { + "description": "patternProperty invalidates property", + "data": {"foo": []}, + "valid": false + }, + { + "description": "patternProperty validates nonproperty", + "data": {"fxo": [1, 2]}, + "valid": true + }, + { + "description": "patternProperty invalidates nonproperty", + "data": {"fxo": []}, + "valid": false + }, + { + "description": "additionalProperty ignores property", + "data": {"bar": []}, + "valid": true + }, + { + "description": "additionalProperty validates others", + "data": {"quux": 3}, + "valid": true + }, + { + "description": "additionalProperty invalidates others", + "data": {"quux": "foo"}, + "valid": false + } + ] + }, + { + "description": "properties with boolean schema", + "schema": { + "properties": { + "foo": true, + "bar": false + } + }, + "tests": [ + { + "description": "no property present is valid", + "data": {}, + "valid": true + }, + { + "description": "only 'true' property present is valid", + "data": {"foo": 1}, + "valid": true + }, + { + "description": "only 'false' property present is invalid", + "data": {"bar": 2}, + "valid": false + }, + { + "description": "both properties present is invalid", + "data": {"foo": 1, "bar": 2}, + "valid": false + } + ] + }, + { + "description": "properties with escaped characters", + "schema": { + "properties": { + "foo\nbar": {"type": "number"}, + "foo\"bar": {"type": "number"}, + "foo\\bar": {"type": "number"}, + "foo\rbar": {"type": "number"}, + "foo\tbar": {"type": "number"}, + "foo\fbar": {"type": "number"} + } + }, + "tests": [ + { + "description": "object with all numbers is valid", + "data": { + "foo\nbar": 1, + "foo\"bar": 1, + "foo\\bar": 1, + "foo\rbar": 1, + "foo\tbar": 1, + "foo\fbar": 1 + }, + "valid": true + }, + { + "description": "object with strings is invalid", + "data": { + "foo\nbar": "1", + "foo\"bar": "1", + "foo\\bar": "1", + "foo\rbar": "1", + "foo\tbar": "1", + "foo\fbar": "1" + }, + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/propertyNames.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/propertyNames.json new file mode 100755 index 00000000000..f0788e649ff --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/propertyNames.json @@ -0,0 +1,107 @@ +[ + { + "description": "propertyNames validation", + "schema": { + "propertyNames": {"maxLength": 3} + }, + "tests": [ + { + "description": "all property names valid", + "data": { + "f": {}, + "foo": {} + }, + "valid": true + }, + { + "description": "some property names invalid", + "data": { + "foo": {}, + "foobar": {} + }, + "valid": false + }, + { + "description": "object without properties is valid", + "data": {}, + "valid": true + }, + { + "description": "ignores arrays", + "data": [1, 2, 3, 4], + "valid": true + }, + { + "description": "ignores strings", + "data": "foobar", + "valid": true + }, + { + "description": "ignores other non-objects", + "data": 12, + "valid": true + } + ] + }, + { + "description": "propertyNames validation with pattern", + "schema": { + "propertyNames": { "pattern": "^a+$" } + }, + "tests": [ + { + "description": "matching property names valid", + "data": { + "a": {}, + "aa": {}, + "aaa": {} + }, + "valid": true + }, + { + "description": "non-matching property name is invalid", + "data": { + "aaA": {} + }, + "valid": false + }, + { + "description": "object without properties is valid", + "data": {}, + "valid": true + } + ] + }, + { + "description": "propertyNames with boolean schema true", + "schema": {"propertyNames": true}, + "tests": [ + { + "description": "object with any properties is valid", + "data": {"foo": 1}, + "valid": true + }, + { + "description": "empty object is valid", + "data": {}, + "valid": true + } + ] + }, + { + "description": "propertyNames with boolean schema false", + "schema": {"propertyNames": false}, + "tests": [ + { + "description": "object with any properties is invalid", + "data": {"foo": 1}, + "valid": false + }, + { + "description": "empty object is valid", + "data": {}, + "valid": true + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/ref.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/ref.json new file mode 100755 index 00000000000..ce5caf674d4 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/ref.json @@ -0,0 +1,612 @@ +[ + { + "description": "root pointer ref", + "schema": { + "properties": { + "foo": {"$ref": "#"} + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "match", + "data": {"foo": false}, + "valid": true + }, + { + "description": "recursive match", + "data": {"foo": {"foo": false}}, + "valid": true + }, + { + "description": "mismatch", + "data": {"bar": false}, + "valid": false + }, + { + "description": "recursive mismatch", + "data": {"foo": {"bar": false}}, + "valid": false + } + ] + }, + { + "description": "relative pointer ref to object", + "schema": { + "properties": { + "foo": {"type": "integer"}, + "bar": {"$ref": "#/properties/foo"} + } + }, + "tests": [ + { + "description": "match", + "data": {"bar": 3}, + "valid": true + }, + { + "description": "mismatch", + "data": {"bar": true}, + "valid": false + } + ] + }, + { + "description": "relative pointer ref to array", + "schema": { + "items": [ + {"type": "integer"}, + {"$ref": "#/items/0"} + ] + }, + "tests": [ + { + "description": "match array", + "data": [1, 2], + "valid": true + }, + { + "description": "mismatch array", + "data": [1, "foo"], + "valid": false + } + ] + }, + { + "description": "escaped pointer ref", + "schema": { + "definitions": { + "tilde~field": {"type": "integer"}, + "slash/field": {"type": "integer"}, + "percent%field": {"type": "integer"} + }, + "properties": { + "tilde": {"$ref": "#/definitions/tilde~0field"}, + "slash": {"$ref": "#/definitions/slash~1field"}, + "percent": {"$ref": "#/definitions/percent%25field"} + } + }, + "tests": [ + { + "description": "slash invalid", + "data": {"slash": "aoeu"}, + "valid": false + }, + { + "description": "tilde invalid", + "data": {"tilde": "aoeu"}, + "valid": false + }, + { + "description": "percent invalid", + "data": {"percent": "aoeu"}, + "valid": false + }, + { + "description": "slash valid", + "data": {"slash": 123}, + "valid": true + }, + { + "description": "tilde valid", + "data": {"tilde": 123}, + "valid": true + }, + { + "description": "percent valid", + "data": {"percent": 123}, + "valid": true + } + ] + }, + { + "description": "nested refs", + "schema": { + "definitions": { + "a": {"type": "integer"}, + "b": {"$ref": "#/definitions/a"}, + "c": {"$ref": "#/definitions/b"} + }, + "allOf": [{ "$ref": "#/definitions/c" }] + }, + "tests": [ + { + "description": "nested ref valid", + "data": 5, + "valid": true + }, + { + "description": "nested ref invalid", + "data": "a", + "valid": false + } + ] + }, + { + "description": "ref overrides any sibling keywords", + "schema": { + "definitions": { + "reffed": { + "type": "array" + } + }, + "properties": { + "foo": { + "$ref": "#/definitions/reffed", + "maxItems": 2 + } + } + }, + "tests": [ + { + "description": "ref valid", + "data": { "foo": [] }, + "valid": true + }, + { + "description": "ref valid, maxItems ignored", + "data": { "foo": [ 1, 2, 3] }, + "valid": true + }, + { + "description": "ref invalid", + "data": { "foo": "string" }, + "valid": false + } + ] + }, + { + "description": "$ref prevents a sibling $id from changing the base uri", + "schema": { + "$id": "http://localhost:1234/sibling_id/base/", + "definitions": { + "foo": { + "$id": "http://localhost:1234/sibling_id/foo.json", + "type": "string" + }, + "base_foo": { + "$comment": "this canonical uri is http://localhost:1234/sibling_id/base/foo.json", + "$id": "foo.json", + "type": "number" + } + }, + "allOf": [ + { + "$comment": "$ref resolves to http://localhost:1234/sibling_id/base/foo.json, not http://localhost:1234/sibling_id/foo.json", + "$id": "http://localhost:1234/sibling_id/", + "$ref": "foo.json" + } + ] + }, + "tests": [ + { + "description": "$ref resolves to /definitions/base_foo, data does not validate", + "data": "a", + "valid": false + }, + { + "description": "$ref resolves to /definitions/base_foo, data validates", + "data": 1, + "valid": true + } + ] + }, + { + "description": "remote ref, containing refs itself", + "schema": {"$ref": "http://json-schema.org/draft-06/schema#"}, + "tests": [ + { + "description": "remote ref valid", + "data": {"minLength": 1}, + "valid": true + }, + { + "description": "remote ref invalid", + "data": {"minLength": -1}, + "valid": false + } + ] + }, + { + "description": "property named $ref that is not a reference", + "schema": { + "properties": { + "$ref": {"type": "string"} + } + }, + "tests": [ + { + "description": "property named $ref valid", + "data": {"$ref": "a"}, + "valid": true + }, + { + "description": "property named $ref invalid", + "data": {"$ref": 2}, + "valid": false + } + ] + }, + { + "description": "property named $ref, containing an actual $ref", + "schema": { + "properties": { + "$ref": {"$ref": "#/definitions/is-string"} + }, + "definitions": { + "is-string": { + "type": "string" + } + } + }, + "tests": [ + { + "description": "property named $ref valid", + "data": {"$ref": "a"}, + "valid": true + }, + { + "description": "property named $ref invalid", + "data": {"$ref": 2}, + "valid": false + } + ] + }, + { + "description": "$ref to boolean schema true", + "schema": { + "allOf": [{ "$ref": "#/definitions/bool" }], + "definitions": { + "bool": true + } + }, + "tests": [ + { + "description": "any value is valid", + "data": "foo", + "valid": true + } + ] + }, + { + "description": "$ref to boolean schema false", + "schema": { + "allOf": [{ "$ref": "#/definitions/bool" }], + "definitions": { + "bool": false + } + }, + "tests": [ + { + "description": "any value is invalid", + "data": "foo", + "valid": false + } + ] + }, + { + "description": "Recursive references between schemas", + "schema": { + "$id": "http://localhost:1234/tree", + "description": "tree of nodes", + "type": "object", + "properties": { + "meta": {"type": "string"}, + "nodes": { + "type": "array", + "items": {"$ref": "node"} + } + }, + "required": ["meta", "nodes"], + "definitions": { + "node": { + "$id": "http://localhost:1234/node", + "description": "node", + "type": "object", + "properties": { + "value": {"type": "number"}, + "subtree": {"$ref": "tree"} + }, + "required": ["value"] + } + } + }, + "tests": [ + { + "description": "valid tree", + "data": { + "meta": "root", + "nodes": [ + { + "value": 1, + "subtree": { + "meta": "child", + "nodes": [ + {"value": 1.1}, + {"value": 1.2} + ] + } + }, + { + "value": 2, + "subtree": { + "meta": "child", + "nodes": [ + {"value": 2.1}, + {"value": 2.2} + ] + } + } + ] + }, + "valid": true + }, + { + "description": "invalid tree", + "data": { + "meta": "root", + "nodes": [ + { + "value": 1, + "subtree": { + "meta": "child", + "nodes": [ + {"value": "string is invalid"}, + {"value": 1.2} + ] + } + }, + { + "value": 2, + "subtree": { + "meta": "child", + "nodes": [ + {"value": 2.1}, + {"value": 2.2} + ] + } + } + ] + }, + "valid": false + } + ] + }, + { + "description": "refs with quote", + "schema": { + "properties": { + "foo\"bar": {"$ref": "#/definitions/foo%22bar"} + }, + "definitions": { + "foo\"bar": {"type": "number"} + } + }, + "tests": [ + { + "description": "object with numbers is valid", + "data": { + "foo\"bar": 1 + }, + "valid": true + }, + { + "description": "object with strings is invalid", + "data": { + "foo\"bar": "1" + }, + "valid": false + } + ] + }, + { + "description": "Location-independent identifier", + "schema": { + "allOf": [{ + "$ref": "#foo" + }], + "definitions": { + "A": { + "$id": "#foo", + "type": "integer" + } + } + }, + "tests": [ + { + "data": 1, + "description": "match", + "valid": true + }, + { + "data": "a", + "description": "mismatch", + "valid": false + } + ] + }, + { + "description": "Location-independent identifier with base URI change in subschema", + "schema": { + "$id": "http://localhost:1234/root", + "allOf": [{ + "$ref": "http://localhost:1234/nested.json#foo" + }], + "definitions": { + "A": { + "$id": "nested.json", + "definitions": { + "B": { + "$id": "#foo", + "type": "integer" + } + } + } + } + }, + "tests": [ + { + "data": 1, + "description": "match", + "valid": true + }, + { + "data": "a", + "description": "mismatch", + "valid": false + } + ] + }, + { + "description": "naive replacement of $ref with its destination is not correct", + "schema": { + "definitions": { + "a_string": { "type": "string" } + }, + "enum": [ + { "$ref": "#/definitions/a_string" } + ] + }, + "tests": [ + { + "description": "do not evaluate the $ref inside the enum, matching any string", + "data": "this is a string", + "valid": false + }, + { + "description": "do not evaluate the $ref inside the enum, definition exact match", + "data": { "type": "string" }, + "valid": false + }, + { + "description": "match the enum exactly", + "data": { "$ref": "#/definitions/a_string" }, + "valid": true + } + ] + }, + { + "description": "refs with relative uris and defs", + "schema": { + "$id": "http://example.com/schema-relative-uri-defs1.json", + "properties": { + "foo": { + "$id": "schema-relative-uri-defs2.json", + "definitions": { + "inner": { + "properties": { + "bar": { "type": "string" } + } + } + }, + "allOf": [ { "$ref": "#/definitions/inner" } ] + } + }, + "allOf": [ { "$ref": "schema-relative-uri-defs2.json" } ] + }, + "tests": [ + { + "description": "invalid on inner field", + "data": { + "foo": { + "bar": 1 + }, + "bar": "a" + }, + "valid": false + }, + { + "description": "invalid on outer field", + "data": { + "foo": { + "bar": "a" + }, + "bar": 1 + }, + "valid": false + }, + { + "description": "valid on both fields", + "data": { + "foo": { + "bar": "a" + }, + "bar": "a" + }, + "valid": true + } + ] + }, + { + "description": "relative refs with absolute uris and defs", + "schema": { + "$id": "http://example.com/schema-refs-absolute-uris-defs1.json", + "properties": { + "foo": { + "$id": "http://example.com/schema-refs-absolute-uris-defs2.json", + "definitions": { + "inner": { + "properties": { + "bar": { "type": "string" } + } + } + }, + "allOf": [ { "$ref": "#/definitions/inner" } ] + } + }, + "allOf": [ { "$ref": "schema-refs-absolute-uris-defs2.json" } ] + }, + "tests": [ + { + "description": "invalid on inner field", + "data": { + "foo": { + "bar": 1 + }, + "bar": "a" + }, + "valid": false + }, + { + "description": "invalid on outer field", + "data": { + "foo": { + "bar": "a" + }, + "bar": 1 + }, + "valid": false + }, + { + "description": "valid on both fields", + "data": { + "foo": { + "bar": "a" + }, + "bar": "a" + }, + "valid": true + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/refRemote.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/refRemote.json new file mode 100755 index 00000000000..a2221b21390 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/refRemote.json @@ -0,0 +1,196 @@ +[ + { + "description": "remote ref", + "schema": {"$ref": "http://localhost:1234/integer.json"}, + "tests": [ + { + "description": "remote ref valid", + "data": 1, + "valid": true + }, + { + "description": "remote ref invalid", + "data": "a", + "valid": false + } + ] + }, + { + "description": "fragment within remote ref", + "schema": {"$ref": "http://localhost:1234/subSchemas.json#/integer"}, + "tests": [ + { + "description": "remote fragment valid", + "data": 1, + "valid": true + }, + { + "description": "remote fragment invalid", + "data": "a", + "valid": false + } + ] + }, + { + "description": "ref within remote ref", + "schema": { + "$ref": "http://localhost:1234/subSchemas.json#/refToInteger" + }, + "tests": [ + { + "description": "ref within ref valid", + "data": 1, + "valid": true + }, + { + "description": "ref within ref invalid", + "data": "a", + "valid": false + } + ] + }, + { + "description": "base URI change", + "schema": { + "$id": "http://localhost:1234/", + "items": { + "$id": "baseUriChange/", + "items": {"$ref": "folderInteger.json"} + } + }, + "tests": [ + { + "description": "base URI change ref valid", + "data": [[1]], + "valid": true + }, + { + "description": "base URI change ref invalid", + "data": [["a"]], + "valid": false + } + ] + }, + { + "description": "base URI change - change folder", + "schema": { + "$id": "http://localhost:1234/scope_change_defs1.json", + "type" : "object", + "properties": { + "list": {"$ref": "#/definitions/baz"} + }, + "definitions": { + "baz": { + "$id": "baseUriChangeFolder/", + "type": "array", + "items": {"$ref": "folderInteger.json"} + } + } + }, + "tests": [ + { + "description": "number is valid", + "data": {"list": [1]}, + "valid": true + }, + { + "description": "string is invalid", + "data": {"list": ["a"]}, + "valid": false + } + ] + }, + { + "description": "base URI change - change folder in subschema", + "schema": { + "$id": "http://localhost:1234/scope_change_defs2.json", + "type" : "object", + "properties": { + "list": {"$ref": "#/definitions/baz/definitions/bar"} + }, + "definitions": { + "baz": { + "$id": "baseUriChangeFolderInSubschema/", + "definitions": { + "bar": { + "type": "array", + "items": {"$ref": "folderInteger.json"} + } + } + } + } + }, + "tests": [ + { + "description": "number is valid", + "data": {"list": [1]}, + "valid": true + }, + { + "description": "string is invalid", + "data": {"list": ["a"]}, + "valid": false + } + ] + }, + { + "description": "root ref in remote ref", + "schema": { + "$id": "http://localhost:1234/object", + "type": "object", + "properties": { + "name": {"$ref": "name.json#/definitions/orNull"} + } + }, + "tests": [ + { + "description": "string is valid", + "data": { + "name": "foo" + }, + "valid": true + }, + { + "description": "null is valid", + "data": { + "name": null + }, + "valid": true + }, + { + "description": "object is invalid", + "data": { + "name": { + "name": null + } + }, + "valid": false + } + ] + }, + { + "description": "remote ref with ref to definitions", + "schema": { + "$id": "http://localhost:1234/schema-remote-ref-ref-defs1.json", + "allOf": [ + { "$ref": "ref-and-definitions.json" } + ] + }, + "tests": [ + { + "description": "invalid", + "data": { + "bar": 1 + }, + "valid": false + }, + { + "description": "valid", + "data": { + "bar": "a" + }, + "valid": true + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/required.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/required.json new file mode 100755 index 00000000000..abf18f34594 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/required.json @@ -0,0 +1,105 @@ +[ + { + "description": "required validation", + "schema": { + "properties": { + "foo": {}, + "bar": {} + }, + "required": ["foo"] + }, + "tests": [ + { + "description": "present required property is valid", + "data": {"foo": 1}, + "valid": true + }, + { + "description": "non-present required property is invalid", + "data": {"bar": 1}, + "valid": false + }, + { + "description": "ignores arrays", + "data": [], + "valid": true + }, + { + "description": "ignores strings", + "data": "", + "valid": true + }, + { + "description": "ignores other non-objects", + "data": 12, + "valid": true + } + ] + }, + { + "description": "required default validation", + "schema": { + "properties": { + "foo": {} + } + }, + "tests": [ + { + "description": "not required by default", + "data": {}, + "valid": true + } + ] + }, + { + "description": "required with empty array", + "schema": { + "properties": { + "foo": {} + }, + "required": [] + }, + "tests": [ + { + "description": "property not required", + "data": {}, + "valid": true + } + ] + }, + { + "description": "required with escaped characters", + "schema": { + "required": [ + "foo\nbar", + "foo\"bar", + "foo\\bar", + "foo\rbar", + "foo\tbar", + "foo\fbar" + ] + }, + "tests": [ + { + "description": "object with all properties present is valid", + "data": { + "foo\nbar": 1, + "foo\"bar": 1, + "foo\\bar": 1, + "foo\rbar": 1, + "foo\tbar": 1, + "foo\fbar": 1 + }, + "valid": true + }, + { + "description": "object with some properties missing is invalid", + "data": { + "foo\nbar": "1", + "foo\"bar": "1" + }, + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/type.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/type.json new file mode 100755 index 00000000000..83046470298 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/type.json @@ -0,0 +1,474 @@ +[ + { + "description": "integer type matches integers", + "schema": {"type": "integer"}, + "tests": [ + { + "description": "an integer is an integer", + "data": 1, + "valid": true + }, + { + "description": "a float with zero fractional part is an integer", + "data": 1.0, + "valid": true + }, + { + "description": "a float is not an integer", + "data": 1.1, + "valid": false + }, + { + "description": "a string is not an integer", + "data": "foo", + "valid": false + }, + { + "description": "a string is still not an integer, even if it looks like one", + "data": "1", + "valid": false + }, + { + "description": "an object is not an integer", + "data": {}, + "valid": false + }, + { + "description": "an array is not an integer", + "data": [], + "valid": false + }, + { + "description": "a boolean is not an integer", + "data": true, + "valid": false + }, + { + "description": "null is not an integer", + "data": null, + "valid": false + } + ] + }, + { + "description": "number type matches numbers", + "schema": {"type": "number"}, + "tests": [ + { + "description": "an integer is a number", + "data": 1, + "valid": true + }, + { + "description": "a float with zero fractional part is a number (and an integer)", + "data": 1.0, + "valid": true + }, + { + "description": "a float is a number", + "data": 1.1, + "valid": true + }, + { + "description": "a string is not a number", + "data": "foo", + "valid": false + }, + { + "description": "a string is still not a number, even if it looks like one", + "data": "1", + "valid": false + }, + { + "description": "an object is not a number", + "data": {}, + "valid": false + }, + { + "description": "an array is not a number", + "data": [], + "valid": false + }, + { + "description": "a boolean is not a number", + "data": true, + "valid": false + }, + { + "description": "null is not a number", + "data": null, + "valid": false + } + ] + }, + { + "description": "string type matches strings", + "schema": {"type": "string"}, + "tests": [ + { + "description": "1 is not a string", + "data": 1, + "valid": false + }, + { + "description": "a float is not a string", + "data": 1.1, + "valid": false + }, + { + "description": "a string is a string", + "data": "foo", + "valid": true + }, + { + "description": "a string is still a string, even if it looks like a number", + "data": "1", + "valid": true + }, + { + "description": "an empty string is still a string", + "data": "", + "valid": true + }, + { + "description": "an object is not a string", + "data": {}, + "valid": false + }, + { + "description": "an array is not a string", + "data": [], + "valid": false + }, + { + "description": "a boolean is not a string", + "data": true, + "valid": false + }, + { + "description": "null is not a string", + "data": null, + "valid": false + } + ] + }, + { + "description": "object type matches objects", + "schema": {"type": "object"}, + "tests": [ + { + "description": "an integer is not an object", + "data": 1, + "valid": false + }, + { + "description": "a float is not an object", + "data": 1.1, + "valid": false + }, + { + "description": "a string is not an object", + "data": "foo", + "valid": false + }, + { + "description": "an object is an object", + "data": {}, + "valid": true + }, + { + "description": "an array is not an object", + "data": [], + "valid": false + }, + { + "description": "a boolean is not an object", + "data": true, + "valid": false + }, + { + "description": "null is not an object", + "data": null, + "valid": false + } + ] + }, + { + "description": "array type matches arrays", + "schema": {"type": "array"}, + "tests": [ + { + "description": "an integer is not an array", + "data": 1, + "valid": false + }, + { + "description": "a float is not an array", + "data": 1.1, + "valid": false + }, + { + "description": "a string is not an array", + "data": "foo", + "valid": false + }, + { + "description": "an object is not an array", + "data": {}, + "valid": false + }, + { + "description": "an array is an array", + "data": [], + "valid": true + }, + { + "description": "a boolean is not an array", + "data": true, + "valid": false + }, + { + "description": "null is not an array", + "data": null, + "valid": false + } + ] + }, + { + "description": "boolean type matches booleans", + "schema": {"type": "boolean"}, + "tests": [ + { + "description": "an integer is not a boolean", + "data": 1, + "valid": false + }, + { + "description": "zero is not a boolean", + "data": 0, + "valid": false + }, + { + "description": "a float is not a boolean", + "data": 1.1, + "valid": false + }, + { + "description": "a string is not a boolean", + "data": "foo", + "valid": false + }, + { + "description": "an empty string is not a boolean", + "data": "", + "valid": false + }, + { + "description": "an object is not a boolean", + "data": {}, + "valid": false + }, + { + "description": "an array is not a boolean", + "data": [], + "valid": false + }, + { + "description": "true is a boolean", + "data": true, + "valid": true + }, + { + "description": "false is a boolean", + "data": false, + "valid": true + }, + { + "description": "null is not a boolean", + "data": null, + "valid": false + } + ] + }, + { + "description": "null type matches only the null object", + "schema": {"type": "null"}, + "tests": [ + { + "description": "an integer is not null", + "data": 1, + "valid": false + }, + { + "description": "a float is not null", + "data": 1.1, + "valid": false + }, + { + "description": "zero is not null", + "data": 0, + "valid": false + }, + { + "description": "a string is not null", + "data": "foo", + "valid": false + }, + { + "description": "an empty string is not null", + "data": "", + "valid": false + }, + { + "description": "an object is not null", + "data": {}, + "valid": false + }, + { + "description": "an array is not null", + "data": [], + "valid": false + }, + { + "description": "true is not null", + "data": true, + "valid": false + }, + { + "description": "false is not null", + "data": false, + "valid": false + }, + { + "description": "null is null", + "data": null, + "valid": true + } + ] + }, + { + "description": "multiple types can be specified in an array", + "schema": {"type": ["integer", "string"]}, + "tests": [ + { + "description": "an integer is valid", + "data": 1, + "valid": true + }, + { + "description": "a string is valid", + "data": "foo", + "valid": true + }, + { + "description": "a float is invalid", + "data": 1.1, + "valid": false + }, + { + "description": "an object is invalid", + "data": {}, + "valid": false + }, + { + "description": "an array is invalid", + "data": [], + "valid": false + }, + { + "description": "a boolean is invalid", + "data": true, + "valid": false + }, + { + "description": "null is invalid", + "data": null, + "valid": false + } + ] + }, + { + "description": "type as array with one item", + "schema": { + "type": ["string"] + }, + "tests": [ + { + "description": "string is valid", + "data": "foo", + "valid": true + }, + { + "description": "number is invalid", + "data": 123, + "valid": false + } + ] + }, + { + "description": "type: array or object", + "schema": { + "type": ["array", "object"] + }, + "tests": [ + { + "description": "array is valid", + "data": [1,2,3], + "valid": true + }, + { + "description": "object is valid", + "data": {"foo": 123}, + "valid": true + }, + { + "description": "number is invalid", + "data": 123, + "valid": false + }, + { + "description": "string is invalid", + "data": "foo", + "valid": false + }, + { + "description": "null is invalid", + "data": null, + "valid": false + } + ] + }, + { + "description": "type: array, object or null", + "schema": { + "type": ["array", "object", "null"] + }, + "tests": [ + { + "description": "array is valid", + "data": [1,2,3], + "valid": true + }, + { + "description": "object is valid", + "data": {"foo": 123}, + "valid": true + }, + { + "description": "null is valid", + "data": null, + "valid": true + }, + { + "description": "number is invalid", + "data": 123, + "valid": false + }, + { + "description": "string is invalid", + "data": "foo", + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/uniqueItems.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/uniqueItems.json new file mode 100755 index 00000000000..2ccf666d7df --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/uniqueItems.json @@ -0,0 +1,404 @@ +[ + { + "description": "uniqueItems validation", + "schema": {"uniqueItems": true}, + "tests": [ + { + "description": "unique array of integers is valid", + "data": [1, 2], + "valid": true + }, + { + "description": "non-unique array of integers is invalid", + "data": [1, 1], + "valid": false + }, + { + "description": "non-unique array of more than two integers is invalid", + "data": [1, 2, 1], + "valid": false + }, + { + "description": "numbers are unique if mathematically unequal", + "data": [1.0, 1.00, 1], + "valid": false + }, + { + "description": "false is not equal to zero", + "data": [0, false], + "valid": true + }, + { + "description": "true is not equal to one", + "data": [1, true], + "valid": true + }, + { + "description": "unique array of strings is valid", + "data": ["foo", "bar", "baz"], + "valid": true + }, + { + "description": "non-unique array of strings is invalid", + "data": ["foo", "bar", "foo"], + "valid": false + }, + { + "description": "unique array of objects is valid", + "data": [{"foo": "bar"}, {"foo": "baz"}], + "valid": true + }, + { + "description": "non-unique array of objects is invalid", + "data": [{"foo": "bar"}, {"foo": "bar"}], + "valid": false + }, + { + "description": "unique array of nested objects is valid", + "data": [ + {"foo": {"bar" : {"baz" : true}}}, + {"foo": {"bar" : {"baz" : false}}} + ], + "valid": true + }, + { + "description": "non-unique array of nested objects is invalid", + "data": [ + {"foo": {"bar" : {"baz" : true}}}, + {"foo": {"bar" : {"baz" : true}}} + ], + "valid": false + }, + { + "description": "unique array of arrays is valid", + "data": [["foo"], ["bar"]], + "valid": true + }, + { + "description": "non-unique array of arrays is invalid", + "data": [["foo"], ["foo"]], + "valid": false + }, + { + "description": "non-unique array of more than two arrays is invalid", + "data": [["foo"], ["bar"], ["foo"]], + "valid": false + }, + { + "description": "1 and true are unique", + "data": [1, true], + "valid": true + }, + { + "description": "0 and false are unique", + "data": [0, false], + "valid": true + }, + { + "description": "[1] and [true] are unique", + "data": [[1], [true]], + "valid": true + }, + { + "description": "[0] and [false] are unique", + "data": [[0], [false]], + "valid": true + }, + { + "description": "nested [1] and [true] are unique", + "data": [[[1], "foo"], [[true], "foo"]], + "valid": true + }, + { + "description": "nested [0] and [false] are unique", + "data": [[[0], "foo"], [[false], "foo"]], + "valid": true + }, + { + "description": "unique heterogeneous types are valid", + "data": [{}, [1], true, null, 1, "{}"], + "valid": true + }, + { + "description": "non-unique heterogeneous types are invalid", + "data": [{}, [1], true, null, {}, 1], + "valid": false + }, + { + "description": "different objects are unique", + "data": [{"a": 1, "b": 2}, {"a": 2, "b": 1}], + "valid": true + }, + { + "description": "objects are non-unique despite key order", + "data": [{"a": 1, "b": 2}, {"b": 2, "a": 1}], + "valid": false + }, + { + "description": "{\"a\": false} and {\"a\": 0} are unique", + "data": [{"a": false}, {"a": 0}], + "valid": true + }, + { + "description": "{\"a\": true} and {\"a\": 1} are unique", + "data": [{"a": true}, {"a": 1}], + "valid": true + } + ] + }, + { + "description": "uniqueItems with an array of items", + "schema": { + "items": [{"type": "boolean"}, {"type": "boolean"}], + "uniqueItems": true + }, + "tests": [ + { + "description": "[false, true] from items array is valid", + "data": [false, true], + "valid": true + }, + { + "description": "[true, false] from items array is valid", + "data": [true, false], + "valid": true + }, + { + "description": "[false, false] from items array is not valid", + "data": [false, false], + "valid": false + }, + { + "description": "[true, true] from items array is not valid", + "data": [true, true], + "valid": false + }, + { + "description": "unique array extended from [false, true] is valid", + "data": [false, true, "foo", "bar"], + "valid": true + }, + { + "description": "unique array extended from [true, false] is valid", + "data": [true, false, "foo", "bar"], + "valid": true + }, + { + "description": "non-unique array extended from [false, true] is not valid", + "data": [false, true, "foo", "foo"], + "valid": false + }, + { + "description": "non-unique array extended from [true, false] is not valid", + "data": [true, false, "foo", "foo"], + "valid": false + } + ] + }, + { + "description": "uniqueItems with an array of items and additionalItems=false", + "schema": { + "items": [{"type": "boolean"}, {"type": "boolean"}], + "uniqueItems": true, + "additionalItems": false + }, + "tests": [ + { + "description": "[false, true] from items array is valid", + "data": [false, true], + "valid": true + }, + { + "description": "[true, false] from items array is valid", + "data": [true, false], + "valid": true + }, + { + "description": "[false, false] from items array is not valid", + "data": [false, false], + "valid": false + }, + { + "description": "[true, true] from items array is not valid", + "data": [true, true], + "valid": false + }, + { + "description": "extra items are invalid even if unique", + "data": [false, true, null], + "valid": false + } + ] + }, + { + "description": "uniqueItems=false validation", + "schema": { "uniqueItems": false }, + "tests": [ + { + "description": "unique array of integers is valid", + "data": [1, 2], + "valid": true + }, + { + "description": "non-unique array of integers is valid", + "data": [1, 1], + "valid": true + }, + { + "description": "numbers are unique if mathematically unequal", + "data": [1.0, 1.00, 1], + "valid": true + }, + { + "description": "false is not equal to zero", + "data": [0, false], + "valid": true + }, + { + "description": "true is not equal to one", + "data": [1, true], + "valid": true + }, + { + "description": "unique array of objects is valid", + "data": [{"foo": "bar"}, {"foo": "baz"}], + "valid": true + }, + { + "description": "non-unique array of objects is valid", + "data": [{"foo": "bar"}, {"foo": "bar"}], + "valid": true + }, + { + "description": "unique array of nested objects is valid", + "data": [ + {"foo": {"bar" : {"baz" : true}}}, + {"foo": {"bar" : {"baz" : false}}} + ], + "valid": true + }, + { + "description": "non-unique array of nested objects is valid", + "data": [ + {"foo": {"bar" : {"baz" : true}}}, + {"foo": {"bar" : {"baz" : true}}} + ], + "valid": true + }, + { + "description": "unique array of arrays is valid", + "data": [["foo"], ["bar"]], + "valid": true + }, + { + "description": "non-unique array of arrays is valid", + "data": [["foo"], ["foo"]], + "valid": true + }, + { + "description": "1 and true are unique", + "data": [1, true], + "valid": true + }, + { + "description": "0 and false are unique", + "data": [0, false], + "valid": true + }, + { + "description": "unique heterogeneous types are valid", + "data": [{}, [1], true, null, 1], + "valid": true + }, + { + "description": "non-unique heterogeneous types are valid", + "data": [{}, [1], true, null, {}, 1], + "valid": true + } + ] + }, + { + "description": "uniqueItems=false with an array of items", + "schema": { + "items": [{"type": "boolean"}, {"type": "boolean"}], + "uniqueItems": false + }, + "tests": [ + { + "description": "[false, true] from items array is valid", + "data": [false, true], + "valid": true + }, + { + "description": "[true, false] from items array is valid", + "data": [true, false], + "valid": true + }, + { + "description": "[false, false] from items array is valid", + "data": [false, false], + "valid": true + }, + { + "description": "[true, true] from items array is valid", + "data": [true, true], + "valid": true + }, + { + "description": "unique array extended from [false, true] is valid", + "data": [false, true, "foo", "bar"], + "valid": true + }, + { + "description": "unique array extended from [true, false] is valid", + "data": [true, false, "foo", "bar"], + "valid": true + }, + { + "description": "non-unique array extended from [false, true] is valid", + "data": [false, true, "foo", "foo"], + "valid": true + }, + { + "description": "non-unique array extended from [true, false] is valid", + "data": [true, false, "foo", "foo"], + "valid": true + } + ] + }, + { + "description": "uniqueItems=false with an array of items and additionalItems=false", + "schema": { + "items": [{"type": "boolean"}, {"type": "boolean"}], + "uniqueItems": false, + "additionalItems": false + }, + "tests": [ + { + "description": "[false, true] from items array is valid", + "data": [false, true], + "valid": true + }, + { + "description": "[true, false] from items array is valid", + "data": [true, false], + "valid": true + }, + { + "description": "[false, false] from items array is valid", + "data": [false, false], + "valid": true + }, + { + "description": "[true, true] from items array is valid", + "data": [true, true], + "valid": true + }, + { + "description": "extra items are invalid even if unique", + "data": [false, true, null], + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/unknownKeyword.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/unknownKeyword.json new file mode 100755 index 00000000000..1f58d97e3e6 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/unknownKeyword.json @@ -0,0 +1,56 @@ +[ + { + "description": "$id inside an unknown keyword is not a real identifier", + "comment": "the implementation must not be confused by an $id in locations we do not know how to parse", + "schema": { + "definitions": { + "id_in_unknown0": { + "not": { + "array_of_schemas": [ + { + "$id": "https://localhost:1234/unknownKeyword/my_identifier.json", + "type": "null" + } + ] + } + }, + "real_id_in_schema": { + "$id": "https://localhost:1234/unknownKeyword/my_identifier.json", + "type": "string" + }, + "id_in_unknown1": { + "not": { + "object_of_schemas": { + "foo": { + "$id": "https://localhost:1234/unknownKeyword/my_identifier.json", + "type": "integer" + } + } + } + } + }, + "anyOf": [ + { "$ref": "#/definitions/id_in_unknown0" }, + { "$ref": "#/definitions/id_in_unknown1" }, + { "$ref": "https://localhost:1234/unknownKeyword/my_identifier.json" } + ] + }, + "tests": [ + { + "description": "type matches second anyOf, which has a real schema in it", + "data": "a string", + "valid": true + }, + { + "description": "type matches non-schema in first anyOf", + "data": null, + "valid": false + }, + { + "description": "type matches non-schema in third anyOf", + "data": 1, + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/openapi_additions/type.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/openapi_additions/type.json new file mode 100755 index 00000000000..2125a444303 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/openapi_additions/type.json @@ -0,0 +1,43 @@ +[ + { + "description": "array type matches arrays", + "schema": {"type": "array", "items": {}}, + "tests": [ + { + "description": "an integer is not an array", + "data": 1, + "valid": false + }, + { + "description": "a float is not an array", + "data": 1.1, + "valid": false + }, + { + "description": "a string is not an array", + "data": "foo", + "valid": false + }, + { + "description": "an object is not an array", + "data": {}, + "valid": false + }, + { + "description": "an array is an array", + "data": [], + "valid": true + }, + { + "description": "a boolean is not an array", + "data": true, + "valid": false + }, + { + "description": "null is not an array", + "data": null, + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py new file mode 100644 index 00000000000..854c3694f56 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -0,0 +1,189 @@ +import dataclasses +import re +import json +import pathlib +import typing + +import yaml + +""" +Swagger-parser can create one spec from multiple files BUT: +- it must use refs to values in another file +- those refs will be turned into component schemas $refs +- so it will not dereference and inline schemas + +Note: +- 3.0.3: schema supports only a single example +- That example could $ref a component example but we have not ability to test negative examples +- Higher spec versions do have examples BUT: examples does not store pass fail info + - that info could be added as an x-flag + +components.examples Re-use solution: +- including an x-valid tag in each example to note if it should pass or fail +- v3.0.3: add x-examples to schema for passing and failing examples +- ref the needed examples +- using examples for passing examples + +BUT: +- the parser already supports refing examples to a separate yaml file any way + +TODO: +- [DONE] load json file and write it into components/schemas +- [DONE] ensure that examples are being written there +- [DONE] add recursive casting of test examples to ObjectWithTypeBooleans +- [DONE] move processing to defaultCodegen +- [DONE] turn tests on +- add endpoints with those components in: +- request body +- response body +- all parameter types +- add main spec that uses type spec +""" + +@dataclasses.dataclass +class JsonSchemaTestCase: + description: str + data: typing.Union[str, int, float, bool, None, list, dict] + valid: bool + +@dataclasses.dataclass +class JsonSchemaTestSchema: + description: str + schema: dict + tests: typing.List[JsonSchemaTestCase] + + +class ExclusionReason: + v303_does_not_support_array_of_types = 'v3.0.3 does not support type with array of values' + v303_requires_array_have_items = 'v3.0.3 requires that items MUST be present if the type is array' + +json_schema_test_draft = 'draft6' +filepath_to_excluded_case_and_reason = { + (json_schema_test_draft, 'type.json'): { + 'multiple types can be specified in an array': ExclusionReason.v303_does_not_support_array_of_types, + 'type as array with one item': ExclusionReason.v303_does_not_support_array_of_types, + 'type: array or object': ExclusionReason.v303_does_not_support_array_of_types, + 'type: array, object or null': ExclusionReason.v303_does_not_support_array_of_types, + 'array type matches arrays': ExclusionReason.v303_requires_array_have_items, + } +} + +def get_json_schema_test_schemas(file_path: typing.Tuple[str]) -> typing.List[JsonSchemaTestSchema]: + json_schema_test_schemas = [] + filename = file_path[-1] + excluded_case_to_reason = filepath_to_excluded_case_and_reason.get(file_path, {}) + path = pathlib.PurePath(*file_path) + with open(path) as json_file: + test_schema_dicts = json.load(json_file) + for test_schema_dict in test_schema_dicts: + test_schema_dict['tests'] = [JsonSchemaTestCase(**t) for t in test_schema_dict['tests']] + json_schema_test_schema = JsonSchemaTestSchema(**test_schema_dict) + test_case_desc = json_schema_test_schema.description + excluded_reason = excluded_case_to_reason.get(test_case_desc) + if excluded_reason: + print(f'Excluding {test_case_desc} because {excluded_reason}') + continue + + json_schema_test_schemas.append(json_schema_test_schema) + + return json_schema_test_schemas + +openapi_additions = 'openapi_additions' + +json_schema_test_file_to_folders = { + 'type.json': (json_schema_test_draft, openapi_additions) +} + +openapi_version = '3.0.3' + + +@dataclasses.dataclass +class OpenApiDocumentInfo: + title: str + description: str + version: str + +OpenApiSchema = typing.TypedDict( + 'OpenApiSchema', + { + 'type': str, + 'x-test-examples': typing.Dict[str, JsonSchemaTestCase], + 'items': 'OpenApiSchema' + } +) + +@dataclasses.dataclass +class OpenApiExample: + description: str + value: typing.Union[str, int, float, bool, None, list, dict] + +@dataclasses.dataclass +class OpenApiComponents: + schemas: typing.Dict[str, OpenApiSchema] + +@dataclasses.dataclass +class OpenApiDocument: + openapi: str + info: OpenApiDocumentInfo + paths: typing.Dict[str, typing.Any] + components: OpenApiComponents + + +def get_new_openapi() -> OpenApiDocument: + return OpenApiDocument( + openapi=openapi_version, + info=OpenApiDocumentInfo( + title=f"openapi {openapi_version} sample spec", + description=f"sample spec for testing openapi functionality, built from json schema tests for {json_schema_test_draft}", + version="0.0.1" + ), + paths={}, + components=OpenApiComponents( + schemas={}, + ) + ) + +def description_to_component_name(descr: str) -> str: + res = ''.join(descr.title().split()) + return re.sub(r'[^A-Za-z0-9 ]+', '', res) + +def get_test_case_name(test: JsonSchemaTestSchema) -> str: + res = ''.join(test.description.title().split()) + return re.sub(r'[^A-Za-z0-9 ]+', '', res) + +def get_openapi_from_test_file(json_schema_test_file: str, folders: typing.Tuple[str]) -> OpenApiDocument: + openapi = get_new_openapi() + for folder in folders: + file_path_tuple = (folder, json_schema_test_file) + test_schemas = get_json_schema_test_schemas(file_path_tuple) + for test_schema in test_schemas: + component_name = description_to_component_name(test_schema.description) + kwargs = { + 'x-test-examples': {} + } + schema = OpenApiSchema( + **test_schema.schema, **kwargs + ) + openapi.components.schemas[component_name] = schema + for test in test_schema.tests: + test_case_name = get_test_case_name(test) + schema['x-test-examples'][test_case_name] = test + return openapi + +for json_schema_test_file, folders in json_schema_test_file_to_folders.items(): + openapi = get_openapi_from_test_file(json_schema_test_file, folders) + print( + yaml.dump( + dataclasses.asdict(openapi), + sort_keys=False + ) + ) + filename_prefix = pathlib.Path(json_schema_test_file).stem + spec_out = f'{filename_prefix}.yaml' + with open(spec_out, 'w') as yaml_out: + yaml_out.write( + yaml.dump( + dataclasses.asdict(openapi), + sort_keys=False + ) + ) \ No newline at end of file diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml new file mode 100644 index 00000000000..d2991f6eaac --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml @@ -0,0 +1,275 @@ +openapi: 3.0.3 +info: + title: openapi 3.0.3 sample spec + description: sample spec for testing openapi functionality, built from json schema + tests for draft6 + version: 0.0.1 +paths: {} +components: + schemas: + IntegerTypeMatchesIntegers: + type: integer + x-test-examples: + AnIntegerIsAnInteger: + description: an integer is an integer + data: 1 + valid: true + AFloatWithZeroFractionalPartIsAnInteger: + description: a float with zero fractional part is an integer + data: 1.0 + valid: true + AFloatIsNotAnInteger: + description: a float is not an integer + data: 1.1 + valid: false + AStringIsNotAnInteger: + description: a string is not an integer + data: foo + valid: false + AStringIsStillNotAnIntegerEvenIfItLooksLikeOne: + description: a string is still not an integer, even if it looks like one + data: '1' + valid: false + AnObjectIsNotAnInteger: + description: an object is not an integer + data: {} + valid: false + AnArrayIsNotAnInteger: + description: an array is not an integer + data: [] + valid: false + ABooleanIsNotAnInteger: + description: a boolean is not an integer + data: true + valid: false + NullIsNotAnInteger: + description: null is not an integer + data: null + valid: false + NumberTypeMatchesNumbers: + type: number + x-test-examples: + AnIntegerIsANumber: + description: an integer is a number + data: 1 + valid: true + AFloatWithZeroFractionalPartIsANumberAndAnInteger: + description: a float with zero fractional part is a number (and an integer) + data: 1.0 + valid: true + AFloatIsANumber: + description: a float is a number + data: 1.1 + valid: true + AStringIsNotANumber: + description: a string is not a number + data: foo + valid: false + AStringIsStillNotANumberEvenIfItLooksLikeOne: + description: a string is still not a number, even if it looks like one + data: '1' + valid: false + AnObjectIsNotANumber: + description: an object is not a number + data: {} + valid: false + AnArrayIsNotANumber: + description: an array is not a number + data: [] + valid: false + ABooleanIsNotANumber: + description: a boolean is not a number + data: true + valid: false + NullIsNotANumber: + description: null is not a number + data: null + valid: false + StringTypeMatchesStrings: + type: string + x-test-examples: + 1IsNotAString: + description: 1 is not a string + data: 1 + valid: false + AFloatIsNotAString: + description: a float is not a string + data: 1.1 + valid: false + AStringIsAString: + description: a string is a string + data: foo + valid: true + AStringIsStillAStringEvenIfItLooksLikeANumber: + description: a string is still a string, even if it looks like a number + data: '1' + valid: true + AnEmptyStringIsStillAString: + description: an empty string is still a string + data: '' + valid: true + AnObjectIsNotAString: + description: an object is not a string + data: {} + valid: false + AnArrayIsNotAString: + description: an array is not a string + data: [] + valid: false + ABooleanIsNotAString: + description: a boolean is not a string + data: true + valid: false + NullIsNotAString: + description: null is not a string + data: null + valid: false + ObjectTypeMatchesObjects: + type: object + x-test-examples: + AnIntegerIsNotAnObject: + description: an integer is not an object + data: 1 + valid: false + AFloatIsNotAnObject: + description: a float is not an object + data: 1.1 + valid: false + AStringIsNotAnObject: + description: a string is not an object + data: foo + valid: false + AnObjectIsAnObject: + description: an object is an object + data: {} + valid: true + AnArrayIsNotAnObject: + description: an array is not an object + data: [] + valid: false + ABooleanIsNotAnObject: + description: a boolean is not an object + data: true + valid: false + NullIsNotAnObject: + description: null is not an object + data: null + valid: false + BooleanTypeMatchesBooleans: + type: boolean + x-test-examples: + AnIntegerIsNotABoolean: + description: an integer is not a boolean + data: 1 + valid: false + ZeroIsNotABoolean: + description: zero is not a boolean + data: 0 + valid: false + AFloatIsNotABoolean: + description: a float is not a boolean + data: 1.1 + valid: false + AStringIsNotABoolean: + description: a string is not a boolean + data: foo + valid: false + AnEmptyStringIsNotABoolean: + description: an empty string is not a boolean + data: '' + valid: false + AnObjectIsNotABoolean: + description: an object is not a boolean + data: {} + valid: false + AnArrayIsNotABoolean: + description: an array is not a boolean + data: [] + valid: false + TrueIsABoolean: + description: true is a boolean + data: true + valid: true + FalseIsABoolean: + description: false is a boolean + data: false + valid: true + NullIsNotABoolean: + description: null is not a boolean + data: null + valid: false + NullTypeMatchesOnlyTheNullObject: + type: 'null' + x-test-examples: + AnIntegerIsNotNull: + description: an integer is not null + data: 1 + valid: false + AFloatIsNotNull: + description: a float is not null + data: 1.1 + valid: false + ZeroIsNotNull: + description: zero is not null + data: 0 + valid: false + AStringIsNotNull: + description: a string is not null + data: foo + valid: false + AnEmptyStringIsNotNull: + description: an empty string is not null + data: '' + valid: false + AnObjectIsNotNull: + description: an object is not null + data: {} + valid: false + AnArrayIsNotNull: + description: an array is not null + data: [] + valid: false + TrueIsNotNull: + description: true is not null + data: true + valid: false + FalseIsNotNull: + description: false is not null + data: false + valid: false + NullIsNull: + description: null is null + data: null + valid: true + ArrayTypeMatchesArrays: + type: array + items: {} + x-test-examples: + AnIntegerIsNotAnArray: + description: an integer is not an array + data: 1 + valid: false + AFloatIsNotAnArray: + description: a float is not an array + data: 1.1 + valid: false + AStringIsNotAnArray: + description: a string is not an array + data: foo + valid: false + AnObjectIsNotAnArray: + description: an object is not an array + data: {} + valid: false + AnArrayIsAnArray: + description: an array is an array + data: [] + valid: true + ABooleanIsNotAnArray: + description: a boolean is not an array + data: true + valid: false + NullIsNotAnArray: + description: null is not an array + data: null + valid: false diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.gitignore b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.gitignore new file mode 100644 index 00000000000..a62e8aba43f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.gitignore @@ -0,0 +1,67 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt +dev-requirements.txt.log + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ +venv/ +.venv/ +.python-version +.pytest_cache + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +#Ipython Notebook +.ipynb_checkpoints diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.gitlab-ci.yml b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.gitlab-ci.yml new file mode 100644 index 00000000000..22e33bfaa20 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.gitlab-ci.yml @@ -0,0 +1,24 @@ +# ref: https://docs.gitlab.com/ee/ci/README.html + +stages: + - test + +.tests: + stage: test + script: + - pip install -r requirements.txt + - pip install -r test-requirements.txt + - pytest --cov=unit_test_api + +test-3.5: + extends: .tests + image: python:3.5-alpine +test-3.6: + extends: .tests + image: python:3.6-alpine +test-3.7: + extends: .tests + image: python:3.7-alpine +test-3.8: + extends: .tests + image: python:3.8-alpine diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator-ignore b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator-ignore new file mode 100644 index 00000000000..7484ee590a3 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES new file mode 100644 index 00000000000..6fa4115e71a --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -0,0 +1,33 @@ +.gitignore +.gitlab-ci.yml +.travis.yml +README.md +docs/ArrayTypeMatchesArrays.md +docs/BooleanTypeMatchesBooleans.md +docs/IntegerTypeMatchesIntegers.md +docs/NullTypeMatchesOnlyTheNullObject.md +docs/NumberTypeMatchesNumbers.md +docs/StringTypeMatchesStrings.md +git_push.sh +requirements.txt +setup.cfg +setup.py +test-requirements.txt +test/__init__.py +tox.ini +unit_test_api/__init__.py +unit_test_api/api/__init__.py +unit_test_api/api_client.py +unit_test_api/apis/__init__.py +unit_test_api/configuration.py +unit_test_api/exceptions.py +unit_test_api/model/__init__.py +unit_test_api/model/array_type_matches_arrays.py +unit_test_api/model/boolean_type_matches_booleans.py +unit_test_api/model/integer_type_matches_integers.py +unit_test_api/model/null_type_matches_only_the_null_object.py +unit_test_api/model/number_type_matches_numbers.py +unit_test_api/model/string_type_matches_strings.py +unit_test_api/models/__init__.py +unit_test_api/rest.py +unit_test_api/schemas.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/VERSION b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/VERSION new file mode 100644 index 00000000000..717311e32e3 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/VERSION @@ -0,0 +1 @@ +unset \ No newline at end of file diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.travis.yml b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.travis.yml new file mode 100644 index 00000000000..a0d79cf14a9 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.travis.yml @@ -0,0 +1,13 @@ +# ref: https://docs.travis-ci.com/user/languages/python +language: python +python: + - "3.5" + - "3.6" + - "3.7" + - "3.8" +# command to install dependencies +install: + - "pip install -r requirements.txt" + - "pip install -r test-requirements.txt" +# command to run tests +script: pytest --cov=unit_test_api diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/Makefile b/samples/openapi3/client/3_0_3_unit_test/python-experimental/Makefile new file mode 100644 index 00000000000..863c380ebef --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/Makefile @@ -0,0 +1,16 @@ +REQUIREMENTS_FILE=dev-requirements.txt +REQUIREMENTS_OUT=dev-requirements.txt.log +SETUP_OUT=*.egg-info +VENV=venv + +clean: + rm -rf $(REQUIREMENTS_OUT) + rm -rf $(SETUP_OUT) + rm -rf $(VENV) + rm -rf .tox + rm -rf .coverage + find . -name "*.py[oc]" -delete + find . -name "__pycache__" -delete + +test: clean + bash ./test_python.sh \ No newline at end of file diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md new file mode 100644 index 00000000000..f0a363fdef8 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md @@ -0,0 +1,96 @@ +# unit-test-api +sample spec for testing openapi functionality, built from json schema tests for draft6 + +This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: + +- API version: 0.0.1 +- Package version: 1.0.0 +- Build package: org.openapitools.codegen.languages.PythonExperimentalClientCodegen + +## Requirements. + +Python >=3.9 +v3.9 is needed so one can combine classmethod and property decorators to define +object schema properties as classes + +## Installation & Usage +### pip install + +If the python package is hosted on a repository, you can install directly using: + +```sh +pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git +``` +(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git`) + +Then import the package: +```python +import unit_test_api +``` + +### Setuptools + +Install via [Setuptools](http://pypi.python.org/pypi/setuptools). + +```sh +python setup.py install --user +``` +(or `sudo python setup.py install` to install the package for all users) + +Then import the package: +```python +import unit_test_api +``` + +## Getting Started + +Please follow the [installation procedure](#installation--usage) and then run the following: + +```python + +import time +import unit_test_api +from pprint import pprint +``` + +## Documentation for API Endpoints + +All URIs are relative to *http://localhost* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- + +## Documentation For Models + + - [ArrayTypeMatchesArrays](docs/ArrayTypeMatchesArrays.md) + - [BooleanTypeMatchesBooleans](docs/BooleanTypeMatchesBooleans.md) + - [IntegerTypeMatchesIntegers](docs/IntegerTypeMatchesIntegers.md) + - [NullTypeMatchesOnlyTheNullObject](docs/NullTypeMatchesOnlyTheNullObject.md) + - [NumberTypeMatchesNumbers](docs/NumberTypeMatchesNumbers.md) + - [StringTypeMatchesStrings](docs/StringTypeMatchesStrings.md) + +## Documentation For Authorization + + All endpoints do not require authorization. + +## Author + + +## Notes for Large OpenAPI documents +If the OpenAPI document is large, imports in unit_test_api.apis and unit_test_api.models may fail with a +RecursionError indicating the maximum recursion limit has been exceeded. In that case, there are a couple of solutions: + +Solution 1: +Use specific imports for apis and models like: +- `from unit_test_api.api.default_api import DefaultApi` +- `from unit_test_api.model.pet import Pet` + +Solution 1: +Before importing the package, adjust the maximum recursion limit as shown below: +``` +import sys +sys.setrecursionlimit(1500) +import unit_test_api +from unit_test_api.apis import * +from unit_test_api.models import * +``` diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/dev-requirements.txt b/samples/openapi3/client/3_0_3_unit_test/python-experimental/dev-requirements.txt new file mode 100644 index 00000000000..ccdfca62949 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/dev-requirements.txt @@ -0,0 +1,2 @@ +tox +flake8 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ArrayTypeMatchesArrays.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ArrayTypeMatchesArrays.md new file mode 100644 index 00000000000..bf72f2c35bc --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ArrayTypeMatchesArrays.md @@ -0,0 +1,8 @@ +# ArrayTypeMatchesArrays + +Type | Description | Notes +------------- | ------------- | ------------- +**[bool, date, datetime, dict, float, int, list, str, none_type]** | | + +[[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/3_0_3_unit_test/python-experimental/docs/BooleanTypeMatchesBooleans.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/BooleanTypeMatchesBooleans.md new file mode 100644 index 00000000000..fa68a60fd2b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/BooleanTypeMatchesBooleans.md @@ -0,0 +1,8 @@ +# BooleanTypeMatchesBooleans + +Type | Description | Notes +------------- | ------------- | ------------- +**bool** | | + +[[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/3_0_3_unit_test/python-experimental/docs/IntegerTypeMatchesIntegers.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/IntegerTypeMatchesIntegers.md new file mode 100644 index 00000000000..141e17fd9ae --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/IntegerTypeMatchesIntegers.md @@ -0,0 +1,8 @@ +# IntegerTypeMatchesIntegers + +Type | Description | Notes +------------- | ------------- | ------------- +**int** | | + +[[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/3_0_3_unit_test/python-experimental/docs/NullTypeMatchesOnlyTheNullObject.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NullTypeMatchesOnlyTheNullObject.md new file mode 100644 index 00000000000..54a530d1d33 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NullTypeMatchesOnlyTheNullObject.md @@ -0,0 +1,8 @@ +# NullTypeMatchesOnlyTheNullObject + +Type | Description | Notes +------------- | ------------- | ------------- +**none_type** | | + +[[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/3_0_3_unit_test/python-experimental/docs/NumberTypeMatchesNumbers.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NumberTypeMatchesNumbers.md new file mode 100644 index 00000000000..8348aeef2bc --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NumberTypeMatchesNumbers.md @@ -0,0 +1,8 @@ +# NumberTypeMatchesNumbers + +Type | Description | Notes +------------- | ------------- | ------------- +**float** | | + +[[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/3_0_3_unit_test/python-experimental/docs/StringTypeMatchesStrings.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/StringTypeMatchesStrings.md new file mode 100644 index 00000000000..cd1125671ab --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/StringTypeMatchesStrings.md @@ -0,0 +1,8 @@ +# StringTypeMatchesStrings + +Type | Description | Notes +------------- | ------------- | ------------- +**str** | | + +[[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/3_0_3_unit_test/python-experimental/git_push.sh b/samples/openapi3/client/3_0_3_unit_test/python-experimental/git_push.sh new file mode 100644 index 00000000000..ced3be2b0c7 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/git_push.sh @@ -0,0 +1,58 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/pom.xml b/samples/openapi3/client/3_0_3_unit_test/python-experimental/pom.xml new file mode 100644 index 00000000000..5352ff0ac54 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/pom.xml @@ -0,0 +1,46 @@ +<project> + <modelVersion>4.0.0</modelVersion> + <groupId>org.openapitools</groupId> + <artifactId>PythonExperimental303UnitTests</artifactId> + <packaging>pom</packaging> + <version>1.0-SNAPSHOT</version> + <name>Python Experimental OpenAPI3 Unit Test Api Client</name> + <build> + <plugins> + <plugin> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>copy-dependencies</goal> + </goals> + <configuration> + <outputDirectory>${project.build.directory}</outputDirectory> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <version>1.2.1</version> + <executions> + <execution> + <id>test</id> + <phase>integration-test</phase> + <goals> + <goal>exec</goal> + </goals> + <configuration> + <executable>make</executable> + <arguments> + <argument>test</argument> + </arguments> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/requirements.txt b/samples/openapi3/client/3_0_3_unit_test/python-experimental/requirements.txt new file mode 100644 index 00000000000..c9227e58a1b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/requirements.txt @@ -0,0 +1,5 @@ +certifi >= 14.05.14 +frozendict >= 2.0.3 +python_dateutil >= 2.5.3 +setuptools >= 21.0.0 +urllib3 >= 1.15.1 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/setup.cfg b/samples/openapi3/client/3_0_3_unit_test/python-experimental/setup.cfg new file mode 100644 index 00000000000..11433ee875a --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/setup.cfg @@ -0,0 +1,2 @@ +[flake8] +max-line-length=99 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/setup.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/setup.py new file mode 100644 index 00000000000..bac2d323981 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/setup.py @@ -0,0 +1,45 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +from setuptools import setup, find_packages # noqa: H301 + +NAME = "unit-test-api" +VERSION = "1.0.0" +# To install the library, run the following +# +# python setup.py install +# +# prerequisite: setuptools +# http://pypi.python.org/pypi/setuptools + +REQUIRES = [ + "urllib3 >= 1.15", + "certifi", + "python-dateutil", + "frozendict >= 2.0.3", +] + +setup( + name=NAME, + version=VERSION, + description="openapi 3.0.3 sample spec", + author="OpenAPI Generator community", + author_email="team@openapitools.org", + url="", + keywords=["OpenAPI", "OpenAPI-Generator", "openapi 3.0.3 sample spec"], + python_requires=">=3.9", + install_requires=REQUIRES, + packages=find_packages(exclude=["test", "tests"]), + include_package_data=True, + long_description="""\ + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + """ +) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test-requirements.txt b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test-requirements.txt new file mode 100644 index 00000000000..2d88b034192 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test-requirements.txt @@ -0,0 +1,3 @@ +pytest~=4.6.7 # needed for python 3.4 +pytest-cov>=2.8.1 +pytest-randomly==1.2.3 # needed for python 3.4 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py new file mode 100644 index 00000000000..47e27f0ea52 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py @@ -0,0 +1,73 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.array_type_matches_arrays import ArrayTypeMatchesArrays + + +class TestArrayTypeMatchesArrays(unittest.TestCase): + """ArrayTypeMatchesArrays unit test stubs""" + + def test_a_float_is_not_an_array_fails(self): + # a float is not an array + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + ArrayTypeMatchesArrays( + 1.1 + ) + + def test_a_boolean_is_not_an_array_fails(self): + # a boolean is not an array + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + ArrayTypeMatchesArrays( + True + ) + + def test_null_is_not_an_array_fails(self): + # null is not an array + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + ArrayTypeMatchesArrays( + None + ) + + def test_an_object_is_not_an_array_fails(self): + # an object is not an array + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + ArrayTypeMatchesArrays( + { + } + ) + + def test_a_string_is_not_an_array_fails(self): + # a string is not an array + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + ArrayTypeMatchesArrays( + "foo" + ) + + def test_an_array_is_an_array_passes(self): + # an array is an array + ArrayTypeMatchesArrays( + [ + ] + ) + + def test_an_integer_is_not_an_array_fails(self): + # an integer is not an array + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + ArrayTypeMatchesArrays( + 1 + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py new file mode 100644 index 00000000000..6e6fab281e7 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py @@ -0,0 +1,93 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.boolean_type_matches_booleans import BooleanTypeMatchesBooleans + + +class TestBooleanTypeMatchesBooleans(unittest.TestCase): + """BooleanTypeMatchesBooleans unit test stubs""" + + def test_an_empty_string_is_not_a_boolean_fails(self): + # an empty string is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + BooleanTypeMatchesBooleans( + "" + ) + + def test_a_float_is_not_a_boolean_fails(self): + # a float is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + BooleanTypeMatchesBooleans( + 1.1 + ) + + def test_null_is_not_a_boolean_fails(self): + # null is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + BooleanTypeMatchesBooleans( + None + ) + + def test_zero_is_not_a_boolean_fails(self): + # zero is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + BooleanTypeMatchesBooleans( + 0 + ) + + def test_an_array_is_not_a_boolean_fails(self): + # an array is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + BooleanTypeMatchesBooleans( + [ + ] + ) + + def test_a_string_is_not_a_boolean_fails(self): + # a string is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + BooleanTypeMatchesBooleans( + "foo" + ) + + def test_false_is_a_boolean_passes(self): + # false is a boolean + BooleanTypeMatchesBooleans( + False + ) + + def test_an_integer_is_not_a_boolean_fails(self): + # an integer is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + BooleanTypeMatchesBooleans( + 1 + ) + + def test_true_is_a_boolean_passes(self): + # true is a boolean + BooleanTypeMatchesBooleans( + True + ) + + def test_an_object_is_not_a_boolean_fails(self): + # an object is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + BooleanTypeMatchesBooleans( + { + } + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py new file mode 100644 index 00000000000..b118d36ab04 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py @@ -0,0 +1,86 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.integer_type_matches_integers import IntegerTypeMatchesIntegers + + +class TestIntegerTypeMatchesIntegers(unittest.TestCase): + """IntegerTypeMatchesIntegers unit test stubs""" + + def test_an_object_is_not_an_integer_fails(self): + # an object is not an integer + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + IntegerTypeMatchesIntegers( + { + } + ) + + def test_a_string_is_not_an_integer_fails(self): + # a string is not an integer + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + IntegerTypeMatchesIntegers( + "foo" + ) + + def test_null_is_not_an_integer_fails(self): + # null is not an integer + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + IntegerTypeMatchesIntegers( + None + ) + + def test_a_float_with_zero_fractional_part_is_an_integer_passes(self): + # a float with zero fractional part is an integer + IntegerTypeMatchesIntegers( + 1.0 + ) + + def test_a_float_is_not_an_integer_fails(self): + # a float is not an integer + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + IntegerTypeMatchesIntegers( + 1.1 + ) + + def test_a_boolean_is_not_an_integer_fails(self): + # a boolean is not an integer + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + IntegerTypeMatchesIntegers( + True + ) + + def test_an_integer_is_an_integer_passes(self): + # an integer is an integer + IntegerTypeMatchesIntegers( + 1 + ) + + def test_a_string_is_still_not_an_integer_even_if_it_looks_like_one_fails(self): + # a string is still not an integer, even if it looks like one + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + IntegerTypeMatchesIntegers( + "1" + ) + + def test_an_array_is_not_an_integer_fails(self): + # an array is not an integer + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + IntegerTypeMatchesIntegers( + [ + ] + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py new file mode 100644 index 00000000000..bf8b35d150a --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py @@ -0,0 +1,94 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.null_type_matches_only_the_null_object import NullTypeMatchesOnlyTheNullObject + + +class TestNullTypeMatchesOnlyTheNullObject(unittest.TestCase): + """NullTypeMatchesOnlyTheNullObject unit test stubs""" + + def test_a_float_is_not_null_fails(self): + # a float is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NullTypeMatchesOnlyTheNullObject( + 1.1 + ) + + def test_an_object_is_not_null_fails(self): + # an object is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NullTypeMatchesOnlyTheNullObject( + { + } + ) + + def test_false_is_not_null_fails(self): + # false is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NullTypeMatchesOnlyTheNullObject( + False + ) + + def test_an_integer_is_not_null_fails(self): + # an integer is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NullTypeMatchesOnlyTheNullObject( + 1 + ) + + def test_true_is_not_null_fails(self): + # true is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NullTypeMatchesOnlyTheNullObject( + True + ) + + def test_zero_is_not_null_fails(self): + # zero is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NullTypeMatchesOnlyTheNullObject( + 0 + ) + + def test_an_empty_string_is_not_null_fails(self): + # an empty string is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NullTypeMatchesOnlyTheNullObject( + "" + ) + + def test_null_is_null_passes(self): + # null is null + NullTypeMatchesOnlyTheNullObject( + None + ) + + def test_an_array_is_not_null_fails(self): + # an array is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NullTypeMatchesOnlyTheNullObject( + [ + ] + ) + + def test_a_string_is_not_null_fails(self): + # a string is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NullTypeMatchesOnlyTheNullObject( + "foo" + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py new file mode 100644 index 00000000000..24a4c25c842 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py @@ -0,0 +1,85 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.number_type_matches_numbers import NumberTypeMatchesNumbers + + +class TestNumberTypeMatchesNumbers(unittest.TestCase): + """NumberTypeMatchesNumbers unit test stubs""" + + def test_an_array_is_not_a_number_fails(self): + # an array is not a number + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NumberTypeMatchesNumbers( + [ + ] + ) + + def test_null_is_not_a_number_fails(self): + # null is not a number + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NumberTypeMatchesNumbers( + None + ) + + def test_an_object_is_not_a_number_fails(self): + # an object is not a number + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NumberTypeMatchesNumbers( + { + } + ) + + def test_a_boolean_is_not_a_number_fails(self): + # a boolean is not a number + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NumberTypeMatchesNumbers( + True + ) + + def test_a_float_is_a_number_passes(self): + # a float is a number + NumberTypeMatchesNumbers( + 1.1 + ) + + def test_a_string_is_still_not_a_number_even_if_it_looks_like_one_fails(self): + # a string is still not a number, even if it looks like one + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NumberTypeMatchesNumbers( + "1" + ) + + def test_a_string_is_not_a_number_fails(self): + # a string is not a number + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NumberTypeMatchesNumbers( + "foo" + ) + + def test_an_integer_is_a_number_passes(self): + # an integer is a number + NumberTypeMatchesNumbers( + 1 + ) + + def test_a_float_with_zero_fractional_part_is_a_number_and_an_integer_passes(self): + # a float with zero fractional part is a number (and an integer) + NumberTypeMatchesNumbers( + 1.0 + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py new file mode 100644 index 00000000000..8dedf398200 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py @@ -0,0 +1,85 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.string_type_matches_strings import StringTypeMatchesStrings + + +class TestStringTypeMatchesStrings(unittest.TestCase): + """StringTypeMatchesStrings unit test stubs""" + + def test_1_is_not_a_string_fails(self): + # 1 is not a string + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + StringTypeMatchesStrings( + 1 + ) + + def test_a_string_is_still_a_string_even_if_it_looks_like_a_number_passes(self): + # a string is still a string, even if it looks like a number + StringTypeMatchesStrings( + "1" + ) + + def test_an_empty_string_is_still_a_string_passes(self): + # an empty string is still a string + StringTypeMatchesStrings( + "" + ) + + def test_a_float_is_not_a_string_fails(self): + # a float is not a string + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + StringTypeMatchesStrings( + 1.1 + ) + + def test_an_object_is_not_a_string_fails(self): + # an object is not a string + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + StringTypeMatchesStrings( + { + } + ) + + def test_an_array_is_not_a_string_fails(self): + # an array is not a string + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + StringTypeMatchesStrings( + [ + ] + ) + + def test_a_boolean_is_not_a_string_fails(self): + # a boolean is not a string + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + StringTypeMatchesStrings( + True + ) + + def test_null_is_not_a_string_fails(self): + # null is not a string + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + StringTypeMatchesStrings( + None + ) + + def test_a_string_is_a_string_passes(self): + # a string is a string + StringTypeMatchesStrings( + "foo" + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test_python.sh b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test_python.sh new file mode 100755 index 00000000000..9728a9b5316 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test_python.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +REQUIREMENTS_FILE=dev-requirements.txt +REQUIREMENTS_OUT=dev-requirements.txt.log +SETUP_OUT=*.egg-info +VENV=venv +DEACTIVE=false + +export LC_ALL=en_US.UTF-8 +export LANG=en_US.UTF-8 + +### set virtualenv +if [ -z "$VENVV" ]; then + python3 -m venv $VENV + source $VENV/bin/activate + DEACTIVE=true +fi + +### install dependencies +pip install -r $REQUIREMENTS_FILE | tee -a $REQUIREMENTS_OUT +### locally install the package, needed for pycharm problem checking +pip install -e . + +### run tests +tox || exit 1 + +### static analysis of code +#flake8 --show-source petstore_api/ + +### deactivate virtualenv +#if [ $DEACTIVE == true ]; then +# deactivate +#fi diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/tox.ini b/samples/openapi3/client/3_0_3_unit_test/python-experimental/tox.ini new file mode 100644 index 00000000000..e4093b56ea7 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/tox.ini @@ -0,0 +1,9 @@ +[tox] +envlist = py39 + +[testenv] +deps=-r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + +commands= + pytest --cov=unit_test_api diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/__init__.py new file mode 100644 index 00000000000..5ca6e989be0 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/__init__.py @@ -0,0 +1,28 @@ +# coding: utf-8 + +# flake8: noqa + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +__version__ = "1.0.0" + +# import ApiClient +from unit_test_api.api_client import ApiClient + +# import Configuration +from unit_test_api.configuration import Configuration + +# import exceptions +from unit_test_api.exceptions import OpenApiException +from unit_test_api.exceptions import ApiAttributeError +from unit_test_api.exceptions import ApiTypeError +from unit_test_api.exceptions import ApiValueError +from unit_test_api.exceptions import ApiKeyError +from unit_test_api.exceptions import ApiException diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/api/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/api/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/api_client.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/api_client.py new file mode 100644 index 00000000000..66e52cba296 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/api_client.py @@ -0,0 +1,1420 @@ +# coding: utf-8 +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +from dataclasses import dataclass +from decimal import Decimal +import enum +import email +import json +import os +import io +import atexit +from multiprocessing.pool import ThreadPool +import re +import tempfile +import typing +import urllib3 +from urllib3._collections import HTTPHeaderDict +from urllib.parse import quote +from urllib3.fields import RequestField as RequestFieldBase + + +from unit_test_api import rest +from unit_test_api.configuration import Configuration +from unit_test_api.exceptions import ApiTypeError, ApiValueError +from unit_test_api.schemas import ( + NoneClass, + BoolClass, + Schema, + FileIO, + BinarySchema, + date, + datetime, + none_type, + frozendict, + Unset, + unset, +) + + +class RequestField(RequestFieldBase): + def __eq__(self, other): + if not isinstance(other, RequestField): + return False + return self.__dict__ == other.__dict__ + + +class JSONEncoder(json.JSONEncoder): + def default(self, obj): + if isinstance(obj, str): + return str(obj) + elif isinstance(obj, float): + return float(obj) + elif isinstance(obj, int): + return int(obj) + elif isinstance(obj, Decimal): + if obj.as_tuple().exponent >= 0: + return int(obj) + return float(obj) + elif isinstance(obj, NoneClass): + return None + elif isinstance(obj, BoolClass): + return bool(obj) + elif isinstance(obj, (dict, frozendict)): + return {key: self.default(val) for key, val in obj.items()} + elif isinstance(obj, (list, tuple)): + return [self.default(item) for item in obj] + raise ApiValueError('Unable to prepare type {} for serialization'.format(obj.__class__.__name__)) + + +class ParameterInType(enum.Enum): + QUERY = 'query' + HEADER = 'header' + PATH = 'path' + COOKIE = 'cookie' + + +class ParameterStyle(enum.Enum): + MATRIX = 'matrix' + LABEL = 'label' + FORM = 'form' + SIMPLE = 'simple' + SPACE_DELIMITED = 'spaceDelimited' + PIPE_DELIMITED = 'pipeDelimited' + DEEP_OBJECT = 'deepObject' + + +class PrefixSeparatorIterator: + # A class to store prefixes and separators for rfc6570 expansions + + def __init__(self, prefix: str, separator: str): + self.prefix = prefix + self.separator = separator + self.first = True + if separator in {'.', '|', '%20'}: + item_separator = separator + else: + item_separator = ',' + self.item_separator = item_separator + + def __iter__(self): + return self + + def __next__(self): + if self.first: + self.first = False + return self.prefix + return self.separator + + +class ParameterSerializerBase: + @classmethod + def get_default_explode(cls, style: ParameterStyle) -> bool: + return False + + @staticmethod + def __ref6570_item_value(in_data: typing.Any, percent_encode: bool): + """ + Get representation if str/float/int/None/items in list/ values in dict + None is returned if an item is undefined, use cases are value= + - None + - [] + - {} + - [None, None None] + - {'a': None, 'b': None} + """ + if type(in_data) in {str, float, int}: + if percent_encode: + return quote(str(in_data)) + return str(in_data) + elif isinstance(in_data, none_type): + # ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1 + return None + elif isinstance(in_data, list) and not in_data: + # ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1 + return None + elif isinstance(in_data, dict) and not in_data: + # ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1 + return None + raise ApiValueError('Unable to generate a ref6570 item representation of {}'.format(in_data)) + + @staticmethod + def to_dict(name: str, value: str): + return {name: value} + + @classmethod + def ref6570_expansion( + cls, + variable_name: str, + in_data: typing.Any, + explode: bool, + percent_encode: bool, + prefix_separator_iterator: PrefixSeparatorIterator + ) -> str: + """ + Separator is for separate variables like dict with explode true, not for array item separation + """ + named_parameter_expansion = prefix_separator_iterator.separator in {'&', ';'} + var_name_piece = variable_name if named_parameter_expansion else '' + if type(in_data) in {str, float, int}: + item_value = cls.__ref6570_item_value(in_data, percent_encode) + if item_value is None: + return next(prefix_separator_iterator) + var_name_piece + elif item_value == '' and prefix_separator_iterator.separator == ';': + return next(prefix_separator_iterator) + var_name_piece + value_pair_equals = '=' if named_parameter_expansion else '' + return next(prefix_separator_iterator) + var_name_piece + value_pair_equals + item_value + elif isinstance(in_data, none_type): + # ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1 + return "" + elif isinstance(in_data, list): + item_values = [cls.__ref6570_item_value(v, percent_encode) for v in in_data] + item_values = [v for v in item_values if v is not None] + if not item_values: + # ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1 + return "" + value_pair_equals = '=' if named_parameter_expansion else '' + if not explode: + return ( + next(prefix_separator_iterator) + + var_name_piece + + value_pair_equals + + prefix_separator_iterator.item_separator.join(item_values) + ) + # exploded + return next(prefix_separator_iterator) + next(prefix_separator_iterator).join( + [var_name_piece + value_pair_equals + val for val in item_values] + ) + elif isinstance(in_data, dict): + in_data_transformed = {key: cls.__ref6570_item_value(val, percent_encode) for key, val in in_data.items()} + in_data_transformed = {key: val for key, val in in_data_transformed.items() if val is not None} + if not in_data_transformed: + # ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1 + return "" + value_pair_equals = '=' if named_parameter_expansion else '' + if not explode: + return ( + next(prefix_separator_iterator) + + var_name_piece + value_pair_equals + + prefix_separator_iterator.item_separator.join( + prefix_separator_iterator.item_separator.join( + item_pair + ) for item_pair in in_data_transformed.items() + ) + ) + # exploded + return next(prefix_separator_iterator) + next(prefix_separator_iterator).join( + [key + '=' + val for key, val in in_data_transformed.items()] + ) + # bool, bytes, etc + raise ApiValueError('Unable to generate a ref6570 representation of {}'.format(in_data)) + + +class StyleFormSerializer(ParameterSerializerBase): + @classmethod + def get_default_explode(cls, style: ParameterStyle) -> bool: + if style is ParameterStyle.FORM: + return True + return super().get_default_explode(style) + + def serialize_form( + self, + in_data: typing.Union[None, int, float, str, bool, dict, list], + name: str, + explode: bool, + percent_encode: bool, + prefix_separator_iterator: typing.Optional[PrefixSeparatorIterator] = None + ) -> str: + if prefix_separator_iterator is None: + prefix_separator_iterator = PrefixSeparatorIterator('?', '&') + return self.ref6570_expansion( + variable_name=name, + in_data=in_data, + explode=explode, + percent_encode=percent_encode, + prefix_separator_iterator=prefix_separator_iterator + ) + + +class StyleSimpleSerializer(ParameterSerializerBase): + + def serialize_simple( + self, + in_data: typing.Union[None, int, float, str, bool, dict, list], + name: str, + explode: bool, + percent_encode: bool + ) -> str: + prefix_separator_iterator = PrefixSeparatorIterator('', ',') + return self.ref6570_expansion( + variable_name=name, + in_data=in_data, + explode=explode, + percent_encode=percent_encode, + prefix_separator_iterator=prefix_separator_iterator + ) + + +@dataclass +class ParameterBase: + name: str + in_type: ParameterInType + required: bool + style: typing.Optional[ParameterStyle] + explode: typing.Optional[bool] + allow_reserved: typing.Optional[bool] + schema: typing.Optional[typing.Type[Schema]] + content: typing.Optional[typing.Dict[str, typing.Type[Schema]]] + + __style_to_in_type = { + ParameterStyle.MATRIX: {ParameterInType.PATH}, + ParameterStyle.LABEL: {ParameterInType.PATH}, + ParameterStyle.FORM: {ParameterInType.QUERY, ParameterInType.COOKIE}, + ParameterStyle.SIMPLE: {ParameterInType.PATH, ParameterInType.HEADER}, + ParameterStyle.SPACE_DELIMITED: {ParameterInType.QUERY}, + ParameterStyle.PIPE_DELIMITED: {ParameterInType.QUERY}, + ParameterStyle.DEEP_OBJECT: {ParameterInType.QUERY}, + } + __in_type_to_default_style = { + ParameterInType.QUERY: ParameterStyle.FORM, + ParameterInType.PATH: ParameterStyle.SIMPLE, + ParameterInType.HEADER: ParameterStyle.SIMPLE, + ParameterInType.COOKIE: ParameterStyle.FORM, + } + __disallowed_header_names = {'Accept', 'Content-Type', 'Authorization'} + _json_encoder = JSONEncoder() + _json_content_type = 'application/json' + + @classmethod + def __verify_style_to_in_type(cls, style: typing.Optional[ParameterStyle], in_type: ParameterInType): + if style is None: + return + in_type_set = cls.__style_to_in_type[style] + if in_type not in in_type_set: + raise ValueError( + 'Invalid style and in_type combination. For style={} only in_type={} are allowed'.format( + style, in_type_set + ) + ) + + def __init__( + self, + name: str, + in_type: ParameterInType, + required: bool = False, + style: typing.Optional[ParameterStyle] = None, + explode: bool = False, + allow_reserved: typing.Optional[bool] = None, + schema: typing.Optional[typing.Type[Schema]] = None, + content: typing.Optional[typing.Dict[str, typing.Type[Schema]]] = None + ): + if schema is None and content is None: + raise ValueError('Value missing; Pass in either schema or content') + if schema and content: + raise ValueError('Too many values provided. Both schema and content were provided. Only one may be input') + if name in self.__disallowed_header_names and in_type is ParameterInType.HEADER: + raise ValueError('Invalid name, name may not be one of {}'.format(self.__disallowed_header_names)) + self.__verify_style_to_in_type(style, in_type) + if content is None and style is None: + style = self.__in_type_to_default_style[in_type] + if content is not None and in_type in self.__in_type_to_default_style and len(content) != 1: + raise ValueError('Invalid content length, content length must equal 1') + self.in_type = in_type + self.name = name + self.required = required + self.style = style + self.explode = explode + self.allow_reserved = allow_reserved + self.schema = schema + self.content = content + + @staticmethod + def _remove_empty_and_cast( + in_data: typing.Tuple[typing.Tuple[str, str]], + ) -> typing.Dict[str, str]: + data = tuple(t for t in in_data if t) + if not data: + return dict() + return dict(data) + + def _serialize_json( + self, + in_data: typing.Union[None, int, float, str, bool, dict, list] + ) -> str: + return json.dumps(in_data) + + +class PathParameter(ParameterBase, StyleSimpleSerializer): + + def __init__( + self, + name: str, + required: bool = False, + style: typing.Optional[ParameterStyle] = None, + explode: bool = False, + allow_reserved: typing.Optional[bool] = None, + schema: typing.Optional[typing.Type[Schema]] = None, + content: typing.Optional[typing.Dict[str, typing.Type[Schema]]] = None + ): + super().__init__( + name, + in_type=ParameterInType.PATH, + required=required, + style=style, + explode=explode, + allow_reserved=allow_reserved, + schema=schema, + content=content + ) + + def _serialize_label( + self, + in_data: typing.Union[None, int, float, str, bool, dict, list] + ) -> typing.Dict[str, str]: + prefix_separator_iterator = PrefixSeparatorIterator('.', '.') + value = self.ref6570_expansion( + variable_name=self.name, + in_data=in_data, + explode=self.explode, + percent_encode=True, + prefix_separator_iterator=prefix_separator_iterator + ) + return self.to_dict(self.name, value) + + def _serialize_matrix( + self, + in_data: typing.Union[None, int, float, str, bool, dict, list] + ) -> typing.Dict[str, str]: + prefix_separator_iterator = PrefixSeparatorIterator(';', ';') + value = self.ref6570_expansion( + variable_name=self.name, + in_data=in_data, + explode=self.explode, + percent_encode=True, + prefix_separator_iterator=prefix_separator_iterator + ) + return self.to_dict(self.name, value) + + def _serialize_simple( + self, + in_data: typing.Union[None, int, float, str, bool, dict, list], + ) -> typing.Dict[str, str]: + value = self.serialize_simple( + in_data=in_data, + name=self.name, + explode=self.explode, + percent_encode=True + ) + return self.to_dict(self.name, value) + + def serialize( + self, + in_data: typing.Union[ + Schema, Decimal, int, float, str, date, datetime, None, bool, list, tuple, dict, frozendict] + ) -> typing.Dict[str, str]: + if self.schema: + cast_in_data = self.schema(in_data) + cast_in_data = self._json_encoder.default(cast_in_data) + """ + simple -> path + path: + returns path_params: dict + label -> path + returns path_params + matrix -> path + returns path_params + """ + if self.style: + if self.style is ParameterStyle.SIMPLE: + return self._serialize_simple(cast_in_data) + elif self.style is ParameterStyle.LABEL: + return self._serialize_label(cast_in_data) + elif self.style is ParameterStyle.MATRIX: + return self._serialize_matrix(cast_in_data) + # self.content will be length one + for content_type, schema in self.content.items(): + cast_in_data = schema(in_data) + cast_in_data = self._json_encoder.default(cast_in_data) + if content_type == self._json_content_type: + value = self._serialize_json(cast_in_data) + return self.to_dict(self.name, value) + raise NotImplementedError('Serialization of {} has not yet been implemented'.format(content_type)) + + +class QueryParameter(ParameterBase, StyleFormSerializer): + + def __init__( + self, + name: str, + required: bool = False, + style: typing.Optional[ParameterStyle] = None, + explode: typing.Optional[bool] = None, + allow_reserved: typing.Optional[bool] = None, + schema: typing.Optional[typing.Type[Schema]] = None, + content: typing.Optional[typing.Dict[str, typing.Type[Schema]]] = None + ): + used_style = ParameterStyle.FORM if style is None and content is None and schema else style + used_explode = self.get_default_explode(used_style) if explode is None else explode + + super().__init__( + name, + in_type=ParameterInType.QUERY, + required=required, + style=used_style, + explode=used_explode, + allow_reserved=allow_reserved, + schema=schema, + content=content + ) + + def __serialize_space_delimited( + self, + in_data: typing.Union[None, int, float, str, bool, dict, list], + prefix_separator_iterator: typing.Optional[PrefixSeparatorIterator] + ) -> typing.Dict[str, str]: + if prefix_separator_iterator is None: + prefix_separator_iterator = self.get_prefix_separator_iterator() + value = self.ref6570_expansion( + variable_name=self.name, + in_data=in_data, + explode=self.explode, + percent_encode=True, + prefix_separator_iterator=prefix_separator_iterator + ) + return self.to_dict(self.name, value) + + def __serialize_pipe_delimited( + self, + in_data: typing.Union[None, int, float, str, bool, dict, list], + prefix_separator_iterator: typing.Optional[PrefixSeparatorIterator] + ) -> typing.Dict[str, str]: + if prefix_separator_iterator is None: + prefix_separator_iterator = self.get_prefix_separator_iterator() + value = self.ref6570_expansion( + variable_name=self.name, + in_data=in_data, + explode=self.explode, + percent_encode=True, + prefix_separator_iterator=prefix_separator_iterator + ) + return self.to_dict(self.name, value) + + def __serialize_form( + self, + in_data: typing.Union[None, int, float, str, bool, dict, list], + prefix_separator_iterator: typing.Optional[PrefixSeparatorIterator] + ) -> typing.Dict[str, str]: + if prefix_separator_iterator is None: + prefix_separator_iterator = self.get_prefix_separator_iterator() + value = self.serialize_form( + in_data, + name=self.name, + explode=self.explode, + percent_encode=True, + prefix_separator_iterator=prefix_separator_iterator + ) + return self.to_dict(self.name, value) + + def get_prefix_separator_iterator(self) -> typing.Optional[PrefixSeparatorIterator]: + if not self.schema: + return None + if self.style is ParameterStyle.FORM: + return PrefixSeparatorIterator('?', '&') + elif self.style is ParameterStyle.SPACE_DELIMITED: + return PrefixSeparatorIterator('', '%20') + elif self.style is ParameterStyle.PIPE_DELIMITED: + return PrefixSeparatorIterator('', '|') + + def serialize( + self, + in_data: typing.Union[ + Schema, Decimal, int, float, str, date, datetime, None, bool, list, tuple, dict, frozendict], + prefix_separator_iterator: typing.Optional[PrefixSeparatorIterator] = None + ) -> typing.Dict[str, str]: + if self.schema: + cast_in_data = self.schema(in_data) + cast_in_data = self._json_encoder.default(cast_in_data) + """ + form -> query + query: + - GET/HEAD/DELETE: could use fields + - PUT/POST: must use urlencode to send parameters + returns fields: tuple + spaceDelimited -> query + returns fields + pipeDelimited -> query + returns fields + deepObject -> query, https://github.com/OAI/OpenAPI-Specification/issues/1706 + returns fields + """ + if self.style: + # TODO update query ones to omit setting values when [] {} or None is input + if self.style is ParameterStyle.FORM: + return self.__serialize_form(cast_in_data, prefix_separator_iterator) + elif self.style is ParameterStyle.SPACE_DELIMITED: + return self.__serialize_space_delimited(cast_in_data, prefix_separator_iterator) + elif self.style is ParameterStyle.PIPE_DELIMITED: + return self.__serialize_pipe_delimited(cast_in_data, prefix_separator_iterator) + # self.content will be length one + for content_type, schema in self.content.items(): + cast_in_data = schema(in_data) + cast_in_data = self._json_encoder.default(cast_in_data) + if content_type == self._json_content_type: + value = self._serialize_json(cast_in_data) + return self.to_dict(self.name, value) + raise NotImplementedError('Serialization of {} has not yet been implemented'.format(content_type)) + + +class CookieParameter(ParameterBase, StyleFormSerializer): + + def __init__( + self, + name: str, + required: bool = False, + style: typing.Optional[ParameterStyle] = None, + explode: typing.Optional[bool] = None, + allow_reserved: typing.Optional[bool] = None, + schema: typing.Optional[typing.Type[Schema]] = None, + content: typing.Optional[typing.Dict[str, typing.Type[Schema]]] = None + ): + used_style = ParameterStyle.FORM if style is None and content is None and schema else style + used_explode = self.get_default_explode(used_style) if explode is None else explode + + super().__init__( + name, + in_type=ParameterInType.COOKIE, + required=required, + style=used_style, + explode=used_explode, + allow_reserved=allow_reserved, + schema=schema, + content=content + ) + + def serialize( + self, + in_data: typing.Union[ + Schema, Decimal, int, float, str, date, datetime, None, bool, list, tuple, dict, frozendict] + ) -> typing.Dict[str, str]: + if self.schema: + cast_in_data = self.schema(in_data) + cast_in_data = self._json_encoder.default(cast_in_data) + """ + form -> cookie + returns fields: tuple + """ + if self.style: + """ + TODO add escaping of comma, space, equals + or turn encoding on + """ + value = self.serialize_form( + cast_in_data, + explode=self.explode, + name=self.name, + percent_encode=False, + prefix_separator_iterator=PrefixSeparatorIterator('', '&') + ) + return self.to_dict(self.name, value) + # self.content will be length one + for content_type, schema in self.content.items(): + cast_in_data = schema(in_data) + cast_in_data = self._json_encoder.default(cast_in_data) + if content_type == self._json_content_type: + value = self._serialize_json(cast_in_data) + return self.to_dict(self.name, value) + raise NotImplementedError('Serialization of {} has not yet been implemented'.format(content_type)) + + +class HeaderParameter(ParameterBase, StyleSimpleSerializer): + def __init__( + self, + name: str, + required: bool = False, + style: typing.Optional[ParameterStyle] = None, + explode: bool = False, + allow_reserved: typing.Optional[bool] = None, + schema: typing.Optional[typing.Type[Schema]] = None, + content: typing.Optional[typing.Dict[str, typing.Type[Schema]]] = None + ): + super().__init__( + name, + in_type=ParameterInType.HEADER, + required=required, + style=style, + explode=explode, + allow_reserved=allow_reserved, + schema=schema, + content=content + ) + + @staticmethod + def __to_headers(in_data: typing.Tuple[typing.Tuple[str, str], ...]) -> HTTPHeaderDict[str, str]: + data = tuple(t for t in in_data if t) + headers = HTTPHeaderDict() + if not data: + return headers + headers.extend(data) + return headers + + def _serialize_simple( + self, + in_data: typing.Union[None, int, float, str, bool, dict, list], + ) -> str: + return self.serialize_simple(in_data, self.name, self.explode, False) + + def serialize( + self, + in_data: typing.Union[ + Schema, Decimal, int, float, str, date, datetime, None, bool, list, tuple, dict, frozendict] + ) -> HTTPHeaderDict[str, str]: + if self.schema: + cast_in_data = self.schema(in_data) + cast_in_data = self._json_encoder.default(cast_in_data) + """ + simple -> header + headers: PoolManager needs a mapping, tuple is close + returns headers: dict + """ + if self.style: + value = self._serialize_simple(cast_in_data) + return self.__to_headers(((self.name, value),)) + # self.content will be length one + for content_type, schema in self.content.items(): + cast_in_data = schema(in_data) + cast_in_data = self._json_encoder.default(cast_in_data) + if content_type == self._json_content_type: + value = self._serialize_json(cast_in_data) + return self.__to_headers(((self.name, value),)) + raise NotImplementedError('Serialization of {} has not yet been implemented'.format(content_type)) + + +class Encoding: + def __init__( + self, + content_type: str, + headers: typing.Optional[typing.Dict[str, HeaderParameter]] = None, + style: typing.Optional[ParameterStyle] = None, + explode: bool = False, + allow_reserved: bool = False, + ): + self.content_type = content_type + self.headers = headers + self.style = style + self.explode = explode + self.allow_reserved = allow_reserved + + +@dataclass +class MediaType: + """ + Used to store request and response body schema information + encoding: + A map between a property name and its encoding information. + The key, being the property name, MUST exist in the schema as a property. + The encoding object SHALL only apply to requestBody objects when the media type is + multipart or application/x-www-form-urlencoded. + """ + schema: typing.Optional[typing.Type[Schema]] = None + encoding: typing.Optional[typing.Dict[str, Encoding]] = None + + +@dataclass +class ApiResponse: + response: urllib3.HTTPResponse + body: typing.Union[Unset, typing.Type[Schema]] + headers: typing.Union[Unset, typing.List[HeaderParameter]] + + def __init__( + self, + response: urllib3.HTTPResponse, + body: typing.Union[Unset, typing.Type[Schema]], + headers: typing.Union[Unset, typing.List[HeaderParameter]] + ): + """ + pycharm needs this to prevent 'Unexpected argument' warnings + """ + self.response = response + self.body = body + self.headers = headers + + +@dataclass +class ApiResponseWithoutDeserialization(ApiResponse): + response: urllib3.HTTPResponse + body: typing.Union[Unset, typing.Type[Schema]] = unset + headers: typing.Union[Unset, typing.List[HeaderParameter]] = unset + + +class JSONDetector: + @staticmethod + def content_type_is_json(content_type: str) -> bool: + """ + for when content_type strings also include charset info like: + application/json; charset=UTF-8 + """ + content_type_piece = content_type.split(';')[0] + if content_type_piece == 'application/json': + return True + return False + + +class OpenApiResponse(JSONDetector): + def __init__( + self, + response_cls: typing.Type[ApiResponse] = ApiResponse, + content: typing.Optional[typing.Dict[str, MediaType]] = None, + headers: typing.Optional[typing.List[HeaderParameter]] = None, + ): + self.headers = headers + if content is not None and len(content) == 0: + raise ValueError('Invalid value for content, the content dict must have >= 1 entry') + self.content = content + self.response_cls = response_cls + + @staticmethod + def __deserialize_json(response: urllib3.HTTPResponse) -> typing.Any: + # python must be >= 3.9 so we can pass in bytes into json.loads + return json.loads(response.data) + + @staticmethod + def __file_name_from_content_disposition(content_disposition: typing.Optional[str]) -> typing.Optional[str]: + if content_disposition is None: + return None + match = re.search('filename="(.+?)"', content_disposition) + if not match: + return None + return match.group(1) + + def __deserialize_application_octet_stream( + self, response: urllib3.HTTPResponse + ) -> typing.Union[bytes, io.BufferedReader]: + """ + urllib3 use cases: + 1. when preload_content=True (stream=False) then supports_chunked_reads is False and bytes are returned + 2. when preload_content=False (stream=True) then supports_chunked_reads is True and + a file will be written and returned + """ + if response.supports_chunked_reads(): + file_name = self.__file_name_from_content_disposition(response.headers.get('content-disposition')) + + if file_name is None: + _fd, path = tempfile.mkstemp() + else: + path = os.path.join(tempfile.gettempdir(), file_name) + # TODO get file_name from the filename at the end of the url if it exists + with open(path, 'wb') as new_file: + chunk_size = 1024 + while True: + data = response.read(chunk_size) + if not data: + break + new_file.write(data) + # release_conn is needed for streaming connections only + response.release_conn() + new_file = open(path, 'rb') + return new_file + else: + return response.data + + @staticmethod + def __deserialize_multipart_form_data( + response: urllib3.HTTPResponse + ) -> typing.Dict[str, typing.Any]: + msg = email.message_from_bytes(response.data) + return { + part.get_param("name", header="Content-Disposition"): part.get_payload( + decode=True + ).decode(part.get_content_charset()) + if part.get_content_charset() + else part.get_payload() + for part in msg.get_payload() + } + + def deserialize(self, response: urllib3.HTTPResponse, configuration: Configuration) -> ApiResponse: + content_type = response.getheader('content-type') + deserialized_body = unset + streamed = response.supports_chunked_reads() + + deserialized_headers = unset + if self.headers is not None: + # TODO add header deserialiation here + pass + + if self.content is not None: + if content_type not in self.content: + raise ApiValueError( + f'Invalid content_type={content_type} returned for response with ' + 'status_code={str(response.status)}' + ) + body_schema = self.content[content_type].schema + if body_schema is None: + # some specs do not define response content media type schemas + return self.response_cls( + response=response, + headers=deserialized_headers, + body=unset + ) + + if self.content_type_is_json(content_type): + body_data = self.__deserialize_json(response) + elif content_type == 'application/octet-stream': + body_data = self.__deserialize_application_octet_stream(response) + elif content_type.startswith('multipart/form-data'): + body_data = self.__deserialize_multipart_form_data(response) + content_type = 'multipart/form-data' + else: + raise NotImplementedError('Deserialization of {} has not yet been implemented'.format(content_type)) + deserialized_body = body_schema._from_openapi_data( + body_data, _configuration=configuration) + elif streamed: + response.release_conn() + + return self.response_cls( + response=response, + headers=deserialized_headers, + body=deserialized_body + ) + + +class ApiClient: + """Generic API client for OpenAPI client library builds. + + OpenAPI generic API client. This client handles the client- + server communication, and is invariant across implementations. Specifics of + the methods and models for each application are generated from the OpenAPI + templates. + + NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + Do not edit the class manually. + + :param configuration: .Configuration object for this client + :param header_name: a header to pass when making calls to the API. + :param header_value: a header value to pass when making calls to + the API. + :param cookie: a cookie to include in the header when making calls + to the API + :param pool_threads: The number of threads to use for async requests + to the API. More threads means more concurrent API requests. + """ + + _pool = None + __json_encoder = JSONEncoder() + + def __init__( + self, + configuration: typing.Optional[Configuration] = None, + header_name: typing.Optional[str] = None, + header_value: typing.Optional[str] = None, + cookie: typing.Optional[str] = None, + pool_threads: int = 1 + ): + if configuration is None: + configuration = Configuration() + self.configuration = configuration + self.pool_threads = pool_threads + + self.rest_client = rest.RESTClientObject(configuration) + self.default_headers = {} + if header_name is not None: + self.default_headers[header_name] = header_value + self.cookie = cookie + # Set default User-Agent. + self.user_agent = 'OpenAPI-Generator/1.0.0/python' + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + self.close() + + def close(self): + if self._pool: + self._pool.close() + self._pool.join() + self._pool = None + if hasattr(atexit, 'unregister'): + atexit.unregister(self.close) + + @property + def pool(self): + """Create thread pool on first request + avoids instantiating unused threadpool for blocking clients. + """ + if self._pool is None: + atexit.register(self.close) + self._pool = ThreadPool(self.pool_threads) + return self._pool + + @property + def user_agent(self): + """User agent for this API client""" + return self.default_headers['User-Agent'] + + @user_agent.setter + def user_agent(self, value): + self.default_headers['User-Agent'] = value + + def set_default_header(self, header_name, header_value): + self.default_headers[header_name] = header_value + + def __call_api( + self, + resource_path: str, + method: str, + headers: typing.Optional[HTTPHeaderDict] = None, + body: typing.Optional[typing.Union[str, bytes]] = None, + fields: typing.Optional[typing.Tuple[typing.Tuple[str, str], ...]] = None, + auth_settings: typing.Optional[typing.List[str]] = None, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + host: typing.Optional[str] = None, + ) -> urllib3.HTTPResponse: + + # header parameters + headers = headers or {} + headers.update(self.default_headers) + if self.cookie: + headers['Cookie'] = self.cookie + + # auth setting + self.update_params_for_auth(headers, + auth_settings, resource_path, method, body) + + # request url + if host is None: + url = self.configuration.host + resource_path + else: + # use server/host defined in path or operation instead + url = host + resource_path + + # perform request and return response + response = self.request( + method, + url, + headers=headers, + fields=fields, + body=body, + stream=stream, + timeout=timeout, + ) + return response + + def call_api( + self, + resource_path: str, + method: str, + headers: typing.Optional[HTTPHeaderDict] = None, + body: typing.Optional[typing.Union[str, bytes]] = None, + fields: typing.Optional[typing.Tuple[typing.Tuple[str, str], ...]] = None, + auth_settings: typing.Optional[typing.List[str]] = None, + async_req: typing.Optional[bool] = None, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + host: typing.Optional[str] = None, + ) -> urllib3.HTTPResponse: + """Makes the HTTP request (synchronous) and returns deserialized data. + + To make an async_req request, set the async_req parameter. + + :param resource_path: Path to method endpoint. + :param method: Method to call. + :param headers: Header parameters to be + placed in the request header. + :param body: Request body. + :param fields: Request post form parameters, + for `application/x-www-form-urlencoded`, `multipart/form-data`. + :param auth_settings: Auth Settings names for the request. + :param async_req: execute request asynchronously + :type async_req: bool, optional TODO remove, unused + :param stream: if True, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Also when True, if the openapi spec describes a file download, + the data will be written to a local filesystme file and the BinarySchema + instance will also inherit from FileSchema and FileIO + Default is False. + :type stream: bool, optional + :param timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param host: api endpoint host + :return: + If async_req parameter is True, + the request will be called asynchronously. + The method will return the request thread. + If parameter async_req is False or missing, + then the method will return the response directly. + """ + + if not async_req: + return self.__call_api( + resource_path, + method, + headers, + body, + fields, + auth_settings, + stream, + timeout, + host, + ) + + return self.pool.apply_async( + self.__call_api, + ( + resource_path, + method, + headers, + body, + json, + fields, + auth_settings, + stream, + timeout, + host, + ) + ) + + def request( + self, + method: str, + url: str, + headers: typing.Optional[HTTPHeaderDict] = None, + fields: typing.Optional[typing.Tuple[typing.Tuple[str, str], ...]] = None, + body: typing.Optional[typing.Union[str, bytes]] = None, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> urllib3.HTTPResponse: + """Makes the HTTP request using RESTClient.""" + if method == "GET": + return self.rest_client.GET(url, + stream=stream, + timeout=timeout, + headers=headers) + elif method == "HEAD": + return self.rest_client.HEAD(url, + stream=stream, + timeout=timeout, + headers=headers) + elif method == "OPTIONS": + return self.rest_client.OPTIONS(url, + headers=headers, + fields=fields, + stream=stream, + timeout=timeout, + body=body) + elif method == "POST": + return self.rest_client.POST(url, + headers=headers, + fields=fields, + stream=stream, + timeout=timeout, + body=body) + elif method == "PUT": + return self.rest_client.PUT(url, + headers=headers, + fields=fields, + stream=stream, + timeout=timeout, + body=body) + elif method == "PATCH": + return self.rest_client.PATCH(url, + headers=headers, + fields=fields, + stream=stream, + timeout=timeout, + body=body) + elif method == "DELETE": + return self.rest_client.DELETE(url, + headers=headers, + stream=stream, + timeout=timeout, + body=body) + else: + raise ApiValueError( + "http method must be `GET`, `HEAD`, `OPTIONS`," + " `POST`, `PATCH`, `PUT` or `DELETE`." + ) + + def update_params_for_auth(self, headers, auth_settings, + resource_path, method, body): + """Updates header and query params based on authentication setting. + + :param headers: Header parameters dict to be updated. + :param auth_settings: Authentication setting identifiers list. + :param resource_path: A string representation of the HTTP request resource path. + :param method: A string representation of the HTTP request method. + :param body: A object representing the body of the HTTP request. + The object type is the return value of _encoder.default(). + """ + if not auth_settings: + return + + for auth in auth_settings: + auth_setting = self.configuration.auth_settings().get(auth) + if auth_setting: + if auth_setting['in'] == 'cookie': + headers.add('Cookie', auth_setting['value']) + elif auth_setting['in'] == 'header': + if auth_setting['type'] != 'http-signature': + headers.add(auth_setting['key'], auth_setting['value']) + elif auth_setting['in'] == 'query': + """ TODO implement auth in query + need to pass in prefix_separator_iterator + and need to output resource_path with query params added + """ + raise ApiValueError("Auth in query not yet implemented") + else: + raise ApiValueError( + 'Authentication token must be in `query` or `header`' + ) + + +class Api: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client: typing.Optional[ApiClient] = None): + if api_client is None: + api_client = ApiClient() + self.api_client = api_client + + @staticmethod + def _verify_typed_dict_inputs(cls: typing.Type[typing.TypedDict], data: typing.Dict[str, typing.Any]): + """ + Ensures that: + - required keys are present + - additional properties are not input + - value stored under required keys do not have the value unset + Note: detailed value checking is done in schema classes + """ + missing_required_keys = [] + required_keys_with_unset_values = [] + for required_key in cls.__required_keys__: + if required_key not in data: + missing_required_keys.append(required_key) + continue + value = data[required_key] + if value is unset: + required_keys_with_unset_values.append(required_key) + if missing_required_keys: + raise ApiTypeError( + '{} missing {} required arguments: {}'.format( + cls.__name__, len(missing_required_keys), missing_required_keys + ) + ) + if required_keys_with_unset_values: + raise ApiValueError( + '{} contains invalid unset values for {} required keys: {}'.format( + cls.__name__, len(required_keys_with_unset_values), required_keys_with_unset_values + ) + ) + + disallowed_additional_keys = [] + for key in data: + if key in cls.__required_keys__ or key in cls.__optional_keys__: + continue + disallowed_additional_keys.append(key) + if disallowed_additional_keys: + raise ApiTypeError( + '{} got {} unexpected keyword arguments: {}'.format( + cls.__name__, len(disallowed_additional_keys), disallowed_additional_keys + ) + ) + + def get_host( + self, + operation_id: str, + servers: typing.Tuple[typing.Dict[str, str], ...] = tuple(), + host_index: typing.Optional[int] = None + ) -> typing.Optional[str]: + configuration = self.api_client.configuration + try: + if host_index is None: + index = configuration.server_operation_index.get( + operation_id, configuration.server_index + ) + else: + index = host_index + server_variables = configuration.server_operation_variables.get( + operation_id, configuration.server_variables + ) + host = configuration.get_host_from_settings( + index, variables=server_variables, servers=servers + ) + except IndexError: + if servers: + raise ApiValueError( + "Invalid host index. Must be 0 <= index < %s" % + len(servers) + ) + host = None + return host + + +class SerializedRequestBody(typing.TypedDict, total=False): + body: typing.Union[str, bytes] + fields: typing.Tuple[typing.Union[RequestField, tuple[str, str]], ...] + + +class RequestBody(StyleFormSerializer, JSONDetector): + """ + A request body parameter + content: content_type to MediaType Schema info + """ + __json_encoder = JSONEncoder() + + def __init__( + self, + content: typing.Dict[str, MediaType], + required: bool = False, + ): + self.required = required + if len(content) == 0: + raise ValueError('Invalid value for content, the content dict must have >= 1 entry') + self.content = content + + def __serialize_json( + self, + in_data: typing.Any + ) -> typing.Dict[str, bytes]: + in_data = self.__json_encoder.default(in_data) + json_str = json.dumps(in_data, separators=(",", ":"), ensure_ascii=False).encode( + "utf-8" + ) + return dict(body=json_str) + + @staticmethod + def __serialize_text_plain(in_data: typing.Any) -> typing.Dict[str, str]: + if isinstance(in_data, frozendict): + raise ValueError('Unable to serialize type frozendict to text/plain') + elif isinstance(in_data, tuple): + raise ValueError('Unable to serialize type tuple to text/plain') + elif isinstance(in_data, NoneClass): + raise ValueError('Unable to serialize type NoneClass to text/plain') + elif isinstance(in_data, BoolClass): + raise ValueError('Unable to serialize type BoolClass to text/plain') + return dict(body=str(in_data)) + + def __multipart_json_item(self, key: str, value: Schema) -> RequestField: + json_value = self.__json_encoder.default(value) + return RequestField(name=key, data=json.dumps(json_value), headers={'Content-Type': 'application/json'}) + + def __multipart_form_item(self, key: str, value: Schema) -> RequestField: + if isinstance(value, str): + return RequestField(name=key, data=str(value), headers={'Content-Type': 'text/plain'}) + elif isinstance(value, bytes): + return RequestField(name=key, data=value, headers={'Content-Type': 'application/octet-stream'}) + elif isinstance(value, FileIO): + request_field = RequestField( + name=key, + data=value.read(), + filename=os.path.basename(value.name), + headers={'Content-Type': 'application/octet-stream'} + ) + value.close() + return request_field + else: + return self.__multipart_json_item(key=key, value=value) + + def __serialize_multipart_form_data( + self, in_data: Schema + ) -> typing.Dict[str, typing.Tuple[RequestField, ...]]: + if not isinstance(in_data, frozendict): + raise ValueError(f'Unable to serialize {in_data} to multipart/form-data because it is not a dict of data') + """ + In a multipart/form-data request body, each schema property, or each element of a schema array property, + takes a section in the payload with an internal header as defined by RFC7578. The serialization strategy + for each property of a multipart/form-data request body can be specified in an associated Encoding Object. + + When passing in multipart types, boundaries MAY be used to separate sections of the content being + transferred – thus, the following default Content-Types are defined for multipart: + + If the (object) property is a primitive, or an array of primitive values, the default Content-Type is text/plain + If the property is complex, or an array of complex values, the default Content-Type is application/json + Question: how is the array of primitives encoded? + If the property is a type: string with a contentEncoding, the default Content-Type is application/octet-stream + """ + fields = [] + for key, value in in_data.items(): + if isinstance(value, tuple): + if value: + # values use explode = True, so the code makes a RequestField for each item with name=key + for item in value: + request_field = self.__multipart_form_item(key=key, value=item) + fields.append(request_field) + else: + # send an empty array as json because exploding will not send it + request_field = self.__multipart_json_item(key=key, value=value) + fields.append(request_field) + else: + request_field = self.__multipart_form_item(key=key, value=value) + fields.append(request_field) + + return dict(fields=tuple(fields)) + + def __serialize_application_octet_stream(self, in_data: BinarySchema) -> typing.Dict[str, bytes]: + if isinstance(in_data, bytes): + return dict(body=in_data) + # FileIO type + result = dict(body=in_data.read()) + in_data.close() + return result + + def __serialize_application_x_www_form_data( + self, in_data: typing.Any + ) -> SerializedRequestBody: + """ + POST submission of form data in body + """ + if not isinstance(in_data, frozendict): + raise ValueError( + f'Unable to serialize {in_data} to application/x-www-form-urlencoded because it is not a dict of data') + cast_in_data = self.__json_encoder.default(in_data) + value = self.serialize_form(cast_in_data, name='', explode=True, percent_encode=False) + return dict(body=value) + + def serialize( + self, in_data: typing.Any, content_type: str + ) -> SerializedRequestBody: + """ + If a str is returned then the result will be assigned to data when making the request + If a tuple is returned then the result will be used as fields input in encode_multipart_formdata + Return a tuple of + + The key of the return dict is + - body for application/json + - encode_multipart and fields for multipart/form-data + """ + media_type = self.content[content_type] + if isinstance(in_data, media_type.schema): + cast_in_data = in_data + elif isinstance(in_data, (dict, frozendict)) and in_data: + cast_in_data = media_type.schema(**in_data) + else: + cast_in_data = media_type.schema(in_data) + # TODO check for and use encoding if it exists + # and content_type is multipart or application/x-www-form-urlencoded + if self.content_type_is_json(content_type): + return self.__serialize_json(cast_in_data) + elif content_type == 'text/plain': + return self.__serialize_text_plain(cast_in_data) + elif content_type == 'multipart/form-data': + return self.__serialize_multipart_form_data(cast_in_data) + elif content_type == 'application/x-www-form-urlencoded': + return self.__serialize_application_x_www_form_data(cast_in_data) + elif content_type == 'application/octet-stream': + return self.__serialize_application_octet_stream(cast_in_data) + raise NotImplementedError('Serialization has not yet been implemented for {}'.format(content_type)) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/configuration.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/configuration.py new file mode 100644 index 00000000000..80407ef4b44 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/configuration.py @@ -0,0 +1,440 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import copy +import logging +import multiprocessing +import sys +import urllib3 + +from http import client as http_client +from unit_test_api.exceptions import ApiValueError + + +JSON_SCHEMA_VALIDATION_KEYWORDS = { + 'multipleOf', 'maximum', 'exclusiveMaximum', + 'minimum', 'exclusiveMinimum', 'maxLength', + 'minLength', 'pattern', 'maxItems', 'minItems', + 'uniqueItems', 'maxProperties', 'minProperties', +} + +class Configuration(object): + """NOTE: This class is auto generated by OpenAPI Generator + + Ref: https://openapi-generator.tech + Do not edit the class manually. + + :param host: Base url + :param api_key: Dict to store API key(s). + Each entry in the dict specifies an API key. + The dict key is the name of the security scheme in the OAS specification. + The dict value is the API key secret. + :param api_key_prefix: Dict to store API prefix (e.g. Bearer) + The dict key is the name of the security scheme in the OAS specification. + The dict value is an API key prefix when generating the auth data. + :param username: Username for HTTP basic authentication + :param password: Password for HTTP basic authentication + :param discard_unknown_keys: Boolean value indicating whether to discard + unknown properties. A server may send a response that includes additional + properties that are not known by the client in the following scenarios: + 1. The OpenAPI document is incomplete, i.e. it does not match the server + implementation. + 2. The client was generated using an older version of the OpenAPI document + and the server has been upgraded since then. + If a schema in the OpenAPI document defines the additionalProperties attribute, + then all undeclared properties received by the server are injected into the + additional properties map. In that case, there are undeclared properties, and + nothing to discard. + :param disabled_client_side_validations (string): Comma-separated list of + JSON schema validation keywords to disable JSON schema structural validation + rules. The following keywords may be specified: multipleOf, maximum, + exclusiveMaximum, minimum, exclusiveMinimum, maxLength, minLength, pattern, + maxItems, minItems. + By default, the validation is performed for data generated locally by the client + and data received from the server, independent of any validation performed by + the server side. If the input data does not satisfy the JSON schema validation + rules specified in the OpenAPI document, an exception is raised. + If disabled_client_side_validations is set, structural validation is + disabled. This can be useful to troubleshoot data validation problem, such as + when the OpenAPI document validation rules do not match the actual API data + received by the server. + :param server_index: Index to servers configuration. + :param server_variables: Mapping with string values to replace variables in + templated server configuration. The validation of enums is performed for + variables with defined enum values before. + :param server_operation_index: Mapping from operation ID to an index to server + configuration. + :param server_operation_variables: Mapping from operation ID to a mapping with + string values to replace variables in templated server configuration. + The validation of enums is performed for variables with defined enum values before. + + """ + + _default = None + + def __init__(self, host=None, + api_key=None, api_key_prefix=None, + username=None, password=None, + discard_unknown_keys=False, + disabled_client_side_validations="", + server_index=None, server_variables=None, + server_operation_index=None, server_operation_variables=None, + ): + """Constructor + """ + self._base_path = "http://localhost" if host is None else host + """Default Base url + """ + self.server_index = 0 if server_index is None and host is None else server_index + self.server_operation_index = server_operation_index or {} + """Default server index + """ + self.server_variables = server_variables or {} + self.server_operation_variables = server_operation_variables or {} + """Default server variables + """ + self.temp_folder_path = None + """Temp file folder for downloading files + """ + # Authentication Settings + self.api_key = {} + if api_key: + self.api_key = api_key + """dict to store API key(s) + """ + self.api_key_prefix = {} + if api_key_prefix: + self.api_key_prefix = api_key_prefix + """dict to store API prefix (e.g. Bearer) + """ + self.refresh_api_key_hook = None + """function hook to refresh API key if expired + """ + self.username = username + """Username for HTTP basic authentication + """ + self.password = password + """Password for HTTP basic authentication + """ + self.discard_unknown_keys = discard_unknown_keys + self.disabled_client_side_validations = disabled_client_side_validations + self.logger = {} + """Logging Settings + """ + self.logger["package_logger"] = logging.getLogger("unit_test_api") + self.logger["urllib3_logger"] = logging.getLogger("urllib3") + self.logger_format = '%(asctime)s %(levelname)s %(message)s' + """Log format + """ + self.logger_stream_handler = None + """Log stream handler + """ + self.logger_file_handler = None + """Log file handler + """ + self.logger_file = None + """Debug file location + """ + self.debug = False + """Debug switch + """ + + self.verify_ssl = True + """SSL/TLS verification + Set this to false to skip verifying SSL certificate when calling API + from https server. + """ + self.ssl_ca_cert = None + """Set this to customize the certificate file to verify the peer. + """ + self.cert_file = None + """client certificate file + """ + self.key_file = None + """client key file + """ + self.assert_hostname = None + """Set this to True/False to enable/disable SSL hostname verification. + """ + + self.connection_pool_maxsize = multiprocessing.cpu_count() * 5 + """urllib3 connection pool's maximum number of connections saved + per pool. urllib3 uses 1 connection as default value, but this is + not the best value when you are making a lot of possibly parallel + requests to the same host, which is often the case here. + cpu_count * 5 is used as default value to increase performance. + """ + + self.proxy = None + """Proxy URL + """ + self.proxy_headers = None + """Proxy headers + """ + self.safe_chars_for_path_param = '' + """Safe chars for path_param + """ + self.retries = None + """Adding retries to override urllib3 default value 3 + """ + # Enable client side validation + self.client_side_validation = True + + # Options to pass down to the underlying urllib3 socket + self.socket_options = None + + def __deepcopy__(self, memo): + cls = self.__class__ + result = cls.__new__(cls) + memo[id(self)] = result + for k, v in self.__dict__.items(): + if k not in ('logger', 'logger_file_handler'): + setattr(result, k, copy.deepcopy(v, memo)) + # shallow copy of loggers + result.logger = copy.copy(self.logger) + # use setters to configure loggers + result.logger_file = self.logger_file + result.debug = self.debug + return result + + def __setattr__(self, name, value): + object.__setattr__(self, name, value) + if name == 'disabled_client_side_validations': + s = set(filter(None, value.split(','))) + for v in s: + if v not in JSON_SCHEMA_VALIDATION_KEYWORDS: + raise ApiValueError( + "Invalid keyword: '{0}''".format(v)) + self._disabled_client_side_validations = s + + @classmethod + def set_default(cls, default): + """Set default instance of configuration. + + It stores default configuration, which can be + returned by get_default_copy method. + + :param default: object of Configuration + """ + cls._default = copy.deepcopy(default) + + @classmethod + def get_default_copy(cls): + """Return new instance of configuration. + + This method returns newly created, based on default constructor, + object of Configuration class or returns a copy of default + configuration passed by the set_default method. + + :return: The configuration object. + """ + if cls._default is not None: + return copy.deepcopy(cls._default) + return Configuration() + + @property + def logger_file(self): + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + return self.__logger_file + + @logger_file.setter + def logger_file(self, value): + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + self.__logger_file = value + if self.__logger_file: + # If set logging file, + # then add file handler and remove stream handler. + self.logger_file_handler = logging.FileHandler(self.__logger_file) + self.logger_file_handler.setFormatter(self.logger_formatter) + for _, logger in self.logger.items(): + logger.addHandler(self.logger_file_handler) + + @property + def debug(self): + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + return self.__debug + + @debug.setter + def debug(self, value): + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + self.__debug = value + if self.__debug: + # if debug status is True, turn on debug logging + for _, logger in self.logger.items(): + logger.setLevel(logging.DEBUG) + # turn on http_client debug + http_client.HTTPConnection.debuglevel = 1 + else: + # if debug status is False, turn off debug logging, + # setting log level to default `logging.WARNING` + for _, logger in self.logger.items(): + logger.setLevel(logging.WARNING) + # turn off http_client debug + http_client.HTTPConnection.debuglevel = 0 + + @property + def logger_format(self): + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + return self.__logger_format + + @logger_format.setter + def logger_format(self, value): + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + self.__logger_format = value + self.logger_formatter = logging.Formatter(self.__logger_format) + + def get_api_key_with_prefix(self, identifier, alias=None): + """Gets API key (with prefix if set). + + :param identifier: The identifier of apiKey. + :param alias: The alternative identifier of apiKey. + :return: The token for api key authentication. + """ + if self.refresh_api_key_hook is not None: + self.refresh_api_key_hook(self) + key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None) + if key: + prefix = self.api_key_prefix.get(identifier) + if prefix: + return "%s %s" % (prefix, key) + else: + return key + + def get_basic_auth_token(self): + """Gets HTTP basic authentication header (string). + + :return: The token for basic HTTP authentication. + """ + username = "" + if self.username is not None: + username = self.username + password = "" + if self.password is not None: + password = self.password + return urllib3.util.make_headers( + basic_auth=username + ':' + password + ).get('authorization') + + def auth_settings(self): + """Gets Auth Settings dict for api client. + + :return: The Auth Settings information dict. + """ + auth = {} + return auth + + def to_debug_report(self): + """Gets the essential information for debugging. + + :return: The report for debugging. + """ + return "Python SDK Debug Report:\n"\ + "OS: {env}\n"\ + "Python Version: {pyversion}\n"\ + "Version of the API: 0.0.1\n"\ + "SDK Package Version: 1.0.0".\ + format(env=sys.platform, pyversion=sys.version) + + def get_host_settings(self): + """Gets an array of host settings + + :return: An array of host settings + """ + return [ + { + 'url': "", + 'description': "No description provided", + } + ] + + def get_host_from_settings(self, index, variables=None, servers=None): + """Gets host URL based on the index and variables + :param index: array index of the host settings + :param variables: hash of variable and the corresponding value + :param servers: an array of host settings or None + :return: URL based on host settings + """ + if index is None: + return self._base_path + + variables = {} if variables is None else variables + servers = self.get_host_settings() if servers is None else servers + + try: + server = servers[index] + except IndexError: + raise ValueError( + "Invalid index {0} when selecting the host settings. " + "Must be less than {1}".format(index, len(servers))) + + url = server['url'] + + # go through variables and replace placeholders + for variable_name, variable in server.get('variables', {}).items(): + used_value = variables.get( + variable_name, variable['default_value']) + + if 'enum_values' in variable \ + and used_value not in variable['enum_values']: + raise ValueError( + "The variable `{0}` in the host URL has invalid value " + "{1}. Must be {2}.".format( + variable_name, variables[variable_name], + variable['enum_values'])) + + url = url.replace("{" + variable_name + "}", used_value) + + return url + + @property + def host(self): + """Return generated host.""" + return self.get_host_from_settings(self.server_index, variables=self.server_variables) + + @host.setter + def host(self, value): + """Fix base path.""" + self._base_path = value + self.server_index = None diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/exceptions.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/exceptions.py new file mode 100644 index 00000000000..54a51c36ab4 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/exceptions.py @@ -0,0 +1,136 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + + +class OpenApiException(Exception): + """The base exception class for all OpenAPIExceptions""" + + +class ApiTypeError(OpenApiException, TypeError): + def __init__(self, msg, path_to_item=None, valid_classes=None, + key_type=None): + """ Raises an exception for TypeErrors + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list): a list of keys an indices to get to the + current_item + None if unset + valid_classes (tuple): the primitive classes that current item + should be an instance of + None if unset + key_type (bool): False if our value is a value in a dict + True if it is a key in a dict + False if our item is an item in a list + None if unset + """ + self.path_to_item = path_to_item + self.valid_classes = valid_classes + self.key_type = key_type + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiTypeError, self).__init__(full_msg) + + +class ApiValueError(OpenApiException, ValueError): + def __init__(self, msg, path_to_item=None): + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list) the path to the exception in the + received_data dict. None if unset + """ + + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiValueError, self).__init__(full_msg) + + +class ApiAttributeError(OpenApiException, AttributeError): + def __init__(self, msg, path_to_item=None): + """ + Raised when an attribute reference or assignment fails. + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + """ + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiAttributeError, self).__init__(full_msg) + + +class ApiKeyError(OpenApiException, KeyError): + def __init__(self, msg, path_to_item=None): + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + """ + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiKeyError, self).__init__(full_msg) + + +class ApiException(OpenApiException): + + def __init__(self, status=None, reason=None, api_response: 'unit_test_api.api_client.ApiResponse' = None): + if api_response: + self.status = api_response.response.status + self.reason = api_response.response.reason + self.body = api_response.response.data + self.headers = api_response.response.getheaders() + else: + self.status = status + self.reason = reason + self.body = None + self.headers = None + + def __str__(self): + """Custom error messages for exception""" + error_message = "({0})\n"\ + "Reason: {1}\n".format(self.status, self.reason) + if self.headers: + error_message += "HTTP response headers: {0}\n".format( + self.headers) + + if self.body: + error_message += "HTTP response body: {0}\n".format(self.body) + + return error_message + + +def render_path(path_to_item): + """Returns a string representation of a path""" + result = "" + for pth in path_to_item: + if isinstance(pth, int): + result += "[{0}]".format(pth) + else: + result += "['{0}']".format(pth) + return result diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/__init__.py new file mode 100644 index 00000000000..0056d7a31eb --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/__init__.py @@ -0,0 +1,5 @@ +# we can not import model classes here because that would create a circular +# reference which would not work in python2 +# do not import all models into this module because that uses a lot of memory and stack frames +# if you need the ability to import all models from one package, import them with +# from unit_test_api.models import ModelA, ModelB diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/array_type_matches_arrays.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/array_type_matches_arrays.py new file mode 100644 index 00000000000..583f9843b64 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/array_type_matches_arrays.py @@ -0,0 +1,77 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class ArrayTypeMatchesArrays( + ListSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + _items = AnyTypeSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/boolean_type_matches_booleans.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/boolean_type_matches_booleans.py new file mode 100644 index 00000000000..93cd0a0505f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/boolean_type_matches_booleans.py @@ -0,0 +1,67 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) +BooleanTypeMatchesBooleans = BoolSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/integer_type_matches_integers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/integer_type_matches_integers.py new file mode 100644 index 00000000000..472bd37aa71 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/integer_type_matches_integers.py @@ -0,0 +1,67 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) +IntegerTypeMatchesIntegers = IntSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/null_type_matches_only_the_null_object.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/null_type_matches_only_the_null_object.py new file mode 100644 index 00000000000..3ed5b3d6b3b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/null_type_matches_only_the_null_object.py @@ -0,0 +1,67 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) +NullTypeMatchesOnlyTheNullObject = NoneSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/number_type_matches_numbers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/number_type_matches_numbers.py new file mode 100644 index 00000000000..3b33c38f4cd --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/number_type_matches_numbers.py @@ -0,0 +1,67 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) +NumberTypeMatchesNumbers = NumberSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/string_type_matches_strings.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/string_type_matches_strings.py new file mode 100644 index 00000000000..f1c3c9a0302 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/string_type_matches_strings.py @@ -0,0 +1,67 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) +StringTypeMatchesStrings = StrSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py new file mode 100644 index 00000000000..b9d4ccb2508 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py @@ -0,0 +1,19 @@ +# coding: utf-8 + +# flake8: noqa + +# import all models into this package +# if you have many models here with many references from one model to another this may +# raise a RecursionError +# to avoid this, import only the models that you directly need like: +# from from unit_test_api.model.pet import Pet +# or import this package, but before doing it, use: +# import sys +# sys.setrecursionlimit(n) + +from unit_test_api.model.array_type_matches_arrays import ArrayTypeMatchesArrays +from unit_test_api.model.boolean_type_matches_booleans import BooleanTypeMatchesBooleans +from unit_test_api.model.integer_type_matches_integers import IntegerTypeMatchesIntegers +from unit_test_api.model.null_type_matches_only_the_null_object import NullTypeMatchesOnlyTheNullObject +from unit_test_api.model.number_type_matches_numbers import NumberTypeMatchesNumbers +from unit_test_api.model.string_type_matches_strings import StringTypeMatchesStrings diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/rest.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/rest.py new file mode 100644 index 00000000000..75a309eed90 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/rest.py @@ -0,0 +1,253 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import logging +import ssl +from urllib.parse import urlencode +import typing + +import certifi +import urllib3 +from urllib3._collections import HTTPHeaderDict + +from unit_test_api.exceptions import ApiException, ApiValueError + + +logger = logging.getLogger(__name__) + + +class RESTClientObject(object): + + def __init__(self, configuration, pools_size=4, maxsize=None): + # urllib3.PoolManager will pass all kw parameters to connectionpool + # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501 + # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501 + # maxsize is the number of requests to host that are allowed in parallel # noqa: E501 + # Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501 + + # cert_reqs + if configuration.verify_ssl: + cert_reqs = ssl.CERT_REQUIRED + else: + cert_reqs = ssl.CERT_NONE + + # ca_certs + if configuration.ssl_ca_cert: + ca_certs = configuration.ssl_ca_cert + else: + # if not set certificate file, use Mozilla's root certificates. + ca_certs = certifi.where() + + addition_pool_args = {} + if configuration.assert_hostname is not None: + addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 + + if configuration.retries is not None: + addition_pool_args['retries'] = configuration.retries + + if configuration.socket_options is not None: + addition_pool_args['socket_options'] = configuration.socket_options + + if maxsize is None: + if configuration.connection_pool_maxsize is not None: + maxsize = configuration.connection_pool_maxsize + else: + maxsize = 4 + + # https pool manager + if configuration.proxy: + self.pool_manager = urllib3.ProxyManager( + num_pools=pools_size, + maxsize=maxsize, + cert_reqs=cert_reqs, + ca_certs=ca_certs, + cert_file=configuration.cert_file, + key_file=configuration.key_file, + proxy_url=configuration.proxy, + proxy_headers=configuration.proxy_headers, + **addition_pool_args + ) + else: + self.pool_manager = urllib3.PoolManager( + num_pools=pools_size, + maxsize=maxsize, + cert_reqs=cert_reqs, + ca_certs=ca_certs, + cert_file=configuration.cert_file, + key_file=configuration.key_file, + **addition_pool_args + ) + + def request( + self, + method: str, + url: str, + headers: typing.Optional[HTTPHeaderDict] = None, + fields: typing.Optional[typing.Tuple[typing.Tuple[str, typing.Any], ...]] = None, + body: typing.Optional[typing.Union[str, bytes]] = None, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> urllib3.HTTPResponse: + """Perform requests. + + :param method: http request method + :param url: http request url + :param headers: http request headers + :param body: request body, for other types + :param fields: request parameters for + `application/x-www-form-urlencoded` + or `multipart/form-data` + :param stream: if True, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is False. + :param timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + """ + method = method.upper() + assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', + 'PATCH', 'OPTIONS'] + + if fields and body: + raise ApiValueError( + "body parameter cannot be used with fields parameter." + ) + + fields = fields or {} + headers = headers or {} + + if timeout: + if isinstance(timeout, (int, float)): # noqa: E501,F821 + timeout = urllib3.Timeout(total=timeout) + elif (isinstance(timeout, tuple) and + len(timeout) == 2): + timeout = urllib3.Timeout(connect=timeout[0], read=timeout[1]) + + try: + # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` + if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: + if 'Content-Type' not in headers and body is None: + r = self.pool_manager.request( + method, + url, + preload_content=not stream, + timeout=timeout, + headers=headers + ) + elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 + r = self.pool_manager.request( + method, url, + fields=fields, + encode_multipart=False, + preload_content=not stream, + timeout=timeout, + headers=headers) + elif headers['Content-Type'] == 'multipart/form-data': + # must del headers['Content-Type'], or the correct + # Content-Type which generated by urllib3 will be + # overwritten. + del headers['Content-Type'] + r = self.pool_manager.request( + method, url, + fields=fields, + encode_multipart=True, + preload_content=not stream, + timeout=timeout, + headers=headers) + # Pass a `string` parameter directly in the body to support + # other content types than Json when `body` argument is + # provided in serialized form + elif isinstance(body, str) or isinstance(body, bytes): + request_body = body + r = self.pool_manager.request( + method, url, + body=request_body, + preload_content=not stream, + timeout=timeout, + headers=headers) + else: + # Cannot generate the request from given parameters + msg = """Cannot prepare a request message for provided + arguments. Please check that your arguments match + declared content type.""" + raise ApiException(status=0, reason=msg) + # For `GET`, `HEAD` + else: + r = self.pool_manager.request(method, url, + preload_content=not stream, + timeout=timeout, + headers=headers) + except urllib3.exceptions.SSLError as e: + msg = "{0}\n{1}".format(type(e).__name__, str(e)) + raise ApiException(status=0, reason=msg) + + if not stream: + # log response body + logger.debug("response body: %s", r.data) + + return r + + def GET(self, url, headers=None, stream=False, + timeout=None, fields=None) -> urllib3.HTTPResponse: + return self.request("GET", url, + headers=headers, + stream=stream, + timeout=timeout, + fields=fields) + + def HEAD(self, url, headers=None, stream=False, + timeout=None, fields=None) -> urllib3.HTTPResponse: + return self.request("HEAD", url, + headers=headers, + stream=stream, + timeout=timeout, + fields=fields) + + def OPTIONS(self, url, headers=None, + body=None, stream=False, timeout=None, fields=None) -> urllib3.HTTPResponse: + return self.request("OPTIONS", url, + headers=headers, + stream=stream, + timeout=timeout, + body=body, fields=fields) + + def DELETE(self, url, headers=None, body=None, + stream=False, timeout=None, fields=None) -> urllib3.HTTPResponse: + return self.request("DELETE", url, + headers=headers, + stream=stream, + timeout=timeout, + body=body, fields=fields) + + def POST(self, url, headers=None, + body=None, stream=False, timeout=None, fields=None) -> urllib3.HTTPResponse: + return self.request("POST", url, + headers=headers, + stream=stream, + timeout=timeout, + body=body, fields=fields) + + def PUT(self, url, headers=None, + body=None, stream=False, timeout=None, fields=None) -> urllib3.HTTPResponse: + return self.request("PUT", url, + headers=headers, + stream=stream, + timeout=timeout, + body=body, fields=fields) + + def PATCH(self, url, headers=None, + body=None, stream=False, timeout=None, fields=None) -> urllib3.HTTPResponse: + return self.request("PATCH", url, + headers=headers, + stream=stream, + timeout=timeout, + body=body, fields=fields) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/schemas.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/schemas.py new file mode 100644 index 00000000000..0b78a94e7c4 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/schemas.py @@ -0,0 +1,2201 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +from collections import defaultdict +from datetime import date, datetime, timedelta # noqa: F401 +import functools +import decimal +import io +import os +import re +import tempfile +import typing +import uuid + +from dateutil.parser.isoparser import isoparser, _takes_ascii +from frozendict import frozendict + +from unit_test_api.exceptions import ( + ApiTypeError, + ApiValueError, +) +from unit_test_api.configuration import ( + Configuration, +) + + +class Unset(object): + """ + An instance of this class is set as the default value for object type(dict) properties that are optional + When a property has an unset value, that property will not be assigned in the dict + """ + pass + +unset = Unset() + +none_type = type(None) +file_type = io.IOBase + + +class FileIO(io.FileIO): + """ + A class for storing files + Note: this class is not immutable + """ + + def __new__(cls, arg: typing.Union[io.FileIO, io.BufferedReader]): + if isinstance(arg, (io.FileIO, io.BufferedReader)): + arg.close() + inst = super(FileIO, cls).__new__(cls, arg.name) + super(FileIO, inst).__init__(arg.name) + return inst + raise ApiValueError('FileIO must be passed arg which contains the open file') + + +def update(d: dict, u: dict): + """ + Adds u to d + Where each dict is defaultdict(set) + """ + if not u: + return d + for k, v in u.items(): + if not v: + continue + if k not in d: + d[k] = v + else: + d[k] = d[k] | v + + +class ValidationMetadata(frozendict): + """ + A class storing metadata that is needed to validate OpenApi Schema payloads + """ + def __new__( + cls, + path_to_item: typing.Tuple[typing.Union[str, int], ...] = tuple(['args[0]']), + from_server: bool = False, + configuration: typing.Optional[Configuration] = None, + base_classes: typing.FrozenSet[typing.Type] = frozenset(), + ): + """ + Args: + path_to_item: the path to the current data being instantiated. + For {'a': [1]} if the code is handling, 1, then the path is ('args[0]', 'a', 0) + from_server: whether or not this data came form the server + True when receiving server data + False when instantiating model with client side data not form the server + configuration: the Configuration instance to use + This is needed because in Configuration: + - one can disable validation checking + base_classes: when deserializing data that matches multiple schemas, this is used to store + the schemas that have been traversed. This is used to stop processing when a cycle is seen. + """ + return super().__new__( + cls, + path_to_item=path_to_item, + from_server=from_server, + configuration=configuration, + base_classes=base_classes, + ) + + @property + def path_to_item(self) -> typing.Tuple[typing.Union[str, int], ...]: + return self.get('path_to_item') + + @property + def from_server(self) -> bool: + return self.get('from_server') + + @property + def configuration(self) -> typing.Optional[Configuration]: + return self.get('configuration') + + @property + def base_classes(self) -> typing.FrozenSet[typing.Type]: + return self.get('base_classes') + + +class ValidatorBase: + @staticmethod + def __is_json_validation_enabled(schema_keyword, configuration=None): + """Returns true if JSON schema validation is enabled for the specified + validation keyword. This can be used to skip JSON schema structural validation + as requested in the configuration. + + Args: + schema_keyword (string): the name of a JSON schema validation keyword. + configuration (Configuration): the configuration class. + """ + + return (configuration is None or + not hasattr(configuration, '_disabled_client_side_validations') or + schema_keyword not in configuration._disabled_client_side_validations) + + @staticmethod + def __raise_validation_error_message(value, constraint_msg, constraint_value, path_to_item, additional_txt=""): + raise ApiValueError( + "Invalid value `{value}`, {constraint_msg} `{constraint_value}`{additional_txt} at {path_to_item}".format( + value=value, + constraint_msg=constraint_msg, + constraint_value=constraint_value, + additional_txt=additional_txt, + path_to_item=path_to_item, + ) + ) + + @classmethod + def __check_str_validations(cls, + validations, input_values, + validation_metadata: ValidationMetadata): + + if (cls.__is_json_validation_enabled('maxLength', validation_metadata.configuration) and + 'max_length' in validations and + len(input_values) > validations['max_length']): + cls.__raise_validation_error_message( + value=input_values, + constraint_msg="length must be less than or equal to", + constraint_value=validations['max_length'], + path_to_item=validation_metadata.path_to_item + ) + + if (cls.__is_json_validation_enabled('minLength', validation_metadata.configuration) and + 'min_length' in validations and + len(input_values) < validations['min_length']): + cls.__raise_validation_error_message( + value=input_values, + constraint_msg="length must be greater than or equal to", + constraint_value=validations['min_length'], + path_to_item=validation_metadata.path_to_item + ) + + checked_value = input_values + if (cls.__is_json_validation_enabled('pattern', validation_metadata.configuration) and + 'regex' in validations): + for regex_dict in validations['regex']: + flags = regex_dict.get('flags', 0) + if not re.search(regex_dict['pattern'], checked_value, flags=flags): + if flags != 0: + # Don't print the regex flags if the flags are not + # specified in the OAS document. + cls.__raise_validation_error_message( + value=input_values, + constraint_msg="must match regular expression", + constraint_value=regex_dict['pattern'], + path_to_item=validation_metadata.path_to_item, + additional_txt=" with flags=`{}`".format(flags) + ) + cls.__raise_validation_error_message( + value=input_values, + constraint_msg="must match regular expression", + constraint_value=regex_dict['pattern'], + path_to_item=validation_metadata.path_to_item + ) + + @classmethod + def __check_tuple_validations( + cls, validations, input_values, + validation_metadata: ValidationMetadata): + + if (cls.__is_json_validation_enabled('maxItems', validation_metadata.configuration) and + 'max_items' in validations and + len(input_values) > validations['max_items']): + cls.__raise_validation_error_message( + value=input_values, + constraint_msg="number of items must be less than or equal to", + constraint_value=validations['max_items'], + path_to_item=validation_metadata.path_to_item + ) + + if (cls.__is_json_validation_enabled('minItems', validation_metadata.configuration) and + 'min_items' in validations and + len(input_values) < validations['min_items']): + cls.__raise_validation_error_message( + value=input_values, + constraint_msg="number of items must be greater than or equal to", + constraint_value=validations['min_items'], + path_to_item=validation_metadata.path_to_item + ) + + if (cls.__is_json_validation_enabled('uniqueItems', validation_metadata.configuration) and + 'unique_items' in validations and validations['unique_items'] and input_values): + unique_items = [] + for item in input_values: + if item not in unique_items: + unique_items.append(item) + if len(input_values) > len(unique_items): + cls.__raise_validation_error_message( + value=input_values, + constraint_msg="duplicate items were found, and the tuple must not contain duplicates because", + constraint_value='unique_items==True', + path_to_item=validation_metadata.path_to_item + ) + + @classmethod + def __check_dict_validations( + cls, validations, input_values, + validation_metadata: ValidationMetadata): + + if (cls.__is_json_validation_enabled('maxProperties', validation_metadata.configuration) and + 'max_properties' in validations and + len(input_values) > validations['max_properties']): + cls.__raise_validation_error_message( + value=input_values, + constraint_msg="number of properties must be less than or equal to", + constraint_value=validations['max_properties'], + path_to_item=validation_metadata.path_to_item + ) + + if (cls.__is_json_validation_enabled('minProperties', validation_metadata.configuration) and + 'min_properties' in validations and + len(input_values) < validations['min_properties']): + cls.__raise_validation_error_message( + value=input_values, + constraint_msg="number of properties must be greater than or equal to", + constraint_value=validations['min_properties'], + path_to_item=validation_metadata.path_to_item + ) + + @classmethod + def __check_numeric_validations( + cls, validations, input_values, + validation_metadata: ValidationMetadata): + + if cls.__is_json_validation_enabled('multipleOf', + validation_metadata.configuration) and 'multiple_of' in validations: + multiple_of_values = validations['multiple_of'] + for multiple_of_value in multiple_of_values: + if (isinstance(input_values, decimal.Decimal) and + not (float(input_values) / multiple_of_value).is_integer() + ): + # Note 'multipleOf' will be as good as the floating point arithmetic. + cls.__raise_validation_error_message( + value=input_values, + constraint_msg="value must be a multiple of", + constraint_value=multiple_of_value, + path_to_item=validation_metadata.path_to_item + ) + + checking_max_or_min_values = {'exclusive_maximum', 'inclusive_maximum', 'exclusive_minimum', + 'inclusive_minimum'}.isdisjoint(validations) is False + if not checking_max_or_min_values: + return + max_val = input_values + min_val = input_values + + if (cls.__is_json_validation_enabled('exclusiveMaximum', validation_metadata.configuration) and + 'exclusive_maximum' in validations and + max_val >= validations['exclusive_maximum']): + cls.__raise_validation_error_message( + value=input_values, + constraint_msg="must be a value less than", + constraint_value=validations['exclusive_maximum'], + path_to_item=validation_metadata.path_to_item + ) + + if (cls.__is_json_validation_enabled('maximum', validation_metadata.configuration) and + 'inclusive_maximum' in validations and + max_val > validations['inclusive_maximum']): + cls.__raise_validation_error_message( + value=input_values, + constraint_msg="must be a value less than or equal to", + constraint_value=validations['inclusive_maximum'], + path_to_item=validation_metadata.path_to_item + ) + + if (cls.__is_json_validation_enabled('exclusiveMinimum', validation_metadata.configuration) and + 'exclusive_minimum' in validations and + min_val <= validations['exclusive_minimum']): + cls.__raise_validation_error_message( + value=input_values, + constraint_msg="must be a value greater than", + constraint_value=validations['exclusive_maximum'], + path_to_item=validation_metadata.path_to_item + ) + + if (cls.__is_json_validation_enabled('minimum', validation_metadata.configuration) and + 'inclusive_minimum' in validations and + min_val < validations['inclusive_minimum']): + cls.__raise_validation_error_message( + value=input_values, + constraint_msg="must be a value greater than or equal to", + constraint_value=validations['inclusive_minimum'], + path_to_item=validation_metadata.path_to_item + ) + + @classmethod + def _check_validations_for_types( + cls, + validations, + input_values, + validation_metadata: ValidationMetadata + ): + if isinstance(input_values, str): + cls.__check_str_validations(validations, input_values, validation_metadata) + elif isinstance(input_values, tuple): + cls.__check_tuple_validations(validations, input_values, validation_metadata) + elif isinstance(input_values, frozendict): + cls.__check_dict_validations(validations, input_values, validation_metadata) + elif isinstance(input_values, decimal.Decimal): + cls.__check_numeric_validations(validations, input_values, validation_metadata) + try: + return super()._validate_validations_pass(input_values, validation_metadata) + except AttributeError: + return True + + +class Validator(typing.Protocol): + def _validate_validations_pass( + cls, + input_values, + validation_metadata: ValidationMetadata + ): + pass + + +def _SchemaValidator(**validations: typing.Union[str, bool, None, int, float, list[dict[str, typing.Union[str, int, float]]]]) -> Validator: + class SchemaValidator(ValidatorBase): + @classmethod + def _validate_validations_pass( + cls, + input_values, + validation_metadata: ValidationMetadata + ): + cls._check_validations_for_types(validations, input_values, validation_metadata) + try: + return super()._validate_validations_pass(input_values, validation_metadata) + except AttributeError: + return True + + return SchemaValidator + + +class TypeChecker(typing.Protocol): + @classmethod + def _validate_type( + cls, arg_simple_class: type + ) -> typing.Tuple[type]: + pass + + +def _SchemaTypeChecker(union_type_cls: typing.Union[typing.Any]) -> TypeChecker: + if typing.get_origin(union_type_cls) is typing.Union: + union_classes = typing.get_args(union_type_cls) + else: + # note: when a union of a single class is passed in, the union disappears + union_classes = tuple([union_type_cls]) + """ + I want the type hint... union_type_cls + and to use it as a base class but when I do, I get + TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases + """ + class SchemaTypeChecker: + @classmethod + def _validate_type(cls, arg_simple_class: type): + if arg_simple_class not in union_classes: + return union_classes + try: + return super()._validate_type(arg_simple_class) + except AttributeError: + return tuple() + + return SchemaTypeChecker + + +class EnumMakerBase: + @classmethod + @property + def _enum_by_value( + cls + ) -> type: + enum_classes = {} + if not hasattr(cls, "_enum_value_to_name"): + return enum_classes + for enum_value, enum_name in cls._enum_value_to_name.items(): + base_class = type(enum_value) + if base_class is none_type: + enum_classes[enum_value] = get_new_class( + "Dynamic" + cls.__name__, (cls, NoneClass)) + log_cache_usage(get_new_class) + elif base_class is bool: + enum_classes[enum_value] = get_new_class( + "Dynamic" + cls.__name__, (cls, BoolClass)) + log_cache_usage(get_new_class) + else: + enum_classes[enum_value] = get_new_class( + "Dynamic" + cls.__name__, (cls, Singleton, base_class)) + log_cache_usage(get_new_class) + return enum_classes + + +class EnumMakerInterface(typing.Protocol): + @classmethod + @property + def _enum_value_to_name( + cls + ) -> typing.Dict[typing.Union[str, decimal.Decimal, bool, none_type], str]: + pass + + @classmethod + @property + def _enum_by_value( + cls + ) -> type: + pass + + +def _SchemaEnumMaker(enum_value_to_name: typing.Dict[typing.Union[str, decimal.Decimal, bool, none_type], str]) -> EnumMakerInterface: + class SchemaEnumMaker(EnumMakerBase): + @classmethod + @property + def _enum_value_to_name( + cls + ) -> typing.Dict[typing.Union[str, decimal.Decimal, bool, none_type], str]: + pass + try: + super_enum_value_to_name = super()._enum_value_to_name + except AttributeError: + return enum_value_to_name + intersection = dict(enum_value_to_name.items() & super_enum_value_to_name.items()) + return intersection + + return SchemaEnumMaker + + +class Singleton: + """ + Enums and singletons are the same + The same instance is returned for a given key of (cls, arg) + """ + _instances = {} + + def __new__(cls, arg: typing.Any, **kwargs): + key = (cls, arg) + if key not in cls._instances: + if arg in {None, True, False}: + inst = super().__new__(cls) + # inst._value = arg + cls._instances[key] = inst + else: + cls._instances[key] = super().__new__(cls, arg) + return cls._instances[key] + + def __repr__(self): + if isinstance(self, NoneClass): + return f'<{self.__class__.__name__}: None>' + elif isinstance(self, BoolClass): + if (self.__class__, True) in self._instances: + return f'<{self.__class__.__name__}: True>' + return f'<{self.__class__.__name__}: False>' + return f'<{self.__class__.__name__}: {super().__repr__()}>' + + +class NoneClass(Singleton): + @classmethod + @property + def NONE(cls): + return cls(None) + + def __bool__(self) -> bool: + return False + + +class BoolClass(Singleton): + @classmethod + @property + def TRUE(cls): + return cls(True) + + @classmethod + @property + def FALSE(cls): + return cls(False) + + @functools.cache + def __bool__(self) -> bool: + for key, instance in self._instances.items(): + if self is instance: + return key[1] + raise ValueError('Unable to find the boolean value of this instance') + + +class BoolBase: + def is_true(self) -> bool: + """ + A replacement for x is True + True if the instance is a BoolClass True Singleton + """ + if not issubclass(self.__class__, BoolClass): + return False + return bool(self) + + def is_false(self) -> bool: + """ + A replacement for x is False + True if the instance is a BoolClass False Singleton + """ + if not issubclass(self.__class__, BoolClass): + return False + return bool(self) is False + + +class NoneBase: + def is_none(self) -> bool: + """ + A replacement for x is None + True if the instance is a NoneClass None Singleton + """ + if issubclass(self.__class__, NoneClass): + return True + return False + + +class StrBase: + @property + def as_str(self) -> str: + return self + + @property + def as_date(self) -> date: + raise Exception('not implemented') + + @property + def as_datetime(self) -> datetime: + raise Exception('not implemented') + + @property + def as_decimal(self) -> decimal.Decimal: + raise Exception('not implemented') + + @property + def as_uuid(self) -> uuid.UUID: + raise Exception('not implemented') + + +class UUIDBase(StrBase): + @property + @functools.cache + def as_uuid(self) -> uuid.UUID: + return uuid.UUID(self) + + @classmethod + def _validate_format(cls, arg: typing.Optional[str], validation_metadata: ValidationMetadata): + if isinstance(arg, str): + try: + uuid.UUID(arg) + return True + except ValueError: + raise ApiValueError( + "Invalid value '{}' for type UUID at {}".format(arg, validation_metadata.path_to_item) + ) + + @classmethod + def _validate( + cls, + arg, + validation_metadata: typing.Optional[ValidationMetadata] = None, + ): + """ + UUIDBase _validate + """ + cls._validate_format(arg, validation_metadata=validation_metadata) + return super()._validate(arg, validation_metadata=validation_metadata) + + +class CustomIsoparser(isoparser): + + @_takes_ascii + def parse_isodatetime(self, dt_str): + components, pos = self._parse_isodate(dt_str) + if len(dt_str) > pos: + if self._sep is None or dt_str[pos:pos + 1] == self._sep: + components += self._parse_isotime(dt_str[pos + 1:]) + else: + raise ValueError('String contains unknown ISO components') + + if len(components) > 3 and components[3] == 24: + components[3] = 0 + return datetime(*components) + timedelta(days=1) + + if len(components) <= 3: + raise ValueError('Value is not a datetime') + + return datetime(*components) + + @_takes_ascii + def parse_isodate(self, datestr): + components, pos = self._parse_isodate(datestr) + + if len(datestr) > pos: + raise ValueError('String contains invalid time components') + + if len(components) > 3: + raise ValueError('String contains invalid time components') + + return date(*components) + + +DEFAULT_ISOPARSER = CustomIsoparser() + + +class DateBase(StrBase): + @property + @functools.cache + def as_date(self) -> date: + return DEFAULT_ISOPARSER.parse_isodate(self) + + @classmethod + def _validate_format(cls, arg: typing.Optional[str], validation_metadata: ValidationMetadata): + if isinstance(arg, str): + try: + DEFAULT_ISOPARSER.parse_isodate(arg) + return True + except ValueError: + raise ApiValueError( + "Value does not conform to the required ISO-8601 date format. " + "Invalid value '{}' for type date at {}".format(arg, validation_metadata.path_to_item) + ) + + @classmethod + def _validate( + cls, + arg, + validation_metadata: typing.Optional[ValidationMetadata] = None, + ): + """ + DateBase _validate + """ + cls._validate_format(arg, validation_metadata=validation_metadata) + return super()._validate(arg, validation_metadata=validation_metadata) + + +class DateTimeBase: + @property + @functools.cache + def as_datetime(self) -> datetime: + return DEFAULT_ISOPARSER.parse_isodatetime(self) + + @classmethod + def _validate_format(cls, arg: typing.Optional[str], validation_metadata: ValidationMetadata): + if isinstance(arg, str): + try: + DEFAULT_ISOPARSER.parse_isodatetime(arg) + return True + except ValueError: + raise ApiValueError( + "Value does not conform to the required ISO-8601 datetime format. " + "Invalid value '{}' for type datetime at {}".format(arg, validation_metadata.path_to_item) + ) + + @classmethod + def _validate( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + """ + DateTimeBase _validate + """ + cls._validate_format(arg, validation_metadata=validation_metadata) + return super()._validate(arg, validation_metadata=validation_metadata) + + +class DecimalBase(StrBase): + """ + A class for storing decimals that are sent over the wire as strings + These schemas must remain based on StrBase rather than NumberBase + because picking base classes must be deterministic + """ + + @property + @functools.cache + def as_decimal(self) -> decimal.Decimal: + return decimal.Decimal(self) + + @classmethod + def _validate_format(cls, arg: typing.Optional[str], validation_metadata: ValidationMetadata): + if isinstance(arg, str): + try: + decimal.Decimal(arg) + return True + except decimal.InvalidOperation: + raise ApiValueError( + "Value cannot be converted to a decimal. " + "Invalid value '{}' for type decimal at {}".format(arg, validation_metadata.path_to_item) + ) + + @classmethod + def _validate( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + """ + DecimalBase _validate + """ + cls._validate_format(arg, validation_metadata=validation_metadata) + return super()._validate(arg, validation_metadata=validation_metadata) + + +class NumberBase: + @property + def as_int(self) -> int: + try: + return self._as_int + except AttributeError: + """ + Note: for some numbers like 9.0 they could be represented as an + integer but our code chooses to store them as + >>> Decimal('9.0').as_tuple() + DecimalTuple(sign=0, digits=(9, 0), exponent=-1) + so we can tell that the value came from a float and convert it back to a float + during later serialization + """ + if self.as_tuple().exponent < 0: + # this could be represented as an integer but should be represented as a float + # because that's what it was serialized from + raise ApiValueError(f'{self} is not an integer') + self._as_int = int(self) + return self._as_int + + @property + def as_float(self) -> float: + try: + return self._as_float + except AttributeError: + if self.as_tuple().exponent >= 0: + raise ApiValueError(f'{self} is not an float') + self._as_float = float(self) + return self._as_float + + +class ListBase: + @classmethod + def _validate_items(cls, list_items, validation_metadata: ValidationMetadata): + """ + Ensures that: + - values passed in for items are valid + Exceptions will be raised if: + - invalid arguments were passed in + + Args: + list_items: the input list of items + + Raises: + ApiTypeError - for missing required arguments, or for invalid properties + """ + + # if we have definitions for an items schema, use it + # otherwise accept anything + item_cls = getattr(cls, '_items', AnyTypeSchema) + path_to_schemas = {} + for i, value in enumerate(list_items): + if isinstance(value, item_cls): + continue + item_validation_metadata = ValidationMetadata( + from_server=validation_metadata.from_server, + configuration=validation_metadata.configuration, + path_to_item=validation_metadata.path_to_item+(i,) + ) + other_path_to_schemas = item_cls._validate( + value, validation_metadata=item_validation_metadata) + update(path_to_schemas, other_path_to_schemas) + return path_to_schemas + + @classmethod + def _validate( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + """ + ListBase _validate + We return dynamic classes of different bases depending upon the inputs + This makes it so: + - the returned instance is always a subclass of our defining schema + - this allows us to check type based on whether an instance is a subclass of a schema + - the returned instance is a serializable type (except for None, True, and False) which are enums + + Returns: + new_cls (type): the new class + + Raises: + ApiValueError: when a string can't be converted into a date or datetime and it must be one of those classes + ApiTypeError: when the input type is not in the list of allowed spec types + """ + _path_to_schemas = super()._validate(arg, validation_metadata=validation_metadata) + if not isinstance(arg, tuple): + return _path_to_schemas + if cls in validation_metadata.base_classes: + # we have already moved through this class so stop here + return _path_to_schemas + updated_vm = ValidationMetadata( + configuration=validation_metadata.configuration, + from_server=validation_metadata.from_server, + path_to_item=validation_metadata.path_to_item, + base_classes=validation_metadata.base_classes | frozenset({cls}) + ) + other_path_to_schemas = cls._validate_items(arg, validation_metadata=updated_vm) + update(_path_to_schemas, other_path_to_schemas) + return _path_to_schemas + + @classmethod + def _get_items( + cls: 'Schema', + arg: typing.List[typing.Any], + path_to_item: typing.Tuple[typing.Union[str, int], ...], + path_to_schemas: typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Type['Schema']] + ): + ''' + ListBase _get_items + ''' + list_items = arg + cast_items = [] + # if we have definitions for an items schema, use it + # otherwise accept anything + + cls_item_cls = getattr(cls, '_items', AnyTypeSchema) + for i, value in enumerate(list_items): + item_path_to_item = path_to_item + (i,) + item_cls = path_to_schemas.get(item_path_to_item) + if item_cls is None: + item_cls = cls_item_cls + + if isinstance(value, item_cls): + cast_items.append(value) + continue + + new_value = item_cls._get_new_instance_without_conversion( + value, + item_path_to_item, + path_to_schemas + ) + cast_items.append(new_value) + + return cast_items + + +class Discriminable: + @classmethod + def _ensure_discriminator_value_present(cls, disc_property_name: str, validation_metadata: ValidationMetadata, *args): + if not args or args and disc_property_name not in args[0]: + # The input data does not contain the discriminator property + raise ApiValueError( + "Cannot deserialize input data due to missing discriminator. " + "The discriminator property '{}' is missing at path: {}".format(disc_property_name, validation_metadata.path_to_item) + ) + + @classmethod + def _get_discriminated_class(cls, disc_property_name: str, disc_payload_value: str): + """ + Used in schemas with discriminators + """ + if not hasattr(cls, '_discriminator'): + return None + disc = cls._discriminator + if disc_property_name not in disc: + return None + discriminated_cls = disc[disc_property_name].get(disc_payload_value) + if discriminated_cls is not None: + return discriminated_cls + elif not hasattr(cls, '_composed_schemas'): + return None + # TODO stop traveling if a cycle is hit + for allof_cls in cls._composed_schemas['allOf']: + discriminated_cls = allof_cls._get_discriminated_class( + disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) + if discriminated_cls is not None: + return discriminated_cls + for oneof_cls in cls._composed_schemas['oneOf']: + discriminated_cls = oneof_cls._get_discriminated_class( + disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) + if discriminated_cls is not None: + return discriminated_cls + for anyof_cls in cls._composed_schemas['anyOf']: + discriminated_cls = anyof_cls._get_discriminated_class( + disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) + if discriminated_cls is not None: + return discriminated_cls + return None + + +class DictBase(Discriminable): + # subclass properties + _required_property_names = set() + + @classmethod + def _validate_arg_presence(cls, arg): + """ + Ensures that: + - all required arguments are passed in + - the input variable names are valid + - present in properties or + - accepted because additionalProperties exists + Exceptions will be raised if: + - invalid arguments were passed in + - a var_name is invalid if additionProperties == None and var_name not in _properties + - required properties were not passed in + + Args: + arg: the input dict + + Raises: + ApiTypeError - for missing required arguments, or for invalid properties + """ + seen_required_properties = set() + invalid_arguments = [] + for property_name in arg: + if property_name in cls._required_property_names: + seen_required_properties.add(property_name) + elif property_name in cls._property_names: + continue + elif cls._additional_properties: + continue + else: + invalid_arguments.append(property_name) + missing_required_arguments = list(cls._required_property_names - seen_required_properties) + if missing_required_arguments: + missing_required_arguments.sort() + raise ApiTypeError( + "{} is missing {} required argument{}: {}".format( + cls.__name__, + len(missing_required_arguments), + "s" if len(missing_required_arguments) > 1 else "", + missing_required_arguments + ) + ) + if invalid_arguments: + invalid_arguments.sort() + raise ApiTypeError( + "{} was passed {} invalid argument{}: {}".format( + cls.__name__, + len(invalid_arguments), + "s" if len(invalid_arguments) > 1 else "", + invalid_arguments + ) + ) + + @classmethod + def _validate_args(cls, arg, validation_metadata: ValidationMetadata): + """ + Ensures that: + - values passed in for properties are valid + Exceptions will be raised if: + - invalid arguments were passed in + + Args: + arg: the input dict + + Raises: + ApiTypeError - for missing required arguments, or for invalid properties + """ + path_to_schemas = {} + for property_name, value in arg.items(): + if property_name in cls._required_property_names or property_name in cls._property_names: + schema = getattr(cls, property_name) + elif cls._additional_properties: + schema = cls._additional_properties + else: + raise ApiTypeError('Unable to find schema for value={} in class={} at path_to_item={}'.format( + value, cls, validation_metadata.path_to_item+(property_name,) + )) + if isinstance(value, schema): + continue + arg_validation_metadata = ValidationMetadata( + from_server=validation_metadata.from_server, + configuration=validation_metadata.configuration, + path_to_item=validation_metadata.path_to_item+(property_name,) + ) + other_path_to_schemas = schema._validate(value, validation_metadata=arg_validation_metadata) + update(path_to_schemas, other_path_to_schemas) + return path_to_schemas + + @classmethod + def _validate( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + """ + DictBase _validate + We return dynamic classes of different bases depending upon the inputs + This makes it so: + - the returned instance is always a subclass of our defining schema + - this allows us to check type based on whether an instance is a subclass of a schema + - the returned instance is a serializable type (except for None, True, and False) which are enums + + Returns: + new_cls (type): the new class + + Raises: + ApiValueError: when a string can't be converted into a date or datetime and it must be one of those classes + ApiTypeError: when the input type is not in the list of allowed spec types + """ + if isinstance(arg, cls): + # an instance of the correct type was passed in + return {} + _path_to_schemas = super()._validate(arg, validation_metadata=validation_metadata) + if not isinstance(arg, frozendict): + return _path_to_schemas + cls._validate_arg_presence(arg) + other_path_to_schemas = cls._validate_args(arg, validation_metadata=validation_metadata) + update(_path_to_schemas, other_path_to_schemas) + try: + _discriminator = cls._discriminator + except AttributeError: + return _path_to_schemas + # discriminator exists + disc_prop_name = list(_discriminator.keys())[0] + cls._ensure_discriminator_value_present(disc_prop_name, validation_metadata, arg) + discriminated_cls = cls._get_discriminated_class( + disc_property_name=disc_prop_name, disc_payload_value=arg[disc_prop_name]) + if discriminated_cls is None: + raise ApiValueError( + "Invalid discriminator value was passed in to {}.{} Only the values {} are allowed at {}".format( + cls.__name__, + disc_prop_name, + list(_discriminator[disc_prop_name].keys()), + validation_metadata.path_to_item + (disc_prop_name,) + ) + ) + if discriminated_cls in validation_metadata.base_classes: + # we have already moved through this class so stop here + return _path_to_schemas + updated_vm = ValidationMetadata( + configuration=validation_metadata.configuration, + from_server=validation_metadata.from_server, + path_to_item=validation_metadata.path_to_item, + base_classes=validation_metadata.base_classes | frozenset({cls}) + ) + other_path_to_schemas = discriminated_cls._validate(arg, validation_metadata=updated_vm) + update(_path_to_schemas, other_path_to_schemas) + return _path_to_schemas + + @classmethod + @property + def _additional_properties(cls): + return AnyTypeSchema + + @classmethod + @property + @functools.cache + def _property_names(cls): + property_names = set() + for var_name, var_value in cls.__dict__.items(): + # referenced models are classmethods + is_classmethod = type(var_value) is classmethod + if is_classmethod: + property_names.add(var_name) + continue + is_class = type(var_value) is type + if not is_class: + continue + if not issubclass(var_value, Schema): + continue + if var_name == '_additional_properties': + continue + property_names.add(var_name) + property_names = list(property_names) + property_names.sort() + return tuple(property_names) + + @classmethod + def _get_properties( + cls, + arg: typing.Dict[str, typing.Any], + path_to_item: typing.Tuple[typing.Union[str, int], ...], + path_to_schemas: typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Type['Schema']] + ): + """ + DictBase _get_properties, this is how properties are set + These values already passed validation + """ + dict_items = {} + # if we have definitions for property schemas convert values using it + # otherwise accept anything + + for property_name_js, value in arg.items(): + property_cls = getattr(cls, property_name_js, cls._additional_properties) + property_path_to_item = path_to_item + (property_name_js,) + stored_property_cls = path_to_schemas.get(property_path_to_item) + if stored_property_cls: + property_cls = stored_property_cls + + if isinstance(value, property_cls): + dict_items[property_name_js] = value + continue + + new_value = property_cls._get_new_instance_without_conversion( + value, + property_path_to_item, + path_to_schemas + ) + dict_items[property_name_js] = new_value + return dict_items + + def __setattr__(self, name, value): + if not isinstance(self, FileIO): + raise AttributeError('property setting not supported on immutable instances') + + def __getattr__(self, name): + if isinstance(self, frozendict): + # if an attribute does not exist + try: + return self[name] + except KeyError as ex: + raise AttributeError(str(ex)) + return super().__getattr__(self, name) + + def __getattribute__(self, name): + # if an attribute does exist (for example as a class property but not as an instance method) + try: + return self[name] + except (KeyError, TypeError): + return super().__getattribute__(name) + + +inheritable_primitive_types_set = {decimal.Decimal, str, tuple, frozendict, FileIO, bytes} + + +class Schema: + """ + the base class of all swagger/openapi schemas/models + + ensures that: + - payload passes required validations + - payload is of allowed types + - payload value is an allowed enum value + """ + + @staticmethod + def __get_simple_class(input_value): + """Returns an input_value's simple class that we will use for type checking + + Args: + input_value (class/class_instance): the item for which we will return + the simple class + """ + if isinstance(input_value, tuple): + return tuple + elif isinstance(input_value, frozendict): + return frozendict + elif isinstance(input_value, none_type): + return none_type + elif isinstance(input_value, bytes): + return bytes + elif isinstance(input_value, (io.FileIO, io.BufferedReader)): + return FileIO + elif isinstance(input_value, bool): + # this must be higher than the int check because + # isinstance(True, int) == True + return bool + elif isinstance(input_value, int): + return int + elif isinstance(input_value, float): + return float + elif isinstance(input_value, datetime): + # this must be higher than the date check because + # isinstance(datetime_instance, date) == True + return datetime + elif isinstance(input_value, date): + return date + elif isinstance(input_value, str): + return str + return type(input_value) + + @staticmethod + def __get_valid_classes_phrase(input_classes): + """Returns a string phrase describing what types are allowed""" + all_classes = list(input_classes) + all_classes = sorted(all_classes, key=lambda cls: cls.__name__) + all_class_names = [cls.__name__ for cls in all_classes] + if len(all_class_names) == 1: + return "is {0}".format(all_class_names[0]) + return "is one of [{0}]".format(", ".join(all_class_names)) + + @classmethod + def __type_error_message( + cls, var_value=None, var_name=None, valid_classes=None, key_type=None + ): + """ + Keyword Args: + var_value (any): the variable which has the type_error + var_name (str): the name of the variable which has the typ error + valid_classes (tuple): the accepted classes for current_item's + value + key_type (bool): False if our value is a value in a dict + True if it is a key in a dict + False if our item is an item in a tuple + """ + key_or_value = "value" + if key_type: + key_or_value = "key" + valid_classes_phrase = cls.__get_valid_classes_phrase(valid_classes) + msg = "Invalid type. Required {1} type {2} and " "passed type was {3}".format( + var_name, + key_or_value, + valid_classes_phrase, + type(var_value).__name__, + ) + return msg + + @classmethod + def __get_type_error(cls, var_value, path_to_item, valid_classes, key_type=False): + error_msg = cls.__type_error_message( + var_name=path_to_item[-1], + var_value=var_value, + valid_classes=valid_classes, + key_type=key_type, + ) + return ApiTypeError( + error_msg, + path_to_item=path_to_item, + valid_classes=valid_classes, + key_type=key_type, + ) + + @classmethod + def _class_by_base_class(cls, base_cls: type) -> type: + cls_name = "Dynamic"+cls.__name__ + if base_cls is bool: + new_cls = get_new_class(cls_name, (cls, BoolBase, BoolClass)) + elif base_cls is str: + new_cls = get_new_class(cls_name, (cls, StrBase, str)) + elif base_cls is decimal.Decimal: + new_cls = get_new_class(cls_name, (cls, NumberBase, decimal.Decimal)) + elif base_cls is tuple: + new_cls = get_new_class(cls_name, (cls, ListBase, tuple)) + elif base_cls is frozendict: + new_cls = get_new_class(cls_name, (cls, DictBase, frozendict)) + elif base_cls is none_type: + new_cls = get_new_class(cls_name, (cls, NoneBase, NoneClass)) + log_cache_usage(get_new_class) + return new_cls + + @classmethod + def _validate( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + """ + Schema _validate + Runs all schema validation logic and + returns a dynamic class of different bases depending upon the input + This makes it so: + - the returned instance is always a subclass of our defining schema + - this allows us to check type based on whether an instance is a subclass of a schema + - the returned instance is a serializable type (except for None, True, and False) which are enums + + Use cases: + 1. inheritable type: string/decimal.Decimal/frozendict/tuple + 2. enum value cases: 'hi', 1 -> no base_class set because the enum includes the base class + 3. uninheritable type: True/False/None -> no base_class because the base class is not inheritable + _enum_by_value will handle this use case + + Required Steps: + 1. verify type of input is valid vs the allowed _types + 2. check validations that are applicable for this type of input + 3. if enums exist, check that the value exists in the enum + + Returns: + path_to_schemas: a map of path to schemas + + Raises: + ApiValueError: when a string can't be converted into a date or datetime and it must be one of those classes + ApiTypeError: when the input type is not in the list of allowed spec types + """ + base_class = cls.__get_simple_class(arg) + failed_type_check_classes = cls._validate_type(base_class) + if failed_type_check_classes: + raise cls.__get_type_error( + arg, + validation_metadata.path_to_item, + failed_type_check_classes, + key_type=False, + ) + if hasattr(cls, '_validate_validations_pass'): + cls._validate_validations_pass(arg, validation_metadata) + path_to_schemas = {} + if validation_metadata.path_to_item not in path_to_schemas: + path_to_schemas[validation_metadata.path_to_item] = set() + path_to_schemas[validation_metadata.path_to_item].add(cls) + + if hasattr(cls, "_enum_by_value"): + cls._validate_enum_value(arg) + return path_to_schemas + + if base_class is none_type or base_class is bool: + return path_to_schemas + + path_to_schemas[validation_metadata.path_to_item].add(base_class) + return path_to_schemas + + @classmethod + def _validate_enum_value(cls, arg): + try: + cls._enum_by_value[arg] + except KeyError: + raise ApiValueError("Invalid value {} passed in to {}, {}".format(arg, cls, cls._enum_value_to_name)) + + @classmethod + def __get_new_cls( + cls, + arg, + validation_metadata: ValidationMetadata + ) -> typing.Dict[typing.Tuple[typing.Union[str, int], ...], 'Schema']: + """ + Make a new dynamic class and return an instance of that class + We are making an instance of cls, but instead of making cls + make a new class, new_cls + which includes dynamic bases including cls + return an instance of that new class + + Dict property + List Item Assignment Use cases: + 1. value is NOT an instance of the required schema class + the value is validated by _validate + _validate returns a key value pair + where the key is the path to the item, and the value will be the required manufactured class + made out of the matching schemas + 2. value is an instance of the the correct schema type + the value is NOT validated by _validate, _validate only checks that the instance is of the correct schema type + for this value, _validate does NOT return an entry for it in _path_to_schemas + and in list/dict _get_items,_get_properties the value will be directly assigned + because value is of the correct type, and validation was run earlier when the instance was created + """ + _path_to_schemas = cls._validate(arg, validation_metadata=validation_metadata) + # loop through it make a new class for each entry + # do not modify the returned result because it is cached and we would be modifying the cached value + path_to_schemas = {} + for path, schema_classes in _path_to_schemas.items(): + enum_schema = any( + hasattr(this_cls, '_enum_by_value') for this_cls in schema_classes) + inheritable_primitive_type = schema_classes.intersection(inheritable_primitive_types_set) + chosen_schema_classes = schema_classes + suffix = tuple() + if inheritable_primitive_type: + chosen_schema_classes = schema_classes - inheritable_primitive_types_set + if not enum_schema: + # include the inheritable_primitive_type + suffix = tuple(inheritable_primitive_type) + + if len(chosen_schema_classes) == 1 and not suffix: + mfg_cls = tuple(chosen_schema_classes)[0] + else: + x_schema = schema_descendents & chosen_schema_classes + if x_schema: + x_schema = x_schema.pop() + if any(c is not x_schema and issubclass(c, x_schema) for c in chosen_schema_classes): + # needed to not have a mro error in get_new_class + chosen_schema_classes.remove(x_schema) + used_classes = tuple(sorted(chosen_schema_classes, key=lambda a_cls: a_cls.__name__)) + suffix + mfg_cls = get_new_class(class_name='DynamicSchema', bases=used_classes) + + if inheritable_primitive_type and not enum_schema: + path_to_schemas[path] = mfg_cls + continue + + # Use case: value is None, True, False, or an enum value + value = arg + for key in path[1:]: + # if path is bigger than one, get the value that mfg_cls validated + value = value[key] + if hasattr(mfg_cls, '_enum_by_value'): + mfg_cls = mfg_cls._enum_by_value[value] + elif value in {True, False}: + mfg_cls = mfg_cls._class_by_base_class(bool) + elif value is None: + mfg_cls = mfg_cls._class_by_base_class(none_type) + else: + raise ApiValueError('Unhandled case value={} bases={}'.format(value, mfg_cls.__bases__)) + path_to_schemas[path] = mfg_cls + + return path_to_schemas + + @classmethod + def _get_new_instance_without_conversion( + cls: 'Schema', + arg: typing.Any, + path_to_item: typing.Tuple[typing.Union[str, int], ...], + path_to_schemas: typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Type['Schema']] + ): + # We have a Dynamic class and we are making an instance of it + if issubclass(cls, frozendict): + properties = cls._get_properties(arg, path_to_item, path_to_schemas) + return super(Schema, cls).__new__(cls, properties) + elif issubclass(cls, tuple): + items = cls._get_items(arg, path_to_item, path_to_schemas) + return super(Schema, cls).__new__(cls, items) + """ + str = openapi str, date, and datetime + decimal.Decimal = openapi int and float + FileIO = openapi binary type and the user inputs a file + bytes = openapi binary type and the user inputs bytes + """ + return super(Schema, cls).__new__(cls, arg) + + @classmethod + def _from_openapi_data( + cls, + arg: typing.Union[ + str, + date, + datetime, + int, + float, + decimal.Decimal, + bool, + None, + 'Schema', + dict, + frozendict, + tuple, + list, + io.FileIO, + io.BufferedReader, + bytes + ], + _configuration: typing.Optional[Configuration] + ): + """ + Schema _from_openapi_data + """ + arg = cast_to_allowed_types(arg, from_server=True) + validation_metadata = ValidationMetadata(from_server=True, configuration=_configuration) + path_to_schemas = cls.__get_new_cls(arg, validation_metadata) + new_cls = path_to_schemas[validation_metadata.path_to_item] + new_inst = new_cls._get_new_instance_without_conversion( + arg, + validation_metadata.path_to_item, + path_to_schemas + ) + return new_inst + + @staticmethod + def __get_input_dict(*args, **kwargs) -> frozendict: + input_dict = {} + if args and isinstance(args[0], (dict, frozendict)): + input_dict.update(args[0]) + if kwargs: + input_dict.update(kwargs) + return frozendict(input_dict) + + @staticmethod + def __remove_unsets(kwargs): + return {key: val for key, val in kwargs.items() if val is not unset} + + def __new__(cls, *args: typing.Union[dict, frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema'], _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Union[dict, frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema', Unset]): + """ + Schema __new__ + + Args: + args (int/float/decimal.Decimal/str/list/tuple/dict/frozendict/bool/None): the value + kwargs (str, int/float/decimal.Decimal/str/list/tuple/dict/frozendict/bool/None): dict values + _configuration: contains the Configuration that enables json schema validation keywords + like minItems, minLength etc + """ + kwargs = cls.__remove_unsets(kwargs) + if not args and not kwargs: + raise TypeError( + 'No input given. args or kwargs must be given.' + ) + if not kwargs and args and not isinstance(args[0], dict): + arg = args[0] + else: + arg = cls.__get_input_dict(*args, **kwargs) + validation_metadata = ValidationMetadata(configuration=_configuration, from_server=False) + arg = cast_to_allowed_types(arg, from_server=validation_metadata.from_server) + path_to_schemas = cls.__get_new_cls(arg, validation_metadata) + new_cls = path_to_schemas[validation_metadata.path_to_item] + return new_cls._get_new_instance_without_conversion( + arg, + validation_metadata.path_to_item, + path_to_schemas + ) + + def __init__( + self, + *args: typing.Union[ + dict, frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema'], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Union[ + dict, frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema', Unset + ] + ): + """ + this is needed to fix 'Unexpected argument' warning in pycharm + this code does nothing because all Schema instances are immutable + this means that all input data is passed into and used in new, and after the new instance is made + no new attributes are assigned and init is not used + """ + pass + + +def cast_to_allowed_types(arg: typing.Union[str, date, datetime, decimal.Decimal, int, float, None, dict, frozendict, list, tuple, bytes, Schema], from_server=False) -> typing.Union[str, bytes, decimal.Decimal, None, frozendict, tuple, Schema]: + """ + from_server=False date, datetime -> str + int, float -> Decimal + StrSchema will convert that to bytes and remember the encoding when we pass in str input + """ + if isinstance(arg, str): + return arg + elif type(arg) is dict or type(arg) is frozendict: + return frozendict({key: cast_to_allowed_types(val) for key, val in arg.items()}) + elif isinstance(arg, bool): + """ + this check must come before isinstance(arg, (int, float)) + because isinstance(True, int) is True + """ + return arg + elif isinstance(arg, int): + return decimal.Decimal(arg) + elif isinstance(arg, float): + decimal_from_float = decimal.Decimal(arg) + if decimal_from_float.as_integer_ratio()[1] == 1: + # 9.0 -> Decimal('9.0') + # 3.4028234663852886e+38 -> Decimal('340282346638528859811704183484516925440.0') + return decimal.Decimal(str(decimal_from_float)+'.0') + return decimal_from_float + elif type(arg) is list or type(arg) is tuple: + return tuple([cast_to_allowed_types(item) for item in arg]) + elif arg is None: + return arg + elif isinstance(arg, (date, datetime)): + if not from_server: + return arg.isoformat() + # ApiTypeError will be thrown later by _validate_type + return arg + elif isinstance(arg, uuid.UUID): + if not from_server: + return str(arg) + # ApiTypeError will be thrown later by _validate_type + return arg + elif isinstance(arg, decimal.Decimal): + return arg + elif isinstance(arg, bytes): + return arg + elif isinstance(arg, decimal.Decimal): + return arg + elif isinstance(arg, (io.FileIO, io.BufferedReader)): + if arg.closed: + raise ApiValueError('Invalid file state; file is closed and must be open') + return arg + elif isinstance(arg, Schema): + return arg + raise ValueError('Invalid type passed in got input={} type={}'.format(arg, type(arg))) + + +class ComposedBase(Discriminable): + + @classmethod + def __get_allof_classes(cls, arg, validation_metadata: ValidationMetadata): + path_to_schemas = defaultdict(set) + for allof_cls in cls._composed_schemas['allOf']: + if allof_cls in validation_metadata.base_classes: + continue + other_path_to_schemas = allof_cls._validate(arg, validation_metadata=validation_metadata) + update(path_to_schemas, other_path_to_schemas) + return path_to_schemas + + @classmethod + def __get_oneof_class( + cls, + arg, + discriminated_cls, + validation_metadata: ValidationMetadata, + path_to_schemas: typing.Dict[typing.Tuple, typing.Set[typing.Type[Schema]]] + ): + oneof_classes = [] + chosen_oneof_cls = None + original_base_classes = validation_metadata.base_classes + new_base_classes = validation_metadata.base_classes + path_to_schemas = defaultdict(set) + for oneof_cls in cls._composed_schemas['oneOf']: + if oneof_cls in path_to_schemas[validation_metadata.path_to_item]: + oneof_classes.append(oneof_cls) + continue + if isinstance(arg, oneof_cls): + # passed in instance is the correct type + chosen_oneof_cls = oneof_cls + oneof_classes.append(oneof_cls) + continue + try: + path_to_schemas = oneof_cls._validate(arg, validation_metadata=validation_metadata) + new_base_classes = validation_metadata.base_classes + except (ApiValueError, ApiTypeError) as ex: + if discriminated_cls is not None and oneof_cls is discriminated_cls: + raise ex + continue + chosen_oneof_cls = oneof_cls + oneof_classes.append(oneof_cls) + if not oneof_classes: + raise ApiValueError( + "Invalid inputs given to generate an instance of {}. None " + "of the oneOf schemas matched the input data.".format(cls) + ) + elif len(oneof_classes) > 1: + raise ApiValueError( + "Invalid inputs given to generate an instance of {}. Multiple " + "oneOf schemas {} matched the inputs, but a max of one is allowed.".format(cls, oneof_classes) + ) + return path_to_schemas + + @classmethod + def __get_anyof_classes( + cls, + arg, + discriminated_cls, + validation_metadata: ValidationMetadata + ): + anyof_classes = [] + chosen_anyof_cls = None + original_base_classes = validation_metadata.base_classes + path_to_schemas = defaultdict(set) + for anyof_cls in cls._composed_schemas['anyOf']: + if anyof_cls in validation_metadata.base_classes: + continue + if isinstance(arg, anyof_cls): + # passed in instance is the correct type + chosen_anyof_cls = anyof_cls + anyof_classes.append(anyof_cls) + continue + + try: + other_path_to_schemas = anyof_cls._validate(arg, validation_metadata=validation_metadata) + except (ApiValueError, ApiTypeError) as ex: + if discriminated_cls is not None and anyof_cls is discriminated_cls: + raise ex + continue + original_base_classes = validation_metadata.base_classes + chosen_anyof_cls = anyof_cls + anyof_classes.append(anyof_cls) + update(path_to_schemas, other_path_to_schemas) + if not anyof_classes: + raise ApiValueError( + "Invalid inputs given to generate an instance of {}. None " + "of the anyOf schemas matched the input data.".format(cls) + ) + return path_to_schemas + + @classmethod + def _validate( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + """ + ComposedBase _validate + We return dynamic classes of different bases depending upon the inputs + This makes it so: + - the returned instance is always a subclass of our defining schema + - this allows us to check type based on whether an instance is a subclass of a schema + - the returned instance is a serializable type (except for None, True, and False) which are enums + + Returns: + new_cls (type): the new class + + Raises: + ApiValueError: when a string can't be converted into a date or datetime and it must be one of those classes + ApiTypeError: when the input type is not in the list of allowed spec types + """ + if isinstance(arg, Schema) and validation_metadata.from_server is False: + if isinstance(arg, cls): + # an instance of the correct type was passed in + return {} + raise ApiTypeError( + 'Incorrect type passed in, required type was {} and passed type was {} at {}'.format( + cls, + type(arg), + validation_metadata.path_to_item + ) + ) + + # validation checking on types, validations, and enums + path_to_schemas = super()._validate(arg, validation_metadata=validation_metadata) + + updated_vm = ValidationMetadata( + configuration=validation_metadata.configuration, + from_server=validation_metadata.from_server, + path_to_item=validation_metadata.path_to_item, + base_classes=validation_metadata.base_classes | frozenset({cls}) + ) + + # process composed schema + _discriminator = getattr(cls, '_discriminator', None) + discriminated_cls = None + if _discriminator and arg and isinstance(arg, frozendict): + disc_property_name = list(_discriminator.keys())[0] + cls._ensure_discriminator_value_present(disc_property_name, updated_vm, arg) + # get discriminated_cls by looking at the dict in the current class + discriminated_cls = cls._get_discriminated_class( + disc_property_name=disc_property_name, disc_payload_value=arg[disc_property_name]) + if discriminated_cls is None: + raise ApiValueError( + "Invalid discriminator value '{}' was passed in to {}.{} Only the values {} are allowed at {}".format( + arg[disc_property_name], + cls.__name__, + disc_property_name, + list(_discriminator[disc_property_name].keys()), + updated_vm.path_to_item + (disc_property_name,) + ) + ) + + if cls._composed_schemas['allOf']: + other_path_to_schemas = cls.__get_allof_classes(arg, validation_metadata=updated_vm) + update(path_to_schemas, other_path_to_schemas) + if cls._composed_schemas['oneOf']: + other_path_to_schemas = cls.__get_oneof_class( + arg, + discriminated_cls=discriminated_cls, + validation_metadata=updated_vm, + path_to_schemas=path_to_schemas + ) + update(path_to_schemas, other_path_to_schemas) + if cls._composed_schemas['anyOf']: + other_path_to_schemas = cls.__get_anyof_classes( + arg, + discriminated_cls=discriminated_cls, + validation_metadata=updated_vm + ) + update(path_to_schemas, other_path_to_schemas) + not_cls = cls._composed_schemas['not'] + if not_cls: + other_path_to_schemas = None + try: + other_path_to_schemas = not_cls._validate(arg, validation_metadata=updated_vm) + except (ApiValueError, ApiTypeError): + pass + if other_path_to_schemas: + raise ApiValueError( + "Invalid value '{}' was passed in to {}. Value is invalid because it is disallowed by {}".format( + arg, + cls.__name__, + not_cls.__name__, + ) + ) + + if discriminated_cls is not None: + # TODO use an exception from this package here + assert discriminated_cls in path_to_schemas[updated_vm.path_to_item] + return path_to_schemas + + +# DictBase, ListBase, NumberBase, StrBase, BoolBase, NoneBase +class ComposedSchema( + _SchemaTypeChecker(typing.Union[none_type, str, decimal.Decimal, bool, tuple, frozendict]), + ComposedBase, + DictBase, + ListBase, + NumberBase, + StrBase, + BoolBase, + NoneBase, + Schema +): + + # subclass properties + _composed_schemas = {} + + @classmethod + def _from_openapi_data(cls, *args: typing.Any, _configuration: typing.Optional[Configuration] = None, **kwargs): + if not args: + if not kwargs: + raise ApiTypeError('{} is missing required input data in args or kwargs'.format(cls.__name__)) + args = (kwargs, ) + return super()._from_openapi_data(args[0], _configuration=_configuration) + + +class ListSchema( + _SchemaTypeChecker(typing.Union[tuple]), + ListBase, + Schema +): + + @classmethod + def _from_openapi_data(cls, arg: typing.List[typing.Any], _configuration: typing.Optional[Configuration] = None): + return super()._from_openapi_data(arg, _configuration=_configuration) + + def __new__(cls, arg: typing.Union[list, tuple], **kwargs: ValidationMetadata): + return super().__new__(cls, arg, **kwargs) + + +class NoneSchema( + _SchemaTypeChecker(typing.Union[none_type]), + NoneBase, + Schema +): + + @classmethod + def _from_openapi_data(cls, arg: None, _configuration: typing.Optional[Configuration] = None): + return super()._from_openapi_data(arg, _configuration=_configuration) + + def __new__(cls, arg: None, **kwargs: typing.Union[ValidationMetadata]): + return super().__new__(cls, arg, **kwargs) + + +class NumberSchema( + _SchemaTypeChecker(typing.Union[decimal.Decimal]), + NumberBase, + Schema +): + """ + This is used for type: number with no format + Both integers AND floats are accepted + """ + + @classmethod + def _from_openapi_data(cls, arg: typing.Union[int, float, decimal.Decimal], _configuration: typing.Optional[Configuration] = None): + return super()._from_openapi_data(arg, _configuration=_configuration) + + def __new__(cls, arg: typing.Union[decimal.Decimal, int, float], **kwargs: typing.Union[ValidationMetadata]): + return super().__new__(cls, arg, **kwargs) + + +class IntBase(NumberBase): + @property + def as_int(self) -> int: + try: + return self._as_int + except AttributeError: + self._as_int = int(self) + return self._as_int + + @classmethod + def _validate_format(cls, arg: typing.Optional[decimal.Decimal], validation_metadata: ValidationMetadata): + if isinstance(arg, decimal.Decimal): + + denominator = arg.as_integer_ratio()[-1] + if denominator != 1: + raise ApiValueError( + "Invalid value '{}' for type integer at {}".format(arg, validation_metadata.path_to_item) + ) + + @classmethod + def _validate( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + """ + IntBase _validate + TODO what about types = (int, number) -> IntBase, NumberBase? We could drop int and keep number only + """ + cls._validate_format(arg, validation_metadata=validation_metadata) + return super()._validate(arg, validation_metadata=validation_metadata) + + +class IntSchema(IntBase, NumberSchema): + + @classmethod + def _from_openapi_data(cls, arg: int, _configuration: typing.Optional[Configuration] = None): + return super()._from_openapi_data(arg, _configuration=_configuration) + + def __new__(cls, arg: typing.Union[decimal.Decimal, int], **kwargs: typing.Union[ValidationMetadata]): + return super().__new__(cls, arg, **kwargs) + + +class Int32Base( + _SchemaValidator( + inclusive_minimum=decimal.Decimal(-2147483648), + inclusive_maximum=decimal.Decimal(2147483647) + ), +): + pass + + +class Int32Schema( + Int32Base, + IntSchema +): + pass + + +class Int64Base( + _SchemaValidator( + inclusive_minimum=decimal.Decimal(-9223372036854775808), + inclusive_maximum=decimal.Decimal(9223372036854775807) + ), +): + pass + + +class Int64Schema( + Int64Base, + IntSchema +): + pass + + +class Float32Base( + _SchemaValidator( + inclusive_minimum=decimal.Decimal(-3.4028234663852886e+38), + inclusive_maximum=decimal.Decimal(3.4028234663852886e+38) + ), +): + pass + + +class Float32Schema( + Float32Base, + NumberSchema +): + + @classmethod + def _from_openapi_data(cls, arg: typing.Union[float, decimal.Decimal], _configuration: typing.Optional[Configuration] = None): + # todo check format + return super()._from_openapi_data(arg, _configuration=_configuration) + + +class Float64Base( + _SchemaValidator( + inclusive_minimum=decimal.Decimal(-1.7976931348623157E+308), + inclusive_maximum=decimal.Decimal(1.7976931348623157E+308) + ), +): + pass + + +class Float64Schema( + Float64Base, + NumberSchema +): + + @classmethod + def _from_openapi_data(cls, arg: typing.Union[float, decimal.Decimal], _configuration: typing.Optional[Configuration] = None): + # todo check format + return super()._from_openapi_data(arg, _configuration=_configuration) + + +class StrSchema( + _SchemaTypeChecker(typing.Union[str]), + StrBase, + Schema +): + """ + date + datetime string types must inherit from this class + That is because one can validate a str payload as both: + - type: string (format unset) + - type: string, format: date + """ + + @classmethod + def _from_openapi_data(cls, arg: typing.Union[str], _configuration: typing.Optional[Configuration] = None) -> 'StrSchema': + return super()._from_openapi_data(arg, _configuration=_configuration) + + def __new__(cls, arg: typing.Union[str, date, datetime, uuid.UUID], **kwargs: typing.Union[ValidationMetadata]): + return super().__new__(cls, arg, **kwargs) + + +class UUIDSchema(UUIDBase, StrSchema): + + def __new__(cls, arg: typing.Union[str, uuid.UUID], **kwargs: typing.Union[ValidationMetadata]): + return super().__new__(cls, arg, **kwargs) + + +class DateSchema(DateBase, StrSchema): + + def __new__(cls, arg: typing.Union[str, datetime], **kwargs: typing.Union[ValidationMetadata]): + return super().__new__(cls, arg, **kwargs) + + +class DateTimeSchema(DateTimeBase, StrSchema): + + def __new__(cls, arg: typing.Union[str, datetime], **kwargs: typing.Union[ValidationMetadata]): + return super().__new__(cls, arg, **kwargs) + + +class DecimalSchema(DecimalBase, StrSchema): + + def __new__(cls, arg: typing.Union[str], **kwargs: typing.Union[ValidationMetadata]): + """ + Note: Decimals may not be passed in because cast_to_allowed_types is only invoked once for payloads + which can be simple (str) or complex (dicts or lists with nested values) + Because casting is only done once and recursively casts all values prior to validation then for a potential + client side Decimal input if Decimal was accepted as an input in DecimalSchema then one would not know + if one was using it for a StrSchema (where it should be cast to str) or one is using it for NumberSchema + where it should stay as Decimal. + """ + return super().__new__(cls, arg, **kwargs) + + +class BytesSchema( + _SchemaTypeChecker(typing.Union[bytes]), + Schema, +): + """ + this class will subclass bytes and is immutable + """ + def __new__(cls, arg: typing.Union[bytes], **kwargs: typing.Union[ValidationMetadata]): + return super(Schema, cls).__new__(cls, arg) + + +class FileSchema( + _SchemaTypeChecker(typing.Union[FileIO]), + Schema, +): + """ + This class is NOT immutable + Dynamic classes are built using it for example when AnyType allows in binary data + Al other schema classes ARE immutable + If one wanted to make this immutable one could make this a DictSchema with required properties: + - data = BytesSchema (which would be an immutable bytes based schema) + - file_name = StrSchema + and cast_to_allowed_types would convert bytes and file instances into dicts containing data + file_name + The downside would be that data would be stored in memory which one may not want to do for very large files + + The developer is responsible for closing this file and deleting it + + This class was kept as mutable: + - to allow file reading and writing to disk + - to be able to preserve file name info + """ + + def __new__(cls, arg: typing.Union[io.FileIO, io.BufferedReader], **kwargs: typing.Union[ValidationMetadata]): + return super(Schema, cls).__new__(cls, arg) + + +class BinaryBase: + pass + + +class BinarySchema( + _SchemaTypeChecker(typing.Union[bytes, FileIO]), + ComposedBase, + BinaryBase, + Schema, +): + + @classmethod + @property + def _composed_schemas(cls): + # 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 because 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 { + 'allOf': [], + 'oneOf': [ + BytesSchema, + FileSchema, + ], + 'anyOf': [ + ], + 'not': None + } + + def __new__(cls, arg: typing.Union[io.FileIO, io.BufferedReader, bytes], **kwargs: typing.Union[ValidationMetadata]): + return super().__new__(cls, arg) + + +class BoolSchema( + _SchemaTypeChecker(typing.Union[bool]), + BoolBase, + Schema +): + + @classmethod + def _from_openapi_data(cls, arg: bool, _configuration: typing.Optional[Configuration] = None): + return super()._from_openapi_data(arg, _configuration=_configuration) + + def __new__(cls, arg: bool, **kwargs: typing.Union[ValidationMetadata]): + return super().__new__(cls, arg, **kwargs) + + +class AnyTypeSchema( + _SchemaTypeChecker( + typing.Union[frozendict, tuple, decimal.Decimal, str, bool, none_type, bytes, FileIO] + ), + DictBase, + ListBase, + NumberBase, + StrBase, + BoolBase, + NoneBase, + Schema +): + pass + + +class DictSchema( + _SchemaTypeChecker(typing.Union[frozendict]), + DictBase, + Schema +): + + @classmethod + def _from_openapi_data(cls, arg: typing.Dict[str, typing.Any], _configuration: typing.Optional[Configuration] = None): + return super()._from_openapi_data(arg, _configuration=_configuration) + + def __new__(cls, *args: typing.Union[dict, frozendict], **kwargs: typing.Union[dict, frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, bytes, Schema, Unset, ValidationMetadata]): + return super().__new__(cls, *args, **kwargs) + + +schema_descendents = set([NoneSchema, DictSchema, ListSchema, NumberSchema, StrSchema, BoolSchema]) + + +def deserialize_file(response_data, configuration, content_disposition=None): + """Deserializes body to file + + Saves response body into a file in a temporary folder, + using the filename from the `Content-Disposition` header if provided. + + Args: + param response_data (str): the file data to write + configuration (Configuration): the instance to use to convert files + + Keyword Args: + content_disposition (str): the value of the Content-Disposition + header + + Returns: + (file_type): the deserialized file which is open + The user is responsible for closing and reading the file + """ + fd, path = tempfile.mkstemp(dir=configuration.temp_folder_path) + os.close(fd) + os.remove(path) + + if content_disposition: + filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', + content_disposition).group(1) + path = os.path.join(os.path.dirname(path), filename) + + with open(path, "wb") as f: + if isinstance(response_data, str): + # change str to bytes so we can write it + response_data = response_data.encode('utf-8') + f.write(response_data) + + f = open(path, "rb") + return f + + +@functools.cache +def get_new_class( + class_name: str, + bases: typing.Tuple[typing.Type[typing.Union[Schema, typing.Any]], ...] +) -> typing.Type[Schema]: + """ + Returns a new class that is made with the subclass bases + """ + return type(class_name, bases, {}) + + +LOG_CACHE_USAGE = False + + +def log_cache_usage(cache_fn): + if LOG_CACHE_USAGE: + print(cache_fn.__name__, cache_fn.cache_info()) -- GitLab From 7cdcfd95dacf54a4e104752b2a5eb10d981b208f Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Tue, 21 Jun 2022 17:40:17 -0700 Subject: [PATCH 02/43] Adds processing of multiple files --- .../3_0/unit_test_spec/spec_writer.py | 126 ++++++++++++------ .../resources/3_0/unit_test_spec/type.yaml | 121 +++++++++++++++++ 2 files changed, 208 insertions(+), 39 deletions(-) diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index 854c3694f56..aea8b979dff 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -46,19 +46,42 @@ class JsonSchemaTestCase: data: typing.Union[str, int, float, bool, None, list, dict] valid: bool +JsonSchema = typing.TypedDict( + 'JsonSchema', + { + 'type': str, + 'properties': typing.Dict[str, 'JsonSchema'], + 'patternProperties': typing.Dict[str, 'JsonSchema'], + 'additionalProperties': typing.Union[bool, 'JsonSchema'], + 'allOf': typing.List['JsonSchema'], + 'anyOf': typing.List['JsonSchema'], + 'oneOf': typing.List['JsonSchema'], + 'not': 'JsonSchema', + 'maxLength': int, + 'minLength': int, + 'required': typing.List[str], + 'maximum': typing.Union[int, float], + 'minimum': typing.Union[int, float], + 'multipleOf': typing.Union[int, float], + }, + total=False +) + @dataclasses.dataclass class JsonSchemaTestSchema: description: str - schema: dict + schema: typing.Union[bool, JsonSchema] tests: typing.List[JsonSchemaTestCase] class ExclusionReason: v303_does_not_support_array_of_types = 'v3.0.3 does not support type with array of values' v303_requires_array_have_items = 'v3.0.3 requires that items MUST be present if the type is array' + v303_does_not_support_additionalItems = 'v3.0.3 does not support the additionalItems keyword' + v303_does_not_support_const = 'v3.0.3 does not support the const keyword' json_schema_test_draft = 'draft6' -filepath_to_excluded_case_and_reason = { +FILEPATH_TO_EXCLUDED_CASE_AND_REASON = { (json_schema_test_draft, 'type.json'): { 'multiple types can be specified in an array': ExclusionReason.v303_does_not_support_array_of_types, 'type as array with one item': ExclusionReason.v303_does_not_support_array_of_types, @@ -67,11 +90,31 @@ filepath_to_excluded_case_and_reason = { 'array type matches arrays': ExclusionReason.v303_requires_array_have_items, } } +FILEPATH_TO_EXCLUDE_REASON = { + (json_schema_test_draft, 'additionalItems.json'): ExclusionReason.v303_does_not_support_additionalItems, + +} + +openapi_additions = 'openapi_additions' + +JSON_SCHEMA_TEST_FILE_TO_FOLDERS = { + 'type.json': (json_schema_test_draft, openapi_additions), + 'additionalItems.json': (json_schema_test_draft,), + 'additionalProperties.json': (json_schema_test_draft,), + 'allOf.json': (json_schema_test_draft,), + 'anyOf.json': (json_schema_test_draft,), + 'boolean_schema.json': (json_schema_test_draft,), + 'const.json': (json_schema_test_draft,), +} def get_json_schema_test_schemas(file_path: typing.Tuple[str]) -> typing.List[JsonSchemaTestSchema]: json_schema_test_schemas = [] filename = file_path[-1] - excluded_case_to_reason = filepath_to_excluded_case_and_reason.get(file_path, {}) + exclude_file_reason = FILEPATH_TO_EXCLUDE_REASON.get(file_path) + if exclude_file_reason: + print(f'Excluding {file_path} because {exclude_file_reason}') + return + excluded_case_to_reason = FILEPATH_TO_EXCLUDED_CASE_AND_REASON.get(file_path, {}) path = pathlib.PurePath(*file_path) with open(path) as json_file: test_schema_dicts = json.load(json_file) @@ -88,12 +131,6 @@ def get_json_schema_test_schemas(file_path: typing.Tuple[str]) -> typing.List[Js return json_schema_test_schemas -openapi_additions = 'openapi_additions' - -json_schema_test_file_to_folders = { - 'type.json': (json_schema_test_draft, openapi_additions) -} - openapi_version = '3.0.3' @@ -108,7 +145,8 @@ OpenApiSchema = typing.TypedDict( { 'type': str, 'x-test-examples': typing.Dict[str, JsonSchemaTestCase], - 'items': 'OpenApiSchema' + 'items': 'OpenApiSchema', + 'properties': typing.Dict[str, 'OpenApiSchema'] } ) @@ -151,39 +189,49 @@ def get_test_case_name(test: JsonSchemaTestSchema) -> str: res = ''.join(test.description.title().split()) return re.sub(r'[^A-Za-z0-9 ]+', '', res) -def get_openapi_from_test_file(json_schema_test_file: str, folders: typing.Tuple[str]) -> OpenApiDocument: - openapi = get_new_openapi() - for folder in folders: - file_path_tuple = (folder, json_schema_test_file) - test_schemas = get_json_schema_test_schemas(file_path_tuple) - for test_schema in test_schemas: - component_name = description_to_component_name(test_schema.description) - kwargs = { - 'x-test-examples': {} - } - schema = OpenApiSchema( - **test_schema.schema, **kwargs - ) - openapi.components.schemas[component_name] = schema - for test in test_schema.tests: - test_case_name = get_test_case_name(test) - schema['x-test-examples'][test_case_name] = test - return openapi - -for json_schema_test_file, folders in json_schema_test_file_to_folders.items(): - openapi = get_openapi_from_test_file(json_schema_test_file, folders) - print( - yaml.dump( - dataclasses.asdict(openapi), - sort_keys=False +def get_component_schemas(json_schema_test_file: str, folders: typing.Tuple[str]) -> typing.Dict[str, OpenApiSchema]: + component_schemas = {} + for folder in folders: + file_path_tuple = (folder, json_schema_test_file) + test_schemas = get_json_schema_test_schemas(file_path_tuple) + if not test_schemas: + continue + for test_schema in test_schemas: + component_name = description_to_component_name(test_schema.description) + kwargs = { + 'x-test-examples': {} + } + print(test_schema) + schema = OpenApiSchema( + **test_schema.schema, **kwargs + ) + component_schemas[component_name] = schema + for test in test_schema.tests: + test_case_name = get_test_case_name(test) + schema['x-test-examples'][test_case_name] = test + return component_schemas + +def write_openapi_spec(): + openapi = get_new_openapi() + for json_schema_test_file, folders in JSON_SCHEMA_TEST_FILE_TO_FOLDERS.items(): + component_schemas = get_component_schemas(json_schema_test_file, folders) + for component_name, schema in component_schemas.items(): + if component_name in openapi.components.schemas: + raise ValueError('A component with that nae is already defined!') + openapi.components.schemas[component_name] = schema + print( + yaml.dump( + dataclasses.asdict(openapi), + sort_keys=False + ) ) - ) - filename_prefix = pathlib.Path(json_schema_test_file).stem - spec_out = f'{filename_prefix}.yaml' + spec_out = 'type.yaml' with open(spec_out, 'w') as yaml_out: yaml_out.write( yaml.dump( dataclasses.asdict(openapi), sort_keys=False ) - ) \ No newline at end of file + ) + +write_openapi_spec() \ No newline at end of file diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml index d2991f6eaac..74a1bb31809 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml @@ -273,3 +273,124 @@ components: description: null is not an array data: null valid: false + AdditionalpropertiesBeingFalseDoesNotAllowOtherProperties: + properties: + foo: {} + bar: {} + patternProperties: + ^v: {} + additionalProperties: false + x-test-examples: + NoAdditionalPropertiesIsValid: + description: no additional properties is valid + data: + foo: 1 + valid: true + AnAdditionalPropertyIsInvalid: + description: an additional property is invalid + data: + foo: 1 + bar: 2 + quux: boom + valid: false + IgnoresArrays: + description: ignores arrays + data: + - 1 + - 2 + - 3 + valid: true + IgnoresStrings: + description: ignores strings + data: foobarbaz + valid: true + IgnoresOtherNonObjects: + description: ignores other non-objects + data: 12 + valid: true + PatternpropertiesAreNotAdditionalProperties: + description: patternProperties are not additional properties + data: + foo: 1 + vroom: 2 + valid: true + NonAsciiPatternWithAdditionalproperties: + patternProperties: + "^\xE1": {} + additionalProperties: false + x-test-examples: + MatchingThePatternIsValid: + description: matching the pattern is valid + data: + "\xE1rm\xE1nyos": 2 + valid: true + NotMatchingThePatternIsInvalid: + description: not matching the pattern is invalid + data: + "\xE9lm\xE9ny": 2 + valid: false + AdditionalpropertiesAllowsASchemaWhichShouldValidate: + properties: + foo: {} + bar: {} + additionalProperties: + type: boolean + x-test-examples: + NoAdditionalPropertiesIsValid: + description: no additional properties is valid + data: + foo: 1 + valid: true + AnAdditionalValidPropertyIsValid: + description: an additional valid property is valid + data: + foo: 1 + bar: 2 + quux: true + valid: true + AnAdditionalInvalidPropertyIsInvalid: + description: an additional invalid property is invalid + data: + foo: 1 + bar: 2 + quux: 12 + valid: false + AdditionalpropertiesCanExistByItself: + additionalProperties: + type: boolean + x-test-examples: + AnAdditionalValidPropertyIsValid: + description: an additional valid property is valid + data: + foo: true + valid: true + AnAdditionalInvalidPropertyIsInvalid: + description: an additional invalid property is invalid + data: + foo: 1 + valid: false + AdditionalpropertiesAreAllowedByDefault: + properties: + foo: {} + bar: {} + x-test-examples: + AdditionalPropertiesAreAllowed: + description: additional properties are allowed + data: + foo: 1 + bar: 2 + quux: true + valid: true + AdditionalpropertiesShouldNotLookInApplicators: + allOf: + - properties: + foo: {} + additionalProperties: + type: boolean + x-test-examples: + PropertiesDefinedInAllofAreNotExamined: + description: properties defined in allOf are not examined + data: + foo: 1 + bar: true + valid: false -- GitLab From a1009a054136cc9c4d2172d4e2bd1f3a99f611b2 Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Tue, 21 Jun 2022 18:16:40 -0700 Subject: [PATCH 03/43] Moves test examples into a different component so component schemas can be booleans --- .../3_0/unit_test_spec/spec_writer.py | 64 +- .../resources/3_0/unit_test_spec/type.yaml | 1111 ++++++++++++----- 2 files changed, 806 insertions(+), 369 deletions(-) diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index aea8b979dff..5e72d3f6aea 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -92,7 +92,7 @@ FILEPATH_TO_EXCLUDED_CASE_AND_REASON = { } FILEPATH_TO_EXCLUDE_REASON = { (json_schema_test_draft, 'additionalItems.json'): ExclusionReason.v303_does_not_support_additionalItems, - + (json_schema_test_draft, 'const.json'): ExclusionReason.v303_does_not_support_const, } openapi_additions = 'openapi_additions' @@ -155,9 +155,13 @@ class OpenApiExample: description: str value: typing.Union[str, int, float, bool, None, list, dict] -@dataclasses.dataclass -class OpenApiComponents: - schemas: typing.Dict[str, OpenApiSchema] +OpenApiComponents = typing.TypedDict( + 'OpenApiComponents', + { + 'schemas': typing.Dict[str, typing.Union[bool, OpenApiSchema]], + 'x-schema-test-examples': typing.Dict[str, typing.Dict[str, JsonSchemaTestCase]] + } +) @dataclasses.dataclass class OpenApiDocument: @@ -176,9 +180,10 @@ def get_new_openapi() -> OpenApiDocument: version="0.0.1" ), paths={}, - components=OpenApiComponents( - schemas={}, - ) + components=OpenApiComponents({ + 'schemas': {}, + 'x-schema-test-examples': {} + }) ) def description_to_component_name(descr: str) -> str: @@ -189,8 +194,9 @@ def get_test_case_name(test: JsonSchemaTestSchema) -> str: res = ''.join(test.description.title().split()) return re.sub(r'[^A-Za-z0-9 ]+', '', res) -def get_component_schemas(json_schema_test_file: str, folders: typing.Tuple[str]) -> typing.Dict[str, OpenApiSchema]: +def get_component_schemas_and_test_examples(json_schema_test_file: str, folders: typing.Tuple[str]) -> typing.Dict[str, OpenApiSchema]: component_schemas = {} + component_name_to_test_examples = {} for folder in folders: file_path_tuple = (folder, json_schema_test_file) test_schemas = get_json_schema_test_schemas(file_path_tuple) @@ -198,33 +204,37 @@ def get_component_schemas(json_schema_test_file: str, folders: typing.Tuple[str] continue for test_schema in test_schemas: component_name = description_to_component_name(test_schema.description) - kwargs = { - 'x-test-examples': {} - } - print(test_schema) - schema = OpenApiSchema( - **test_schema.schema, **kwargs - ) - component_schemas[component_name] = schema + if isinstance(test_schema.schema, bool): + component_schemas[component_name] = test_schema.schema + else: + component_schemas[component_name] = OpenApiSchema(**test_schema.schema) for test in test_schema.tests: + if component_name not in component_name_to_test_examples: + component_name_to_test_examples[component_name] = {} test_case_name = get_test_case_name(test) - schema['x-test-examples'][test_case_name] = test - return component_schemas + component_name_to_test_examples[component_name][test_case_name] = test + return component_schemas, component_name_to_test_examples def write_openapi_spec(): openapi = get_new_openapi() for json_schema_test_file, folders in JSON_SCHEMA_TEST_FILE_TO_FOLDERS.items(): - component_schemas = get_component_schemas(json_schema_test_file, folders) + component_schemas, component_name_to_test_examples = ( + get_component_schemas_and_test_examples(json_schema_test_file, folders) + ) for component_name, schema in component_schemas.items(): - if component_name in openapi.components.schemas: - raise ValueError('A component with that nae is already defined!') - openapi.components.schemas[component_name] = schema - print( - yaml.dump( - dataclasses.asdict(openapi), - sort_keys=False - ) + if component_name in openapi.components['schemas']: + raise ValueError('A component schema with that name is already defined!') + openapi.components['schemas'][component_name] = schema + for component_name, test_examples in component_name_to_test_examples.items(): + if component_name in openapi.components['x-schema-test-examples']: + raise ValueError('A component schema test example map with that name is already defined!') + openapi.components['x-schema-test-examples'][component_name] = test_examples + print( + yaml.dump( + dataclasses.asdict(openapi), + sort_keys=False ) + ) spec_out = 'type.yaml' with open(spec_out, 'w') as yaml_out: yaml_out.write( diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml index 74a1bb31809..b74689ff212 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml @@ -9,270 +9,19 @@ components: schemas: IntegerTypeMatchesIntegers: type: integer - x-test-examples: - AnIntegerIsAnInteger: - description: an integer is an integer - data: 1 - valid: true - AFloatWithZeroFractionalPartIsAnInteger: - description: a float with zero fractional part is an integer - data: 1.0 - valid: true - AFloatIsNotAnInteger: - description: a float is not an integer - data: 1.1 - valid: false - AStringIsNotAnInteger: - description: a string is not an integer - data: foo - valid: false - AStringIsStillNotAnIntegerEvenIfItLooksLikeOne: - description: a string is still not an integer, even if it looks like one - data: '1' - valid: false - AnObjectIsNotAnInteger: - description: an object is not an integer - data: {} - valid: false - AnArrayIsNotAnInteger: - description: an array is not an integer - data: [] - valid: false - ABooleanIsNotAnInteger: - description: a boolean is not an integer - data: true - valid: false - NullIsNotAnInteger: - description: null is not an integer - data: null - valid: false NumberTypeMatchesNumbers: type: number - x-test-examples: - AnIntegerIsANumber: - description: an integer is a number - data: 1 - valid: true - AFloatWithZeroFractionalPartIsANumberAndAnInteger: - description: a float with zero fractional part is a number (and an integer) - data: 1.0 - valid: true - AFloatIsANumber: - description: a float is a number - data: 1.1 - valid: true - AStringIsNotANumber: - description: a string is not a number - data: foo - valid: false - AStringIsStillNotANumberEvenIfItLooksLikeOne: - description: a string is still not a number, even if it looks like one - data: '1' - valid: false - AnObjectIsNotANumber: - description: an object is not a number - data: {} - valid: false - AnArrayIsNotANumber: - description: an array is not a number - data: [] - valid: false - ABooleanIsNotANumber: - description: a boolean is not a number - data: true - valid: false - NullIsNotANumber: - description: null is not a number - data: null - valid: false StringTypeMatchesStrings: type: string - x-test-examples: - 1IsNotAString: - description: 1 is not a string - data: 1 - valid: false - AFloatIsNotAString: - description: a float is not a string - data: 1.1 - valid: false - AStringIsAString: - description: a string is a string - data: foo - valid: true - AStringIsStillAStringEvenIfItLooksLikeANumber: - description: a string is still a string, even if it looks like a number - data: '1' - valid: true - AnEmptyStringIsStillAString: - description: an empty string is still a string - data: '' - valid: true - AnObjectIsNotAString: - description: an object is not a string - data: {} - valid: false - AnArrayIsNotAString: - description: an array is not a string - data: [] - valid: false - ABooleanIsNotAString: - description: a boolean is not a string - data: true - valid: false - NullIsNotAString: - description: null is not a string - data: null - valid: false ObjectTypeMatchesObjects: type: object - x-test-examples: - AnIntegerIsNotAnObject: - description: an integer is not an object - data: 1 - valid: false - AFloatIsNotAnObject: - description: a float is not an object - data: 1.1 - valid: false - AStringIsNotAnObject: - description: a string is not an object - data: foo - valid: false - AnObjectIsAnObject: - description: an object is an object - data: {} - valid: true - AnArrayIsNotAnObject: - description: an array is not an object - data: [] - valid: false - ABooleanIsNotAnObject: - description: a boolean is not an object - data: true - valid: false - NullIsNotAnObject: - description: null is not an object - data: null - valid: false BooleanTypeMatchesBooleans: type: boolean - x-test-examples: - AnIntegerIsNotABoolean: - description: an integer is not a boolean - data: 1 - valid: false - ZeroIsNotABoolean: - description: zero is not a boolean - data: 0 - valid: false - AFloatIsNotABoolean: - description: a float is not a boolean - data: 1.1 - valid: false - AStringIsNotABoolean: - description: a string is not a boolean - data: foo - valid: false - AnEmptyStringIsNotABoolean: - description: an empty string is not a boolean - data: '' - valid: false - AnObjectIsNotABoolean: - description: an object is not a boolean - data: {} - valid: false - AnArrayIsNotABoolean: - description: an array is not a boolean - data: [] - valid: false - TrueIsABoolean: - description: true is a boolean - data: true - valid: true - FalseIsABoolean: - description: false is a boolean - data: false - valid: true - NullIsNotABoolean: - description: null is not a boolean - data: null - valid: false NullTypeMatchesOnlyTheNullObject: type: 'null' - x-test-examples: - AnIntegerIsNotNull: - description: an integer is not null - data: 1 - valid: false - AFloatIsNotNull: - description: a float is not null - data: 1.1 - valid: false - ZeroIsNotNull: - description: zero is not null - data: 0 - valid: false - AStringIsNotNull: - description: a string is not null - data: foo - valid: false - AnEmptyStringIsNotNull: - description: an empty string is not null - data: '' - valid: false - AnObjectIsNotNull: - description: an object is not null - data: {} - valid: false - AnArrayIsNotNull: - description: an array is not null - data: [] - valid: false - TrueIsNotNull: - description: true is not null - data: true - valid: false - FalseIsNotNull: - description: false is not null - data: false - valid: false - NullIsNull: - description: null is null - data: null - valid: true ArrayTypeMatchesArrays: type: array items: {} - x-test-examples: - AnIntegerIsNotAnArray: - description: an integer is not an array - data: 1 - valid: false - AFloatIsNotAnArray: - description: a float is not an array - data: 1.1 - valid: false - AStringIsNotAnArray: - description: a string is not an array - data: foo - valid: false - AnObjectIsNotAnArray: - description: an object is not an array - data: {} - valid: false - AnArrayIsAnArray: - description: an array is an array - data: [] - valid: true - ABooleanIsNotAnArray: - description: a boolean is not an array - data: true - valid: false - NullIsNotAnArray: - description: null is not an array - data: null - valid: false AdditionalpropertiesBeingFalseDoesNotAllowOtherProperties: properties: foo: {} @@ -280,117 +29,795 @@ components: patternProperties: ^v: {} additionalProperties: false - x-test-examples: - NoAdditionalPropertiesIsValid: - description: no additional properties is valid - data: - foo: 1 - valid: true - AnAdditionalPropertyIsInvalid: - description: an additional property is invalid - data: - foo: 1 - bar: 2 - quux: boom - valid: false - IgnoresArrays: - description: ignores arrays - data: - - 1 - - 2 - - 3 - valid: true - IgnoresStrings: - description: ignores strings - data: foobarbaz - valid: true - IgnoresOtherNonObjects: - description: ignores other non-objects - data: 12 - valid: true - PatternpropertiesAreNotAdditionalProperties: - description: patternProperties are not additional properties - data: - foo: 1 - vroom: 2 - valid: true NonAsciiPatternWithAdditionalproperties: patternProperties: "^\xE1": {} additionalProperties: false - x-test-examples: - MatchingThePatternIsValid: - description: matching the pattern is valid - data: - "\xE1rm\xE1nyos": 2 - valid: true - NotMatchingThePatternIsInvalid: - description: not matching the pattern is invalid - data: - "\xE9lm\xE9ny": 2 - valid: false AdditionalpropertiesAllowsASchemaWhichShouldValidate: properties: foo: {} bar: {} additionalProperties: type: boolean - x-test-examples: - NoAdditionalPropertiesIsValid: - description: no additional properties is valid - data: - foo: 1 - valid: true - AnAdditionalValidPropertyIsValid: - description: an additional valid property is valid - data: - foo: 1 - bar: 2 - quux: true - valid: true - AnAdditionalInvalidPropertyIsInvalid: - description: an additional invalid property is invalid - data: - foo: 1 - bar: 2 - quux: 12 - valid: false AdditionalpropertiesCanExistByItself: additionalProperties: type: boolean - x-test-examples: - AnAdditionalValidPropertyIsValid: - description: an additional valid property is valid - data: - foo: true - valid: true - AnAdditionalInvalidPropertyIsInvalid: - description: an additional invalid property is invalid - data: - foo: 1 - valid: false AdditionalpropertiesAreAllowedByDefault: properties: foo: {} bar: {} - x-test-examples: - AdditionalPropertiesAreAllowed: - description: additional properties are allowed - data: - foo: 1 - bar: 2 - quux: true - valid: true AdditionalpropertiesShouldNotLookInApplicators: allOf: - properties: foo: {} additionalProperties: type: boolean - x-test-examples: - PropertiesDefinedInAllofAreNotExamined: - description: properties defined in allOf are not examined - data: - foo: 1 - bar: true - valid: false + Allof: + allOf: + - properties: + bar: + type: integer + required: + - bar + - properties: + foo: + type: string + required: + - foo + AllofWithBaseSchema: + properties: + bar: + type: integer + required: + - bar + allOf: + - properties: + foo: + type: string + required: + - foo + - properties: + baz: + type: 'null' + required: + - baz + AllofSimpleTypes: + allOf: + - maximum: 30 + - minimum: 20 + AllofWithBooleanSchemasAllTrue: + allOf: + - true + - true + AllofWithBooleanSchemasSomeFalse: + allOf: + - true + - false + AllofWithBooleanSchemasAllFalse: + allOf: + - false + - false + AllofWithOneEmptySchema: + allOf: + - {} + AllofWithTwoEmptySchemas: + allOf: + - {} + - {} + AllofWithTheFirstEmptySchema: + allOf: + - {} + - type: number + AllofWithTheLastEmptySchema: + allOf: + - type: number + - {} + NestedAllofToCheckValidationSemantics: + allOf: + - allOf: + - type: 'null' + AllofCombinedWithAnyofOneof: + allOf: + - multipleOf: 2 + anyOf: + - multipleOf: 3 + oneOf: + - multipleOf: 5 + Anyof: + anyOf: + - type: integer + - minimum: 2 + AnyofWithBaseSchema: + type: string + anyOf: + - maxLength: 2 + - minLength: 4 + AnyofWithBooleanSchemasAllTrue: + anyOf: + - true + - true + AnyofWithBooleanSchemasSomeTrue: + anyOf: + - true + - false + AnyofWithBooleanSchemasAllFalse: + anyOf: + - false + - false + AnyofComplexTypes: + anyOf: + - properties: + bar: + type: integer + required: + - bar + - properties: + foo: + type: string + required: + - foo + AnyofWithOneEmptySchema: + anyOf: + - type: number + - {} + NestedAnyofToCheckValidationSemantics: + anyOf: + - anyOf: + - type: 'null' + BooleanSchemaTrue: true + BooleanSchemaFalse: false + x-schema-test-examples: + IntegerTypeMatchesIntegers: + AnIntegerIsAnInteger: + description: an integer is an integer + data: 1 + valid: true + AFloatWithZeroFractionalPartIsAnInteger: + description: a float with zero fractional part is an integer + data: 1.0 + valid: true + AFloatIsNotAnInteger: + description: a float is not an integer + data: 1.1 + valid: false + AStringIsNotAnInteger: + description: a string is not an integer + data: foo + valid: false + AStringIsStillNotAnIntegerEvenIfItLooksLikeOne: + description: a string is still not an integer, even if it looks like one + data: '1' + valid: false + AnObjectIsNotAnInteger: + description: an object is not an integer + data: {} + valid: false + AnArrayIsNotAnInteger: + description: an array is not an integer + data: [] + valid: false + ABooleanIsNotAnInteger: + description: a boolean is not an integer + data: true + valid: false + NullIsNotAnInteger: + description: null is not an integer + data: null + valid: false + NumberTypeMatchesNumbers: + AnIntegerIsANumber: + description: an integer is a number + data: 1 + valid: true + AFloatWithZeroFractionalPartIsANumberAndAnInteger: + description: a float with zero fractional part is a number (and an integer) + data: 1.0 + valid: true + AFloatIsANumber: + description: a float is a number + data: 1.1 + valid: true + AStringIsNotANumber: + description: a string is not a number + data: foo + valid: false + AStringIsStillNotANumberEvenIfItLooksLikeOne: + description: a string is still not a number, even if it looks like one + data: '1' + valid: false + AnObjectIsNotANumber: + description: an object is not a number + data: {} + valid: false + AnArrayIsNotANumber: + description: an array is not a number + data: [] + valid: false + ABooleanIsNotANumber: + description: a boolean is not a number + data: true + valid: false + NullIsNotANumber: + description: null is not a number + data: null + valid: false + StringTypeMatchesStrings: + 1IsNotAString: + description: 1 is not a string + data: 1 + valid: false + AFloatIsNotAString: + description: a float is not a string + data: 1.1 + valid: false + AStringIsAString: + description: a string is a string + data: foo + valid: true + AStringIsStillAStringEvenIfItLooksLikeANumber: + description: a string is still a string, even if it looks like a number + data: '1' + valid: true + AnEmptyStringIsStillAString: + description: an empty string is still a string + data: '' + valid: true + AnObjectIsNotAString: + description: an object is not a string + data: {} + valid: false + AnArrayIsNotAString: + description: an array is not a string + data: [] + valid: false + ABooleanIsNotAString: + description: a boolean is not a string + data: true + valid: false + NullIsNotAString: + description: null is not a string + data: null + valid: false + ObjectTypeMatchesObjects: + AnIntegerIsNotAnObject: + description: an integer is not an object + data: 1 + valid: false + AFloatIsNotAnObject: + description: a float is not an object + data: 1.1 + valid: false + AStringIsNotAnObject: + description: a string is not an object + data: foo + valid: false + AnObjectIsAnObject: + description: an object is an object + data: {} + valid: true + AnArrayIsNotAnObject: + description: an array is not an object + data: [] + valid: false + ABooleanIsNotAnObject: + description: a boolean is not an object + data: true + valid: false + NullIsNotAnObject: + description: null is not an object + data: null + valid: false + BooleanTypeMatchesBooleans: + AnIntegerIsNotABoolean: + description: an integer is not a boolean + data: 1 + valid: false + ZeroIsNotABoolean: + description: zero is not a boolean + data: 0 + valid: false + AFloatIsNotABoolean: + description: a float is not a boolean + data: 1.1 + valid: false + AStringIsNotABoolean: + description: a string is not a boolean + data: foo + valid: false + AnEmptyStringIsNotABoolean: + description: an empty string is not a boolean + data: '' + valid: false + AnObjectIsNotABoolean: + description: an object is not a boolean + data: {} + valid: false + AnArrayIsNotABoolean: + description: an array is not a boolean + data: [] + valid: false + TrueIsABoolean: + description: true is a boolean + data: true + valid: true + FalseIsABoolean: + description: false is a boolean + data: false + valid: true + NullIsNotABoolean: + description: null is not a boolean + data: null + valid: false + NullTypeMatchesOnlyTheNullObject: + AnIntegerIsNotNull: + description: an integer is not null + data: 1 + valid: false + AFloatIsNotNull: + description: a float is not null + data: 1.1 + valid: false + ZeroIsNotNull: + description: zero is not null + data: 0 + valid: false + AStringIsNotNull: + description: a string is not null + data: foo + valid: false + AnEmptyStringIsNotNull: + description: an empty string is not null + data: '' + valid: false + AnObjectIsNotNull: + description: an object is not null + data: {} + valid: false + AnArrayIsNotNull: + description: an array is not null + data: [] + valid: false + TrueIsNotNull: + description: true is not null + data: true + valid: false + FalseIsNotNull: + description: false is not null + data: false + valid: false + NullIsNull: + description: null is null + data: null + valid: true + ArrayTypeMatchesArrays: + AnIntegerIsNotAnArray: + description: an integer is not an array + data: 1 + valid: false + AFloatIsNotAnArray: + description: a float is not an array + data: 1.1 + valid: false + AStringIsNotAnArray: + description: a string is not an array + data: foo + valid: false + AnObjectIsNotAnArray: + description: an object is not an array + data: {} + valid: false + AnArrayIsAnArray: + description: an array is an array + data: [] + valid: true + ABooleanIsNotAnArray: + description: a boolean is not an array + data: true + valid: false + NullIsNotAnArray: + description: null is not an array + data: null + valid: false + AdditionalpropertiesBeingFalseDoesNotAllowOtherProperties: + NoAdditionalPropertiesIsValid: + description: no additional properties is valid + data: + foo: 1 + valid: true + AnAdditionalPropertyIsInvalid: + description: an additional property is invalid + data: + foo: 1 + bar: 2 + quux: boom + valid: false + IgnoresArrays: + description: ignores arrays + data: + - 1 + - 2 + - 3 + valid: true + IgnoresStrings: + description: ignores strings + data: foobarbaz + valid: true + IgnoresOtherNonObjects: + description: ignores other non-objects + data: 12 + valid: true + PatternpropertiesAreNotAdditionalProperties: + description: patternProperties are not additional properties + data: + foo: 1 + vroom: 2 + valid: true + NonAsciiPatternWithAdditionalproperties: + MatchingThePatternIsValid: + description: matching the pattern is valid + data: + "\xE1rm\xE1nyos": 2 + valid: true + NotMatchingThePatternIsInvalid: + description: not matching the pattern is invalid + data: + "\xE9lm\xE9ny": 2 + valid: false + AdditionalpropertiesAllowsASchemaWhichShouldValidate: + NoAdditionalPropertiesIsValid: + description: no additional properties is valid + data: + foo: 1 + valid: true + AnAdditionalValidPropertyIsValid: + description: an additional valid property is valid + data: + foo: 1 + bar: 2 + quux: true + valid: true + AnAdditionalInvalidPropertyIsInvalid: + description: an additional invalid property is invalid + data: + foo: 1 + bar: 2 + quux: 12 + valid: false + AdditionalpropertiesCanExistByItself: + AnAdditionalValidPropertyIsValid: + description: an additional valid property is valid + data: + foo: true + valid: true + AnAdditionalInvalidPropertyIsInvalid: + description: an additional invalid property is invalid + data: + foo: 1 + valid: false + AdditionalpropertiesAreAllowedByDefault: + AdditionalPropertiesAreAllowed: + description: additional properties are allowed + data: + foo: 1 + bar: 2 + quux: true + valid: true + AdditionalpropertiesShouldNotLookInApplicators: + PropertiesDefinedInAllofAreNotExamined: + description: properties defined in allOf are not examined + data: + foo: 1 + bar: true + valid: false + Allof: + Allof: + description: allOf + data: + foo: baz + bar: 2 + valid: true + MismatchSecond: + description: mismatch second + data: + foo: baz + valid: false + MismatchFirst: + description: mismatch first + data: + bar: 2 + valid: false + WrongType: + description: wrong type + data: + foo: baz + bar: quux + valid: false + AllofWithBaseSchema: + Valid: + description: valid + data: + foo: quux + bar: 2 + baz: null + valid: true + MismatchBaseSchema: + description: mismatch base schema + data: + foo: quux + baz: null + valid: false + MismatchFirstAllof: + description: mismatch first allOf + data: + bar: 2 + baz: null + valid: false + MismatchSecondAllof: + description: mismatch second allOf + data: + foo: quux + bar: 2 + valid: false + MismatchBoth: + description: mismatch both + data: + bar: 2 + valid: false + AllofSimpleTypes: + Valid: + description: valid + data: 25 + valid: true + MismatchOne: + description: mismatch one + data: 35 + valid: false + AllofWithBooleanSchemasAllTrue: + AnyValueIsValid: + description: any value is valid + data: foo + valid: true + AllofWithBooleanSchemasSomeFalse: + AnyValueIsInvalid: + description: any value is invalid + data: foo + valid: false + AllofWithBooleanSchemasAllFalse: + AnyValueIsInvalid: + description: any value is invalid + data: foo + valid: false + AllofWithOneEmptySchema: + AnyDataIsValid: + description: any data is valid + data: 1 + valid: true + AllofWithTwoEmptySchemas: + AnyDataIsValid: + description: any data is valid + data: 1 + valid: true + AllofWithTheFirstEmptySchema: + NumberIsValid: + description: number is valid + data: 1 + valid: true + StringIsInvalid: + description: string is invalid + data: foo + valid: false + AllofWithTheLastEmptySchema: + NumberIsValid: + description: number is valid + data: 1 + valid: true + StringIsInvalid: + description: string is invalid + data: foo + valid: false + NestedAllofToCheckValidationSemantics: + NullIsValid: + description: null is valid + data: null + valid: true + AnythingNonNullIsInvalid: + description: anything non-null is invalid + data: 123 + valid: false + AllofCombinedWithAnyofOneof: + AllofFalseAnyofFalseOneofFalse: + description: 'allOf: false, anyOf: false, oneOf: false' + data: 1 + valid: false + AllofFalseAnyofFalseOneofTrue: + description: 'allOf: false, anyOf: false, oneOf: true' + data: 5 + valid: false + AllofFalseAnyofTrueOneofFalse: + description: 'allOf: false, anyOf: true, oneOf: false' + data: 3 + valid: false + AllofFalseAnyofTrueOneofTrue: + description: 'allOf: false, anyOf: true, oneOf: true' + data: 15 + valid: false + AllofTrueAnyofFalseOneofFalse: + description: 'allOf: true, anyOf: false, oneOf: false' + data: 2 + valid: false + AllofTrueAnyofFalseOneofTrue: + description: 'allOf: true, anyOf: false, oneOf: true' + data: 10 + valid: false + AllofTrueAnyofTrueOneofFalse: + description: 'allOf: true, anyOf: true, oneOf: false' + data: 6 + valid: false + AllofTrueAnyofTrueOneofTrue: + description: 'allOf: true, anyOf: true, oneOf: true' + data: 30 + valid: true + Anyof: + FirstAnyofValid: + description: first anyOf valid + data: 1 + valid: true + SecondAnyofValid: + description: second anyOf valid + data: 2.5 + valid: true + BothAnyofValid: + description: both anyOf valid + data: 3 + valid: true + NeitherAnyofValid: + description: neither anyOf valid + data: 1.5 + valid: false + AnyofWithBaseSchema: + MismatchBaseSchema: + description: mismatch base schema + data: 3 + valid: false + OneAnyofValid: + description: one anyOf valid + data: foobar + valid: true + BothAnyofInvalid: + description: both anyOf invalid + data: foo + valid: false + AnyofWithBooleanSchemasAllTrue: + AnyValueIsValid: + description: any value is valid + data: foo + valid: true + AnyofWithBooleanSchemasSomeTrue: + AnyValueIsValid: + description: any value is valid + data: foo + valid: true + AnyofWithBooleanSchemasAllFalse: + AnyValueIsInvalid: + description: any value is invalid + data: foo + valid: false + AnyofComplexTypes: + FirstAnyofValidComplex: + description: first anyOf valid (complex) + data: + bar: 2 + valid: true + SecondAnyofValidComplex: + description: second anyOf valid (complex) + data: + foo: baz + valid: true + BothAnyofValidComplex: + description: both anyOf valid (complex) + data: + foo: baz + bar: 2 + valid: true + NeitherAnyofValidComplex: + description: neither anyOf valid (complex) + data: + foo: 2 + bar: quux + valid: false + AnyofWithOneEmptySchema: + StringIsValid: + description: string is valid + data: foo + valid: true + NumberIsValid: + description: number is valid + data: 123 + valid: true + NestedAnyofToCheckValidationSemantics: + NullIsValid: + description: null is valid + data: null + valid: true + AnythingNonNullIsInvalid: + description: anything non-null is invalid + data: 123 + valid: false + BooleanSchemaTrue: + NumberIsValid: + description: number is valid + data: 1 + valid: true + StringIsValid: + description: string is valid + data: foo + valid: true + BooleanTrueIsValid: + description: boolean true is valid + data: true + valid: true + BooleanFalseIsValid: + description: boolean false is valid + data: false + valid: true + NullIsValid: + description: null is valid + data: null + valid: true + ObjectIsValid: + description: object is valid + data: + foo: bar + valid: true + EmptyObjectIsValid: + description: empty object is valid + data: {} + valid: true + ArrayIsValid: + description: array is valid + data: + - foo + valid: true + EmptyArrayIsValid: + description: empty array is valid + data: [] + valid: true + BooleanSchemaFalse: + NumberIsInvalid: + description: number is invalid + data: 1 + valid: false + StringIsInvalid: + description: string is invalid + data: foo + valid: false + BooleanTrueIsInvalid: + description: boolean true is invalid + data: true + valid: false + BooleanFalseIsInvalid: + description: boolean false is invalid + data: false + valid: false + NullIsInvalid: + description: null is invalid + data: null + valid: false + ObjectIsInvalid: + description: object is invalid + data: + foo: bar + valid: false + EmptyObjectIsInvalid: + description: empty object is invalid + data: {} + valid: false + ArrayIsInvalid: + description: array is invalid + data: + - foo + valid: false + EmptyArrayIsInvalid: + description: empty array is invalid + data: [] + valid: false -- GitLab From 4f9e6d5c02db078b7ac7cb166f12cf70016fe753 Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Tue, 21 Jun 2022 19:56:33 -0700 Subject: [PATCH 04/43] Excludes boolean schema cases and some others that contain patternProperties --- .../3_0/unit_test_spec/spec_writer.py | 7 + .../resources/3_0/unit_test_spec/type.yaml | 136 ------------------ 2 files changed, 7 insertions(+), 136 deletions(-) diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index 5e72d3f6aea..2737de5b994 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -78,7 +78,9 @@ class ExclusionReason: v303_does_not_support_array_of_types = 'v3.0.3 does not support type with array of values' v303_requires_array_have_items = 'v3.0.3 requires that items MUST be present if the type is array' v303_does_not_support_additionalItems = 'v3.0.3 does not support the additionalItems keyword' + v303_does_not_support_patternProperties = 'v3.0.3 does not support the patternProperties keyword' v303_does_not_support_const = 'v3.0.3 does not support the const keyword' + v303_does_not_support_boolean_schemas_in_components = 'v3.0.3 does not support boolean schemas in components' json_schema_test_draft = 'draft6' FILEPATH_TO_EXCLUDED_CASE_AND_REASON = { @@ -88,11 +90,16 @@ FILEPATH_TO_EXCLUDED_CASE_AND_REASON = { 'type: array or object': ExclusionReason.v303_does_not_support_array_of_types, 'type: array, object or null': ExclusionReason.v303_does_not_support_array_of_types, 'array type matches arrays': ExclusionReason.v303_requires_array_have_items, + }, + (json_schema_test_draft, 'additionalProperties.json'): { + 'non-ASCII pattern with additionalProperties': ExclusionReason.v303_does_not_support_patternProperties, + 'additionalProperties being false does not allow other properties': ExclusionReason.v303_does_not_support_patternProperties, } } FILEPATH_TO_EXCLUDE_REASON = { (json_schema_test_draft, 'additionalItems.json'): ExclusionReason.v303_does_not_support_additionalItems, (json_schema_test_draft, 'const.json'): ExclusionReason.v303_does_not_support_const, + (json_schema_test_draft, 'boolean_schema.json'): ExclusionReason.v303_does_not_support_boolean_schemas_in_components, } openapi_additions = 'openapi_additions' diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml index b74689ff212..39101323df9 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml @@ -22,17 +22,6 @@ components: ArrayTypeMatchesArrays: type: array items: {} - AdditionalpropertiesBeingFalseDoesNotAllowOtherProperties: - properties: - foo: {} - bar: {} - patternProperties: - ^v: {} - additionalProperties: false - NonAsciiPatternWithAdditionalproperties: - patternProperties: - "^\xE1": {} - additionalProperties: false AdditionalpropertiesAllowsASchemaWhichShouldValidate: properties: foo: {} @@ -164,8 +153,6 @@ components: anyOf: - anyOf: - type: 'null' - BooleanSchemaTrue: true - BooleanSchemaFalse: false x-schema-test-examples: IntegerTypeMatchesIntegers: AnIntegerIsAnInteger: @@ -418,51 +405,6 @@ components: description: null is not an array data: null valid: false - AdditionalpropertiesBeingFalseDoesNotAllowOtherProperties: - NoAdditionalPropertiesIsValid: - description: no additional properties is valid - data: - foo: 1 - valid: true - AnAdditionalPropertyIsInvalid: - description: an additional property is invalid - data: - foo: 1 - bar: 2 - quux: boom - valid: false - IgnoresArrays: - description: ignores arrays - data: - - 1 - - 2 - - 3 - valid: true - IgnoresStrings: - description: ignores strings - data: foobarbaz - valid: true - IgnoresOtherNonObjects: - description: ignores other non-objects - data: 12 - valid: true - PatternpropertiesAreNotAdditionalProperties: - description: patternProperties are not additional properties - data: - foo: 1 - vroom: 2 - valid: true - NonAsciiPatternWithAdditionalproperties: - MatchingThePatternIsValid: - description: matching the pattern is valid - data: - "\xE1rm\xE1nyos": 2 - valid: true - NotMatchingThePatternIsInvalid: - description: not matching the pattern is invalid - data: - "\xE9lm\xE9ny": 2 - valid: false AdditionalpropertiesAllowsASchemaWhichShouldValidate: NoAdditionalPropertiesIsValid: description: no additional properties is valid @@ -743,81 +685,3 @@ components: description: anything non-null is invalid data: 123 valid: false - BooleanSchemaTrue: - NumberIsValid: - description: number is valid - data: 1 - valid: true - StringIsValid: - description: string is valid - data: foo - valid: true - BooleanTrueIsValid: - description: boolean true is valid - data: true - valid: true - BooleanFalseIsValid: - description: boolean false is valid - data: false - valid: true - NullIsValid: - description: null is valid - data: null - valid: true - ObjectIsValid: - description: object is valid - data: - foo: bar - valid: true - EmptyObjectIsValid: - description: empty object is valid - data: {} - valid: true - ArrayIsValid: - description: array is valid - data: - - foo - valid: true - EmptyArrayIsValid: - description: empty array is valid - data: [] - valid: true - BooleanSchemaFalse: - NumberIsInvalid: - description: number is invalid - data: 1 - valid: false - StringIsInvalid: - description: string is invalid - data: foo - valid: false - BooleanTrueIsInvalid: - description: boolean true is invalid - data: true - valid: false - BooleanFalseIsInvalid: - description: boolean false is invalid - data: false - valid: false - NullIsInvalid: - description: null is invalid - data: null - valid: false - ObjectIsInvalid: - description: object is invalid - data: - foo: bar - valid: false - EmptyObjectIsInvalid: - description: empty object is invalid - data: {} - valid: false - ArrayIsInvalid: - description: array is invalid - data: - - foo - valid: false - EmptyArrayIsInvalid: - description: empty array is invalid - data: [] - valid: false -- GitLab From 5e6c4dd8beadf88ac84cf78a0ac3dcfb235f35cc Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Tue, 21 Jun 2022 23:36:28 -0700 Subject: [PATCH 05/43] Adds automatic test generation, template not quite working with indentation --- .../openapitools/codegen/CodegenModel.java | 1 + .../openapitools/codegen/DefaultCodegen.java | 55 ++++---- .../payload_renderer.handlebars | 32 ++--- .../python-experimental/model_test.handlebars | 22 ++-- .../.openapi-generator/FILES | 78 +++++++++++ .../python-experimental/README.md | 24 ++++ ...pertiesAllowsASchemaWhichShouldValidate.md | 11 ++ ...AdditionalpropertiesAreAllowedByDefault.md | 11 ++ .../AdditionalpropertiesCanExistByItself.md | 9 ++ ...nalpropertiesShouldNotLookInApplicators.md | 9 ++ .../python-experimental/docs/Allof.md | 9 ++ .../docs/AllofCombinedWithAnyofOneof.md | 9 ++ .../docs/AllofSimpleTypes.md | 9 ++ .../docs/AllofWithBaseSchema.md | 10 ++ .../docs/AllofWithBooleanSchemasAllFalse.md | 9 ++ .../docs/AllofWithBooleanSchemasAllTrue.md | 9 ++ .../docs/AllofWithBooleanSchemasSomeFalse.md | 9 ++ .../docs/AllofWithOneEmptySchema.md | 9 ++ .../docs/AllofWithTheFirstEmptySchema.md | 9 ++ .../docs/AllofWithTheLastEmptySchema.md | 9 ++ .../docs/AllofWithTwoEmptySchemas.md | 9 ++ .../python-experimental/docs/Anyof.md | 9 ++ .../docs/AnyofComplexTypes.md | 9 ++ .../docs/AnyofWithBaseSchema.md | 8 ++ .../docs/AnyofWithBooleanSchemasAllFalse.md | 9 ++ .../docs/AnyofWithBooleanSchemasAllTrue.md | 9 ++ .../docs/AnyofWithBooleanSchemasSomeTrue.md | 9 ++ .../docs/AnyofWithOneEmptySchema.md | 9 ++ .../NestedAllofToCheckValidationSemantics.md | 9 ++ .../NestedAnyofToCheckValidationSemantics.md | 9 ++ ...s_allows_a_schema_which_should_validate.py | 59 +++++++++ ...tionalproperties_are_allowed_by_default.py | 36 ++++++ ...dditionalproperties_can_exist_by_itself.py | 42 ++++++ ...operties_should_not_look_in_applicators.py | 35 +++++ .../python-experimental/test/test_allof.py | 66 ++++++++++ .../test_allof_combined_with_anyof_oneof.py | 70 ++++++++++ .../test/test_allof_simple_types.py | 34 +++++ .../test/test_allof_with_base_schema.py | 82 ++++++++++++ ...st_allof_with_boolean_schemas_all_false.py | 29 +++++ ...est_allof_with_boolean_schemas_all_true.py | 28 ++++ ...t_allof_with_boolean_schemas_some_false.py | 29 +++++ .../test/test_allof_with_one_empty_schema.py | 28 ++++ .../test_allof_with_the_first_empty_schema.py | 34 +++++ .../test_allof_with_the_last_empty_schema.py | 34 +++++ .../test/test_allof_with_two_empty_schemas.py | 28 ++++ .../python-experimental/test/test_anyof.py | 44 +++++++ .../test/test_anyof_complex_types.py | 64 +++++++++ .../test/test_anyof_with_base_schema.py | 40 ++++++ ...st_anyof_with_boolean_schemas_all_false.py | 29 +++++ ...est_anyof_with_boolean_schemas_all_true.py | 28 ++++ ...st_anyof_with_boolean_schemas_some_true.py | 28 ++++ .../test/test_anyof_with_one_empty_schema.py | 33 +++++ .../test/test_array_type_matches_arrays.py | 19 +-- .../test_boolean_type_matches_booleans.py | 28 ++-- .../test_integer_type_matches_integers.py | 25 ++-- ...ted_allof_to_check_validation_semantics.py | 34 +++++ ...ted_anyof_to_check_validation_semantics.py | 34 +++++ ..._null_type_matches_only_the_null_object.py | 28 ++-- .../test/test_number_type_matches_numbers.py | 25 ++-- .../test/test_string_type_matches_strings.py | 25 ++-- ...s_allows_a_schema_which_should_validate.py | 97 ++++++++++++++ ...tionalproperties_are_allowed_by_default.py | 95 ++++++++++++++ ...dditionalproperties_can_exist_by_itself.py | 91 +++++++++++++ ...operties_should_not_look_in_applicators.py | 114 +++++++++++++++++ .../unit_test_api/model/allof.py | 115 +++++++++++++++++ .../model/allof_combined_with_anyof_oneof.py | 117 +++++++++++++++++ .../unit_test_api/model/allof_simple_types.py | 115 +++++++++++++++++ .../model/allof_with_base_schema.py | 121 ++++++++++++++++++ .../allof_with_boolean_schemas_all_false.py | 111 ++++++++++++++++ .../allof_with_boolean_schemas_all_true.py | 111 ++++++++++++++++ .../allof_with_boolean_schemas_some_false.py | 111 ++++++++++++++++ .../model/allof_with_one_empty_schema.py | 113 ++++++++++++++++ .../allof_with_the_first_empty_schema.py | 115 +++++++++++++++++ .../model/allof_with_the_last_empty_schema.py | 115 +++++++++++++++++ .../model/allof_with_two_empty_schemas.py | 115 +++++++++++++++++ .../unit_test_api/model/anyof.py | 115 +++++++++++++++++ .../model/anyof_complex_types.py | 115 +++++++++++++++++ .../model/anyof_with_base_schema.py | 114 +++++++++++++++++ .../anyof_with_boolean_schemas_all_false.py | 111 ++++++++++++++++ .../anyof_with_boolean_schemas_all_true.py | 111 ++++++++++++++++ .../anyof_with_boolean_schemas_some_true.py | 111 ++++++++++++++++ .../model/anyof_with_one_empty_schema.py | 115 +++++++++++++++++ ...ted_allof_to_check_validation_semantics.py | 113 ++++++++++++++++ ...ted_anyof_to_check_validation_semantics.py | 113 ++++++++++++++++ .../unit_test_api/models/__init__.py | 24 ++++ 85 files changed, 4092 insertions(+), 156 deletions(-) create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAreAllowedByDefault.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesCanExistByItself.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesShouldNotLookInApplicators.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Allof.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofCombinedWithAnyofOneof.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofSimpleTypes.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithBaseSchema.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithBooleanSchemasAllFalse.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithBooleanSchemasAllTrue.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithBooleanSchemasSomeFalse.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithOneEmptySchema.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithTheFirstEmptySchema.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithTheLastEmptySchema.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithTwoEmptySchemas.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Anyof.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofComplexTypes.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithBaseSchema.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithBooleanSchemasAllFalse.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithBooleanSchemasAllTrue.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithBooleanSchemasSomeTrue.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithOneEmptySchema.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedAllofToCheckValidationSemantics.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedAnyofToCheckValidationSemantics.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_combined_with_anyof_oneof.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_simple_types.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_base_schema.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_all_false.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_all_true.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_some_false.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_one_empty_schema.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_first_empty_schema.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_last_empty_schema.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_two_empty_schemas.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_complex_types.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_base_schema.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_boolean_schemas_all_false.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_boolean_schemas_all_true.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_boolean_schemas_some_true.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_one_empty_schema.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_allof_to_check_validation_semantics.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_anyof_to_check_validation_semantics.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_allows_a_schema_which_should_validate.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_are_allowed_by_default.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_can_exist_by_itself.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_should_not_look_in_applicators.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_combined_with_anyof_oneof.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_simple_types.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_base_schema.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_boolean_schemas_all_false.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_boolean_schemas_all_true.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_boolean_schemas_some_false.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_one_empty_schema.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_the_first_empty_schema.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_the_last_empty_schema.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_two_empty_schemas.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_complex_types.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_base_schema.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_boolean_schemas_all_false.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_boolean_schemas_all_true.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_boolean_schemas_some_true.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_one_empty_schema.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_allof_to_check_validation_semantics.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_anyof_to_check_validation_semantics.py diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java index 9033a21b4d0..e00e646f564 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java @@ -109,6 +109,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties { public Map<String, Object> vendorExtensions = new HashMap<>(); private CodegenComposedSchemas composedSchemas; private boolean hasMultipleTypes = false; + public HashMap<String, SchemaTestCase> testCases = new HashMap<>(); /** * The type of the value for the additionalProperties keyword in the OAS document. diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index 2c9d261162b..881ea807bec 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -2701,29 +2701,35 @@ public class DefaultCodegen implements CodegenConfig { } /** - * Processes any test cases if they exist in the vendor extensions - * If they exist then cast them to java class instances and assign them back as the value - * in the x-test-examples vendor extension - * @param vendorExtensions - */ - private void processTestCases(HashMap<String, Object> vendorExtensions) { - String testExamplesKey = "x-test-examples"; - HashMap<String, SchemaTestCase> testCases = new HashMap<>(); - if (vendorExtensions.containsKey(testExamplesKey)) { - LinkedHashMap<String, Object> testExamples = (LinkedHashMap<String, Object>) vendorExtensions.get(testExamplesKey); - for(Map.Entry<String, Object> testExampleEntry: testExamples.entrySet()) { - String exampleName = testExampleEntry.getKey(); - LinkedHashMap<String, Object> testExample = (LinkedHashMap<String, Object>) testExampleEntry.getValue(); - String nameInSnakeCase = toTesCaseName(exampleName); - SchemaTestCase testCase = new SchemaTestCase( - (String) testExample.getOrDefault("description", ""), - new ObjectWithTypeBooleans(testExample.get("data")), - (boolean) testExample.get("valid") - ); - testCases.put(nameInSnakeCase, testCase); - } - vendorExtensions.put(testExamplesKey, testCases); + * Processes any test cases if they exist in the components.x-test-examples vendor extensions + * If they exist then cast them to java class instances and return them back in a map + * @param schemaName the component schema name that the test cases are for + * @param vendorExtensions the extensions that may or may not hold the data + */ + private HashMap<String, SchemaTestCase> extractSchemaTestCases(String schemaName, HashMap<String, Object> vendorExtensions) { + String testExamplesKey = "x-schema-test-examples"; + // schemaName to a map of test case name to test case + if (vendorExtensions == null || !vendorExtensions.containsKey(testExamplesKey)) { + return null; + } + HashMap<String, SchemaTestCase> schemaTestCases = new HashMap<>(); + LinkedHashMap<String, Object> schemaNameToTestCases = (LinkedHashMap<String, Object>) vendorExtensions.get(testExamplesKey); + + if (!schemaNameToTestCases.containsKey(schemaName)) { + return null; + } + LinkedHashMap<String, LinkedHashMap<String, Object>> testNameToTesCase = (LinkedHashMap<String, LinkedHashMap<String, Object>>) schemaNameToTestCases.get(schemaName); + for (Entry<String, LinkedHashMap<String, Object>> entry: testNameToTesCase.entrySet()) { + LinkedHashMap<String, Object> testExample = (LinkedHashMap<String, Object>) entry.getValue(); + String nameInSnakeCase = toTesCaseName(entry.getKey()); + SchemaTestCase testCase = new SchemaTestCase( + (String) testExample.getOrDefault("description", ""), + new ObjectWithTypeBooleans(testExample.get("data")), + (boolean) testExample.get("valid") + ); + schemaTestCases.put(nameInSnakeCase, testCase); } + return schemaTestCases; } /** @@ -2735,8 +2741,8 @@ public class DefaultCodegen implements CodegenConfig { */ @Override public CodegenModel fromModel(String name, Schema schema) { - HashMap<String, Object> vendorExtensions = (HashMap<String, Object>) schema.getExtensions(); - processTestCases(vendorExtensions); + HashMap<String, Object> vendorExtensions = (HashMap<String, Object>) openAPI.getComponents().getExtensions(); + HashMap<String, SchemaTestCase> schemaTestCases = extractSchemaTestCases(name, vendorExtensions); Map<String, Schema> allDefinitions = ModelUtils.getSchemas(this.openAPI); if (typeAliases == null) { @@ -2753,6 +2759,7 @@ public class DefaultCodegen implements CodegenConfig { CodegenModel m = CodegenModelFactory.newInstance(CodegenModelType.MODEL); ModelUtils.syncValidationProperties(schema, m); + m.testCases = schemaTestCases; if (reservedWords.contains(name)) { m.name = escapeReservedWord(name); diff --git a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars index 12d9c8c77bc..3d4a485fd8e 100644 --- a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars +++ b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars @@ -1,33 +1,17 @@ -{{#or isNumber isUnboundedInteger}} - {{value}} -{{/or}} -{{#if isBoolean}} - {{#if value}} - True - {{else}} - False - {{/if}} -{{/if}} -{{#if isNull}} - None -{{/if}} -{{#if isString}} - "{{value}}" -{{/if}} {{#if isArray}} - [ +[ {{#each value}} {{> model_templates/payload_renderer }} {{/each}} - ] -{{/if}} +] +{{else}} {{#if isMap}} - { +{ {{#each value}} - "{{@key}}": + "{{@key}}": {{#with this}} - {{> model_templates/payload_renderer }}, + {{> model_templates/payload_renderer }}, {{/with}} {{/each}} - } -{{/if}} \ No newline at end of file +} +{{else}}{{#or isNumber isUnboundedInteger}}{{value}}{{/or}}{{#if isBoolean}}{{#if value}}True{{else}}False{{/if}}{{/if}}{{#if isNull}}None{{/if}}{{#if isString}}"{{value}}"{{/if}}{{/if}}{{/if}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python-experimental/model_test.handlebars b/modules/openapi-generator/src/main/resources/python-experimental/model_test.handlebars index 4f4ab258434..c0ac05c852c 100644 --- a/modules/openapi-generator/src/main/resources/python-experimental/model_test.handlebars +++ b/modules/openapi-generator/src/main/resources/python-experimental/model_test.handlebars @@ -13,28 +13,26 @@ from {{packageName}}.{{modelPackage}}.{{classFilename}} import {{classname}} class Test{{classname}}(unittest.TestCase): """{{classname}} unit test stubs""" -{{#each vendorExtensions}} -{{#if @key eq "x-test-examples" }} -{{#each this }} +{{#each testCases}} + {{#with this }} def test_{{@key}}_{{#if valid}}passes{{else}}fails{{/if}}(self): # {{description}} -{{#if valid}} + {{#if valid}} {{classname}}( {{#with data}} - {{>model_templates/payload_renderer}} + {{>model_templates/payload_renderer}} {{/with}} - ) -{{else}} +nl ) + {{else}} with self.assertRaises(({{packageName}}.ApiValueError, {{packageName}}.ApiTypeError)): {{classname}}( {{#with data}} - {{>model_templates/payload_renderer}} + {{>model_templates/payload_renderer}} {{/with}} - ) -{{/if}} +nl ) + {{/if}} + {{/with}} -{{/each}} -{{/if}} {{/each}} {{/with}} {{/each}} diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index 6fa4115e71a..d1913f0d0e4 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -2,9 +2,33 @@ .gitlab-ci.yml .travis.yml README.md +docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md +docs/AdditionalpropertiesAreAllowedByDefault.md +docs/AdditionalpropertiesCanExistByItself.md +docs/AdditionalpropertiesShouldNotLookInApplicators.md +docs/Allof.md +docs/AllofCombinedWithAnyofOneof.md +docs/AllofSimpleTypes.md +docs/AllofWithBaseSchema.md +docs/AllofWithBooleanSchemasAllFalse.md +docs/AllofWithBooleanSchemasAllTrue.md +docs/AllofWithBooleanSchemasSomeFalse.md +docs/AllofWithOneEmptySchema.md +docs/AllofWithTheFirstEmptySchema.md +docs/AllofWithTheLastEmptySchema.md +docs/AllofWithTwoEmptySchemas.md +docs/Anyof.md +docs/AnyofComplexTypes.md +docs/AnyofWithBaseSchema.md +docs/AnyofWithBooleanSchemasAllFalse.md +docs/AnyofWithBooleanSchemasAllTrue.md +docs/AnyofWithBooleanSchemasSomeTrue.md +docs/AnyofWithOneEmptySchema.md docs/ArrayTypeMatchesArrays.md docs/BooleanTypeMatchesBooleans.md docs/IntegerTypeMatchesIntegers.md +docs/NestedAllofToCheckValidationSemantics.md +docs/NestedAnyofToCheckValidationSemantics.md docs/NullTypeMatchesOnlyTheNullObject.md docs/NumberTypeMatchesNumbers.md docs/StringTypeMatchesStrings.md @@ -14,6 +38,36 @@ setup.cfg setup.py test-requirements.txt test/__init__.py +test/test_additionalproperties_allows_a_schema_which_should_validate.py +test/test_additionalproperties_are_allowed_by_default.py +test/test_additionalproperties_can_exist_by_itself.py +test/test_additionalproperties_should_not_look_in_applicators.py +test/test_allof.py +test/test_allof_combined_with_anyof_oneof.py +test/test_allof_simple_types.py +test/test_allof_with_base_schema.py +test/test_allof_with_boolean_schemas_all_false.py +test/test_allof_with_boolean_schemas_all_true.py +test/test_allof_with_boolean_schemas_some_false.py +test/test_allof_with_one_empty_schema.py +test/test_allof_with_the_first_empty_schema.py +test/test_allof_with_the_last_empty_schema.py +test/test_allof_with_two_empty_schemas.py +test/test_anyof.py +test/test_anyof_complex_types.py +test/test_anyof_with_base_schema.py +test/test_anyof_with_boolean_schemas_all_false.py +test/test_anyof_with_boolean_schemas_all_true.py +test/test_anyof_with_boolean_schemas_some_true.py +test/test_anyof_with_one_empty_schema.py +test/test_array_type_matches_arrays.py +test/test_boolean_type_matches_booleans.py +test/test_integer_type_matches_integers.py +test/test_nested_allof_to_check_validation_semantics.py +test/test_nested_anyof_to_check_validation_semantics.py +test/test_null_type_matches_only_the_null_object.py +test/test_number_type_matches_numbers.py +test/test_string_type_matches_strings.py tox.ini unit_test_api/__init__.py unit_test_api/api/__init__.py @@ -22,9 +76,33 @@ unit_test_api/apis/__init__.py unit_test_api/configuration.py unit_test_api/exceptions.py unit_test_api/model/__init__.py +unit_test_api/model/additionalproperties_allows_a_schema_which_should_validate.py +unit_test_api/model/additionalproperties_are_allowed_by_default.py +unit_test_api/model/additionalproperties_can_exist_by_itself.py +unit_test_api/model/additionalproperties_should_not_look_in_applicators.py +unit_test_api/model/allof.py +unit_test_api/model/allof_combined_with_anyof_oneof.py +unit_test_api/model/allof_simple_types.py +unit_test_api/model/allof_with_base_schema.py +unit_test_api/model/allof_with_boolean_schemas_all_false.py +unit_test_api/model/allof_with_boolean_schemas_all_true.py +unit_test_api/model/allof_with_boolean_schemas_some_false.py +unit_test_api/model/allof_with_one_empty_schema.py +unit_test_api/model/allof_with_the_first_empty_schema.py +unit_test_api/model/allof_with_the_last_empty_schema.py +unit_test_api/model/allof_with_two_empty_schemas.py +unit_test_api/model/anyof.py +unit_test_api/model/anyof_complex_types.py +unit_test_api/model/anyof_with_base_schema.py +unit_test_api/model/anyof_with_boolean_schemas_all_false.py +unit_test_api/model/anyof_with_boolean_schemas_all_true.py +unit_test_api/model/anyof_with_boolean_schemas_some_true.py +unit_test_api/model/anyof_with_one_empty_schema.py unit_test_api/model/array_type_matches_arrays.py unit_test_api/model/boolean_type_matches_booleans.py unit_test_api/model/integer_type_matches_integers.py +unit_test_api/model/nested_allof_to_check_validation_semantics.py +unit_test_api/model/nested_anyof_to_check_validation_semantics.py unit_test_api/model/null_type_matches_only_the_null_object.py unit_test_api/model/number_type_matches_numbers.py unit_test_api/model/string_type_matches_strings.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md index f0a363fdef8..28a9b93fd35 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md @@ -62,9 +62,33 @@ Class | Method | HTTP request | Description ## Documentation For Models + - [AdditionalpropertiesAllowsASchemaWhichShouldValidate](docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md) + - [AdditionalpropertiesAreAllowedByDefault](docs/AdditionalpropertiesAreAllowedByDefault.md) + - [AdditionalpropertiesCanExistByItself](docs/AdditionalpropertiesCanExistByItself.md) + - [AdditionalpropertiesShouldNotLookInApplicators](docs/AdditionalpropertiesShouldNotLookInApplicators.md) + - [Allof](docs/Allof.md) + - [AllofCombinedWithAnyofOneof](docs/AllofCombinedWithAnyofOneof.md) + - [AllofSimpleTypes](docs/AllofSimpleTypes.md) + - [AllofWithBaseSchema](docs/AllofWithBaseSchema.md) + - [AllofWithBooleanSchemasAllFalse](docs/AllofWithBooleanSchemasAllFalse.md) + - [AllofWithBooleanSchemasAllTrue](docs/AllofWithBooleanSchemasAllTrue.md) + - [AllofWithBooleanSchemasSomeFalse](docs/AllofWithBooleanSchemasSomeFalse.md) + - [AllofWithOneEmptySchema](docs/AllofWithOneEmptySchema.md) + - [AllofWithTheFirstEmptySchema](docs/AllofWithTheFirstEmptySchema.md) + - [AllofWithTheLastEmptySchema](docs/AllofWithTheLastEmptySchema.md) + - [AllofWithTwoEmptySchemas](docs/AllofWithTwoEmptySchemas.md) + - [Anyof](docs/Anyof.md) + - [AnyofComplexTypes](docs/AnyofComplexTypes.md) + - [AnyofWithBaseSchema](docs/AnyofWithBaseSchema.md) + - [AnyofWithBooleanSchemasAllFalse](docs/AnyofWithBooleanSchemasAllFalse.md) + - [AnyofWithBooleanSchemasAllTrue](docs/AnyofWithBooleanSchemasAllTrue.md) + - [AnyofWithBooleanSchemasSomeTrue](docs/AnyofWithBooleanSchemasSomeTrue.md) + - [AnyofWithOneEmptySchema](docs/AnyofWithOneEmptySchema.md) - [ArrayTypeMatchesArrays](docs/ArrayTypeMatchesArrays.md) - [BooleanTypeMatchesBooleans](docs/BooleanTypeMatchesBooleans.md) - [IntegerTypeMatchesIntegers](docs/IntegerTypeMatchesIntegers.md) + - [NestedAllofToCheckValidationSemantics](docs/NestedAllofToCheckValidationSemantics.md) + - [NestedAnyofToCheckValidationSemantics](docs/NestedAnyofToCheckValidationSemantics.md) - [NullTypeMatchesOnlyTheNullObject](docs/NullTypeMatchesOnlyTheNullObject.md) - [NumberTypeMatchesNumbers](docs/NumberTypeMatchesNumbers.md) - [StringTypeMatchesStrings](docs/StringTypeMatchesStrings.md) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md new file mode 100644 index 00000000000..d9981bf45a7 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md @@ -0,0 +1,11 @@ +# AdditionalpropertiesAllowsASchemaWhichShouldValidate + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**foo** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] +**bar** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] +**any string name** | **bool** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAreAllowedByDefault.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAreAllowedByDefault.md new file mode 100644 index 00000000000..d5e7d2747ee --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAreAllowedByDefault.md @@ -0,0 +1,11 @@ +# AdditionalpropertiesAreAllowedByDefault + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**foo** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] +**bar** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesCanExistByItself.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesCanExistByItself.md new file mode 100644 index 00000000000..72b091b888a --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesCanExistByItself.md @@ -0,0 +1,9 @@ +# AdditionalpropertiesCanExistByItself + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesShouldNotLookInApplicators.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesShouldNotLookInApplicators.md new file mode 100644 index 00000000000..31efeb974b1 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesShouldNotLookInApplicators.md @@ -0,0 +1,9 @@ +# AdditionalpropertiesShouldNotLookInApplicators + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Allof.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Allof.md new file mode 100644 index 00000000000..77328e52d3f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Allof.md @@ -0,0 +1,9 @@ +# Allof + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofCombinedWithAnyofOneof.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofCombinedWithAnyofOneof.md new file mode 100644 index 00000000000..403b07716ce --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofCombinedWithAnyofOneof.md @@ -0,0 +1,9 @@ +# AllofCombinedWithAnyofOneof + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofSimpleTypes.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofSimpleTypes.md new file mode 100644 index 00000000000..b1ababc3e59 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofSimpleTypes.md @@ -0,0 +1,9 @@ +# AllofSimpleTypes + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithBaseSchema.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithBaseSchema.md new file mode 100644 index 00000000000..a01c8b13de9 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithBaseSchema.md @@ -0,0 +1,10 @@ +# AllofWithBaseSchema + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**bar** | **int** | | +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithBooleanSchemasAllFalse.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithBooleanSchemasAllFalse.md new file mode 100644 index 00000000000..387f413d822 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithBooleanSchemasAllFalse.md @@ -0,0 +1,9 @@ +# AllofWithBooleanSchemasAllFalse + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithBooleanSchemasAllTrue.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithBooleanSchemasAllTrue.md new file mode 100644 index 00000000000..14b9d72db54 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithBooleanSchemasAllTrue.md @@ -0,0 +1,9 @@ +# AllofWithBooleanSchemasAllTrue + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithBooleanSchemasSomeFalse.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithBooleanSchemasSomeFalse.md new file mode 100644 index 00000000000..ee097e71b8b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithBooleanSchemasSomeFalse.md @@ -0,0 +1,9 @@ +# AllofWithBooleanSchemasSomeFalse + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithOneEmptySchema.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithOneEmptySchema.md new file mode 100644 index 00000000000..21e4d7d4ef9 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithOneEmptySchema.md @@ -0,0 +1,9 @@ +# AllofWithOneEmptySchema + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithTheFirstEmptySchema.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithTheFirstEmptySchema.md new file mode 100644 index 00000000000..d25f5664846 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithTheFirstEmptySchema.md @@ -0,0 +1,9 @@ +# AllofWithTheFirstEmptySchema + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithTheLastEmptySchema.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithTheLastEmptySchema.md new file mode 100644 index 00000000000..aefbea30368 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithTheLastEmptySchema.md @@ -0,0 +1,9 @@ +# AllofWithTheLastEmptySchema + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithTwoEmptySchemas.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithTwoEmptySchemas.md new file mode 100644 index 00000000000..220b95e4f0c --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithTwoEmptySchemas.md @@ -0,0 +1,9 @@ +# AllofWithTwoEmptySchemas + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Anyof.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Anyof.md new file mode 100644 index 00000000000..2a5107e980c --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Anyof.md @@ -0,0 +1,9 @@ +# Anyof + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofComplexTypes.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofComplexTypes.md new file mode 100644 index 00000000000..a6a3dcfa534 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofComplexTypes.md @@ -0,0 +1,9 @@ +# AnyofComplexTypes + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithBaseSchema.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithBaseSchema.md new file mode 100644 index 00000000000..cf00c6413dc --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithBaseSchema.md @@ -0,0 +1,8 @@ +# AnyofWithBaseSchema + +Type | Description | Notes +------------- | ------------- | ------------- +**str** | | + +[[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/3_0_3_unit_test/python-experimental/docs/AnyofWithBooleanSchemasAllFalse.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithBooleanSchemasAllFalse.md new file mode 100644 index 00000000000..7f04439fae5 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithBooleanSchemasAllFalse.md @@ -0,0 +1,9 @@ +# AnyofWithBooleanSchemasAllFalse + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithBooleanSchemasAllTrue.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithBooleanSchemasAllTrue.md new file mode 100644 index 00000000000..3a8976b2717 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithBooleanSchemasAllTrue.md @@ -0,0 +1,9 @@ +# AnyofWithBooleanSchemasAllTrue + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithBooleanSchemasSomeTrue.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithBooleanSchemasSomeTrue.md new file mode 100644 index 00000000000..65ee138224d --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithBooleanSchemasSomeTrue.md @@ -0,0 +1,9 @@ +# AnyofWithBooleanSchemasSomeTrue + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithOneEmptySchema.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithOneEmptySchema.md new file mode 100644 index 00000000000..2d3666e55b2 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithOneEmptySchema.md @@ -0,0 +1,9 @@ +# AnyofWithOneEmptySchema + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedAllofToCheckValidationSemantics.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedAllofToCheckValidationSemantics.md new file mode 100644 index 00000000000..abd73afca55 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedAllofToCheckValidationSemantics.md @@ -0,0 +1,9 @@ +# NestedAllofToCheckValidationSemantics + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedAnyofToCheckValidationSemantics.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedAnyofToCheckValidationSemantics.md new file mode 100644 index 00000000000..d95966736d7 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedAnyofToCheckValidationSemantics.md @@ -0,0 +1,9 @@ +# NestedAnyofToCheckValidationSemantics + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py new file mode 100644 index 00000000000..90ea79b75d3 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py @@ -0,0 +1,59 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.additionalproperties_allows_a_schema_which_should_validate import AdditionalpropertiesAllowsASchemaWhichShouldValidate + + +class TestAdditionalpropertiesAllowsASchemaWhichShouldValidate(unittest.TestCase): + """AdditionalpropertiesAllowsASchemaWhichShouldValidate unit test stubs""" + + def test_no_additional_properties_is_valid_passes(self): + # no additional properties is valid + AdditionalpropertiesAllowsASchemaWhichShouldValidate( + { + "foo": + 1, + } + nl ) + + def test_an_additional_invalid_property_is_invalid_fails(self): + # an additional invalid property is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AdditionalpropertiesAllowsASchemaWhichShouldValidate( + { + "foo": + 1, + "bar": + 2, + "quux": + 12, + } + nl ) + + def test_an_additional_valid_property_is_valid_passes(self): + # an additional valid property is valid + AdditionalpropertiesAllowsASchemaWhichShouldValidate( + { + "foo": + 1, + "bar": + 2, + "quux": + True, + } + nl ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py new file mode 100644 index 00000000000..f96fb233305 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py @@ -0,0 +1,36 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.additionalproperties_are_allowed_by_default import AdditionalpropertiesAreAllowedByDefault + + +class TestAdditionalpropertiesAreAllowedByDefault(unittest.TestCase): + """AdditionalpropertiesAreAllowedByDefault unit test stubs""" + + def test_additional_properties_are_allowed_passes(self): + # additional properties are allowed + AdditionalpropertiesAreAllowedByDefault( + { + "foo": + 1, + "bar": + 2, + "quux": + True, + } + nl ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py new file mode 100644 index 00000000000..99a238c6471 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py @@ -0,0 +1,42 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.additionalproperties_can_exist_by_itself import AdditionalpropertiesCanExistByItself + + +class TestAdditionalpropertiesCanExistByItself(unittest.TestCase): + """AdditionalpropertiesCanExistByItself unit test stubs""" + + def test_an_additional_invalid_property_is_invalid_fails(self): + # an additional invalid property is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AdditionalpropertiesCanExistByItself( + { + "foo": + 1, + } + nl ) + + def test_an_additional_valid_property_is_valid_passes(self): + # an additional valid property is valid + AdditionalpropertiesCanExistByItself( + { + "foo": + True, + } + nl ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py new file mode 100644 index 00000000000..3757ec25376 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py @@ -0,0 +1,35 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.additionalproperties_should_not_look_in_applicators import AdditionalpropertiesShouldNotLookInApplicators + + +class TestAdditionalpropertiesShouldNotLookInApplicators(unittest.TestCase): + """AdditionalpropertiesShouldNotLookInApplicators unit test stubs""" + + def test_properties_defined_in_allof_are_not_examined_fails(self): + # properties defined in allOf are not examined + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AdditionalpropertiesShouldNotLookInApplicators( + { + "foo": + 1, + "bar": + True, + } + nl ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof.py new file mode 100644 index 00000000000..8229279fdcb --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof.py @@ -0,0 +1,66 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.allof import Allof + + +class TestAllof(unittest.TestCase): + """Allof unit test stubs""" + + def test_allof_passes(self): + # allOf + Allof( + { + "foo": + "baz", + "bar": + 2, + } + nl ) + + def test_mismatch_first_fails(self): + # mismatch first + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + Allof( + { + "bar": + 2, + } + nl ) + + def test_mismatch_second_fails(self): + # mismatch second + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + Allof( + { + "foo": + "baz", + } + nl ) + + def test_wrong_type_fails(self): + # wrong type + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + Allof( + { + "foo": + "baz", + "bar": + "quux", + } + nl ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_combined_with_anyof_oneof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_combined_with_anyof_oneof.py new file mode 100644 index 00000000000..30b20cfc508 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_combined_with_anyof_oneof.py @@ -0,0 +1,70 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.allof_combined_with_anyof_oneof import AllofCombinedWithAnyofOneof + + +class TestAllofCombinedWithAnyofOneof(unittest.TestCase): + """AllofCombinedWithAnyofOneof unit test stubs""" + + def test_allof_true_anyof_false_oneof_false_fails(self): + # allOf: true, anyOf: false, oneOf: false + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofCombinedWithAnyofOneof( +2nl ) + + def test_allof_false_anyof_false_oneof_true_fails(self): + # allOf: false, anyOf: false, oneOf: true + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofCombinedWithAnyofOneof( +5nl ) + + def test_allof_false_anyof_true_oneof_true_fails(self): + # allOf: false, anyOf: true, oneOf: true + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofCombinedWithAnyofOneof( +15nl ) + + def test_allof_true_anyof_true_oneof_false_fails(self): + # allOf: true, anyOf: true, oneOf: false + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofCombinedWithAnyofOneof( +6nl ) + + def test_allof_true_anyof_true_oneof_true_passes(self): + # allOf: true, anyOf: true, oneOf: true + AllofCombinedWithAnyofOneof( +30nl ) + + def test_allof_true_anyof_false_oneof_true_fails(self): + # allOf: true, anyOf: false, oneOf: true + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofCombinedWithAnyofOneof( +10nl ) + + def test_allof_false_anyof_true_oneof_false_fails(self): + # allOf: false, anyOf: true, oneOf: false + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofCombinedWithAnyofOneof( +3nl ) + + def test_allof_false_anyof_false_oneof_false_fails(self): + # allOf: false, anyOf: false, oneOf: false + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofCombinedWithAnyofOneof( +1nl ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_simple_types.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_simple_types.py new file mode 100644 index 00000000000..0a67da1123a --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_simple_types.py @@ -0,0 +1,34 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.allof_simple_types import AllofSimpleTypes + + +class TestAllofSimpleTypes(unittest.TestCase): + """AllofSimpleTypes unit test stubs""" + + def test_valid_passes(self): + # valid + AllofSimpleTypes( +25nl ) + + def test_mismatch_one_fails(self): + # mismatch one + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofSimpleTypes( +35nl ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_base_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_base_schema.py new file mode 100644 index 00000000000..097aa1515a5 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_base_schema.py @@ -0,0 +1,82 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.allof_with_base_schema import AllofWithBaseSchema + + +class TestAllofWithBaseSchema(unittest.TestCase): + """AllofWithBaseSchema unit test stubs""" + + def test_valid_passes(self): + # valid + AllofWithBaseSchema( + { + "foo": + "quux", + "bar": + 2, + "baz": + None, + } + nl ) + + def test_mismatch_first_allof_fails(self): + # mismatch first allOf + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofWithBaseSchema( + { + "bar": + 2, + "baz": + None, + } + nl ) + + def test_mismatch_base_schema_fails(self): + # mismatch base schema + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofWithBaseSchema( + { + "foo": + "quux", + "baz": + None, + } + nl ) + + def test_mismatch_both_fails(self): + # mismatch both + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofWithBaseSchema( + { + "bar": + 2, + } + nl ) + + def test_mismatch_second_allof_fails(self): + # mismatch second allOf + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofWithBaseSchema( + { + "foo": + "quux", + "bar": + 2, + } + nl ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_all_false.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_all_false.py new file mode 100644 index 00000000000..a320063b5e7 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_all_false.py @@ -0,0 +1,29 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.allof_with_boolean_schemas_all_false import AllofWithBooleanSchemasAllFalse + + +class TestAllofWithBooleanSchemasAllFalse(unittest.TestCase): + """AllofWithBooleanSchemasAllFalse unit test stubs""" + + def test_any_value_is_invalid_fails(self): + # any value is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofWithBooleanSchemasAllFalse( +"foo"nl ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_all_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_all_true.py new file mode 100644 index 00000000000..1098055dfe7 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_all_true.py @@ -0,0 +1,28 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.allof_with_boolean_schemas_all_true import AllofWithBooleanSchemasAllTrue + + +class TestAllofWithBooleanSchemasAllTrue(unittest.TestCase): + """AllofWithBooleanSchemasAllTrue unit test stubs""" + + def test_any_value_is_valid_passes(self): + # any value is valid + AllofWithBooleanSchemasAllTrue( +"foo"nl ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_some_false.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_some_false.py new file mode 100644 index 00000000000..592f532e3d9 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_some_false.py @@ -0,0 +1,29 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.allof_with_boolean_schemas_some_false import AllofWithBooleanSchemasSomeFalse + + +class TestAllofWithBooleanSchemasSomeFalse(unittest.TestCase): + """AllofWithBooleanSchemasSomeFalse unit test stubs""" + + def test_any_value_is_invalid_fails(self): + # any value is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofWithBooleanSchemasSomeFalse( +"foo"nl ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_one_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_one_empty_schema.py new file mode 100644 index 00000000000..b93716dff74 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_one_empty_schema.py @@ -0,0 +1,28 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.allof_with_one_empty_schema import AllofWithOneEmptySchema + + +class TestAllofWithOneEmptySchema(unittest.TestCase): + """AllofWithOneEmptySchema unit test stubs""" + + def test_any_data_is_valid_passes(self): + # any data is valid + AllofWithOneEmptySchema( +1nl ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_first_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_first_empty_schema.py new file mode 100644 index 00000000000..05bcd574ccc --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_first_empty_schema.py @@ -0,0 +1,34 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.allof_with_the_first_empty_schema import AllofWithTheFirstEmptySchema + + +class TestAllofWithTheFirstEmptySchema(unittest.TestCase): + """AllofWithTheFirstEmptySchema unit test stubs""" + + def test_string_is_invalid_fails(self): + # string is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofWithTheFirstEmptySchema( +"foo"nl ) + + def test_number_is_valid_passes(self): + # number is valid + AllofWithTheFirstEmptySchema( +1nl ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_last_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_last_empty_schema.py new file mode 100644 index 00000000000..6a142d4412f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_last_empty_schema.py @@ -0,0 +1,34 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.allof_with_the_last_empty_schema import AllofWithTheLastEmptySchema + + +class TestAllofWithTheLastEmptySchema(unittest.TestCase): + """AllofWithTheLastEmptySchema unit test stubs""" + + def test_string_is_invalid_fails(self): + # string is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AllofWithTheLastEmptySchema( +"foo"nl ) + + def test_number_is_valid_passes(self): + # number is valid + AllofWithTheLastEmptySchema( +1nl ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_two_empty_schemas.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_two_empty_schemas.py new file mode 100644 index 00000000000..db0b444cf6f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_two_empty_schemas.py @@ -0,0 +1,28 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.allof_with_two_empty_schemas import AllofWithTwoEmptySchemas + + +class TestAllofWithTwoEmptySchemas(unittest.TestCase): + """AllofWithTwoEmptySchemas unit test stubs""" + + def test_any_data_is_valid_passes(self): + # any data is valid + AllofWithTwoEmptySchemas( +1nl ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof.py new file mode 100644 index 00000000000..17521a0b1f3 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof.py @@ -0,0 +1,44 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.anyof import Anyof + + +class TestAnyof(unittest.TestCase): + """Anyof unit test stubs""" + + def test_second_anyof_valid_passes(self): + # second anyOf valid + Anyof( +2.5nl ) + + def test_neither_anyof_valid_fails(self): + # neither anyOf valid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + Anyof( +1.5nl ) + + def test_both_anyof_valid_passes(self): + # both anyOf valid + Anyof( +3nl ) + + def test_first_anyof_valid_passes(self): + # first anyOf valid + Anyof( +1nl ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_complex_types.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_complex_types.py new file mode 100644 index 00000000000..92a4d35229d --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_complex_types.py @@ -0,0 +1,64 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.anyof_complex_types import AnyofComplexTypes + + +class TestAnyofComplexTypes(unittest.TestCase): + """AnyofComplexTypes unit test stubs""" + + def test_second_anyof_valid_complex_passes(self): + # second anyOf valid (complex) + AnyofComplexTypes( + { + "foo": + "baz", + } + nl ) + + def test_neither_anyof_valid_complex_fails(self): + # neither anyOf valid (complex) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AnyofComplexTypes( + { + "foo": + 2, + "bar": + "quux", + } + nl ) + + def test_both_anyof_valid_complex_passes(self): + # both anyOf valid (complex) + AnyofComplexTypes( + { + "foo": + "baz", + "bar": + 2, + } + nl ) + + def test_first_anyof_valid_complex_passes(self): + # first anyOf valid (complex) + AnyofComplexTypes( + { + "bar": + 2, + } + nl ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_base_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_base_schema.py new file mode 100644 index 00000000000..b9fe9e2f8c3 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_base_schema.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.anyof_with_base_schema import AnyofWithBaseSchema + + +class TestAnyofWithBaseSchema(unittest.TestCase): + """AnyofWithBaseSchema unit test stubs""" + + def test_one_anyof_valid_passes(self): + # one anyOf valid + AnyofWithBaseSchema( +"foobar"nl ) + + def test_both_anyof_invalid_fails(self): + # both anyOf invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AnyofWithBaseSchema( +"foo"nl ) + + def test_mismatch_base_schema_fails(self): + # mismatch base schema + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AnyofWithBaseSchema( +3nl ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_boolean_schemas_all_false.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_boolean_schemas_all_false.py new file mode 100644 index 00000000000..0bfcc59d019 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_boolean_schemas_all_false.py @@ -0,0 +1,29 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.anyof_with_boolean_schemas_all_false import AnyofWithBooleanSchemasAllFalse + + +class TestAnyofWithBooleanSchemasAllFalse(unittest.TestCase): + """AnyofWithBooleanSchemasAllFalse unit test stubs""" + + def test_any_value_is_invalid_fails(self): + # any value is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + AnyofWithBooleanSchemasAllFalse( +"foo"nl ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_boolean_schemas_all_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_boolean_schemas_all_true.py new file mode 100644 index 00000000000..7928dfcac6e --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_boolean_schemas_all_true.py @@ -0,0 +1,28 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.anyof_with_boolean_schemas_all_true import AnyofWithBooleanSchemasAllTrue + + +class TestAnyofWithBooleanSchemasAllTrue(unittest.TestCase): + """AnyofWithBooleanSchemasAllTrue unit test stubs""" + + def test_any_value_is_valid_passes(self): + # any value is valid + AnyofWithBooleanSchemasAllTrue( +"foo"nl ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_boolean_schemas_some_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_boolean_schemas_some_true.py new file mode 100644 index 00000000000..a1e1ac43c8d --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_boolean_schemas_some_true.py @@ -0,0 +1,28 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.anyof_with_boolean_schemas_some_true import AnyofWithBooleanSchemasSomeTrue + + +class TestAnyofWithBooleanSchemasSomeTrue(unittest.TestCase): + """AnyofWithBooleanSchemasSomeTrue unit test stubs""" + + def test_any_value_is_valid_passes(self): + # any value is valid + AnyofWithBooleanSchemasSomeTrue( +"foo"nl ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_one_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_one_empty_schema.py new file mode 100644 index 00000000000..082d9952e52 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_one_empty_schema.py @@ -0,0 +1,33 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.anyof_with_one_empty_schema import AnyofWithOneEmptySchema + + +class TestAnyofWithOneEmptySchema(unittest.TestCase): + """AnyofWithOneEmptySchema unit test stubs""" + + def test_string_is_valid_passes(self): + # string is valid + AnyofWithOneEmptySchema( +"foo"nl ) + + def test_number_is_valid_passes(self): + # number is valid + AnyofWithOneEmptySchema( +123nl ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py index 47e27f0ea52..7d25daad70b 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py @@ -22,22 +22,19 @@ class TestArrayTypeMatchesArrays(unittest.TestCase): # a float is not an array with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): ArrayTypeMatchesArrays( - 1.1 - ) +1.1nl ) def test_a_boolean_is_not_an_array_fails(self): # a boolean is not an array with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): ArrayTypeMatchesArrays( - True - ) +Truenl ) def test_null_is_not_an_array_fails(self): # null is not an array with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): ArrayTypeMatchesArrays( - None - ) +Nonenl ) def test_an_object_is_not_an_array_fails(self): # an object is not an array @@ -45,28 +42,26 @@ class TestArrayTypeMatchesArrays(unittest.TestCase): ArrayTypeMatchesArrays( { } - ) + nl ) def test_a_string_is_not_an_array_fails(self): # a string is not an array with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): ArrayTypeMatchesArrays( - "foo" - ) +"foo"nl ) def test_an_array_is_an_array_passes(self): # an array is an array ArrayTypeMatchesArrays( [ ] - ) +nl ) def test_an_integer_is_not_an_array_fails(self): # an integer is not an array with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): ArrayTypeMatchesArrays( - 1 - ) +1nl ) if __name__ == '__main__': diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py index 6e6fab281e7..68a2d7f5437 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py @@ -22,29 +22,25 @@ class TestBooleanTypeMatchesBooleans(unittest.TestCase): # an empty string is not a boolean with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): BooleanTypeMatchesBooleans( - "" - ) +""nl ) def test_a_float_is_not_a_boolean_fails(self): # a float is not a boolean with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): BooleanTypeMatchesBooleans( - 1.1 - ) +1.1nl ) def test_null_is_not_a_boolean_fails(self): # null is not a boolean with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): BooleanTypeMatchesBooleans( - None - ) +Nonenl ) def test_zero_is_not_a_boolean_fails(self): # zero is not a boolean with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): BooleanTypeMatchesBooleans( - 0 - ) +0nl ) def test_an_array_is_not_a_boolean_fails(self): # an array is not a boolean @@ -52,33 +48,29 @@ class TestBooleanTypeMatchesBooleans(unittest.TestCase): BooleanTypeMatchesBooleans( [ ] - ) +nl ) def test_a_string_is_not_a_boolean_fails(self): # a string is not a boolean with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): BooleanTypeMatchesBooleans( - "foo" - ) +"foo"nl ) def test_false_is_a_boolean_passes(self): # false is a boolean BooleanTypeMatchesBooleans( - False - ) +Falsenl ) def test_an_integer_is_not_a_boolean_fails(self): # an integer is not a boolean with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): BooleanTypeMatchesBooleans( - 1 - ) +1nl ) def test_true_is_a_boolean_passes(self): # true is a boolean BooleanTypeMatchesBooleans( - True - ) +Truenl ) def test_an_object_is_not_a_boolean_fails(self): # an object is not a boolean @@ -86,7 +78,7 @@ class TestBooleanTypeMatchesBooleans(unittest.TestCase): BooleanTypeMatchesBooleans( { } - ) + nl ) if __name__ == '__main__': diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py index b118d36ab04..bc7c56ea96c 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py @@ -24,54 +24,47 @@ class TestIntegerTypeMatchesIntegers(unittest.TestCase): IntegerTypeMatchesIntegers( { } - ) + nl ) def test_a_string_is_not_an_integer_fails(self): # a string is not an integer with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): IntegerTypeMatchesIntegers( - "foo" - ) +"foo"nl ) def test_null_is_not_an_integer_fails(self): # null is not an integer with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): IntegerTypeMatchesIntegers( - None - ) +Nonenl ) def test_a_float_with_zero_fractional_part_is_an_integer_passes(self): # a float with zero fractional part is an integer IntegerTypeMatchesIntegers( - 1.0 - ) +1.0nl ) def test_a_float_is_not_an_integer_fails(self): # a float is not an integer with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): IntegerTypeMatchesIntegers( - 1.1 - ) +1.1nl ) def test_a_boolean_is_not_an_integer_fails(self): # a boolean is not an integer with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): IntegerTypeMatchesIntegers( - True - ) +Truenl ) def test_an_integer_is_an_integer_passes(self): # an integer is an integer IntegerTypeMatchesIntegers( - 1 - ) +1nl ) def test_a_string_is_still_not_an_integer_even_if_it_looks_like_one_fails(self): # a string is still not an integer, even if it looks like one with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): IntegerTypeMatchesIntegers( - "1" - ) +"1"nl ) def test_an_array_is_not_an_integer_fails(self): # an array is not an integer @@ -79,7 +72,7 @@ class TestIntegerTypeMatchesIntegers(unittest.TestCase): IntegerTypeMatchesIntegers( [ ] - ) +nl ) if __name__ == '__main__': diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_allof_to_check_validation_semantics.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_allof_to_check_validation_semantics.py new file mode 100644 index 00000000000..4d01667d8c0 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_allof_to_check_validation_semantics.py @@ -0,0 +1,34 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.nested_allof_to_check_validation_semantics import NestedAllofToCheckValidationSemantics + + +class TestNestedAllofToCheckValidationSemantics(unittest.TestCase): + """NestedAllofToCheckValidationSemantics unit test stubs""" + + def test_anything_non_null_is_invalid_fails(self): + # anything non-null is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NestedAllofToCheckValidationSemantics( +123nl ) + + def test_null_is_valid_passes(self): + # null is valid + NestedAllofToCheckValidationSemantics( +Nonenl ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_anyof_to_check_validation_semantics.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_anyof_to_check_validation_semantics.py new file mode 100644 index 00000000000..c6f47309c3e --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_anyof_to_check_validation_semantics.py @@ -0,0 +1,34 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.nested_anyof_to_check_validation_semantics import NestedAnyofToCheckValidationSemantics + + +class TestNestedAnyofToCheckValidationSemantics(unittest.TestCase): + """NestedAnyofToCheckValidationSemantics unit test stubs""" + + def test_anything_non_null_is_invalid_fails(self): + # anything non-null is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + NestedAnyofToCheckValidationSemantics( +123nl ) + + def test_null_is_valid_passes(self): + # null is valid + NestedAnyofToCheckValidationSemantics( +Nonenl ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py index bf8b35d150a..dd52cc566a3 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py @@ -22,8 +22,7 @@ class TestNullTypeMatchesOnlyTheNullObject(unittest.TestCase): # a float is not null with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NullTypeMatchesOnlyTheNullObject( - 1.1 - ) +1.1nl ) def test_an_object_is_not_null_fails(self): # an object is not null @@ -31,48 +30,42 @@ class TestNullTypeMatchesOnlyTheNullObject(unittest.TestCase): NullTypeMatchesOnlyTheNullObject( { } - ) + nl ) def test_false_is_not_null_fails(self): # false is not null with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NullTypeMatchesOnlyTheNullObject( - False - ) +Falsenl ) def test_an_integer_is_not_null_fails(self): # an integer is not null with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NullTypeMatchesOnlyTheNullObject( - 1 - ) +1nl ) def test_true_is_not_null_fails(self): # true is not null with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NullTypeMatchesOnlyTheNullObject( - True - ) +Truenl ) def test_zero_is_not_null_fails(self): # zero is not null with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NullTypeMatchesOnlyTheNullObject( - 0 - ) +0nl ) def test_an_empty_string_is_not_null_fails(self): # an empty string is not null with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NullTypeMatchesOnlyTheNullObject( - "" - ) +""nl ) def test_null_is_null_passes(self): # null is null NullTypeMatchesOnlyTheNullObject( - None - ) +Nonenl ) def test_an_array_is_not_null_fails(self): # an array is not null @@ -80,14 +73,13 @@ class TestNullTypeMatchesOnlyTheNullObject(unittest.TestCase): NullTypeMatchesOnlyTheNullObject( [ ] - ) +nl ) def test_a_string_is_not_null_fails(self): # a string is not null with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NullTypeMatchesOnlyTheNullObject( - "foo" - ) +"foo"nl ) if __name__ == '__main__': diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py index 24a4c25c842..cd1b1b8b7d6 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py @@ -24,14 +24,13 @@ class TestNumberTypeMatchesNumbers(unittest.TestCase): NumberTypeMatchesNumbers( [ ] - ) +nl ) def test_null_is_not_a_number_fails(self): # null is not a number with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NumberTypeMatchesNumbers( - None - ) +Nonenl ) def test_an_object_is_not_a_number_fails(self): # an object is not a number @@ -39,46 +38,40 @@ class TestNumberTypeMatchesNumbers(unittest.TestCase): NumberTypeMatchesNumbers( { } - ) + nl ) def test_a_boolean_is_not_a_number_fails(self): # a boolean is not a number with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NumberTypeMatchesNumbers( - True - ) +Truenl ) def test_a_float_is_a_number_passes(self): # a float is a number NumberTypeMatchesNumbers( - 1.1 - ) +1.1nl ) def test_a_string_is_still_not_a_number_even_if_it_looks_like_one_fails(self): # a string is still not a number, even if it looks like one with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NumberTypeMatchesNumbers( - "1" - ) +"1"nl ) def test_a_string_is_not_a_number_fails(self): # a string is not a number with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NumberTypeMatchesNumbers( - "foo" - ) +"foo"nl ) def test_an_integer_is_a_number_passes(self): # an integer is a number NumberTypeMatchesNumbers( - 1 - ) +1nl ) def test_a_float_with_zero_fractional_part_is_a_number_and_an_integer_passes(self): # a float with zero fractional part is a number (and an integer) NumberTypeMatchesNumbers( - 1.0 - ) +1.0nl ) if __name__ == '__main__': diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py index 8dedf398200..9a84dfae947 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py @@ -22,27 +22,23 @@ class TestStringTypeMatchesStrings(unittest.TestCase): # 1 is not a string with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): StringTypeMatchesStrings( - 1 - ) +1nl ) def test_a_string_is_still_a_string_even_if_it_looks_like_a_number_passes(self): # a string is still a string, even if it looks like a number StringTypeMatchesStrings( - "1" - ) +"1"nl ) def test_an_empty_string_is_still_a_string_passes(self): # an empty string is still a string StringTypeMatchesStrings( - "" - ) +""nl ) def test_a_float_is_not_a_string_fails(self): # a float is not a string with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): StringTypeMatchesStrings( - 1.1 - ) +1.1nl ) def test_an_object_is_not_a_string_fails(self): # an object is not a string @@ -50,7 +46,7 @@ class TestStringTypeMatchesStrings(unittest.TestCase): StringTypeMatchesStrings( { } - ) + nl ) def test_an_array_is_not_a_string_fails(self): # an array is not a string @@ -58,27 +54,24 @@ class TestStringTypeMatchesStrings(unittest.TestCase): StringTypeMatchesStrings( [ ] - ) +nl ) def test_a_boolean_is_not_a_string_fails(self): # a boolean is not a string with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): StringTypeMatchesStrings( - True - ) +Truenl ) def test_null_is_not_a_string_fails(self): # null is not a string with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): StringTypeMatchesStrings( - None - ) +Nonenl ) def test_a_string_is_a_string_passes(self): # a string is a string StringTypeMatchesStrings( - "foo" - ) +"foo"nl ) if __name__ == '__main__': diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_allows_a_schema_which_should_validate.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_allows_a_schema_which_should_validate.py new file mode 100644 index 00000000000..8e986da86fc --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_allows_a_schema_which_should_validate.py @@ -0,0 +1,97 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class AdditionalpropertiesAllowsASchemaWhichShouldValidate( + DictSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + foo = AnyTypeSchema + bar = AnyTypeSchema + _additional_properties = BoolSchema + + + def __new__( + cls, + *args: typing.Union[dict, frozendict, ], + foo: typing.Union[foo, Unset] = unset, + bar: typing.Union[bar, Unset] = unset, + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'AdditionalpropertiesAllowsASchemaWhichShouldValidate': + return super().__new__( + cls, + *args, + foo=foo, + bar=bar, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_are_allowed_by_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_are_allowed_by_default.py new file mode 100644 index 00000000000..2251b2f815a --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_are_allowed_by_default.py @@ -0,0 +1,95 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class AdditionalpropertiesAreAllowedByDefault( + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + foo = AnyTypeSchema + bar = AnyTypeSchema + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + foo: typing.Union[foo, Unset] = unset, + bar: typing.Union[bar, Unset] = unset, + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'AdditionalpropertiesAreAllowedByDefault': + return super().__new__( + cls, + *args, + foo=foo, + bar=bar, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_can_exist_by_itself.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_can_exist_by_itself.py new file mode 100644 index 00000000000..383a01af174 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_can_exist_by_itself.py @@ -0,0 +1,91 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class AdditionalpropertiesCanExistByItself( + DictSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + _additional_properties = BoolSchema + + + def __new__( + cls, + *args: typing.Union[dict, frozendict, ], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'AdditionalpropertiesCanExistByItself': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_should_not_look_in_applicators.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_should_not_look_in_applicators.py new file mode 100644 index 00000000000..66547528189 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_should_not_look_in_applicators.py @@ -0,0 +1,114 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class AdditionalpropertiesShouldNotLookInApplicators( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + _additional_properties = BoolSchema + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 + allOf_0 = AnyTypeSchema + return { + 'allOf': [ + allOf_0, + ], + 'oneOf': [ + ], + 'anyOf': [ + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'AdditionalpropertiesShouldNotLookInApplicators': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof.py new file mode 100644 index 00000000000..475f6aed9e0 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof.py @@ -0,0 +1,115 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class Allof( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 + allOf_0 = AnyTypeSchema + allOf_1 = AnyTypeSchema + return { + 'allOf': [ + allOf_0, + allOf_1, + ], + 'oneOf': [ + ], + 'anyOf': [ + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'Allof': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_combined_with_anyof_oneof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_combined_with_anyof_oneof.py new file mode 100644 index 00000000000..1ac089847fb --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_combined_with_anyof_oneof.py @@ -0,0 +1,117 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class AllofCombinedWithAnyofOneof( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 + allOf_0 = AnyTypeSchema + oneOf_0 = AnyTypeSchema + anyOf_0 = AnyTypeSchema + return { + 'allOf': [ + allOf_0, + ], + 'oneOf': [ + oneOf_0, + ], + 'anyOf': [ + anyOf_0, + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'AllofCombinedWithAnyofOneof': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_simple_types.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_simple_types.py new file mode 100644 index 00000000000..3e5f0c525c7 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_simple_types.py @@ -0,0 +1,115 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class AllofSimpleTypes( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 + allOf_0 = AnyTypeSchema + allOf_1 = AnyTypeSchema + return { + 'allOf': [ + allOf_0, + allOf_1, + ], + 'oneOf': [ + ], + 'anyOf': [ + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'AllofSimpleTypes': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_base_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_base_schema.py new file mode 100644 index 00000000000..f73a66a8bd9 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_base_schema.py @@ -0,0 +1,121 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class AllofWithBaseSchema( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + _required_property_names = set(( + 'bar', + )) + bar = IntSchema + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 + allOf_0 = AnyTypeSchema + allOf_1 = AnyTypeSchema + return { + 'allOf': [ + allOf_0, + allOf_1, + ], + 'oneOf': [ + ], + 'anyOf': [ + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + bar: bar, + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'AllofWithBaseSchema': + return super().__new__( + cls, + *args, + bar=bar, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_boolean_schemas_all_false.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_boolean_schemas_all_false.py new file mode 100644 index 00000000000..d2cf5a9a40e --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_boolean_schemas_all_false.py @@ -0,0 +1,111 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class AllofWithBooleanSchemasAllFalse( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 { + 'allOf': [ + ], + 'oneOf': [ + ], + 'anyOf': [ + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'AllofWithBooleanSchemasAllFalse': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_boolean_schemas_all_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_boolean_schemas_all_true.py new file mode 100644 index 00000000000..8724b72b4e1 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_boolean_schemas_all_true.py @@ -0,0 +1,111 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class AllofWithBooleanSchemasAllTrue( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 { + 'allOf': [ + ], + 'oneOf': [ + ], + 'anyOf': [ + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'AllofWithBooleanSchemasAllTrue': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_boolean_schemas_some_false.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_boolean_schemas_some_false.py new file mode 100644 index 00000000000..ed8b1e80727 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_boolean_schemas_some_false.py @@ -0,0 +1,111 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class AllofWithBooleanSchemasSomeFalse( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 { + 'allOf': [ + ], + 'oneOf': [ + ], + 'anyOf': [ + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'AllofWithBooleanSchemasSomeFalse': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_one_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_one_empty_schema.py new file mode 100644 index 00000000000..2f3b66d35ea --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_one_empty_schema.py @@ -0,0 +1,113 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class AllofWithOneEmptySchema( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 + allOf_0 = AnyTypeSchema + return { + 'allOf': [ + allOf_0, + ], + 'oneOf': [ + ], + 'anyOf': [ + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'AllofWithOneEmptySchema': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_the_first_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_the_first_empty_schema.py new file mode 100644 index 00000000000..9fac19ec1f3 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_the_first_empty_schema.py @@ -0,0 +1,115 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class AllofWithTheFirstEmptySchema( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 + allOf_0 = AnyTypeSchema + allOf_1 = NumberSchema + return { + 'allOf': [ + allOf_0, + allOf_1, + ], + 'oneOf': [ + ], + 'anyOf': [ + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'AllofWithTheFirstEmptySchema': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_the_last_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_the_last_empty_schema.py new file mode 100644 index 00000000000..069709c6602 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_the_last_empty_schema.py @@ -0,0 +1,115 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class AllofWithTheLastEmptySchema( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 + allOf_0 = NumberSchema + allOf_1 = AnyTypeSchema + return { + 'allOf': [ + allOf_0, + allOf_1, + ], + 'oneOf': [ + ], + 'anyOf': [ + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'AllofWithTheLastEmptySchema': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_two_empty_schemas.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_two_empty_schemas.py new file mode 100644 index 00000000000..d0013312256 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_two_empty_schemas.py @@ -0,0 +1,115 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class AllofWithTwoEmptySchemas( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 + allOf_0 = AnyTypeSchema + allOf_1 = AnyTypeSchema + return { + 'allOf': [ + allOf_0, + allOf_1, + ], + 'oneOf': [ + ], + 'anyOf': [ + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'AllofWithTwoEmptySchemas': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof.py new file mode 100644 index 00000000000..474cf1b9f27 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof.py @@ -0,0 +1,115 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class Anyof( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 + anyOf_0 = IntSchema + anyOf_1 = AnyTypeSchema + return { + 'allOf': [ + ], + 'oneOf': [ + ], + 'anyOf': [ + anyOf_0, + anyOf_1, + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'Anyof': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_complex_types.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_complex_types.py new file mode 100644 index 00000000000..675cfa90c4f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_complex_types.py @@ -0,0 +1,115 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class AnyofComplexTypes( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 + anyOf_0 = AnyTypeSchema + anyOf_1 = AnyTypeSchema + return { + 'allOf': [ + ], + 'oneOf': [ + ], + 'anyOf': [ + anyOf_0, + anyOf_1, + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'AnyofComplexTypes': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_base_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_base_schema.py new file mode 100644 index 00000000000..cb7935fd573 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_base_schema.py @@ -0,0 +1,114 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class AnyofWithBaseSchema( + ComposedBase, + StrSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 + anyOf_0 = AnyTypeSchema + anyOf_1 = AnyTypeSchema + return { + 'allOf': [ + ], + 'oneOf': [ + ], + 'anyOf': [ + anyOf_0, + anyOf_1, + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[str, ], + _configuration: typing.Optional[Configuration] = None, + ) -> 'AnyofWithBaseSchema': + return super().__new__( + cls, + *args, + _configuration=_configuration, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_boolean_schemas_all_false.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_boolean_schemas_all_false.py new file mode 100644 index 00000000000..139c02838e5 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_boolean_schemas_all_false.py @@ -0,0 +1,111 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class AnyofWithBooleanSchemasAllFalse( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 { + 'allOf': [ + ], + 'oneOf': [ + ], + 'anyOf': [ + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'AnyofWithBooleanSchemasAllFalse': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_boolean_schemas_all_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_boolean_schemas_all_true.py new file mode 100644 index 00000000000..f908bcea507 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_boolean_schemas_all_true.py @@ -0,0 +1,111 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class AnyofWithBooleanSchemasAllTrue( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 { + 'allOf': [ + ], + 'oneOf': [ + ], + 'anyOf': [ + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'AnyofWithBooleanSchemasAllTrue': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_boolean_schemas_some_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_boolean_schemas_some_true.py new file mode 100644 index 00000000000..f33528b1865 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_boolean_schemas_some_true.py @@ -0,0 +1,111 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class AnyofWithBooleanSchemasSomeTrue( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 { + 'allOf': [ + ], + 'oneOf': [ + ], + 'anyOf': [ + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'AnyofWithBooleanSchemasSomeTrue': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_one_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_one_empty_schema.py new file mode 100644 index 00000000000..57ff15839c1 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_one_empty_schema.py @@ -0,0 +1,115 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class AnyofWithOneEmptySchema( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 + anyOf_0 = NumberSchema + anyOf_1 = AnyTypeSchema + return { + 'allOf': [ + ], + 'oneOf': [ + ], + 'anyOf': [ + anyOf_0, + anyOf_1, + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'AnyofWithOneEmptySchema': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_allof_to_check_validation_semantics.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_allof_to_check_validation_semantics.py new file mode 100644 index 00000000000..611175f27f1 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_allof_to_check_validation_semantics.py @@ -0,0 +1,113 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class NestedAllofToCheckValidationSemantics( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 + allOf_0 = AnyTypeSchema + return { + 'allOf': [ + allOf_0, + ], + 'oneOf': [ + ], + 'anyOf': [ + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'NestedAllofToCheckValidationSemantics': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_anyof_to_check_validation_semantics.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_anyof_to_check_validation_semantics.py new file mode 100644 index 00000000000..99ba5f7f356 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_anyof_to_check_validation_semantics.py @@ -0,0 +1,113 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class NestedAnyofToCheckValidationSemantics( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 + anyOf_0 = AnyTypeSchema + return { + 'allOf': [ + ], + 'oneOf': [ + ], + 'anyOf': [ + anyOf_0, + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'NestedAnyofToCheckValidationSemantics': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py index b9d4ccb2508..da590fbb733 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py @@ -11,9 +11,33 @@ # import sys # sys.setrecursionlimit(n) +from unit_test_api.model.additionalproperties_allows_a_schema_which_should_validate import AdditionalpropertiesAllowsASchemaWhichShouldValidate +from unit_test_api.model.additionalproperties_are_allowed_by_default import AdditionalpropertiesAreAllowedByDefault +from unit_test_api.model.additionalproperties_can_exist_by_itself import AdditionalpropertiesCanExistByItself +from unit_test_api.model.additionalproperties_should_not_look_in_applicators import AdditionalpropertiesShouldNotLookInApplicators +from unit_test_api.model.allof import Allof +from unit_test_api.model.allof_combined_with_anyof_oneof import AllofCombinedWithAnyofOneof +from unit_test_api.model.allof_simple_types import AllofSimpleTypes +from unit_test_api.model.allof_with_base_schema import AllofWithBaseSchema +from unit_test_api.model.allof_with_boolean_schemas_all_false import AllofWithBooleanSchemasAllFalse +from unit_test_api.model.allof_with_boolean_schemas_all_true import AllofWithBooleanSchemasAllTrue +from unit_test_api.model.allof_with_boolean_schemas_some_false import AllofWithBooleanSchemasSomeFalse +from unit_test_api.model.allof_with_one_empty_schema import AllofWithOneEmptySchema +from unit_test_api.model.allof_with_the_first_empty_schema import AllofWithTheFirstEmptySchema +from unit_test_api.model.allof_with_the_last_empty_schema import AllofWithTheLastEmptySchema +from unit_test_api.model.allof_with_two_empty_schemas import AllofWithTwoEmptySchemas +from unit_test_api.model.anyof import Anyof +from unit_test_api.model.anyof_complex_types import AnyofComplexTypes +from unit_test_api.model.anyof_with_base_schema import AnyofWithBaseSchema +from unit_test_api.model.anyof_with_boolean_schemas_all_false import AnyofWithBooleanSchemasAllFalse +from unit_test_api.model.anyof_with_boolean_schemas_all_true import AnyofWithBooleanSchemasAllTrue +from unit_test_api.model.anyof_with_boolean_schemas_some_true import AnyofWithBooleanSchemasSomeTrue +from unit_test_api.model.anyof_with_one_empty_schema import AnyofWithOneEmptySchema from unit_test_api.model.array_type_matches_arrays import ArrayTypeMatchesArrays from unit_test_api.model.boolean_type_matches_booleans import BooleanTypeMatchesBooleans from unit_test_api.model.integer_type_matches_integers import IntegerTypeMatchesIntegers +from unit_test_api.model.nested_allof_to_check_validation_semantics import NestedAllofToCheckValidationSemantics +from unit_test_api.model.nested_anyof_to_check_validation_semantics import NestedAnyofToCheckValidationSemantics from unit_test_api.model.null_type_matches_only_the_null_object import NullTypeMatchesOnlyTheNullObject from unit_test_api.model.number_type_matches_numbers import NumberTypeMatchesNumbers from unit_test_api.model.string_type_matches_strings import StringTypeMatchesStrings -- GitLab From f3aad50c60f59de322c63811510dcadf1c95a8c9 Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Wed, 22 Jun 2022 00:19:01 -0700 Subject: [PATCH 06/43] Turns on allOf tests, some failing --- .../payload_renderer.handlebars | 9 +- .../python-experimental/model_test.handlebars | 12 +- .../3_0/unit_test_spec/spec_writer.py | 2 +- .../resources/3_0/unit_test_spec/type.yaml | 127 ------------------ .../.openapi-generator/FILES | 24 ---- .../python-experimental/README.md | 8 -- .../python-experimental/docs/Anyof.md | 9 -- .../docs/AnyofComplexTypes.md | 9 -- .../docs/AnyofWithBaseSchema.md | 8 -- .../docs/AnyofWithBooleanSchemasAllFalse.md | 9 -- .../docs/AnyofWithBooleanSchemasAllTrue.md | 9 -- .../docs/AnyofWithBooleanSchemasSomeTrue.md | 9 -- .../docs/AnyofWithOneEmptySchema.md | 9 -- .../NestedAnyofToCheckValidationSemantics.md | 9 -- ...s_allows_a_schema_which_should_validate.py | 27 ++-- ...tionalproperties_are_allowed_by_default.py | 9 +- ...dditionalproperties_can_exist_by_itself.py | 13 +- ...operties_should_not_look_in_applicators.py | 9 +- .../python-experimental/test/test_allof.py | 30 +++-- .../test_allof_combined_with_anyof_oneof.py | 30 ++--- .../test/test_allof_simple_types.py | 6 +- .../test/test_allof_with_base_schema.py | 42 +++--- ...st_allof_with_boolean_schemas_all_false.py | 5 +- ...est_allof_with_boolean_schemas_all_true.py | 3 +- ...t_allof_with_boolean_schemas_some_false.py | 5 +- .../test/test_allof_with_one_empty_schema.py | 2 +- .../test_allof_with_the_first_empty_schema.py | 7 +- .../test_allof_with_the_last_empty_schema.py | 7 +- .../test/test_allof_with_two_empty_schemas.py | 2 +- .../python-experimental/test/test_anyof.py | 44 ------ .../test/test_anyof_complex_types.py | 64 --------- .../test/test_anyof_with_base_schema.py | 40 ------ ...st_anyof_with_boolean_schemas_all_false.py | 29 ---- ...est_anyof_with_boolean_schemas_all_true.py | 28 ---- ...st_anyof_with_boolean_schemas_some_true.py | 28 ---- .../test/test_anyof_with_one_empty_schema.py | 33 ----- .../test/test_array_type_matches_arrays.py | 29 ++-- .../test_boolean_type_matches_booleans.py | 41 +++--- .../test_integer_type_matches_integers.py | 36 ++--- ...ted_allof_to_check_validation_semantics.py | 7 +- ...ted_anyof_to_check_validation_semantics.py | 34 ----- ..._null_type_matches_only_the_null_object.py | 43 +++--- .../test/test_number_type_matches_numbers.py | 34 ++--- .../test/test_string_type_matches_strings.py | 35 ++--- .../unit_test_api/model/anyof.py | 115 ---------------- .../model/anyof_complex_types.py | 115 ---------------- .../model/anyof_with_base_schema.py | 114 ---------------- .../anyof_with_boolean_schemas_all_false.py | 111 --------------- .../anyof_with_boolean_schemas_all_true.py | 111 --------------- .../anyof_with_boolean_schemas_some_true.py | 111 --------------- .../model/anyof_with_one_empty_schema.py | 115 ---------------- ...ted_anyof_to_check_validation_semantics.py | 113 ---------------- .../unit_test_api/models/__init__.py | 8 -- 53 files changed, 247 insertions(+), 1641 deletions(-) delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Anyof.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofComplexTypes.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithBaseSchema.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithBooleanSchemasAllFalse.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithBooleanSchemasAllTrue.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithBooleanSchemasSomeTrue.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithOneEmptySchema.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedAnyofToCheckValidationSemantics.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_complex_types.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_base_schema.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_boolean_schemas_all_false.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_boolean_schemas_all_true.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_boolean_schemas_some_true.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_one_empty_schema.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_anyof_to_check_validation_semantics.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_complex_types.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_base_schema.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_boolean_schemas_all_false.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_boolean_schemas_all_true.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_boolean_schemas_some_true.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_one_empty_schema.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_anyof_to_check_validation_semantics.py diff --git a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars index 3d4a485fd8e..1b5340b29f6 100644 --- a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars +++ b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars @@ -6,7 +6,7 @@ ] {{else}} {{#if isMap}} -{ +{{#not value.isEmpty}}**{{/not}}{ {{#each value}} "{{@key}}": {{#with this}} @@ -14,4 +14,9 @@ {{/with}} {{/each}} } -{{else}}{{#or isNumber isUnboundedInteger}}{{value}}{{/or}}{{#if isBoolean}}{{#if value}}True{{else}}False{{/if}}{{/if}}{{#if isNull}}None{{/if}}{{#if isString}}"{{value}}"{{/if}}{{/if}}{{/if}} \ No newline at end of file +{{else}}{{#or isNumber isUnboundedInteger}} +{{value}}{{/or}}{{#if isBoolean}}{{#if value}} +True{{else}} +False{{/if}}{{/if}}{{#if isNull}} +None{{/if}}{{#if isString}} +"{{value}}"{{/if}}{{/if}}{{/if}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python-experimental/model_test.handlebars b/modules/openapi-generator/src/main/resources/python-experimental/model_test.handlebars index c0ac05c852c..8313533a8b5 100644 --- a/modules/openapi-generator/src/main/resources/python-experimental/model_test.handlebars +++ b/modules/openapi-generator/src/main/resources/python-experimental/model_test.handlebars @@ -20,16 +20,14 @@ class Test{{classname}}(unittest.TestCase): {{#if valid}} {{classname}}( {{#with data}} - {{>model_templates/payload_renderer}} -{{/with}} -nl ) + {{>model_templates/payload_renderer}}{{/with}} + ) {{else}} - with self.assertRaises(({{packageName}}.ApiValueError, {{packageName}}.ApiTypeError)): + with self.assertRaises(({{packageName}}.ApiValueError, {{packageName}}.ApiTypeError, TypeError)): {{classname}}( {{#with data}} - {{>model_templates/payload_renderer}} -{{/with}} -nl ) + {{>model_templates/payload_renderer}}{{/with}} + ) {{/if}} {{/with}} diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index 2737de5b994..4fc48c6f0e4 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -109,7 +109,7 @@ JSON_SCHEMA_TEST_FILE_TO_FOLDERS = { 'additionalItems.json': (json_schema_test_draft,), 'additionalProperties.json': (json_schema_test_draft,), 'allOf.json': (json_schema_test_draft,), - 'anyOf.json': (json_schema_test_draft,), +# 'anyOf.json': (json_schema_test_draft,), 'boolean_schema.json': (json_schema_test_draft,), 'const.json': (json_schema_test_draft,), } diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml index 39101323df9..48ef4afa551 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml @@ -112,47 +112,6 @@ components: - multipleOf: 3 oneOf: - multipleOf: 5 - Anyof: - anyOf: - - type: integer - - minimum: 2 - AnyofWithBaseSchema: - type: string - anyOf: - - maxLength: 2 - - minLength: 4 - AnyofWithBooleanSchemasAllTrue: - anyOf: - - true - - true - AnyofWithBooleanSchemasSomeTrue: - anyOf: - - true - - false - AnyofWithBooleanSchemasAllFalse: - anyOf: - - false - - false - AnyofComplexTypes: - anyOf: - - properties: - bar: - type: integer - required: - - bar - - properties: - foo: - type: string - required: - - foo - AnyofWithOneEmptySchema: - anyOf: - - type: number - - {} - NestedAnyofToCheckValidationSemantics: - anyOf: - - anyOf: - - type: 'null' x-schema-test-examples: IntegerTypeMatchesIntegers: AnIntegerIsAnInteger: @@ -599,89 +558,3 @@ components: description: 'allOf: true, anyOf: true, oneOf: true' data: 30 valid: true - Anyof: - FirstAnyofValid: - description: first anyOf valid - data: 1 - valid: true - SecondAnyofValid: - description: second anyOf valid - data: 2.5 - valid: true - BothAnyofValid: - description: both anyOf valid - data: 3 - valid: true - NeitherAnyofValid: - description: neither anyOf valid - data: 1.5 - valid: false - AnyofWithBaseSchema: - MismatchBaseSchema: - description: mismatch base schema - data: 3 - valid: false - OneAnyofValid: - description: one anyOf valid - data: foobar - valid: true - BothAnyofInvalid: - description: both anyOf invalid - data: foo - valid: false - AnyofWithBooleanSchemasAllTrue: - AnyValueIsValid: - description: any value is valid - data: foo - valid: true - AnyofWithBooleanSchemasSomeTrue: - AnyValueIsValid: - description: any value is valid - data: foo - valid: true - AnyofWithBooleanSchemasAllFalse: - AnyValueIsInvalid: - description: any value is invalid - data: foo - valid: false - AnyofComplexTypes: - FirstAnyofValidComplex: - description: first anyOf valid (complex) - data: - bar: 2 - valid: true - SecondAnyofValidComplex: - description: second anyOf valid (complex) - data: - foo: baz - valid: true - BothAnyofValidComplex: - description: both anyOf valid (complex) - data: - foo: baz - bar: 2 - valid: true - NeitherAnyofValidComplex: - description: neither anyOf valid (complex) - data: - foo: 2 - bar: quux - valid: false - AnyofWithOneEmptySchema: - StringIsValid: - description: string is valid - data: foo - valid: true - NumberIsValid: - description: number is valid - data: 123 - valid: true - NestedAnyofToCheckValidationSemantics: - NullIsValid: - description: null is valid - data: null - valid: true - AnythingNonNullIsInvalid: - description: anything non-null is invalid - data: 123 - valid: false diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index d1913f0d0e4..4951241492f 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -17,18 +17,10 @@ docs/AllofWithOneEmptySchema.md docs/AllofWithTheFirstEmptySchema.md docs/AllofWithTheLastEmptySchema.md docs/AllofWithTwoEmptySchemas.md -docs/Anyof.md -docs/AnyofComplexTypes.md -docs/AnyofWithBaseSchema.md -docs/AnyofWithBooleanSchemasAllFalse.md -docs/AnyofWithBooleanSchemasAllTrue.md -docs/AnyofWithBooleanSchemasSomeTrue.md -docs/AnyofWithOneEmptySchema.md docs/ArrayTypeMatchesArrays.md docs/BooleanTypeMatchesBooleans.md docs/IntegerTypeMatchesIntegers.md docs/NestedAllofToCheckValidationSemantics.md -docs/NestedAnyofToCheckValidationSemantics.md docs/NullTypeMatchesOnlyTheNullObject.md docs/NumberTypeMatchesNumbers.md docs/StringTypeMatchesStrings.md @@ -53,18 +45,10 @@ test/test_allof_with_one_empty_schema.py test/test_allof_with_the_first_empty_schema.py test/test_allof_with_the_last_empty_schema.py test/test_allof_with_two_empty_schemas.py -test/test_anyof.py -test/test_anyof_complex_types.py -test/test_anyof_with_base_schema.py -test/test_anyof_with_boolean_schemas_all_false.py -test/test_anyof_with_boolean_schemas_all_true.py -test/test_anyof_with_boolean_schemas_some_true.py -test/test_anyof_with_one_empty_schema.py test/test_array_type_matches_arrays.py test/test_boolean_type_matches_booleans.py test/test_integer_type_matches_integers.py test/test_nested_allof_to_check_validation_semantics.py -test/test_nested_anyof_to_check_validation_semantics.py test/test_null_type_matches_only_the_null_object.py test/test_number_type_matches_numbers.py test/test_string_type_matches_strings.py @@ -91,18 +75,10 @@ unit_test_api/model/allof_with_one_empty_schema.py unit_test_api/model/allof_with_the_first_empty_schema.py unit_test_api/model/allof_with_the_last_empty_schema.py unit_test_api/model/allof_with_two_empty_schemas.py -unit_test_api/model/anyof.py -unit_test_api/model/anyof_complex_types.py -unit_test_api/model/anyof_with_base_schema.py -unit_test_api/model/anyof_with_boolean_schemas_all_false.py -unit_test_api/model/anyof_with_boolean_schemas_all_true.py -unit_test_api/model/anyof_with_boolean_schemas_some_true.py -unit_test_api/model/anyof_with_one_empty_schema.py unit_test_api/model/array_type_matches_arrays.py unit_test_api/model/boolean_type_matches_booleans.py unit_test_api/model/integer_type_matches_integers.py unit_test_api/model/nested_allof_to_check_validation_semantics.py -unit_test_api/model/nested_anyof_to_check_validation_semantics.py unit_test_api/model/null_type_matches_only_the_null_object.py unit_test_api/model/number_type_matches_numbers.py unit_test_api/model/string_type_matches_strings.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md index 28a9b93fd35..88b77743fa5 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md @@ -77,18 +77,10 @@ Class | Method | HTTP request | Description - [AllofWithTheFirstEmptySchema](docs/AllofWithTheFirstEmptySchema.md) - [AllofWithTheLastEmptySchema](docs/AllofWithTheLastEmptySchema.md) - [AllofWithTwoEmptySchemas](docs/AllofWithTwoEmptySchemas.md) - - [Anyof](docs/Anyof.md) - - [AnyofComplexTypes](docs/AnyofComplexTypes.md) - - [AnyofWithBaseSchema](docs/AnyofWithBaseSchema.md) - - [AnyofWithBooleanSchemasAllFalse](docs/AnyofWithBooleanSchemasAllFalse.md) - - [AnyofWithBooleanSchemasAllTrue](docs/AnyofWithBooleanSchemasAllTrue.md) - - [AnyofWithBooleanSchemasSomeTrue](docs/AnyofWithBooleanSchemasSomeTrue.md) - - [AnyofWithOneEmptySchema](docs/AnyofWithOneEmptySchema.md) - [ArrayTypeMatchesArrays](docs/ArrayTypeMatchesArrays.md) - [BooleanTypeMatchesBooleans](docs/BooleanTypeMatchesBooleans.md) - [IntegerTypeMatchesIntegers](docs/IntegerTypeMatchesIntegers.md) - [NestedAllofToCheckValidationSemantics](docs/NestedAllofToCheckValidationSemantics.md) - - [NestedAnyofToCheckValidationSemantics](docs/NestedAnyofToCheckValidationSemantics.md) - [NullTypeMatchesOnlyTheNullObject](docs/NullTypeMatchesOnlyTheNullObject.md) - [NumberTypeMatchesNumbers](docs/NumberTypeMatchesNumbers.md) - [StringTypeMatchesStrings](docs/StringTypeMatchesStrings.md) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Anyof.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Anyof.md deleted file mode 100644 index 2a5107e980c..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Anyof.md +++ /dev/null @@ -1,9 +0,0 @@ -# Anyof - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofComplexTypes.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofComplexTypes.md deleted file mode 100644 index a6a3dcfa534..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofComplexTypes.md +++ /dev/null @@ -1,9 +0,0 @@ -# AnyofComplexTypes - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithBaseSchema.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithBaseSchema.md deleted file mode 100644 index cf00c6413dc..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithBaseSchema.md +++ /dev/null @@ -1,8 +0,0 @@ -# AnyofWithBaseSchema - -Type | Description | Notes -------------- | ------------- | ------------- -**str** | | - -[[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/3_0_3_unit_test/python-experimental/docs/AnyofWithBooleanSchemasAllFalse.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithBooleanSchemasAllFalse.md deleted file mode 100644 index 7f04439fae5..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithBooleanSchemasAllFalse.md +++ /dev/null @@ -1,9 +0,0 @@ -# AnyofWithBooleanSchemasAllFalse - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithBooleanSchemasAllTrue.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithBooleanSchemasAllTrue.md deleted file mode 100644 index 3a8976b2717..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithBooleanSchemasAllTrue.md +++ /dev/null @@ -1,9 +0,0 @@ -# AnyofWithBooleanSchemasAllTrue - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithBooleanSchemasSomeTrue.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithBooleanSchemasSomeTrue.md deleted file mode 100644 index 65ee138224d..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithBooleanSchemasSomeTrue.md +++ /dev/null @@ -1,9 +0,0 @@ -# AnyofWithBooleanSchemasSomeTrue - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithOneEmptySchema.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithOneEmptySchema.md deleted file mode 100644 index 2d3666e55b2..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AnyofWithOneEmptySchema.md +++ /dev/null @@ -1,9 +0,0 @@ -# AnyofWithOneEmptySchema - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedAnyofToCheckValidationSemantics.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedAnyofToCheckValidationSemantics.md deleted file mode 100644 index d95966736d7..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedAnyofToCheckValidationSemantics.md +++ /dev/null @@ -1,9 +0,0 @@ -# NestedAnyofToCheckValidationSemantics - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py index 90ea79b75d3..3efa9239a1b 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py @@ -21,38 +21,39 @@ class TestAdditionalpropertiesAllowsASchemaWhichShouldValidate(unittest.TestCase def test_no_additional_properties_is_valid_passes(self): # no additional properties is valid AdditionalpropertiesAllowsASchemaWhichShouldValidate( - { + **{ "foo": - 1, + 1, } - nl ) + ) def test_an_additional_invalid_property_is_invalid_fails(self): # an additional invalid property is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): AdditionalpropertiesAllowsASchemaWhichShouldValidate( - { + **{ "foo": - 1, + 1, "bar": - 2, + 2, "quux": - 12, + 12, } - nl ) + ) def test_an_additional_valid_property_is_valid_passes(self): # an additional valid property is valid AdditionalpropertiesAllowsASchemaWhichShouldValidate( - { + **{ "foo": - 1, + 1, "bar": - 2, + 2, "quux": + True, } - nl ) + ) if __name__ == '__main__': diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py index f96fb233305..6a87df188f9 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py @@ -21,15 +21,16 @@ class TestAdditionalpropertiesAreAllowedByDefault(unittest.TestCase): def test_additional_properties_are_allowed_passes(self): # additional properties are allowed AdditionalpropertiesAreAllowedByDefault( - { + **{ "foo": - 1, + 1, "bar": - 2, + 2, "quux": + True, } - nl ) + ) if __name__ == '__main__': diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py index 99a238c6471..968b9449901 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py @@ -20,22 +20,23 @@ class TestAdditionalpropertiesCanExistByItself(unittest.TestCase): def test_an_additional_invalid_property_is_invalid_fails(self): # an additional invalid property is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): AdditionalpropertiesCanExistByItself( - { + **{ "foo": - 1, + 1, } - nl ) + ) def test_an_additional_valid_property_is_valid_passes(self): # an additional valid property is valid AdditionalpropertiesCanExistByItself( - { + **{ "foo": + True, } - nl ) + ) if __name__ == '__main__': diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py index 3757ec25376..e46111271d3 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py @@ -20,15 +20,16 @@ class TestAdditionalpropertiesShouldNotLookInApplicators(unittest.TestCase): def test_properties_defined_in_allof_are_not_examined_fails(self): # properties defined in allOf are not examined - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): AdditionalpropertiesShouldNotLookInApplicators( - { + **{ "foo": - 1, + 1, "bar": + True, } - nl ) + ) if __name__ == '__main__': diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof.py index 8229279fdcb..48891550f6a 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof.py @@ -21,45 +21,49 @@ class TestAllof(unittest.TestCase): def test_allof_passes(self): # allOf Allof( - { + **{ "foo": + "baz", "bar": - 2, + 2, } - nl ) + ) def test_mismatch_first_fails(self): # mismatch first - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): Allof( - { + **{ "bar": - 2, + 2, } - nl ) + ) def test_mismatch_second_fails(self): # mismatch second - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): Allof( - { + **{ "foo": + "baz", } - nl ) + ) def test_wrong_type_fails(self): # wrong type - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): Allof( - { + **{ "foo": + "baz", "bar": + "quux", } - nl ) + ) if __name__ == '__main__': diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_combined_with_anyof_oneof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_combined_with_anyof_oneof.py index 30b20cfc508..9da90d3694e 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_combined_with_anyof_oneof.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_combined_with_anyof_oneof.py @@ -20,50 +20,50 @@ class TestAllofCombinedWithAnyofOneof(unittest.TestCase): def test_allof_true_anyof_false_oneof_false_fails(self): # allOf: true, anyOf: false, oneOf: false - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): AllofCombinedWithAnyofOneof( -2nl ) + 2 ) def test_allof_false_anyof_false_oneof_true_fails(self): # allOf: false, anyOf: false, oneOf: true - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): AllofCombinedWithAnyofOneof( -5nl ) + 5 ) def test_allof_false_anyof_true_oneof_true_fails(self): # allOf: false, anyOf: true, oneOf: true - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): AllofCombinedWithAnyofOneof( -15nl ) + 15 ) def test_allof_true_anyof_true_oneof_false_fails(self): # allOf: true, anyOf: true, oneOf: false - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): AllofCombinedWithAnyofOneof( -6nl ) + 6 ) def test_allof_true_anyof_true_oneof_true_passes(self): # allOf: true, anyOf: true, oneOf: true AllofCombinedWithAnyofOneof( -30nl ) + 30 ) def test_allof_true_anyof_false_oneof_true_fails(self): # allOf: true, anyOf: false, oneOf: true - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): AllofCombinedWithAnyofOneof( -10nl ) + 10 ) def test_allof_false_anyof_true_oneof_false_fails(self): # allOf: false, anyOf: true, oneOf: false - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): AllofCombinedWithAnyofOneof( -3nl ) + 3 ) def test_allof_false_anyof_false_oneof_false_fails(self): # allOf: false, anyOf: false, oneOf: false - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): AllofCombinedWithAnyofOneof( -1nl ) + 1 ) if __name__ == '__main__': diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_simple_types.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_simple_types.py index 0a67da1123a..1c78fbc8df9 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_simple_types.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_simple_types.py @@ -21,13 +21,13 @@ class TestAllofSimpleTypes(unittest.TestCase): def test_valid_passes(self): # valid AllofSimpleTypes( -25nl ) + 25 ) def test_mismatch_one_fails(self): # mismatch one - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): AllofSimpleTypes( -35nl ) + 35 ) if __name__ == '__main__': diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_base_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_base_schema.py index 097aa1515a5..514d5a7a75f 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_base_schema.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_base_schema.py @@ -21,61 +21,67 @@ class TestAllofWithBaseSchema(unittest.TestCase): def test_valid_passes(self): # valid AllofWithBaseSchema( - { + **{ "foo": + "quux", "bar": - 2, + 2, "baz": + None, } - nl ) + ) def test_mismatch_first_allof_fails(self): # mismatch first allOf - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): AllofWithBaseSchema( - { + **{ "bar": - 2, + 2, "baz": + None, } - nl ) + ) def test_mismatch_base_schema_fails(self): # mismatch base schema - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): AllofWithBaseSchema( - { + **{ "foo": + "quux", "baz": + None, } - nl ) + ) def test_mismatch_both_fails(self): # mismatch both - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): AllofWithBaseSchema( - { + **{ "bar": - 2, + 2, } - nl ) + ) def test_mismatch_second_allof_fails(self): # mismatch second allOf - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): AllofWithBaseSchema( - { + **{ "foo": + "quux", "bar": - 2, + 2, } - nl ) + ) if __name__ == '__main__': diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_all_false.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_all_false.py index a320063b5e7..f1b999b0c43 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_all_false.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_all_false.py @@ -20,9 +20,10 @@ class TestAllofWithBooleanSchemasAllFalse(unittest.TestCase): def test_any_value_is_invalid_fails(self): # any value is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): AllofWithBooleanSchemasAllFalse( -"foo"nl ) + + "foo" ) if __name__ == '__main__': diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_all_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_all_true.py index 1098055dfe7..f3e0792dcae 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_all_true.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_all_true.py @@ -21,7 +21,8 @@ class TestAllofWithBooleanSchemasAllTrue(unittest.TestCase): def test_any_value_is_valid_passes(self): # any value is valid AllofWithBooleanSchemasAllTrue( -"foo"nl ) + + "foo" ) if __name__ == '__main__': diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_some_false.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_some_false.py index 592f532e3d9..6c6f5d9d63d 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_some_false.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_some_false.py @@ -20,9 +20,10 @@ class TestAllofWithBooleanSchemasSomeFalse(unittest.TestCase): def test_any_value_is_invalid_fails(self): # any value is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): AllofWithBooleanSchemasSomeFalse( -"foo"nl ) + + "foo" ) if __name__ == '__main__': diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_one_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_one_empty_schema.py index b93716dff74..180ad530185 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_one_empty_schema.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_one_empty_schema.py @@ -21,7 +21,7 @@ class TestAllofWithOneEmptySchema(unittest.TestCase): def test_any_data_is_valid_passes(self): # any data is valid AllofWithOneEmptySchema( -1nl ) + 1 ) if __name__ == '__main__': diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_first_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_first_empty_schema.py index 05bcd574ccc..0637322964f 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_first_empty_schema.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_first_empty_schema.py @@ -20,14 +20,15 @@ class TestAllofWithTheFirstEmptySchema(unittest.TestCase): def test_string_is_invalid_fails(self): # string is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): AllofWithTheFirstEmptySchema( -"foo"nl ) + + "foo" ) def test_number_is_valid_passes(self): # number is valid AllofWithTheFirstEmptySchema( -1nl ) + 1 ) if __name__ == '__main__': diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_last_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_last_empty_schema.py index 6a142d4412f..4742f9e280f 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_last_empty_schema.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_last_empty_schema.py @@ -20,14 +20,15 @@ class TestAllofWithTheLastEmptySchema(unittest.TestCase): def test_string_is_invalid_fails(self): # string is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): AllofWithTheLastEmptySchema( -"foo"nl ) + + "foo" ) def test_number_is_valid_passes(self): # number is valid AllofWithTheLastEmptySchema( -1nl ) + 1 ) if __name__ == '__main__': diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_two_empty_schemas.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_two_empty_schemas.py index db0b444cf6f..a8f32676a2d 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_two_empty_schemas.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_two_empty_schemas.py @@ -21,7 +21,7 @@ class TestAllofWithTwoEmptySchemas(unittest.TestCase): def test_any_data_is_valid_passes(self): # any data is valid AllofWithTwoEmptySchemas( -1nl ) + 1 ) if __name__ == '__main__': diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof.py deleted file mode 100644 index 17521a0b1f3..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof.py +++ /dev/null @@ -1,44 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.anyof import Anyof - - -class TestAnyof(unittest.TestCase): - """Anyof unit test stubs""" - - def test_second_anyof_valid_passes(self): - # second anyOf valid - Anyof( -2.5nl ) - - def test_neither_anyof_valid_fails(self): - # neither anyOf valid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): - Anyof( -1.5nl ) - - def test_both_anyof_valid_passes(self): - # both anyOf valid - Anyof( -3nl ) - - def test_first_anyof_valid_passes(self): - # first anyOf valid - Anyof( -1nl ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_complex_types.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_complex_types.py deleted file mode 100644 index 92a4d35229d..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_complex_types.py +++ /dev/null @@ -1,64 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.anyof_complex_types import AnyofComplexTypes - - -class TestAnyofComplexTypes(unittest.TestCase): - """AnyofComplexTypes unit test stubs""" - - def test_second_anyof_valid_complex_passes(self): - # second anyOf valid (complex) - AnyofComplexTypes( - { - "foo": - "baz", - } - nl ) - - def test_neither_anyof_valid_complex_fails(self): - # neither anyOf valid (complex) - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): - AnyofComplexTypes( - { - "foo": - 2, - "bar": - "quux", - } - nl ) - - def test_both_anyof_valid_complex_passes(self): - # both anyOf valid (complex) - AnyofComplexTypes( - { - "foo": - "baz", - "bar": - 2, - } - nl ) - - def test_first_anyof_valid_complex_passes(self): - # first anyOf valid (complex) - AnyofComplexTypes( - { - "bar": - 2, - } - nl ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_base_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_base_schema.py deleted file mode 100644 index b9fe9e2f8c3..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_base_schema.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.anyof_with_base_schema import AnyofWithBaseSchema - - -class TestAnyofWithBaseSchema(unittest.TestCase): - """AnyofWithBaseSchema unit test stubs""" - - def test_one_anyof_valid_passes(self): - # one anyOf valid - AnyofWithBaseSchema( -"foobar"nl ) - - def test_both_anyof_invalid_fails(self): - # both anyOf invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): - AnyofWithBaseSchema( -"foo"nl ) - - def test_mismatch_base_schema_fails(self): - # mismatch base schema - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): - AnyofWithBaseSchema( -3nl ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_boolean_schemas_all_false.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_boolean_schemas_all_false.py deleted file mode 100644 index 0bfcc59d019..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_boolean_schemas_all_false.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.anyof_with_boolean_schemas_all_false import AnyofWithBooleanSchemasAllFalse - - -class TestAnyofWithBooleanSchemasAllFalse(unittest.TestCase): - """AnyofWithBooleanSchemasAllFalse unit test stubs""" - - def test_any_value_is_invalid_fails(self): - # any value is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): - AnyofWithBooleanSchemasAllFalse( -"foo"nl ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_boolean_schemas_all_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_boolean_schemas_all_true.py deleted file mode 100644 index 7928dfcac6e..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_boolean_schemas_all_true.py +++ /dev/null @@ -1,28 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.anyof_with_boolean_schemas_all_true import AnyofWithBooleanSchemasAllTrue - - -class TestAnyofWithBooleanSchemasAllTrue(unittest.TestCase): - """AnyofWithBooleanSchemasAllTrue unit test stubs""" - - def test_any_value_is_valid_passes(self): - # any value is valid - AnyofWithBooleanSchemasAllTrue( -"foo"nl ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_boolean_schemas_some_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_boolean_schemas_some_true.py deleted file mode 100644 index a1e1ac43c8d..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_boolean_schemas_some_true.py +++ /dev/null @@ -1,28 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.anyof_with_boolean_schemas_some_true import AnyofWithBooleanSchemasSomeTrue - - -class TestAnyofWithBooleanSchemasSomeTrue(unittest.TestCase): - """AnyofWithBooleanSchemasSomeTrue unit test stubs""" - - def test_any_value_is_valid_passes(self): - # any value is valid - AnyofWithBooleanSchemasSomeTrue( -"foo"nl ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_one_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_one_empty_schema.py deleted file mode 100644 index 082d9952e52..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_anyof_with_one_empty_schema.py +++ /dev/null @@ -1,33 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.anyof_with_one_empty_schema import AnyofWithOneEmptySchema - - -class TestAnyofWithOneEmptySchema(unittest.TestCase): - """AnyofWithOneEmptySchema unit test stubs""" - - def test_string_is_valid_passes(self): - # string is valid - AnyofWithOneEmptySchema( -"foo"nl ) - - def test_number_is_valid_passes(self): - # number is valid - AnyofWithOneEmptySchema( -123nl ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py index 7d25daad70b..695efa692be 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py @@ -20,48 +20,51 @@ class TestArrayTypeMatchesArrays(unittest.TestCase): def test_a_float_is_not_an_array_fails(self): # a float is not an array - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): ArrayTypeMatchesArrays( -1.1nl ) + 1.1 ) def test_a_boolean_is_not_an_array_fails(self): # a boolean is not an array - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): ArrayTypeMatchesArrays( -Truenl ) + + True ) def test_null_is_not_an_array_fails(self): # null is not an array - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): ArrayTypeMatchesArrays( -Nonenl ) + + None ) def test_an_object_is_not_an_array_fails(self): # an object is not an array - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): ArrayTypeMatchesArrays( { } - nl ) + ) def test_a_string_is_not_an_array_fails(self): # a string is not an array - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): ArrayTypeMatchesArrays( -"foo"nl ) + + "foo" ) def test_an_array_is_an_array_passes(self): # an array is an array ArrayTypeMatchesArrays( [ ] -nl ) + ) def test_an_integer_is_not_an_array_fails(self): # an integer is not an array - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): ArrayTypeMatchesArrays( -1nl ) + 1 ) if __name__ == '__main__': diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py index 68a2d7f5437..3ce46c5e25b 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py @@ -20,65 +20,70 @@ class TestBooleanTypeMatchesBooleans(unittest.TestCase): def test_an_empty_string_is_not_a_boolean_fails(self): # an empty string is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): BooleanTypeMatchesBooleans( -""nl ) + + "" ) def test_a_float_is_not_a_boolean_fails(self): # a float is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): BooleanTypeMatchesBooleans( -1.1nl ) + 1.1 ) def test_null_is_not_a_boolean_fails(self): # null is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): BooleanTypeMatchesBooleans( -Nonenl ) + + None ) def test_zero_is_not_a_boolean_fails(self): # zero is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): BooleanTypeMatchesBooleans( -0nl ) + 0 ) def test_an_array_is_not_a_boolean_fails(self): # an array is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): BooleanTypeMatchesBooleans( [ ] -nl ) + ) def test_a_string_is_not_a_boolean_fails(self): # a string is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): BooleanTypeMatchesBooleans( -"foo"nl ) + + "foo" ) def test_false_is_a_boolean_passes(self): # false is a boolean BooleanTypeMatchesBooleans( -Falsenl ) + + False ) def test_an_integer_is_not_a_boolean_fails(self): # an integer is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): BooleanTypeMatchesBooleans( -1nl ) + 1 ) def test_true_is_a_boolean_passes(self): # true is a boolean BooleanTypeMatchesBooleans( -Truenl ) + + True ) def test_an_object_is_not_a_boolean_fails(self): # an object is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): BooleanTypeMatchesBooleans( { } - nl ) + ) if __name__ == '__main__': diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py index bc7c56ea96c..4478fe8a01f 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py @@ -20,59 +20,63 @@ class TestIntegerTypeMatchesIntegers(unittest.TestCase): def test_an_object_is_not_an_integer_fails(self): # an object is not an integer - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): IntegerTypeMatchesIntegers( { } - nl ) + ) def test_a_string_is_not_an_integer_fails(self): # a string is not an integer - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): IntegerTypeMatchesIntegers( -"foo"nl ) + + "foo" ) def test_null_is_not_an_integer_fails(self): # null is not an integer - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): IntegerTypeMatchesIntegers( -Nonenl ) + + None ) def test_a_float_with_zero_fractional_part_is_an_integer_passes(self): # a float with zero fractional part is an integer IntegerTypeMatchesIntegers( -1.0nl ) + 1.0 ) def test_a_float_is_not_an_integer_fails(self): # a float is not an integer - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): IntegerTypeMatchesIntegers( -1.1nl ) + 1.1 ) def test_a_boolean_is_not_an_integer_fails(self): # a boolean is not an integer - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): IntegerTypeMatchesIntegers( -Truenl ) + + True ) def test_an_integer_is_an_integer_passes(self): # an integer is an integer IntegerTypeMatchesIntegers( -1nl ) + 1 ) def test_a_string_is_still_not_an_integer_even_if_it_looks_like_one_fails(self): # a string is still not an integer, even if it looks like one - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): IntegerTypeMatchesIntegers( -"1"nl ) + + "1" ) def test_an_array_is_not_an_integer_fails(self): # an array is not an integer - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): IntegerTypeMatchesIntegers( [ ] -nl ) + ) if __name__ == '__main__': diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_allof_to_check_validation_semantics.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_allof_to_check_validation_semantics.py index 4d01667d8c0..771249ca4d6 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_allof_to_check_validation_semantics.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_allof_to_check_validation_semantics.py @@ -20,14 +20,15 @@ class TestNestedAllofToCheckValidationSemantics(unittest.TestCase): def test_anything_non_null_is_invalid_fails(self): # anything non-null is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): NestedAllofToCheckValidationSemantics( -123nl ) + 123 ) def test_null_is_valid_passes(self): # null is valid NestedAllofToCheckValidationSemantics( -Nonenl ) + + None ) if __name__ == '__main__': diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_anyof_to_check_validation_semantics.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_anyof_to_check_validation_semantics.py deleted file mode 100644 index c6f47309c3e..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_anyof_to_check_validation_semantics.py +++ /dev/null @@ -1,34 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.nested_anyof_to_check_validation_semantics import NestedAnyofToCheckValidationSemantics - - -class TestNestedAnyofToCheckValidationSemantics(unittest.TestCase): - """NestedAnyofToCheckValidationSemantics unit test stubs""" - - def test_anything_non_null_is_invalid_fails(self): - # anything non-null is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): - NestedAnyofToCheckValidationSemantics( -123nl ) - - def test_null_is_valid_passes(self): - # null is valid - NestedAnyofToCheckValidationSemantics( -Nonenl ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py index dd52cc566a3..3db8e2c3c56 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py @@ -20,66 +20,71 @@ class TestNullTypeMatchesOnlyTheNullObject(unittest.TestCase): def test_a_float_is_not_null_fails(self): # a float is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): NullTypeMatchesOnlyTheNullObject( -1.1nl ) + 1.1 ) def test_an_object_is_not_null_fails(self): # an object is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): NullTypeMatchesOnlyTheNullObject( { } - nl ) + ) def test_false_is_not_null_fails(self): # false is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): NullTypeMatchesOnlyTheNullObject( -Falsenl ) + + False ) def test_an_integer_is_not_null_fails(self): # an integer is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): NullTypeMatchesOnlyTheNullObject( -1nl ) + 1 ) def test_true_is_not_null_fails(self): # true is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): NullTypeMatchesOnlyTheNullObject( -Truenl ) + + True ) def test_zero_is_not_null_fails(self): # zero is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): NullTypeMatchesOnlyTheNullObject( -0nl ) + 0 ) def test_an_empty_string_is_not_null_fails(self): # an empty string is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): NullTypeMatchesOnlyTheNullObject( -""nl ) + + "" ) def test_null_is_null_passes(self): # null is null NullTypeMatchesOnlyTheNullObject( -Nonenl ) + + None ) def test_an_array_is_not_null_fails(self): # an array is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): NullTypeMatchesOnlyTheNullObject( [ ] -nl ) + ) def test_a_string_is_not_null_fails(self): # a string is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): NullTypeMatchesOnlyTheNullObject( -"foo"nl ) + + "foo" ) if __name__ == '__main__': diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py index cd1b1b8b7d6..8c5af6e240f 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py @@ -20,58 +20,62 @@ class TestNumberTypeMatchesNumbers(unittest.TestCase): def test_an_array_is_not_a_number_fails(self): # an array is not a number - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): NumberTypeMatchesNumbers( [ ] -nl ) + ) def test_null_is_not_a_number_fails(self): # null is not a number - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): NumberTypeMatchesNumbers( -Nonenl ) + + None ) def test_an_object_is_not_a_number_fails(self): # an object is not a number - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): NumberTypeMatchesNumbers( { } - nl ) + ) def test_a_boolean_is_not_a_number_fails(self): # a boolean is not a number - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): NumberTypeMatchesNumbers( -Truenl ) + + True ) def test_a_float_is_a_number_passes(self): # a float is a number NumberTypeMatchesNumbers( -1.1nl ) + 1.1 ) def test_a_string_is_still_not_a_number_even_if_it_looks_like_one_fails(self): # a string is still not a number, even if it looks like one - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): NumberTypeMatchesNumbers( -"1"nl ) + + "1" ) def test_a_string_is_not_a_number_fails(self): # a string is not a number - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): NumberTypeMatchesNumbers( -"foo"nl ) + + "foo" ) def test_an_integer_is_a_number_passes(self): # an integer is a number NumberTypeMatchesNumbers( -1nl ) + 1 ) def test_a_float_with_zero_fractional_part_is_a_number_and_an_integer_passes(self): # a float with zero fractional part is a number (and an integer) NumberTypeMatchesNumbers( -1.0nl ) + 1.0 ) if __name__ == '__main__': diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py index 9a84dfae947..6b2b76e2b8a 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py @@ -20,58 +20,63 @@ class TestStringTypeMatchesStrings(unittest.TestCase): def test_1_is_not_a_string_fails(self): # 1 is not a string - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): StringTypeMatchesStrings( -1nl ) + 1 ) def test_a_string_is_still_a_string_even_if_it_looks_like_a_number_passes(self): # a string is still a string, even if it looks like a number StringTypeMatchesStrings( -"1"nl ) + + "1" ) def test_an_empty_string_is_still_a_string_passes(self): # an empty string is still a string StringTypeMatchesStrings( -""nl ) + + "" ) def test_a_float_is_not_a_string_fails(self): # a float is not a string - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): StringTypeMatchesStrings( -1.1nl ) + 1.1 ) def test_an_object_is_not_a_string_fails(self): # an object is not a string - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): StringTypeMatchesStrings( { } - nl ) + ) def test_an_array_is_not_a_string_fails(self): # an array is not a string - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): StringTypeMatchesStrings( [ ] -nl ) + ) def test_a_boolean_is_not_a_string_fails(self): # a boolean is not a string - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): StringTypeMatchesStrings( -Truenl ) + + True ) def test_null_is_not_a_string_fails(self): # null is not a string - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): StringTypeMatchesStrings( -Nonenl ) + + None ) def test_a_string_is_a_string_passes(self): # a string is a string StringTypeMatchesStrings( -"foo"nl ) + + "foo" ) if __name__ == '__main__': diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof.py deleted file mode 100644 index 474cf1b9f27..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof.py +++ /dev/null @@ -1,115 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class Anyof( - ComposedSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 - anyOf_0 = IntSchema - anyOf_1 = AnyTypeSchema - return { - 'allOf': [ - ], - 'oneOf': [ - ], - 'anyOf': [ - anyOf_0, - anyOf_1, - ], - 'not': - None - } - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'Anyof': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_complex_types.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_complex_types.py deleted file mode 100644 index 675cfa90c4f..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_complex_types.py +++ /dev/null @@ -1,115 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class AnyofComplexTypes( - ComposedSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 - anyOf_0 = AnyTypeSchema - anyOf_1 = AnyTypeSchema - return { - 'allOf': [ - ], - 'oneOf': [ - ], - 'anyOf': [ - anyOf_0, - anyOf_1, - ], - 'not': - None - } - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'AnyofComplexTypes': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_base_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_base_schema.py deleted file mode 100644 index cb7935fd573..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_base_schema.py +++ /dev/null @@ -1,114 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class AnyofWithBaseSchema( - ComposedBase, - StrSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 - anyOf_0 = AnyTypeSchema - anyOf_1 = AnyTypeSchema - return { - 'allOf': [ - ], - 'oneOf': [ - ], - 'anyOf': [ - anyOf_0, - anyOf_1, - ], - 'not': - None - } - - def __new__( - cls, - *args: typing.Union[str, ], - _configuration: typing.Optional[Configuration] = None, - ) -> 'AnyofWithBaseSchema': - return super().__new__( - cls, - *args, - _configuration=_configuration, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_boolean_schemas_all_false.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_boolean_schemas_all_false.py deleted file mode 100644 index 139c02838e5..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_boolean_schemas_all_false.py +++ /dev/null @@ -1,111 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class AnyofWithBooleanSchemasAllFalse( - ComposedSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 { - 'allOf': [ - ], - 'oneOf': [ - ], - 'anyOf': [ - ], - 'not': - None - } - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'AnyofWithBooleanSchemasAllFalse': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_boolean_schemas_all_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_boolean_schemas_all_true.py deleted file mode 100644 index f908bcea507..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_boolean_schemas_all_true.py +++ /dev/null @@ -1,111 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class AnyofWithBooleanSchemasAllTrue( - ComposedSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 { - 'allOf': [ - ], - 'oneOf': [ - ], - 'anyOf': [ - ], - 'not': - None - } - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'AnyofWithBooleanSchemasAllTrue': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_boolean_schemas_some_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_boolean_schemas_some_true.py deleted file mode 100644 index f33528b1865..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_boolean_schemas_some_true.py +++ /dev/null @@ -1,111 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class AnyofWithBooleanSchemasSomeTrue( - ComposedSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 { - 'allOf': [ - ], - 'oneOf': [ - ], - 'anyOf': [ - ], - 'not': - None - } - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'AnyofWithBooleanSchemasSomeTrue': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_one_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_one_empty_schema.py deleted file mode 100644 index 57ff15839c1..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/anyof_with_one_empty_schema.py +++ /dev/null @@ -1,115 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class AnyofWithOneEmptySchema( - ComposedSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 - anyOf_0 = NumberSchema - anyOf_1 = AnyTypeSchema - return { - 'allOf': [ - ], - 'oneOf': [ - ], - 'anyOf': [ - anyOf_0, - anyOf_1, - ], - 'not': - None - } - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'AnyofWithOneEmptySchema': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_anyof_to_check_validation_semantics.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_anyof_to_check_validation_semantics.py deleted file mode 100644 index 99ba5f7f356..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_anyof_to_check_validation_semantics.py +++ /dev/null @@ -1,113 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class NestedAnyofToCheckValidationSemantics( - ComposedSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 - anyOf_0 = AnyTypeSchema - return { - 'allOf': [ - ], - 'oneOf': [ - ], - 'anyOf': [ - anyOf_0, - ], - 'not': - None - } - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'NestedAnyofToCheckValidationSemantics': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py index da590fbb733..2976cccbc26 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py @@ -26,18 +26,10 @@ from unit_test_api.model.allof_with_one_empty_schema import AllofWithOneEmptySch from unit_test_api.model.allof_with_the_first_empty_schema import AllofWithTheFirstEmptySchema from unit_test_api.model.allof_with_the_last_empty_schema import AllofWithTheLastEmptySchema from unit_test_api.model.allof_with_two_empty_schemas import AllofWithTwoEmptySchemas -from unit_test_api.model.anyof import Anyof -from unit_test_api.model.anyof_complex_types import AnyofComplexTypes -from unit_test_api.model.anyof_with_base_schema import AnyofWithBaseSchema -from unit_test_api.model.anyof_with_boolean_schemas_all_false import AnyofWithBooleanSchemasAllFalse -from unit_test_api.model.anyof_with_boolean_schemas_all_true import AnyofWithBooleanSchemasAllTrue -from unit_test_api.model.anyof_with_boolean_schemas_some_true import AnyofWithBooleanSchemasSomeTrue -from unit_test_api.model.anyof_with_one_empty_schema import AnyofWithOneEmptySchema from unit_test_api.model.array_type_matches_arrays import ArrayTypeMatchesArrays from unit_test_api.model.boolean_type_matches_booleans import BooleanTypeMatchesBooleans from unit_test_api.model.integer_type_matches_integers import IntegerTypeMatchesIntegers from unit_test_api.model.nested_allof_to_check_validation_semantics import NestedAllofToCheckValidationSemantics -from unit_test_api.model.nested_anyof_to_check_validation_semantics import NestedAnyofToCheckValidationSemantics from unit_test_api.model.null_type_matches_only_the_null_object import NullTypeMatchesOnlyTheNullObject from unit_test_api.model.number_type_matches_numbers import NumberTypeMatchesNumbers from unit_test_api.model.string_type_matches_strings import StringTypeMatchesStrings -- GitLab From 64c3968927992521c51f60ae0561f5fcddc72f7d Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Wed, 22 Jun 2022 22:19:33 -0700 Subject: [PATCH 07/43] Adds more generated components and tests --- .../3_0/unit_test_spec/spec_writer.py | 13 +- .../resources/3_0/unit_test_spec/type.yaml | 404 ++++++++++-------- .../.openapi-generator/FILES | 75 ++-- .../python-experimental/README.md | 25 +- .../docs/AllofWithBooleanSchemasAllFalse.md | 9 - .../docs/AllofWithBooleanSchemasAllTrue.md | 9 - .../docs/AllofWithBooleanSchemasSomeFalse.md | 9 - .../docs/AllofWithOneEmptySchema.md | 9 - .../docs/AllofWithTheFirstEmptySchema.md | 9 - .../docs/AllofWithTheLastEmptySchema.md | 9 - .../docs/AllofWithTwoEmptySchemas.md | 9 - .../docs/EnumWith0DoesNotMatchFalse.md | 8 + .../docs/EnumWith1DoesNotMatchTrue.md | 8 + .../docs/EnumWithEscapedCharacters.md | 9 + .../docs/EnumWithFalseDoesNotMatch0.md | 8 + .../docs/EnumWithTrueDoesNotMatch1.md | 8 + ...WithAnyofOneof.md => EnumsInProperties.md} | 4 +- .../docs/HeterogeneousEnumValidation.md | 8 + .../HeterogeneousEnumWithNullValidation.md | 8 + ...pes.md => InvalidStringValueForDefault.md} | 3 +- .../{Allof.md => InvalidTypeForDefault.md} | 3 +- .../NestedAllofToCheckValidationSemantics.md | 9 - .../docs/NulCharactersInStrings.md | Bin 0 -> 310 bytes .../docs/SimpleEnumValidation.md | 8 + ...oesNotDoAnythingIfThePropertyIsMissing.md} | 4 +- .../python-experimental/test/test_allof.py | 70 --- .../test_allof_combined_with_anyof_oneof.py | 70 --- .../test/test_allof_simple_types.py | 34 -- ...st_allof_with_boolean_schemas_all_false.py | 30 -- ...est_allof_with_boolean_schemas_all_true.py | 29 -- ...t_allof_with_boolean_schemas_some_false.py | 30 -- .../test/test_allof_with_one_empty_schema.py | 28 -- .../test_allof_with_the_first_empty_schema.py | 35 -- .../test/test_allof_with_two_empty_schemas.py | 28 -- .../test_enum_with0_does_not_match_false.py | 40 ++ .../test_enum_with1_does_not_match_true.py | 40 ++ .../test/test_enum_with_escaped_characters.py | 43 ++ .../test_enum_with_false_does_not_match0.py | 41 ++ .../test_enum_with_true_does_not_match1.py | 41 ++ ..._schema.py => test_enums_in_properties.py} | 77 ++-- .../test_heterogeneous_enum_validation.py | 69 +++ ...heterogeneous_enum_with_null_validation.py | 41 ++ .../test_invalid_string_value_for_default.py | 40 ++ .../test/test_invalid_type_for_default.py | 39 ++ ...ted_allof_to_check_validation_semantics.py | 35 -- .../test/test_nul_characters_in_strings.py | Bin 0 -> 963 bytes ...hema.py => test_simple_enum_validation.py} | 21 +- ..._do_anything_if_the_property_is_missing.py | 49 +++ .../unit_test_api/model/allof.py | 115 ----- .../model/allof_combined_with_anyof_oneof.py | 117 ----- .../unit_test_api/model/allof_simple_types.py | 115 ----- .../model/allof_with_base_schema.py | 121 ------ .../allof_with_the_first_empty_schema.py | 115 ----- .../model/allof_with_the_last_empty_schema.py | 115 ----- .../model/allof_with_two_empty_schemas.py | 115 ----- .../model/enum_with0_does_not_match_false.py | 86 ++++ .../model/enum_with1_does_not_match_true.py | 86 ++++ .../model/enum_with_escaped_characters.py | 94 ++++ .../model/enum_with_false_does_not_match0.py | 86 ++++ .../model/enum_with_true_does_not_match1.py | 86 ++++ ...s_some_false.py => enums_in_properties.py} | 66 +-- .../model/heterogeneous_enum_validation.py | 110 +++++ ...heterogeneous_enum_with_null_validation.py | 92 ++++ ...py => invalid_string_value_for_default.py} | 39 +- ...l_false.py => invalid_type_for_default.py} | 31 +- ...ted_allof_to_check_validation_semantics.py | 113 ----- .../model/nul_characters_in_strings.py | Bin 0 -> 1688 bytes .../model/simple_enum_validation.py | 98 +++++ ...do_anything_if_the_property_is_missing.py} | 42 +- .../unit_test_api/models/__init__.py | 25 +- 70 files changed, 1680 insertions(+), 1785 deletions(-) delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithBooleanSchemasAllFalse.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithBooleanSchemasAllTrue.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithBooleanSchemasSomeFalse.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithOneEmptySchema.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithTheFirstEmptySchema.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithTheLastEmptySchema.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithTwoEmptySchemas.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWith0DoesNotMatchFalse.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWith1DoesNotMatchTrue.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithEscapedCharacters.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithFalseDoesNotMatch0.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithTrueDoesNotMatch1.md rename samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/{AllofCombinedWithAnyofOneof.md => EnumsInProperties.md} (84%) create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/HeterogeneousEnumValidation.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/HeterogeneousEnumWithNullValidation.md rename samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/{AllofSimpleTypes.md => InvalidStringValueForDefault.md} (78%) rename samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/{Allof.md => InvalidTypeForDefault.md} (88%) delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedAllofToCheckValidationSemantics.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NulCharactersInStrings.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/SimpleEnumValidation.md rename samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/{AllofWithBaseSchema.md => TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md} (73%) delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_combined_with_anyof_oneof.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_simple_types.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_all_false.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_all_true.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_some_false.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_one_empty_schema.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_first_empty_schema.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_two_empty_schemas.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with0_does_not_match_false.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with1_does_not_match_true.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_escaped_characters.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_false_does_not_match0.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_true_does_not_match1.py rename samples/openapi3/client/3_0_3_unit_test/python-experimental/test/{test_allof_with_base_schema.py => test_enums_in_properties.py} (50%) create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_heterogeneous_enum_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_heterogeneous_enum_with_null_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_string_value_for_default.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_type_for_default.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_allof_to_check_validation_semantics.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nul_characters_in_strings.py rename samples/openapi3/client/3_0_3_unit_test/python-experimental/test/{test_allof_with_the_last_empty_schema.py => test_simple_enum_validation.py} (50%) create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_combined_with_anyof_oneof.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_simple_types.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_base_schema.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_the_first_empty_schema.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_the_last_empty_schema.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_two_empty_schemas.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with0_does_not_match_false.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with1_does_not_match_true.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_escaped_characters.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_false_does_not_match0.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_true_does_not_match1.py rename samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/{allof_with_boolean_schemas_some_false.py => enums_in_properties.py} (64%) create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/heterogeneous_enum_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/heterogeneous_enum_with_null_validation.py rename samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/{allof_with_boolean_schemas_all_true.py => invalid_string_value_for_default.py} (69%) rename samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/{allof_with_boolean_schemas_all_false.py => invalid_type_for_default.py} (69%) delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_allof_to_check_validation_semantics.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nul_characters_in_strings.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/simple_enum_validation.py rename samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/{allof_with_one_empty_schema.py => the_default_keyword_does_not_do_anything_if_the_property_is_missing.py} (64%) diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index 4fc48c6f0e4..3ec529990f5 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -81,6 +81,9 @@ class ExclusionReason: v303_does_not_support_patternProperties = 'v3.0.3 does not support the patternProperties keyword' v303_does_not_support_const = 'v3.0.3 does not support the const keyword' v303_does_not_support_boolean_schemas_in_components = 'v3.0.3 does not support boolean schemas in components' + v303_does_not_support_contains = 'v3.0.3 does not support the contains keyword' + v303_does_not_support_definitions = 'v3.0.3 does not support the definitions keyword' + v303_does_not_support_dependencies = 'v3.0.3 does not support the dependencies keyword' json_schema_test_draft = 'draft6' FILEPATH_TO_EXCLUDED_CASE_AND_REASON = { @@ -100,6 +103,9 @@ FILEPATH_TO_EXCLUDE_REASON = { (json_schema_test_draft, 'additionalItems.json'): ExclusionReason.v303_does_not_support_additionalItems, (json_schema_test_draft, 'const.json'): ExclusionReason.v303_does_not_support_const, (json_schema_test_draft, 'boolean_schema.json'): ExclusionReason.v303_does_not_support_boolean_schemas_in_components, + (json_schema_test_draft, 'contains.json'): ExclusionReason.v303_does_not_support_contains, + (json_schema_test_draft, 'definitions.json'): ExclusionReason.v303_does_not_support_definitions, + (json_schema_test_draft, 'dependencies.json'): ExclusionReason.v303_does_not_support_dependencies, } openapi_additions = 'openapi_additions' @@ -108,10 +114,15 @@ JSON_SCHEMA_TEST_FILE_TO_FOLDERS = { 'type.json': (json_schema_test_draft, openapi_additions), 'additionalItems.json': (json_schema_test_draft,), 'additionalProperties.json': (json_schema_test_draft,), - 'allOf.json': (json_schema_test_draft,), +# 'allOf.json': (json_schema_test_draft,), # 'anyOf.json': (json_schema_test_draft,), 'boolean_schema.json': (json_schema_test_draft,), 'const.json': (json_schema_test_draft,), + 'contains.json': (json_schema_test_draft,), + 'default.json': (json_schema_test_draft,), + 'definitions.json': (json_schema_test_draft,), + 'dependencies.json': (json_schema_test_draft,), + 'enum.json': (json_schema_test_draft,), } def get_json_schema_test_schemas(file_path: typing.Tuple[str]) -> typing.List[JsonSchemaTestSchema]: diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml index 48ef4afa551..71fbf8a263b 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml @@ -41,77 +41,72 @@ components: foo: {} additionalProperties: type: boolean - Allof: - allOf: - - properties: - bar: - type: integer - required: - - bar - - properties: - foo: - type: string - required: - - foo - AllofWithBaseSchema: + InvalidTypeForDefault: properties: - bar: + foo: type: integer + default: [] + InvalidStringValueForDefault: + properties: + bar: + type: string + minLength: 4 + default: bad + TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing: + type: object + properties: + alpha: + type: number + maximum: 3 + default: 5 + SimpleEnumValidation: + enum: + - 1 + - 2 + - 3 + HeterogeneousEnumValidation: + enum: + - 6 + - foo + - [] + - true + - foo: 12 + HeterogeneousEnumWithNullValidation: + enum: + - 6 + - null + EnumsInProperties: + type: object + properties: + foo: + enum: + - foo + bar: + enum: + - bar required: - bar - allOf: - - properties: - foo: - type: string - required: - - foo - - properties: - baz: - type: 'null' - required: - - baz - AllofSimpleTypes: - allOf: - - maximum: 30 - - minimum: 20 - AllofWithBooleanSchemasAllTrue: - allOf: - - true - - true - AllofWithBooleanSchemasSomeFalse: - allOf: - - true + EnumWithEscapedCharacters: + enum: + - 'foo + + bar' + - "foo\rbar" + EnumWithFalseDoesNotMatch0: + enum: - false - AllofWithBooleanSchemasAllFalse: - allOf: - - false - - false - AllofWithOneEmptySchema: - allOf: - - {} - AllofWithTwoEmptySchemas: - allOf: - - {} - - {} - AllofWithTheFirstEmptySchema: - allOf: - - {} - - type: number - AllofWithTheLastEmptySchema: - allOf: - - type: number - - {} - NestedAllofToCheckValidationSemantics: - allOf: - - allOf: - - type: 'null' - AllofCombinedWithAnyofOneof: - allOf: - - multipleOf: 2 - anyOf: - - multipleOf: 3 - oneOf: - - multipleOf: 5 + EnumWithTrueDoesNotMatch1: + enum: + - true + EnumWith0DoesNotMatchFalse: + enum: + - 0 + EnumWith1DoesNotMatchTrue: + enum: + - 1 + NulCharactersInStrings: + enum: + - "hello\0there" x-schema-test-examples: IntegerTypeMatchesIntegers: AnIntegerIsAnInteger: @@ -410,151 +405,194 @@ components: foo: 1 bar: true valid: false - Allof: - Allof: - description: allOf + InvalidTypeForDefault: + ValidWhenPropertyIsSpecified: + description: valid when property is specified data: - foo: baz - bar: 2 + foo: 13 + valid: true + StillValidWhenTheInvalidDefaultIsUsed: + description: still valid when the invalid default is used + data: {} valid: true - MismatchSecond: - description: mismatch second + InvalidStringValueForDefault: + ValidWhenPropertyIsSpecified: + description: valid when property is specified data: - foo: baz - valid: false - MismatchFirst: - description: mismatch first + bar: good + valid: true + StillValidWhenTheInvalidDefaultIsUsed: + description: still valid when the invalid default is used + data: {} + valid: true + TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing: + AnExplicitPropertyValueIsCheckedAgainstMaximumPassing: + description: an explicit property value is checked against maximum (passing) data: - bar: 2 - valid: false - WrongType: - description: wrong type + alpha: 1 + valid: true + AnExplicitPropertyValueIsCheckedAgainstMaximumFailing: + description: an explicit property value is checked against maximum (failing) data: - foo: baz - bar: quux + alpha: 5 valid: false - AllofWithBaseSchema: - Valid: - description: valid - data: - foo: quux - bar: 2 - baz: null + MissingPropertiesAreNotFilledInWithTheDefault: + description: missing properties are not filled in with the default + data: {} valid: true - MismatchBaseSchema: - description: mismatch base schema - data: - foo: quux - baz: null + SimpleEnumValidation: + OneOfTheEnumIsValid: + description: one of the enum is valid + data: 1 + valid: true + SomethingElseIsInvalid: + description: something else is invalid + data: 4 valid: false - MismatchFirstAllof: - description: mismatch first allOf - data: - bar: 2 - baz: null + HeterogeneousEnumValidation: + OneOfTheEnumIsValid: + description: one of the enum is valid + data: [] + valid: true + SomethingElseIsInvalid: + description: something else is invalid + data: null valid: false - MismatchSecondAllof: - description: mismatch second allOf + ObjectsAreDeepCompared: + description: objects are deep compared data: - foo: quux - bar: 2 + foo: false valid: false - MismatchBoth: - description: mismatch both + ValidObjectMatches: + description: valid object matches data: - bar: 2 - valid: false - AllofSimpleTypes: - Valid: - description: valid - data: 25 - valid: true - MismatchOne: - description: mismatch one - data: 35 - valid: false - AllofWithBooleanSchemasAllTrue: - AnyValueIsValid: - description: any value is valid - data: foo + foo: 12 valid: true - AllofWithBooleanSchemasSomeFalse: - AnyValueIsInvalid: - description: any value is invalid - data: foo - valid: false - AllofWithBooleanSchemasAllFalse: - AnyValueIsInvalid: - description: any value is invalid - data: foo + ExtraPropertiesInObjectIsInvalid: + description: extra properties in object is invalid + data: + foo: 12 + boo: 42 valid: false - AllofWithOneEmptySchema: - AnyDataIsValid: - description: any data is valid - data: 1 - valid: true - AllofWithTwoEmptySchemas: - AnyDataIsValid: - description: any data is valid - data: 1 + HeterogeneousEnumWithNullValidation: + NullIsValid: + description: null is valid + data: null valid: true - AllofWithTheFirstEmptySchema: NumberIsValid: description: number is valid - data: 1 + data: 6 valid: true - StringIsInvalid: - description: string is invalid - data: foo + SomethingElseIsInvalid: + description: something else is invalid + data: test valid: false - AllofWithTheLastEmptySchema: - NumberIsValid: - description: number is valid - data: 1 + EnumsInProperties: + BothPropertiesAreValid: + description: both properties are valid + data: + foo: foo + bar: bar valid: true - StringIsInvalid: - description: string is invalid - data: foo + WrongFooValue: + description: wrong foo value + data: + foo: foot + bar: bar valid: false - NestedAllofToCheckValidationSemantics: - NullIsValid: - description: null is valid - data: null + WrongBarValue: + description: wrong bar value + data: + foo: foo + bar: bart + valid: false + MissingOptionalPropertyIsValid: + description: missing optional property is valid + data: + bar: bar valid: true - AnythingNonNullIsInvalid: - description: anything non-null is invalid - data: 123 + MissingRequiredPropertyIsInvalid: + description: missing required property is invalid + data: + foo: foo valid: false - AllofCombinedWithAnyofOneof: - AllofFalseAnyofFalseOneofFalse: - description: 'allOf: false, anyOf: false, oneOf: false' - data: 1 + MissingAllPropertiesIsInvalid: + description: missing all properties is invalid + data: {} valid: false - AllofFalseAnyofFalseOneofTrue: - description: 'allOf: false, anyOf: false, oneOf: true' - data: 5 + EnumWithEscapedCharacters: + Member1IsValid: + description: member 1 is valid + data: 'foo + + bar' + valid: true + Member2IsValid: + description: member 2 is valid + data: "foo\rbar" + valid: true + AnotherStringIsInvalid: + description: another string is invalid + data: abc valid: false - AllofFalseAnyofTrueOneofFalse: - description: 'allOf: false, anyOf: true, oneOf: false' - data: 3 + EnumWithFalseDoesNotMatch0: + FalseIsValid: + description: false is valid + data: false + valid: true + IntegerZeroIsInvalid: + description: integer zero is invalid + data: 0 valid: false - AllofFalseAnyofTrueOneofTrue: - description: 'allOf: false, anyOf: true, oneOf: true' - data: 15 + FloatZeroIsInvalid: + description: float zero is invalid + data: 0.0 + valid: false + EnumWithTrueDoesNotMatch1: + TrueIsValid: + description: true is valid + data: true + valid: true + IntegerOneIsInvalid: + description: integer one is invalid + data: 1 valid: false - AllofTrueAnyofFalseOneofFalse: - description: 'allOf: true, anyOf: false, oneOf: false' - data: 2 + FloatOneIsInvalid: + description: float one is invalid + data: 1.0 valid: false - AllofTrueAnyofFalseOneofTrue: - description: 'allOf: true, anyOf: false, oneOf: true' - data: 10 + EnumWith0DoesNotMatchFalse: + FalseIsInvalid: + description: false is invalid + data: false valid: false - AllofTrueAnyofTrueOneofFalse: - description: 'allOf: true, anyOf: true, oneOf: false' - data: 6 + IntegerZeroIsValid: + description: integer zero is valid + data: 0 + valid: true + FloatZeroIsValid: + description: float zero is valid + data: 0.0 + valid: true + EnumWith1DoesNotMatchTrue: + TrueIsInvalid: + description: true is invalid + data: true valid: false - AllofTrueAnyofTrueOneofTrue: - description: 'allOf: true, anyOf: true, oneOf: true' - data: 30 + IntegerOneIsValid: + description: integer one is valid + data: 1 + valid: true + FloatOneIsValid: + description: float one is valid + data: 1.0 + valid: true + NulCharactersInStrings: + MatchStringWithNul: + description: match string with nul + data: "hello\0there" valid: true + DoNotMatchStringLackingNul: + description: do not match string lacking nul + data: hellothere + valid: false diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index 4951241492f..e5b6c039728 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -6,24 +6,25 @@ docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md docs/AdditionalpropertiesAreAllowedByDefault.md docs/AdditionalpropertiesCanExistByItself.md docs/AdditionalpropertiesShouldNotLookInApplicators.md -docs/Allof.md -docs/AllofCombinedWithAnyofOneof.md -docs/AllofSimpleTypes.md -docs/AllofWithBaseSchema.md -docs/AllofWithBooleanSchemasAllFalse.md -docs/AllofWithBooleanSchemasAllTrue.md -docs/AllofWithBooleanSchemasSomeFalse.md -docs/AllofWithOneEmptySchema.md -docs/AllofWithTheFirstEmptySchema.md -docs/AllofWithTheLastEmptySchema.md -docs/AllofWithTwoEmptySchemas.md docs/ArrayTypeMatchesArrays.md docs/BooleanTypeMatchesBooleans.md +docs/EnumWith0DoesNotMatchFalse.md +docs/EnumWith1DoesNotMatchTrue.md +docs/EnumWithEscapedCharacters.md +docs/EnumWithFalseDoesNotMatch0.md +docs/EnumWithTrueDoesNotMatch1.md +docs/EnumsInProperties.md +docs/HeterogeneousEnumValidation.md +docs/HeterogeneousEnumWithNullValidation.md docs/IntegerTypeMatchesIntegers.md -docs/NestedAllofToCheckValidationSemantics.md +docs/InvalidStringValueForDefault.md +docs/InvalidTypeForDefault.md +docs/NulCharactersInStrings.md docs/NullTypeMatchesOnlyTheNullObject.md docs/NumberTypeMatchesNumbers.md +docs/SimpleEnumValidation.md docs/StringTypeMatchesStrings.md +docs/TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md git_push.sh requirements.txt setup.cfg @@ -34,24 +35,25 @@ test/test_additionalproperties_allows_a_schema_which_should_validate.py test/test_additionalproperties_are_allowed_by_default.py test/test_additionalproperties_can_exist_by_itself.py test/test_additionalproperties_should_not_look_in_applicators.py -test/test_allof.py -test/test_allof_combined_with_anyof_oneof.py -test/test_allof_simple_types.py -test/test_allof_with_base_schema.py -test/test_allof_with_boolean_schemas_all_false.py -test/test_allof_with_boolean_schemas_all_true.py -test/test_allof_with_boolean_schemas_some_false.py -test/test_allof_with_one_empty_schema.py -test/test_allof_with_the_first_empty_schema.py -test/test_allof_with_the_last_empty_schema.py -test/test_allof_with_two_empty_schemas.py test/test_array_type_matches_arrays.py test/test_boolean_type_matches_booleans.py +test/test_enum_with0_does_not_match_false.py +test/test_enum_with1_does_not_match_true.py +test/test_enum_with_escaped_characters.py +test/test_enum_with_false_does_not_match0.py +test/test_enum_with_true_does_not_match1.py +test/test_enums_in_properties.py +test/test_heterogeneous_enum_validation.py +test/test_heterogeneous_enum_with_null_validation.py test/test_integer_type_matches_integers.py -test/test_nested_allof_to_check_validation_semantics.py +test/test_invalid_string_value_for_default.py +test/test_invalid_type_for_default.py +test/test_nul_characters_in_strings.py test/test_null_type_matches_only_the_null_object.py test/test_number_type_matches_numbers.py +test/test_simple_enum_validation.py test/test_string_type_matches_strings.py +test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py tox.ini unit_test_api/__init__.py unit_test_api/api/__init__.py @@ -64,24 +66,25 @@ unit_test_api/model/additionalproperties_allows_a_schema_which_should_validate.p unit_test_api/model/additionalproperties_are_allowed_by_default.py unit_test_api/model/additionalproperties_can_exist_by_itself.py unit_test_api/model/additionalproperties_should_not_look_in_applicators.py -unit_test_api/model/allof.py -unit_test_api/model/allof_combined_with_anyof_oneof.py -unit_test_api/model/allof_simple_types.py -unit_test_api/model/allof_with_base_schema.py -unit_test_api/model/allof_with_boolean_schemas_all_false.py -unit_test_api/model/allof_with_boolean_schemas_all_true.py -unit_test_api/model/allof_with_boolean_schemas_some_false.py -unit_test_api/model/allof_with_one_empty_schema.py -unit_test_api/model/allof_with_the_first_empty_schema.py -unit_test_api/model/allof_with_the_last_empty_schema.py -unit_test_api/model/allof_with_two_empty_schemas.py unit_test_api/model/array_type_matches_arrays.py unit_test_api/model/boolean_type_matches_booleans.py +unit_test_api/model/enum_with0_does_not_match_false.py +unit_test_api/model/enum_with1_does_not_match_true.py +unit_test_api/model/enum_with_escaped_characters.py +unit_test_api/model/enum_with_false_does_not_match0.py +unit_test_api/model/enum_with_true_does_not_match1.py +unit_test_api/model/enums_in_properties.py +unit_test_api/model/heterogeneous_enum_validation.py +unit_test_api/model/heterogeneous_enum_with_null_validation.py unit_test_api/model/integer_type_matches_integers.py -unit_test_api/model/nested_allof_to_check_validation_semantics.py +unit_test_api/model/invalid_string_value_for_default.py +unit_test_api/model/invalid_type_for_default.py +unit_test_api/model/nul_characters_in_strings.py unit_test_api/model/null_type_matches_only_the_null_object.py unit_test_api/model/number_type_matches_numbers.py +unit_test_api/model/simple_enum_validation.py unit_test_api/model/string_type_matches_strings.py +unit_test_api/model/the_default_keyword_does_not_do_anything_if_the_property_is_missing.py unit_test_api/models/__init__.py unit_test_api/rest.py unit_test_api/schemas.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md index 88b77743fa5..2f3bf8ce284 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md @@ -66,24 +66,25 @@ Class | Method | HTTP request | Description - [AdditionalpropertiesAreAllowedByDefault](docs/AdditionalpropertiesAreAllowedByDefault.md) - [AdditionalpropertiesCanExistByItself](docs/AdditionalpropertiesCanExistByItself.md) - [AdditionalpropertiesShouldNotLookInApplicators](docs/AdditionalpropertiesShouldNotLookInApplicators.md) - - [Allof](docs/Allof.md) - - [AllofCombinedWithAnyofOneof](docs/AllofCombinedWithAnyofOneof.md) - - [AllofSimpleTypes](docs/AllofSimpleTypes.md) - - [AllofWithBaseSchema](docs/AllofWithBaseSchema.md) - - [AllofWithBooleanSchemasAllFalse](docs/AllofWithBooleanSchemasAllFalse.md) - - [AllofWithBooleanSchemasAllTrue](docs/AllofWithBooleanSchemasAllTrue.md) - - [AllofWithBooleanSchemasSomeFalse](docs/AllofWithBooleanSchemasSomeFalse.md) - - [AllofWithOneEmptySchema](docs/AllofWithOneEmptySchema.md) - - [AllofWithTheFirstEmptySchema](docs/AllofWithTheFirstEmptySchema.md) - - [AllofWithTheLastEmptySchema](docs/AllofWithTheLastEmptySchema.md) - - [AllofWithTwoEmptySchemas](docs/AllofWithTwoEmptySchemas.md) - [ArrayTypeMatchesArrays](docs/ArrayTypeMatchesArrays.md) - [BooleanTypeMatchesBooleans](docs/BooleanTypeMatchesBooleans.md) + - [EnumWith0DoesNotMatchFalse](docs/EnumWith0DoesNotMatchFalse.md) + - [EnumWith1DoesNotMatchTrue](docs/EnumWith1DoesNotMatchTrue.md) + - [EnumWithEscapedCharacters](docs/EnumWithEscapedCharacters.md) + - [EnumWithFalseDoesNotMatch0](docs/EnumWithFalseDoesNotMatch0.md) + - [EnumWithTrueDoesNotMatch1](docs/EnumWithTrueDoesNotMatch1.md) + - [EnumsInProperties](docs/EnumsInProperties.md) + - [HeterogeneousEnumValidation](docs/HeterogeneousEnumValidation.md) + - [HeterogeneousEnumWithNullValidation](docs/HeterogeneousEnumWithNullValidation.md) - [IntegerTypeMatchesIntegers](docs/IntegerTypeMatchesIntegers.md) - - [NestedAllofToCheckValidationSemantics](docs/NestedAllofToCheckValidationSemantics.md) + - [InvalidStringValueForDefault](docs/InvalidStringValueForDefault.md) + - [InvalidTypeForDefault](docs/InvalidTypeForDefault.md) + - [NulCharactersInStrings](docs/NulCharactersInStrings.md) - [NullTypeMatchesOnlyTheNullObject](docs/NullTypeMatchesOnlyTheNullObject.md) - [NumberTypeMatchesNumbers](docs/NumberTypeMatchesNumbers.md) + - [SimpleEnumValidation](docs/SimpleEnumValidation.md) - [StringTypeMatchesStrings](docs/StringTypeMatchesStrings.md) + - [TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing](docs/TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md) ## Documentation For Authorization diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithBooleanSchemasAllFalse.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithBooleanSchemasAllFalse.md deleted file mode 100644 index 387f413d822..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithBooleanSchemasAllFalse.md +++ /dev/null @@ -1,9 +0,0 @@ -# AllofWithBooleanSchemasAllFalse - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithBooleanSchemasAllTrue.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithBooleanSchemasAllTrue.md deleted file mode 100644 index 14b9d72db54..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithBooleanSchemasAllTrue.md +++ /dev/null @@ -1,9 +0,0 @@ -# AllofWithBooleanSchemasAllTrue - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithBooleanSchemasSomeFalse.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithBooleanSchemasSomeFalse.md deleted file mode 100644 index ee097e71b8b..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithBooleanSchemasSomeFalse.md +++ /dev/null @@ -1,9 +0,0 @@ -# AllofWithBooleanSchemasSomeFalse - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithOneEmptySchema.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithOneEmptySchema.md deleted file mode 100644 index 21e4d7d4ef9..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithOneEmptySchema.md +++ /dev/null @@ -1,9 +0,0 @@ -# AllofWithOneEmptySchema - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithTheFirstEmptySchema.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithTheFirstEmptySchema.md deleted file mode 100644 index d25f5664846..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithTheFirstEmptySchema.md +++ /dev/null @@ -1,9 +0,0 @@ -# AllofWithTheFirstEmptySchema - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithTheLastEmptySchema.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithTheLastEmptySchema.md deleted file mode 100644 index aefbea30368..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithTheLastEmptySchema.md +++ /dev/null @@ -1,9 +0,0 @@ -# AllofWithTheLastEmptySchema - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithTwoEmptySchemas.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithTwoEmptySchemas.md deleted file mode 100644 index 220b95e4f0c..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithTwoEmptySchemas.md +++ /dev/null @@ -1,9 +0,0 @@ -# AllofWithTwoEmptySchemas - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWith0DoesNotMatchFalse.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWith0DoesNotMatchFalse.md new file mode 100644 index 00000000000..d5a6a187010 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWith0DoesNotMatchFalse.md @@ -0,0 +1,8 @@ +# EnumWith0DoesNotMatchFalse + +Type | Description | Notes +------------- | ------------- | ------------- +**float** | | must be one of [0, ] + +[[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/3_0_3_unit_test/python-experimental/docs/EnumWith1DoesNotMatchTrue.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWith1DoesNotMatchTrue.md new file mode 100644 index 00000000000..302b358dc61 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWith1DoesNotMatchTrue.md @@ -0,0 +1,8 @@ +# EnumWith1DoesNotMatchTrue + +Type | Description | Notes +------------- | ------------- | ------------- +**float** | | must be one of [1, ] + +[[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/3_0_3_unit_test/python-experimental/docs/EnumWithEscapedCharacters.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithEscapedCharacters.md new file mode 100644 index 00000000000..d13b6ca704f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithEscapedCharacters.md @@ -0,0 +1,9 @@ +# EnumWithEscapedCharacters + +Type | Description | Notes +------------- | ------------- | ------------- +**str** | | must be one of ['''foo +bar''', '''foo bar''', ] + +[[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/3_0_3_unit_test/python-experimental/docs/EnumWithFalseDoesNotMatch0.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithFalseDoesNotMatch0.md new file mode 100644 index 00000000000..f1cef961444 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithFalseDoesNotMatch0.md @@ -0,0 +1,8 @@ +# EnumWithFalseDoesNotMatch0 + +Type | Description | Notes +------------- | ------------- | ------------- +**bool** | | must be one of [False, ] + +[[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/3_0_3_unit_test/python-experimental/docs/EnumWithTrueDoesNotMatch1.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithTrueDoesNotMatch1.md new file mode 100644 index 00000000000..09723bcb68c --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithTrueDoesNotMatch1.md @@ -0,0 +1,8 @@ +# EnumWithTrueDoesNotMatch1 + +Type | Description | Notes +------------- | ------------- | ------------- +**bool** | | must be one of [True, ] + +[[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/3_0_3_unit_test/python-experimental/docs/AllofCombinedWithAnyofOneof.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumsInProperties.md similarity index 84% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofCombinedWithAnyofOneof.md rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumsInProperties.md index 403b07716ce..7b058dabb44 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofCombinedWithAnyofOneof.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumsInProperties.md @@ -1,8 +1,10 @@ -# AllofCombinedWithAnyofOneof +# EnumsInProperties #### Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**foo** | **str** | | [optional] +**bar** | **str** | | **any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/HeterogeneousEnumValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/HeterogeneousEnumValidation.md new file mode 100644 index 00000000000..c3e14087519 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/HeterogeneousEnumValidation.md @@ -0,0 +1,8 @@ +# HeterogeneousEnumValidation + +Type | Description | Notes +------------- | ------------- | ------------- +**float** | | must be one of [6, foo, [], true, {"foo":12}, ] + +[[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/3_0_3_unit_test/python-experimental/docs/HeterogeneousEnumWithNullValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/HeterogeneousEnumWithNullValidation.md new file mode 100644 index 00000000000..bfaacb346c0 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/HeterogeneousEnumWithNullValidation.md @@ -0,0 +1,8 @@ +# HeterogeneousEnumWithNullValidation + +Type | Description | Notes +------------- | ------------- | ------------- +**float** | | must be one of [6, null, ] + +[[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/3_0_3_unit_test/python-experimental/docs/AllofSimpleTypes.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidStringValueForDefault.md similarity index 78% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofSimpleTypes.md rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidStringValueForDefault.md index b1ababc3e59..ae129438132 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofSimpleTypes.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidStringValueForDefault.md @@ -1,8 +1,9 @@ -# AllofSimpleTypes +# InvalidStringValueForDefault #### Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**bar** | **str** | | [optional] if omitted the server will use the default value of "bad" **any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Allof.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidTypeForDefault.md similarity index 88% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Allof.md rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidTypeForDefault.md index 77328e52d3f..a251e2dc515 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Allof.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidTypeForDefault.md @@ -1,8 +1,9 @@ -# Allof +# InvalidTypeForDefault #### Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**foo** | **int** | | [optional] **any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedAllofToCheckValidationSemantics.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedAllofToCheckValidationSemantics.md deleted file mode 100644 index abd73afca55..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedAllofToCheckValidationSemantics.md +++ /dev/null @@ -1,9 +0,0 @@ -# NestedAllofToCheckValidationSemantics - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NulCharactersInStrings.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NulCharactersInStrings.md new file mode 100644 index 0000000000000000000000000000000000000000..762e662d872c71c292a4ba7b620d99d62b4e630b GIT binary patch literal 310 zcma)$u?~Vj42GTWDH>Rmc=!yc3=9yXZiL~4Di@C{xhsQ-4==<)bh2rO?@#~!4WSs! zu2oLejLv8F#7^6r7vlWr5uUI|Upw8iCOc9=j9$ojjp`ibFN-Mh?4oGYr|t&Na6uqD z&K1g_MPq2eEjkR=Pzh0%TUFnI336)CfYF|-Y8l6yW18&qH13+Pp?c`hvYP&qS8}qO dcKr%I?&OgD=~ca!Xq%q2<*yU(z@PAy5HGDNUgZD) literal 0 HcmV?d00001 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/SimpleEnumValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/SimpleEnumValidation.md new file mode 100644 index 00000000000..81e6b4f5e6c --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/SimpleEnumValidation.md @@ -0,0 +1,8 @@ +# SimpleEnumValidation + +Type | Description | Notes +------------- | ------------- | ------------- +**float** | | must be one of [1, 2, 3, ] + +[[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/3_0_3_unit_test/python-experimental/docs/AllofWithBaseSchema.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md similarity index 73% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithBaseSchema.md rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md index a01c8b13de9..61162c71aa0 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AllofWithBaseSchema.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md @@ -1,9 +1,9 @@ -# AllofWithBaseSchema +# TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing #### Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**bar** | **int** | | +**alpha** | **int, float** | | [optional] if omitted the server will use the default value of 5 **any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof.py deleted file mode 100644 index 48891550f6a..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof.py +++ /dev/null @@ -1,70 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.allof import Allof - - -class TestAllof(unittest.TestCase): - """Allof unit test stubs""" - - def test_allof_passes(self): - # allOf - Allof( - **{ - "foo": - - "baz", - "bar": - 2, - } - ) - - def test_mismatch_first_fails(self): - # mismatch first - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - Allof( - **{ - "bar": - 2, - } - ) - - def test_mismatch_second_fails(self): - # mismatch second - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - Allof( - **{ - "foo": - - "baz", - } - ) - - def test_wrong_type_fails(self): - # wrong type - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - Allof( - **{ - "foo": - - "baz", - "bar": - - "quux", - } - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_combined_with_anyof_oneof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_combined_with_anyof_oneof.py deleted file mode 100644 index 9da90d3694e..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_combined_with_anyof_oneof.py +++ /dev/null @@ -1,70 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.allof_combined_with_anyof_oneof import AllofCombinedWithAnyofOneof - - -class TestAllofCombinedWithAnyofOneof(unittest.TestCase): - """AllofCombinedWithAnyofOneof unit test stubs""" - - def test_allof_true_anyof_false_oneof_false_fails(self): - # allOf: true, anyOf: false, oneOf: false - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - AllofCombinedWithAnyofOneof( - 2 ) - - def test_allof_false_anyof_false_oneof_true_fails(self): - # allOf: false, anyOf: false, oneOf: true - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - AllofCombinedWithAnyofOneof( - 5 ) - - def test_allof_false_anyof_true_oneof_true_fails(self): - # allOf: false, anyOf: true, oneOf: true - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - AllofCombinedWithAnyofOneof( - 15 ) - - def test_allof_true_anyof_true_oneof_false_fails(self): - # allOf: true, anyOf: true, oneOf: false - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - AllofCombinedWithAnyofOneof( - 6 ) - - def test_allof_true_anyof_true_oneof_true_passes(self): - # allOf: true, anyOf: true, oneOf: true - AllofCombinedWithAnyofOneof( - 30 ) - - def test_allof_true_anyof_false_oneof_true_fails(self): - # allOf: true, anyOf: false, oneOf: true - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - AllofCombinedWithAnyofOneof( - 10 ) - - def test_allof_false_anyof_true_oneof_false_fails(self): - # allOf: false, anyOf: true, oneOf: false - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - AllofCombinedWithAnyofOneof( - 3 ) - - def test_allof_false_anyof_false_oneof_false_fails(self): - # allOf: false, anyOf: false, oneOf: false - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - AllofCombinedWithAnyofOneof( - 1 ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_simple_types.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_simple_types.py deleted file mode 100644 index 1c78fbc8df9..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_simple_types.py +++ /dev/null @@ -1,34 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.allof_simple_types import AllofSimpleTypes - - -class TestAllofSimpleTypes(unittest.TestCase): - """AllofSimpleTypes unit test stubs""" - - def test_valid_passes(self): - # valid - AllofSimpleTypes( - 25 ) - - def test_mismatch_one_fails(self): - # mismatch one - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - AllofSimpleTypes( - 35 ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_all_false.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_all_false.py deleted file mode 100644 index f1b999b0c43..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_all_false.py +++ /dev/null @@ -1,30 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.allof_with_boolean_schemas_all_false import AllofWithBooleanSchemasAllFalse - - -class TestAllofWithBooleanSchemasAllFalse(unittest.TestCase): - """AllofWithBooleanSchemasAllFalse unit test stubs""" - - def test_any_value_is_invalid_fails(self): - # any value is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - AllofWithBooleanSchemasAllFalse( - - "foo" ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_all_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_all_true.py deleted file mode 100644 index f3e0792dcae..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_all_true.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.allof_with_boolean_schemas_all_true import AllofWithBooleanSchemasAllTrue - - -class TestAllofWithBooleanSchemasAllTrue(unittest.TestCase): - """AllofWithBooleanSchemasAllTrue unit test stubs""" - - def test_any_value_is_valid_passes(self): - # any value is valid - AllofWithBooleanSchemasAllTrue( - - "foo" ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_some_false.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_some_false.py deleted file mode 100644 index 6c6f5d9d63d..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_boolean_schemas_some_false.py +++ /dev/null @@ -1,30 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.allof_with_boolean_schemas_some_false import AllofWithBooleanSchemasSomeFalse - - -class TestAllofWithBooleanSchemasSomeFalse(unittest.TestCase): - """AllofWithBooleanSchemasSomeFalse unit test stubs""" - - def test_any_value_is_invalid_fails(self): - # any value is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - AllofWithBooleanSchemasSomeFalse( - - "foo" ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_one_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_one_empty_schema.py deleted file mode 100644 index 180ad530185..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_one_empty_schema.py +++ /dev/null @@ -1,28 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.allof_with_one_empty_schema import AllofWithOneEmptySchema - - -class TestAllofWithOneEmptySchema(unittest.TestCase): - """AllofWithOneEmptySchema unit test stubs""" - - def test_any_data_is_valid_passes(self): - # any data is valid - AllofWithOneEmptySchema( - 1 ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_first_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_first_empty_schema.py deleted file mode 100644 index 0637322964f..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_first_empty_schema.py +++ /dev/null @@ -1,35 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.allof_with_the_first_empty_schema import AllofWithTheFirstEmptySchema - - -class TestAllofWithTheFirstEmptySchema(unittest.TestCase): - """AllofWithTheFirstEmptySchema unit test stubs""" - - def test_string_is_invalid_fails(self): - # string is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - AllofWithTheFirstEmptySchema( - - "foo" ) - - def test_number_is_valid_passes(self): - # number is valid - AllofWithTheFirstEmptySchema( - 1 ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_two_empty_schemas.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_two_empty_schemas.py deleted file mode 100644 index a8f32676a2d..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_two_empty_schemas.py +++ /dev/null @@ -1,28 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.allof_with_two_empty_schemas import AllofWithTwoEmptySchemas - - -class TestAllofWithTwoEmptySchemas(unittest.TestCase): - """AllofWithTwoEmptySchemas unit test stubs""" - - def test_any_data_is_valid_passes(self): - # any data is valid - AllofWithTwoEmptySchemas( - 1 ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with0_does_not_match_false.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with0_does_not_match_false.py new file mode 100644 index 00000000000..1e4ee2ff3f8 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with0_does_not_match_false.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.enum_with0_does_not_match_false import EnumWith0DoesNotMatchFalse + + +class TestEnumWith0DoesNotMatchFalse(unittest.TestCase): + """EnumWith0DoesNotMatchFalse unit test stubs""" + + def test_integer_zero_is_valid_passes(self): + # integer zero is valid + EnumWith0DoesNotMatchFalse( + 0 ) + + def test_float_zero_is_valid_passes(self): + # float zero is valid + EnumWith0DoesNotMatchFalse( + 0.0 ) + + def test_false_is_invalid_fails(self): + # false is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + EnumWith0DoesNotMatchFalse( + + False ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with1_does_not_match_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with1_does_not_match_true.py new file mode 100644 index 00000000000..7f99ceb96b9 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with1_does_not_match_true.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.enum_with1_does_not_match_true import EnumWith1DoesNotMatchTrue + + +class TestEnumWith1DoesNotMatchTrue(unittest.TestCase): + """EnumWith1DoesNotMatchTrue unit test stubs""" + + def test_true_is_invalid_fails(self): + # true is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + EnumWith1DoesNotMatchTrue( + + True ) + + def test_integer_one_is_valid_passes(self): + # integer one is valid + EnumWith1DoesNotMatchTrue( + 1 ) + + def test_float_one_is_valid_passes(self): + # float one is valid + EnumWith1DoesNotMatchTrue( + 1.0 ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_escaped_characters.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_escaped_characters.py new file mode 100644 index 00000000000..539f8ae21f3 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_escaped_characters.py @@ -0,0 +1,43 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.enum_with_escaped_characters import EnumWithEscapedCharacters + + +class TestEnumWithEscapedCharacters(unittest.TestCase): + """EnumWithEscapedCharacters unit test stubs""" + + def test_member2_is_valid_passes(self): + # member 2 is valid + EnumWithEscapedCharacters( + + "foo bar" ) + + def test_member1_is_valid_passes(self): + # member 1 is valid + EnumWithEscapedCharacters( + + "foo +bar" ) + + def test_another_string_is_invalid_fails(self): + # another string is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + EnumWithEscapedCharacters( + + "abc" ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_false_does_not_match0.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_false_does_not_match0.py new file mode 100644 index 00000000000..06dc149a143 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_false_does_not_match0.py @@ -0,0 +1,41 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.enum_with_false_does_not_match0 import EnumWithFalseDoesNotMatch0 + + +class TestEnumWithFalseDoesNotMatch0(unittest.TestCase): + """EnumWithFalseDoesNotMatch0 unit test stubs""" + + def test_false_is_valid_passes(self): + # false is valid + EnumWithFalseDoesNotMatch0( + + False ) + + def test_float_zero_is_invalid_fails(self): + # float zero is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + EnumWithFalseDoesNotMatch0( + 0.0 ) + + def test_integer_zero_is_invalid_fails(self): + # integer zero is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + EnumWithFalseDoesNotMatch0( + 0 ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_true_does_not_match1.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_true_does_not_match1.py new file mode 100644 index 00000000000..e9a3e6c80f9 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_true_does_not_match1.py @@ -0,0 +1,41 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.enum_with_true_does_not_match1 import EnumWithTrueDoesNotMatch1 + + +class TestEnumWithTrueDoesNotMatch1(unittest.TestCase): + """EnumWithTrueDoesNotMatch1 unit test stubs""" + + def test_float_one_is_invalid_fails(self): + # float one is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + EnumWithTrueDoesNotMatch1( + 1.0 ) + + def test_true_is_valid_passes(self): + # true is valid + EnumWithTrueDoesNotMatch1( + + True ) + + def test_integer_one_is_invalid_fails(self): + # integer one is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + EnumWithTrueDoesNotMatch1( + 1 ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_base_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enums_in_properties.py similarity index 50% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_base_schema.py rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enums_in_properties.py index 514d5a7a75f..813311ff2b8 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_base_schema.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enums_in_properties.py @@ -12,74 +12,79 @@ import unittest import unit_test_api -from unit_test_api.model.allof_with_base_schema import AllofWithBaseSchema +from unit_test_api.model.enums_in_properties import EnumsInProperties -class TestAllofWithBaseSchema(unittest.TestCase): - """AllofWithBaseSchema unit test stubs""" +class TestEnumsInProperties(unittest.TestCase): + """EnumsInProperties unit test stubs""" - def test_valid_passes(self): - # valid - AllofWithBaseSchema( + def test_missing_optional_property_is_valid_passes(self): + # missing optional property is valid + EnumsInProperties( **{ - "foo": - - "quux", "bar": - 2, - "baz": - None, + "bar", } ) - def test_mismatch_first_allof_fails(self): - # mismatch first allOf + def test_wrong_foo_value_fails(self): + # wrong foo value with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - AllofWithBaseSchema( + EnumsInProperties( **{ + "foo": + + "foot", "bar": - 2, - "baz": - None, + "bar", } ) - def test_mismatch_base_schema_fails(self): - # mismatch base schema + def test_both_properties_are_valid_passes(self): + # both properties are valid + EnumsInProperties( + **{ + "foo": + + "foo", + "bar": + + "bar", + } + ) + + def test_wrong_bar_value_fails(self): + # wrong bar value with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - AllofWithBaseSchema( + EnumsInProperties( **{ "foo": - "quux", - "baz": + "foo", + "bar": - None, + "bart", } ) - def test_mismatch_both_fails(self): - # mismatch both + def test_missing_all_properties_is_invalid_fails(self): + # missing all properties is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - AllofWithBaseSchema( - **{ - "bar": - 2, + EnumsInProperties( + { } ) - def test_mismatch_second_allof_fails(self): - # mismatch second allOf + def test_missing_required_property_is_invalid_fails(self): + # missing required property is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - AllofWithBaseSchema( + EnumsInProperties( **{ "foo": - "quux", - "bar": - 2, + "foo", } ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_heterogeneous_enum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_heterogeneous_enum_validation.py new file mode 100644 index 00000000000..8d32aa4554d --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_heterogeneous_enum_validation.py @@ -0,0 +1,69 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.heterogeneous_enum_validation import HeterogeneousEnumValidation + + +class TestHeterogeneousEnumValidation(unittest.TestCase): + """HeterogeneousEnumValidation unit test stubs""" + + def test_extra_properties_in_object_is_invalid_fails(self): + # extra properties in object is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + HeterogeneousEnumValidation( + **{ + "foo": + 12, + "boo": + 42, + } + ) + + def test_something_else_is_invalid_fails(self): + # something else is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + HeterogeneousEnumValidation( + + None ) + + def test_objects_are_deep_compared_fails(self): + # objects are deep compared + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + HeterogeneousEnumValidation( + **{ + "foo": + + False, + } + ) + + def test_one_of_the_enum_is_valid_passes(self): + # one of the enum is valid + HeterogeneousEnumValidation( + [ + ] + ) + + def test_valid_object_matches_passes(self): + # valid object matches + HeterogeneousEnumValidation( + **{ + "foo": + 12, + } + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_heterogeneous_enum_with_null_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_heterogeneous_enum_with_null_validation.py new file mode 100644 index 00000000000..b486826a038 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_heterogeneous_enum_with_null_validation.py @@ -0,0 +1,41 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.heterogeneous_enum_with_null_validation import HeterogeneousEnumWithNullValidation + + +class TestHeterogeneousEnumWithNullValidation(unittest.TestCase): + """HeterogeneousEnumWithNullValidation unit test stubs""" + + def test_null_is_valid_passes(self): + # null is valid + HeterogeneousEnumWithNullValidation( + + None ) + + def test_number_is_valid_passes(self): + # number is valid + HeterogeneousEnumWithNullValidation( + 6 ) + + def test_something_else_is_invalid_fails(self): + # something else is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + HeterogeneousEnumWithNullValidation( + + "test" ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_string_value_for_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_string_value_for_default.py new file mode 100644 index 00000000000..9d375f8edfb --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_string_value_for_default.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.invalid_string_value_for_default import InvalidStringValueForDefault + + +class TestInvalidStringValueForDefault(unittest.TestCase): + """InvalidStringValueForDefault unit test stubs""" + + def test_valid_when_property_is_specified_passes(self): + # valid when property is specified + InvalidStringValueForDefault( + **{ + "bar": + + "good", + } + ) + + def test_still_valid_when_the_invalid_default_is_used_passes(self): + # still valid when the invalid default is used + InvalidStringValueForDefault( + { + } + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_type_for_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_type_for_default.py new file mode 100644 index 00000000000..669b1754510 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_type_for_default.py @@ -0,0 +1,39 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.invalid_type_for_default import InvalidTypeForDefault + + +class TestInvalidTypeForDefault(unittest.TestCase): + """InvalidTypeForDefault unit test stubs""" + + def test_valid_when_property_is_specified_passes(self): + # valid when property is specified + InvalidTypeForDefault( + **{ + "foo": + 13, + } + ) + + def test_still_valid_when_the_invalid_default_is_used_passes(self): + # still valid when the invalid default is used + InvalidTypeForDefault( + { + } + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_allof_to_check_validation_semantics.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_allof_to_check_validation_semantics.py deleted file mode 100644 index 771249ca4d6..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_allof_to_check_validation_semantics.py +++ /dev/null @@ -1,35 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.nested_allof_to_check_validation_semantics import NestedAllofToCheckValidationSemantics - - -class TestNestedAllofToCheckValidationSemantics(unittest.TestCase): - """NestedAllofToCheckValidationSemantics unit test stubs""" - - def test_anything_non_null_is_invalid_fails(self): - # anything non-null is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NestedAllofToCheckValidationSemantics( - 123 ) - - def test_null_is_valid_passes(self): - # null is valid - NestedAllofToCheckValidationSemantics( - - None ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nul_characters_in_strings.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nul_characters_in_strings.py new file mode 100644 index 0000000000000000000000000000000000000000..43f8d9d7ae4e8dab44ec155558143e34fc0660d1 GIT binary patch literal 963 zcma))O>f&U42E~suON~`6QFfd6dMKuJrqST^s)_G(5s-xbgfO6Jc-_re?L-Ay`;!t zJ|+Bo-j`Z}jg1R0HH_3=eN<|(SSa8x4j9bf;I`USw~$Rgc!WHlRV95CfHo!|%*12n zwss7bTnxrL+F!zMbe^D1v4<Zy2FSL<-juFf`kQ20`T($m5Pz8(9^Y?nrcK)p;Wwtt z!yvXm{Pzp9-G6<8Cfc#bKs9Wb@}_`&!hp#THn7{*&=C!}zP>)Fxq6whF;#@ND`J)F zhnNV);7C-c<A9ckW*<~xmzp_L^|3);h0$x<nPe<6rFKDQN^C`j!{E=Of0*-6;ro<T zN?C7mhAnS6U$S~ds-)(@WL(!pBj4zJM-fq6g-qiv%P~twgY2A0=?&TLK&byX>a_3= z41#%;(YJ>c@&uMps(F;?0jUPAE(0Zho?$g@lmht{9eN+%@!1kCrVzmT4OJ6$h;QJ$ zu|Iij;cJcaXYiWHuZ2!24{ax)g<Ql{qBGGq<3w)p_uo112ls6Jh>t17bXlxCNpAPU yYi|CzKC(;1{g)+DIN5UQip1F&<yz1>m>#u;yF0khd^LVn`eM5N{3;~6TC2avxjA?M literal 0 HcmV?d00001 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_last_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_simple_enum_validation.py similarity index 50% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_last_empty_schema.py rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_simple_enum_validation.py index 4742f9e280f..48b1efc5794 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_allof_with_the_last_empty_schema.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_simple_enum_validation.py @@ -12,22 +12,21 @@ import unittest import unit_test_api -from unit_test_api.model.allof_with_the_last_empty_schema import AllofWithTheLastEmptySchema +from unit_test_api.model.simple_enum_validation import SimpleEnumValidation -class TestAllofWithTheLastEmptySchema(unittest.TestCase): - """AllofWithTheLastEmptySchema unit test stubs""" +class TestSimpleEnumValidation(unittest.TestCase): + """SimpleEnumValidation unit test stubs""" - def test_string_is_invalid_fails(self): - # string is invalid + def test_something_else_is_invalid_fails(self): + # something else is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - AllofWithTheLastEmptySchema( + SimpleEnumValidation( + 4 ) - "foo" ) - - def test_number_is_valid_passes(self): - # number is valid - AllofWithTheLastEmptySchema( + def test_one_of_the_enum_is_valid_passes(self): + # one of the enum is valid + SimpleEnumValidation( 1 ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py new file mode 100644 index 00000000000..63eb2bf6bc2 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py @@ -0,0 +1,49 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.the_default_keyword_does_not_do_anything_if_the_property_is_missing import TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing + + +class TestTheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing(unittest.TestCase): + """TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing unit test stubs""" + + def test_missing_properties_are_not_filled_in_with_the_default_passes(self): + # missing properties are not filled in with the default + TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing( + { + } + ) + + def test_an_explicit_property_value_is_checked_against_maximum_passing_passes(self): + # an explicit property value is checked against maximum (passing) + TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing( + **{ + "alpha": + 1, + } + ) + + def test_an_explicit_property_value_is_checked_against_maximum_failing_fails(self): + # an explicit property value is checked against maximum (failing) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing( + **{ + "alpha": + 5, + } + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof.py deleted file mode 100644 index 475f6aed9e0..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof.py +++ /dev/null @@ -1,115 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class Allof( - ComposedSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 - allOf_0 = AnyTypeSchema - allOf_1 = AnyTypeSchema - return { - 'allOf': [ - allOf_0, - allOf_1, - ], - 'oneOf': [ - ], - 'anyOf': [ - ], - 'not': - None - } - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'Allof': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_combined_with_anyof_oneof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_combined_with_anyof_oneof.py deleted file mode 100644 index 1ac089847fb..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_combined_with_anyof_oneof.py +++ /dev/null @@ -1,117 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class AllofCombinedWithAnyofOneof( - ComposedSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 - allOf_0 = AnyTypeSchema - oneOf_0 = AnyTypeSchema - anyOf_0 = AnyTypeSchema - return { - 'allOf': [ - allOf_0, - ], - 'oneOf': [ - oneOf_0, - ], - 'anyOf': [ - anyOf_0, - ], - 'not': - None - } - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'AllofCombinedWithAnyofOneof': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_simple_types.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_simple_types.py deleted file mode 100644 index 3e5f0c525c7..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_simple_types.py +++ /dev/null @@ -1,115 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class AllofSimpleTypes( - ComposedSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 - allOf_0 = AnyTypeSchema - allOf_1 = AnyTypeSchema - return { - 'allOf': [ - allOf_0, - allOf_1, - ], - 'oneOf': [ - ], - 'anyOf': [ - ], - 'not': - None - } - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'AllofSimpleTypes': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_base_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_base_schema.py deleted file mode 100644 index f73a66a8bd9..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_base_schema.py +++ /dev/null @@ -1,121 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class AllofWithBaseSchema( - ComposedSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - _required_property_names = set(( - 'bar', - )) - bar = IntSchema - - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 - allOf_0 = AnyTypeSchema - allOf_1 = AnyTypeSchema - return { - 'allOf': [ - allOf_0, - allOf_1, - ], - 'oneOf': [ - ], - 'anyOf': [ - ], - 'not': - None - } - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - bar: bar, - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'AllofWithBaseSchema': - return super().__new__( - cls, - *args, - bar=bar, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_the_first_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_the_first_empty_schema.py deleted file mode 100644 index 9fac19ec1f3..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_the_first_empty_schema.py +++ /dev/null @@ -1,115 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class AllofWithTheFirstEmptySchema( - ComposedSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 - allOf_0 = AnyTypeSchema - allOf_1 = NumberSchema - return { - 'allOf': [ - allOf_0, - allOf_1, - ], - 'oneOf': [ - ], - 'anyOf': [ - ], - 'not': - None - } - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'AllofWithTheFirstEmptySchema': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_the_last_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_the_last_empty_schema.py deleted file mode 100644 index 069709c6602..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_the_last_empty_schema.py +++ /dev/null @@ -1,115 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class AllofWithTheLastEmptySchema( - ComposedSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 - allOf_0 = NumberSchema - allOf_1 = AnyTypeSchema - return { - 'allOf': [ - allOf_0, - allOf_1, - ], - 'oneOf': [ - ], - 'anyOf': [ - ], - 'not': - None - } - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'AllofWithTheLastEmptySchema': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_two_empty_schemas.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_two_empty_schemas.py deleted file mode 100644 index d0013312256..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_two_empty_schemas.py +++ /dev/null @@ -1,115 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class AllofWithTwoEmptySchemas( - ComposedSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 - allOf_0 = AnyTypeSchema - allOf_1 = AnyTypeSchema - return { - 'allOf': [ - allOf_0, - allOf_1, - ], - 'oneOf': [ - ], - 'anyOf': [ - ], - 'not': - None - } - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'AllofWithTwoEmptySchemas': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with0_does_not_match_false.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with0_does_not_match_false.py new file mode 100644 index 00000000000..6cb61f6f053 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with0_does_not_match_false.py @@ -0,0 +1,86 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class EnumWith0DoesNotMatchFalse( + _SchemaEnumMaker( + enum_value_to_name={ + 0: "POSITIVE_0", + } + ), + NumberSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + def POSITIVE_0(cls): + return cls(0) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with1_does_not_match_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with1_does_not_match_true.py new file mode 100644 index 00000000000..6904cda7fa3 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with1_does_not_match_true.py @@ -0,0 +1,86 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class EnumWith1DoesNotMatchTrue( + _SchemaEnumMaker( + enum_value_to_name={ + 1: "POSITIVE_1", + } + ), + NumberSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + def POSITIVE_1(cls): + return cls(1) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_escaped_characters.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_escaped_characters.py new file mode 100644 index 00000000000..3354101f399 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_escaped_characters.py @@ -0,0 +1,94 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class EnumWithEscapedCharacters( + _SchemaEnumMaker( + enum_value_to_name={ + '''foo +bar''': "FOO_BAR", + '''foo bar''': "FOO_BAR", + } + ), + StrSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + def FOO_BAR(cls): + return cls('''foo +bar''') + + @classmethod + @property + def FOO_BAR(cls): + return cls('''foo bar''') diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_false_does_not_match0.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_false_does_not_match0.py new file mode 100644 index 00000000000..223022bb57b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_false_does_not_match0.py @@ -0,0 +1,86 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class EnumWithFalseDoesNotMatch0( + _SchemaEnumMaker( + enum_value_to_name={ + False: "FALSE", + } + ), + BoolSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + def FALSE(cls): + return cls(False) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_true_does_not_match1.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_true_does_not_match1.py new file mode 100644 index 00000000000..6e997008625 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_true_does_not_match1.py @@ -0,0 +1,86 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class EnumWithTrueDoesNotMatch1( + _SchemaEnumMaker( + enum_value_to_name={ + True: "TRUE", + } + ), + BoolSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + def TRUE(cls): + return cls(True) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_boolean_schemas_some_false.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enums_in_properties.py similarity index 64% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_boolean_schemas_some_false.py rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enums_in_properties.py index ed8b1e80727..192305479fc 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_boolean_schemas_some_false.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enums_in_properties.py @@ -66,46 +66,62 @@ from unit_test_api.schemas import ( # noqa: F401 ) -class AllofWithBooleanSchemasSomeFalse( - ComposedSchema +class EnumsInProperties( + DictSchema ): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. """ + _required_property_names = set(( + 'bar', + )) + + + class foo( + _SchemaEnumMaker( + enum_value_to_name={ + "foo": "FOO", + } + ), + StrSchema + ): + + @classmethod + @property + def FOO(cls): + return cls("foo") + + + class bar( + _SchemaEnumMaker( + enum_value_to_name={ + "bar": "BAR", + } + ), + StrSchema + ): + + @classmethod + @property + def BAR(cls): + return cls("bar") - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 { - 'allOf': [ - ], - 'oneOf': [ - ], - 'anyOf': [ - ], - 'not': - None - } def __new__( cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + *args: typing.Union[dict, frozendict, ], + bar: bar, + foo: typing.Union[foo, Unset] = unset, _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Type[Schema], - ) -> 'AllofWithBooleanSchemasSomeFalse': + ) -> 'EnumsInProperties': return super().__new__( cls, *args, + bar=bar, + foo=foo, _configuration=_configuration, **kwargs, ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/heterogeneous_enum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/heterogeneous_enum_validation.py new file mode 100644 index 00000000000..40802e0637d --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/heterogeneous_enum_validation.py @@ -0,0 +1,110 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class HeterogeneousEnumValidation( + _SchemaEnumMaker( + enum_value_to_name={ + 6: "POSITIVE_6", + foo: "FOO", + []: "LEFT_SQUARE_BRACKETRIGHT_SQUARE_BRACKET", + true: "TRUE", + {"foo":12}: "FOO12", + } + ), + NumberSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + def POSITIVE_6(cls): + return cls(6) + + @classmethod + @property + def FOO(cls): + return cls(foo) + + @classmethod + @property + def LEFT_SQUARE_BRACKETRIGHT_SQUARE_BRACKET(cls): + return cls([]) + + @classmethod + @property + def TRUE(cls): + return cls(true) + + @classmethod + @property + def FOO12(cls): + return cls({"foo":12}) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/heterogeneous_enum_with_null_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/heterogeneous_enum_with_null_validation.py new file mode 100644 index 00000000000..77973c578f9 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/heterogeneous_enum_with_null_validation.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class HeterogeneousEnumWithNullValidation( + _SchemaEnumMaker( + enum_value_to_name={ + 6: "POSITIVE_6", + null: "NULL", + } + ), + NumberSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + def POSITIVE_6(cls): + return cls(6) + + @classmethod + @property + def NULL(cls): + return cls(null) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_boolean_schemas_all_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_string_value_for_default.py similarity index 69% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_boolean_schemas_all_true.py rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_string_value_for_default.py index 8724b72b4e1..07ad386d3b8 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_boolean_schemas_all_true.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_string_value_for_default.py @@ -66,46 +66,35 @@ from unit_test_api.schemas import ( # noqa: F401 ) -class AllofWithBooleanSchemasAllTrue( - ComposedSchema +class InvalidStringValueForDefault( + AnyTypeSchema ): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. """ - - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 { - 'allOf': [ - ], - 'oneOf': [ - ], - 'anyOf': [ - ], - 'not': - None - } + + + class bar( + _SchemaValidator( + min_length=4, + ), + StrSchema + ): + pass def __new__( cls, *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + bar: typing.Union[bar, Unset] = unset, _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Type[Schema], - ) -> 'AllofWithBooleanSchemasAllTrue': + ) -> 'InvalidStringValueForDefault': return super().__new__( cls, *args, + bar=bar, _configuration=_configuration, **kwargs, ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_boolean_schemas_all_false.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_type_for_default.py similarity index 69% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_boolean_schemas_all_false.py rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_type_for_default.py index d2cf5a9a40e..bffccf32de0 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_boolean_schemas_all_false.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_type_for_default.py @@ -66,46 +66,27 @@ from unit_test_api.schemas import ( # noqa: F401 ) -class AllofWithBooleanSchemasAllFalse( - ComposedSchema +class InvalidTypeForDefault( + AnyTypeSchema ): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. """ - - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 { - 'allOf': [ - ], - 'oneOf': [ - ], - 'anyOf': [ - ], - 'not': - None - } + foo = IntSchema def __new__( cls, *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + foo: typing.Union[foo, Unset] = unset, _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Type[Schema], - ) -> 'AllofWithBooleanSchemasAllFalse': + ) -> 'InvalidTypeForDefault': return super().__new__( cls, *args, + foo=foo, _configuration=_configuration, **kwargs, ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_allof_to_check_validation_semantics.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_allof_to_check_validation_semantics.py deleted file mode 100644 index 611175f27f1..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_allof_to_check_validation_semantics.py +++ /dev/null @@ -1,113 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class NestedAllofToCheckValidationSemantics( - ComposedSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 - allOf_0 = AnyTypeSchema - return { - 'allOf': [ - allOf_0, - ], - 'oneOf': [ - ], - 'anyOf': [ - ], - 'not': - None - } - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'NestedAllofToCheckValidationSemantics': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nul_characters_in_strings.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nul_characters_in_strings.py new file mode 100644 index 0000000000000000000000000000000000000000..e5a3bf5a390472c90e99c9549f56bfb30d1985bb GIT binary patch literal 1688 zcmb7FU2EGg6y39b#l?L|piMv0m0=jHZPGQ+rK3&v8dUqb)@DndBp2MV|Gq29i7hi2 z^F#1CSNH4a`sM&qnQ`%wKx6Ww4^b4yaRl_p8U?F4%x5RFIcQeZC4#OojhuNvKrR&+ z)P}<B-SS4HhD*UpZrVe5Zg^=RSF(cdS_;r<ffaLJ+WBXS<>mt50EGO>5?H=JIrW(~ z1;Q&TO~F9sU<lq*ZI@qHkjb>EP?!WxsLE4U*k=@|n86I5+XM<@YMmS(cikMlc&k)1 zgK6QKjd)c{Wk6w{{pOsqcf4-(-wmd%ZO8kPhfc12Da)~I<RqY<HxwC94RlEcOc-xh zMTRM_SUJk(qGi;r;T7&;S$qh4HjMY*`JF=}xY^n(-qJ|S{N?FgzR9R4J3W`8-Ly46 zx@$gk7jrF1XN}pATaW}pe8+WwAB`HCS0b<yoS%*C7w1Fbrj%@S#!=y^byGcKkm%`Y zwHU@(kfdY0A;|;I-_Ve{q6r8v7fiK7W-Ub!L=fK6VBt<Pk@J^^=9#A7Q%^#p@vlw) zx)b+`>CV+k*&{1-k8IW+k;pwDO#?7L3*g0h4?A&3#PEa{wm)EH?U5BVL{`$CvFZ(w z)2_!u6}KLIqh&*5FO`?4W9=MX7nuIQkY9?X`of5frco57CDR(#O?h1~#Zp5HXC+7( z`oi_Z&2JZO@8(%M>`0NeudHn7>f~0i3P1jGF4kzDxWKZM?`U-?j1!1&mv?vfo7?5X zGWMm~L%*HN)D!!`kEV&^X)UksH_HSz1=rxKr5Dy13Efh2D{sFWyFEyo&iOxJ{?Bdb z4lX2ZU;~(O<94l2RWZ@9vTS{@-G790_~cGhXbPEmqE@tSm1!NyFo(Y1Nm}ZzBipk= O(<njh=t-c_H2MPu1NmnF literal 0 HcmV?d00001 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/simple_enum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/simple_enum_validation.py new file mode 100644 index 00000000000..86f28a9dae3 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/simple_enum_validation.py @@ -0,0 +1,98 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class SimpleEnumValidation( + _SchemaEnumMaker( + enum_value_to_name={ + 1: "POSITIVE_1", + 2: "POSITIVE_2", + 3: "POSITIVE_3", + } + ), + NumberSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + def POSITIVE_1(cls): + return cls(1) + + @classmethod + @property + def POSITIVE_2(cls): + return cls(2) + + @classmethod + @property + def POSITIVE_3(cls): + return cls(3) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_one_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/the_default_keyword_does_not_do_anything_if_the_property_is_missing.py similarity index 64% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_one_empty_schema.py rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/the_default_keyword_does_not_do_anything_if_the_property_is_missing.py index 2f3b66d35ea..d59150db52b 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/allof_with_one_empty_schema.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/the_default_keyword_does_not_do_anything_if_the_property_is_missing.py @@ -66,48 +66,36 @@ from unit_test_api.schemas import ( # noqa: F401 ) -class AllofWithOneEmptySchema( - ComposedSchema +class TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing( + DictSchema ): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. """ + + + class alpha( + _SchemaValidator( + inclusive_maximum=3, + ), + NumberSchema + ): + pass - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 - allOf_0 = AnyTypeSchema - return { - 'allOf': [ - allOf_0, - ], - 'oneOf': [ - ], - 'anyOf': [ - ], - 'not': - None - } def __new__( cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + *args: typing.Union[dict, frozendict, ], + alpha: typing.Union[alpha, Unset] = unset, _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Type[Schema], - ) -> 'AllofWithOneEmptySchema': + ) -> 'TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing': return super().__new__( cls, *args, + alpha=alpha, _configuration=_configuration, **kwargs, ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py index 2976cccbc26..ad09599a5de 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py @@ -15,21 +15,22 @@ from unit_test_api.model.additionalproperties_allows_a_schema_which_should_valid from unit_test_api.model.additionalproperties_are_allowed_by_default import AdditionalpropertiesAreAllowedByDefault from unit_test_api.model.additionalproperties_can_exist_by_itself import AdditionalpropertiesCanExistByItself from unit_test_api.model.additionalproperties_should_not_look_in_applicators import AdditionalpropertiesShouldNotLookInApplicators -from unit_test_api.model.allof import Allof -from unit_test_api.model.allof_combined_with_anyof_oneof import AllofCombinedWithAnyofOneof -from unit_test_api.model.allof_simple_types import AllofSimpleTypes -from unit_test_api.model.allof_with_base_schema import AllofWithBaseSchema -from unit_test_api.model.allof_with_boolean_schemas_all_false import AllofWithBooleanSchemasAllFalse -from unit_test_api.model.allof_with_boolean_schemas_all_true import AllofWithBooleanSchemasAllTrue -from unit_test_api.model.allof_with_boolean_schemas_some_false import AllofWithBooleanSchemasSomeFalse -from unit_test_api.model.allof_with_one_empty_schema import AllofWithOneEmptySchema -from unit_test_api.model.allof_with_the_first_empty_schema import AllofWithTheFirstEmptySchema -from unit_test_api.model.allof_with_the_last_empty_schema import AllofWithTheLastEmptySchema -from unit_test_api.model.allof_with_two_empty_schemas import AllofWithTwoEmptySchemas from unit_test_api.model.array_type_matches_arrays import ArrayTypeMatchesArrays from unit_test_api.model.boolean_type_matches_booleans import BooleanTypeMatchesBooleans +from unit_test_api.model.enum_with0_does_not_match_false import EnumWith0DoesNotMatchFalse +from unit_test_api.model.enum_with1_does_not_match_true import EnumWith1DoesNotMatchTrue +from unit_test_api.model.enum_with_escaped_characters import EnumWithEscapedCharacters +from unit_test_api.model.enum_with_false_does_not_match0 import EnumWithFalseDoesNotMatch0 +from unit_test_api.model.enum_with_true_does_not_match1 import EnumWithTrueDoesNotMatch1 +from unit_test_api.model.enums_in_properties import EnumsInProperties +from unit_test_api.model.heterogeneous_enum_validation import HeterogeneousEnumValidation +from unit_test_api.model.heterogeneous_enum_with_null_validation import HeterogeneousEnumWithNullValidation from unit_test_api.model.integer_type_matches_integers import IntegerTypeMatchesIntegers -from unit_test_api.model.nested_allof_to_check_validation_semantics import NestedAllofToCheckValidationSemantics +from unit_test_api.model.invalid_string_value_for_default import InvalidStringValueForDefault +from unit_test_api.model.invalid_type_for_default import InvalidTypeForDefault +from unit_test_api.model.nul_characters_in_strings import NulCharactersInStrings from unit_test_api.model.null_type_matches_only_the_null_object import NullTypeMatchesOnlyTheNullObject from unit_test_api.model.number_type_matches_numbers import NumberTypeMatchesNumbers +from unit_test_api.model.simple_enum_validation import SimpleEnumValidation from unit_test_api.model.string_type_matches_strings import StringTypeMatchesStrings +from unit_test_api.model.the_default_keyword_does_not_do_anything_if_the_property_is_missing import TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing -- GitLab From 0f594041803eeb3e80210bbb70b5700ca80cef95 Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Sun, 26 Jun 2022 15:15:09 -0700 Subject: [PATCH 08/43] Adds enum tests --- .../openapitools/codegen/DefaultCodegen.java | 13 +- .../codegen/ObjectWithTypeBooleans.java | 4 + .../PythonExperimentalClientCodegen.java | 37 ++ .../payload_renderer.handlebars | 2 +- .../3_0/unit_test_spec/spec_writer.py | 28 +- .../resources/3_0/unit_test_spec/type.yaml | 433 ------------------ .../.openapi-generator/FILES | 45 -- .../python-experimental/README.md | 15 - ...pertiesAllowsASchemaWhichShouldValidate.md | 11 - ...AdditionalpropertiesAreAllowedByDefault.md | 11 - .../AdditionalpropertiesCanExistByItself.md | 9 - ...nalpropertiesShouldNotLookInApplicators.md | 9 - .../docs/ArrayTypeMatchesArrays.md | 8 - .../docs/BooleanTypeMatchesBooleans.md | 8 - .../docs/HeterogeneousEnumValidation.md | 8 - .../HeterogeneousEnumWithNullValidation.md | 8 - .../docs/IntegerTypeMatchesIntegers.md | 8 - .../docs/InvalidStringValueForDefault.md | 10 - .../docs/InvalidTypeForDefault.md | 10 - .../docs/NulCharactersInStrings.md | Bin 310 -> 313 bytes .../docs/NullTypeMatchesOnlyTheNullObject.md | 8 - .../docs/NumberTypeMatchesNumbers.md | 8 - .../docs/StringTypeMatchesStrings.md | 8 - ...DoesNotDoAnythingIfThePropertyIsMissing.md | 10 - ...s_allows_a_schema_which_should_validate.py | 60 --- ...tionalproperties_are_allowed_by_default.py | 37 -- ...dditionalproperties_can_exist_by_itself.py | 43 -- ...operties_should_not_look_in_applicators.py | 36 -- .../test/test_array_type_matches_arrays.py | 71 --- .../test_boolean_type_matches_booleans.py | 90 ---- .../test/test_enum_with_escaped_characters.py | 6 +- .../test_heterogeneous_enum_validation.py | 69 --- ...heterogeneous_enum_with_null_validation.py | 41 -- .../test_integer_type_matches_integers.py | 83 ---- .../test_invalid_string_value_for_default.py | 40 -- .../test/test_invalid_type_for_default.py | 39 -- .../test/test_nul_characters_in_strings.py | Bin 963 -> 966 bytes ..._null_type_matches_only_the_null_object.py | 91 ---- .../test/test_number_type_matches_numbers.py | 82 ---- .../test/test_string_type_matches_strings.py | 83 ---- ..._do_anything_if_the_property_is_missing.py | 49 -- ...s_allows_a_schema_which_should_validate.py | 97 ---- ...tionalproperties_are_allowed_by_default.py | 95 ---- ...dditionalproperties_can_exist_by_itself.py | 91 ---- ...operties_should_not_look_in_applicators.py | 114 ----- .../model/array_type_matches_arrays.py | 77 ---- .../model/boolean_type_matches_booleans.py | 67 --- .../model/heterogeneous_enum_validation.py | 110 ----- ...heterogeneous_enum_with_null_validation.py | 92 ---- .../model/integer_type_matches_integers.py | 67 --- .../model/invalid_string_value_for_default.py | 100 ---- .../model/invalid_type_for_default.py | 92 ---- .../model/nul_characters_in_strings.py | Bin 1688 -> 1694 bytes .../null_type_matches_only_the_null_object.py | 67 --- .../model/number_type_matches_numbers.py | 67 --- .../model/string_type_matches_strings.py | 67 --- ..._do_anything_if_the_property_is_missing.py | 101 ---- .../unit_test_api/models/__init__.py | 15 - 58 files changed, 74 insertions(+), 2876 deletions(-) delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAreAllowedByDefault.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesCanExistByItself.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesShouldNotLookInApplicators.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ArrayTypeMatchesArrays.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/BooleanTypeMatchesBooleans.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/HeterogeneousEnumValidation.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/HeterogeneousEnumWithNullValidation.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/IntegerTypeMatchesIntegers.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidStringValueForDefault.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidTypeForDefault.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NullTypeMatchesOnlyTheNullObject.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NumberTypeMatchesNumbers.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/StringTypeMatchesStrings.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_heterogeneous_enum_validation.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_heterogeneous_enum_with_null_validation.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_string_value_for_default.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_type_for_default.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_allows_a_schema_which_should_validate.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_are_allowed_by_default.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_can_exist_by_itself.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_should_not_look_in_applicators.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/array_type_matches_arrays.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/boolean_type_matches_booleans.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/heterogeneous_enum_validation.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/heterogeneous_enum_with_null_validation.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/integer_type_matches_integers.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_string_value_for_default.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_type_for_default.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/null_type_matches_only_the_null_object.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/number_type_matches_numbers.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/string_type_matches_strings.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/the_default_keyword_does_not_do_anything_if_the_property_is_missing.py diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index 881ea807bec..c265d8b7b80 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -2700,6 +2700,16 @@ public class DefaultCodegen implements CodegenConfig { return specTestCaseName; } + /** + * A method that allows generators to pre-process test example payloads + * This can be useful if one needs to change how values like null in string are represnted + * @param data + * @return + */ + protected Object processTestExampleData(Object data) { + return data; + } + /** * Processes any test cases if they exist in the components.x-test-examples vendor extensions * If they exist then cast them to java class instances and return them back in a map @@ -2722,9 +2732,10 @@ public class DefaultCodegen implements CodegenConfig { for (Entry<String, LinkedHashMap<String, Object>> entry: testNameToTesCase.entrySet()) { LinkedHashMap<String, Object> testExample = (LinkedHashMap<String, Object>) entry.getValue(); String nameInSnakeCase = toTesCaseName(entry.getKey()); + Object data = processTestExampleData(testExample.get("data")); SchemaTestCase testCase = new SchemaTestCase( (String) testExample.getOrDefault("description", ""), - new ObjectWithTypeBooleans(testExample.get("data")), + new ObjectWithTypeBooleans(data), (boolean) testExample.get("valid") ); schemaTestCases.put(nameInSnakeCase, testCase); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/ObjectWithTypeBooleans.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/ObjectWithTypeBooleans.java index 7f450b51c2f..3b6312b44e0 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/ObjectWithTypeBooleans.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/ObjectWithTypeBooleans.java @@ -8,6 +8,7 @@ public class ObjectWithTypeBooleans { public boolean isUnboundedInteger; public boolean isNumber; public boolean isString; + public boolean isMultilineString; public boolean isMap; public boolean isArray; public boolean isBoolean; @@ -25,6 +26,9 @@ public class ObjectWithTypeBooleans { } else if (value instanceof String) { this.isString = true; this.value = value; + if (((String) value).contains("\n") || ((String) value).contains("\r")) { + this.isMultilineString = true; + } } else if (value instanceof LinkedHashMap) { LinkedHashMap<String, Object> castValue = (LinkedHashMap<String, Object>) value; LinkedHashMap<String, ObjectWithTypeBooleans> castMap = new LinkedHashMap<>(); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java index 7a2a9099e23..2b4647fda74 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java @@ -1157,6 +1157,39 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen { return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, specTestCaseName); } + protected Object processTestExampleData(Object value) { + if (value instanceof Integer){ + return value; + } else if (value instanceof Double || value instanceof Float || value instanceof Boolean){ + return value; + } else if (value instanceof String) { + String nullChar = "\0"; + String stringValue = (String) value; + if (stringValue.contains(nullChar)) { + stringValue = stringValue.replace(nullChar, "\\x00"); + } + return stringValue; + } else if (value instanceof LinkedHashMap) { + LinkedHashMap<String, Object> fixedValues = (LinkedHashMap<String, Object>) value; + for (Map.Entry entry: fixedValues.entrySet()) { + String entryKey = (String) entry.getKey(); + Object entryValue = processTestExampleData(entry.getValue()); + fixedValues.put(entryKey, entryValue); + } + return fixedValues; + } else if (value instanceof ArrayList) { + ArrayList<Object> fixedValues = (ArrayList<Object>) value; + for (int i = 0; i < fixedValues.size(); i++) { + Object item = processTestExampleData(fixedValues.get(i)); + fixedValues.add(i, item); + } + return fixedValues; + } else if (value == null) { + return value; + } + return value; + } + /** * Convert OAS Model object to Codegen Model object * We have a custom version of this method so we can: @@ -1403,6 +1436,10 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen { if (in.matches(strPattern)) { return in; } + String nullChar = "\0"; + if (in.contains(nullChar)) { + in = in.replace(nullChar, "\\x00"); + } return "\"" + in + "\""; } diff --git a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars index 1b5340b29f6..ab5a0d5eec5 100644 --- a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars +++ b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars @@ -19,4 +19,4 @@ True{{else}} False{{/if}}{{/if}}{{#if isNull}} None{{/if}}{{#if isString}} -"{{value}}"{{/if}}{{/if}}{{/if}} \ No newline at end of file +{{#if isMultilineString}}"""{{{value}}}"""{{else}}"{{{value}}}"{{/if}}{{/if}}{{/if}}{{/if}} \ No newline at end of file diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index 3ec529990f5..aadcb8e13ce 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -84,6 +84,7 @@ class ExclusionReason: v303_does_not_support_contains = 'v3.0.3 does not support the contains keyword' v303_does_not_support_definitions = 'v3.0.3 does not support the definitions keyword' v303_does_not_support_dependencies = 'v3.0.3 does not support the dependencies keyword' + swagger_parser_enum_type_bug = "swagger-parser has a bug where schema type is incorrectly set for an enum, https://github.com/swagger-api/swagger-parser/issues/1761" json_schema_test_draft = 'draft6' FILEPATH_TO_EXCLUDED_CASE_AND_REASON = { @@ -94,6 +95,11 @@ FILEPATH_TO_EXCLUDED_CASE_AND_REASON = { 'type: array, object or null': ExclusionReason.v303_does_not_support_array_of_types, 'array type matches arrays': ExclusionReason.v303_requires_array_have_items, }, + (json_schema_test_draft, 'enum.json'): { + 'heterogeneous enum validation': ExclusionReason.swagger_parser_enum_type_bug, + 'heterogeneous enum-with-null validation': ExclusionReason.swagger_parser_enum_type_bug, + }, + (json_schema_test_draft, 'additionalProperties.json'): { 'non-ASCII pattern with additionalProperties': ExclusionReason.v303_does_not_support_patternProperties, 'additionalProperties being false does not allow other properties': ExclusionReason.v303_does_not_support_patternProperties, @@ -111,17 +117,17 @@ FILEPATH_TO_EXCLUDE_REASON = { openapi_additions = 'openapi_additions' JSON_SCHEMA_TEST_FILE_TO_FOLDERS = { - 'type.json': (json_schema_test_draft, openapi_additions), - 'additionalItems.json': (json_schema_test_draft,), - 'additionalProperties.json': (json_schema_test_draft,), -# 'allOf.json': (json_schema_test_draft,), -# 'anyOf.json': (json_schema_test_draft,), - 'boolean_schema.json': (json_schema_test_draft,), - 'const.json': (json_schema_test_draft,), - 'contains.json': (json_schema_test_draft,), - 'default.json': (json_schema_test_draft,), - 'definitions.json': (json_schema_test_draft,), - 'dependencies.json': (json_schema_test_draft,), +# 'type.json': (json_schema_test_draft, openapi_additions), +# 'additionalItems.json': (json_schema_test_draft,), +# 'additionalProperties.json': (json_schema_test_draft,), +# 'allOf.json': (json_schema_test_draft,), # activate later after fixing composition processing +# 'anyOf.json': (json_schema_test_draft,), # activate later after fixing composition processing +# 'boolean_schema.json': (json_schema_test_draft,), +# 'const.json': (json_schema_test_draft,), +# 'contains.json': (json_schema_test_draft,), +# 'default.json': (json_schema_test_draft,), +# 'definitions.json': (json_schema_test_draft,), +# 'dependencies.json': (json_schema_test_draft,), 'enum.json': (json_schema_test_draft,), } diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml index 71fbf8a263b..060a2926c05 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml @@ -7,74 +7,11 @@ info: paths: {} components: schemas: - IntegerTypeMatchesIntegers: - type: integer - NumberTypeMatchesNumbers: - type: number - StringTypeMatchesStrings: - type: string - ObjectTypeMatchesObjects: - type: object - BooleanTypeMatchesBooleans: - type: boolean - NullTypeMatchesOnlyTheNullObject: - type: 'null' - ArrayTypeMatchesArrays: - type: array - items: {} - AdditionalpropertiesAllowsASchemaWhichShouldValidate: - properties: - foo: {} - bar: {} - additionalProperties: - type: boolean - AdditionalpropertiesCanExistByItself: - additionalProperties: - type: boolean - AdditionalpropertiesAreAllowedByDefault: - properties: - foo: {} - bar: {} - AdditionalpropertiesShouldNotLookInApplicators: - allOf: - - properties: - foo: {} - additionalProperties: - type: boolean - InvalidTypeForDefault: - properties: - foo: - type: integer - default: [] - InvalidStringValueForDefault: - properties: - bar: - type: string - minLength: 4 - default: bad - TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing: - type: object - properties: - alpha: - type: number - maximum: 3 - default: 5 SimpleEnumValidation: enum: - 1 - 2 - 3 - HeterogeneousEnumValidation: - enum: - - 6 - - foo - - [] - - true - - foo: 12 - HeterogeneousEnumWithNullValidation: - enum: - - 6 - - null EnumsInProperties: type: object properties: @@ -108,338 +45,6 @@ components: enum: - "hello\0there" x-schema-test-examples: - IntegerTypeMatchesIntegers: - AnIntegerIsAnInteger: - description: an integer is an integer - data: 1 - valid: true - AFloatWithZeroFractionalPartIsAnInteger: - description: a float with zero fractional part is an integer - data: 1.0 - valid: true - AFloatIsNotAnInteger: - description: a float is not an integer - data: 1.1 - valid: false - AStringIsNotAnInteger: - description: a string is not an integer - data: foo - valid: false - AStringIsStillNotAnIntegerEvenIfItLooksLikeOne: - description: a string is still not an integer, even if it looks like one - data: '1' - valid: false - AnObjectIsNotAnInteger: - description: an object is not an integer - data: {} - valid: false - AnArrayIsNotAnInteger: - description: an array is not an integer - data: [] - valid: false - ABooleanIsNotAnInteger: - description: a boolean is not an integer - data: true - valid: false - NullIsNotAnInteger: - description: null is not an integer - data: null - valid: false - NumberTypeMatchesNumbers: - AnIntegerIsANumber: - description: an integer is a number - data: 1 - valid: true - AFloatWithZeroFractionalPartIsANumberAndAnInteger: - description: a float with zero fractional part is a number (and an integer) - data: 1.0 - valid: true - AFloatIsANumber: - description: a float is a number - data: 1.1 - valid: true - AStringIsNotANumber: - description: a string is not a number - data: foo - valid: false - AStringIsStillNotANumberEvenIfItLooksLikeOne: - description: a string is still not a number, even if it looks like one - data: '1' - valid: false - AnObjectIsNotANumber: - description: an object is not a number - data: {} - valid: false - AnArrayIsNotANumber: - description: an array is not a number - data: [] - valid: false - ABooleanIsNotANumber: - description: a boolean is not a number - data: true - valid: false - NullIsNotANumber: - description: null is not a number - data: null - valid: false - StringTypeMatchesStrings: - 1IsNotAString: - description: 1 is not a string - data: 1 - valid: false - AFloatIsNotAString: - description: a float is not a string - data: 1.1 - valid: false - AStringIsAString: - description: a string is a string - data: foo - valid: true - AStringIsStillAStringEvenIfItLooksLikeANumber: - description: a string is still a string, even if it looks like a number - data: '1' - valid: true - AnEmptyStringIsStillAString: - description: an empty string is still a string - data: '' - valid: true - AnObjectIsNotAString: - description: an object is not a string - data: {} - valid: false - AnArrayIsNotAString: - description: an array is not a string - data: [] - valid: false - ABooleanIsNotAString: - description: a boolean is not a string - data: true - valid: false - NullIsNotAString: - description: null is not a string - data: null - valid: false - ObjectTypeMatchesObjects: - AnIntegerIsNotAnObject: - description: an integer is not an object - data: 1 - valid: false - AFloatIsNotAnObject: - description: a float is not an object - data: 1.1 - valid: false - AStringIsNotAnObject: - description: a string is not an object - data: foo - valid: false - AnObjectIsAnObject: - description: an object is an object - data: {} - valid: true - AnArrayIsNotAnObject: - description: an array is not an object - data: [] - valid: false - ABooleanIsNotAnObject: - description: a boolean is not an object - data: true - valid: false - NullIsNotAnObject: - description: null is not an object - data: null - valid: false - BooleanTypeMatchesBooleans: - AnIntegerIsNotABoolean: - description: an integer is not a boolean - data: 1 - valid: false - ZeroIsNotABoolean: - description: zero is not a boolean - data: 0 - valid: false - AFloatIsNotABoolean: - description: a float is not a boolean - data: 1.1 - valid: false - AStringIsNotABoolean: - description: a string is not a boolean - data: foo - valid: false - AnEmptyStringIsNotABoolean: - description: an empty string is not a boolean - data: '' - valid: false - AnObjectIsNotABoolean: - description: an object is not a boolean - data: {} - valid: false - AnArrayIsNotABoolean: - description: an array is not a boolean - data: [] - valid: false - TrueIsABoolean: - description: true is a boolean - data: true - valid: true - FalseIsABoolean: - description: false is a boolean - data: false - valid: true - NullIsNotABoolean: - description: null is not a boolean - data: null - valid: false - NullTypeMatchesOnlyTheNullObject: - AnIntegerIsNotNull: - description: an integer is not null - data: 1 - valid: false - AFloatIsNotNull: - description: a float is not null - data: 1.1 - valid: false - ZeroIsNotNull: - description: zero is not null - data: 0 - valid: false - AStringIsNotNull: - description: a string is not null - data: foo - valid: false - AnEmptyStringIsNotNull: - description: an empty string is not null - data: '' - valid: false - AnObjectIsNotNull: - description: an object is not null - data: {} - valid: false - AnArrayIsNotNull: - description: an array is not null - data: [] - valid: false - TrueIsNotNull: - description: true is not null - data: true - valid: false - FalseIsNotNull: - description: false is not null - data: false - valid: false - NullIsNull: - description: null is null - data: null - valid: true - ArrayTypeMatchesArrays: - AnIntegerIsNotAnArray: - description: an integer is not an array - data: 1 - valid: false - AFloatIsNotAnArray: - description: a float is not an array - data: 1.1 - valid: false - AStringIsNotAnArray: - description: a string is not an array - data: foo - valid: false - AnObjectIsNotAnArray: - description: an object is not an array - data: {} - valid: false - AnArrayIsAnArray: - description: an array is an array - data: [] - valid: true - ABooleanIsNotAnArray: - description: a boolean is not an array - data: true - valid: false - NullIsNotAnArray: - description: null is not an array - data: null - valid: false - AdditionalpropertiesAllowsASchemaWhichShouldValidate: - NoAdditionalPropertiesIsValid: - description: no additional properties is valid - data: - foo: 1 - valid: true - AnAdditionalValidPropertyIsValid: - description: an additional valid property is valid - data: - foo: 1 - bar: 2 - quux: true - valid: true - AnAdditionalInvalidPropertyIsInvalid: - description: an additional invalid property is invalid - data: - foo: 1 - bar: 2 - quux: 12 - valid: false - AdditionalpropertiesCanExistByItself: - AnAdditionalValidPropertyIsValid: - description: an additional valid property is valid - data: - foo: true - valid: true - AnAdditionalInvalidPropertyIsInvalid: - description: an additional invalid property is invalid - data: - foo: 1 - valid: false - AdditionalpropertiesAreAllowedByDefault: - AdditionalPropertiesAreAllowed: - description: additional properties are allowed - data: - foo: 1 - bar: 2 - quux: true - valid: true - AdditionalpropertiesShouldNotLookInApplicators: - PropertiesDefinedInAllofAreNotExamined: - description: properties defined in allOf are not examined - data: - foo: 1 - bar: true - valid: false - InvalidTypeForDefault: - ValidWhenPropertyIsSpecified: - description: valid when property is specified - data: - foo: 13 - valid: true - StillValidWhenTheInvalidDefaultIsUsed: - description: still valid when the invalid default is used - data: {} - valid: true - InvalidStringValueForDefault: - ValidWhenPropertyIsSpecified: - description: valid when property is specified - data: - bar: good - valid: true - StillValidWhenTheInvalidDefaultIsUsed: - description: still valid when the invalid default is used - data: {} - valid: true - TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing: - AnExplicitPropertyValueIsCheckedAgainstMaximumPassing: - description: an explicit property value is checked against maximum (passing) - data: - alpha: 1 - valid: true - AnExplicitPropertyValueIsCheckedAgainstMaximumFailing: - description: an explicit property value is checked against maximum (failing) - data: - alpha: 5 - valid: false - MissingPropertiesAreNotFilledInWithTheDefault: - description: missing properties are not filled in with the default - data: {} - valid: true SimpleEnumValidation: OneOfTheEnumIsValid: description: one of the enum is valid @@ -449,44 +54,6 @@ components: description: something else is invalid data: 4 valid: false - HeterogeneousEnumValidation: - OneOfTheEnumIsValid: - description: one of the enum is valid - data: [] - valid: true - SomethingElseIsInvalid: - description: something else is invalid - data: null - valid: false - ObjectsAreDeepCompared: - description: objects are deep compared - data: - foo: false - valid: false - ValidObjectMatches: - description: valid object matches - data: - foo: 12 - valid: true - ExtraPropertiesInObjectIsInvalid: - description: extra properties in object is invalid - data: - foo: 12 - boo: 42 - valid: false - HeterogeneousEnumWithNullValidation: - NullIsValid: - description: null is valid - data: null - valid: true - NumberIsValid: - description: number is valid - data: 6 - valid: true - SomethingElseIsInvalid: - description: something else is invalid - data: test - valid: false EnumsInProperties: BothPropertiesAreValid: description: both properties are valid diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index e5b6c039728..877d29dd9f6 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -2,58 +2,28 @@ .gitlab-ci.yml .travis.yml README.md -docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md -docs/AdditionalpropertiesAreAllowedByDefault.md -docs/AdditionalpropertiesCanExistByItself.md -docs/AdditionalpropertiesShouldNotLookInApplicators.md -docs/ArrayTypeMatchesArrays.md -docs/BooleanTypeMatchesBooleans.md docs/EnumWith0DoesNotMatchFalse.md docs/EnumWith1DoesNotMatchTrue.md docs/EnumWithEscapedCharacters.md docs/EnumWithFalseDoesNotMatch0.md docs/EnumWithTrueDoesNotMatch1.md docs/EnumsInProperties.md -docs/HeterogeneousEnumValidation.md -docs/HeterogeneousEnumWithNullValidation.md -docs/IntegerTypeMatchesIntegers.md -docs/InvalidStringValueForDefault.md -docs/InvalidTypeForDefault.md docs/NulCharactersInStrings.md -docs/NullTypeMatchesOnlyTheNullObject.md -docs/NumberTypeMatchesNumbers.md docs/SimpleEnumValidation.md -docs/StringTypeMatchesStrings.md -docs/TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md git_push.sh requirements.txt setup.cfg setup.py test-requirements.txt test/__init__.py -test/test_additionalproperties_allows_a_schema_which_should_validate.py -test/test_additionalproperties_are_allowed_by_default.py -test/test_additionalproperties_can_exist_by_itself.py -test/test_additionalproperties_should_not_look_in_applicators.py -test/test_array_type_matches_arrays.py -test/test_boolean_type_matches_booleans.py test/test_enum_with0_does_not_match_false.py test/test_enum_with1_does_not_match_true.py test/test_enum_with_escaped_characters.py test/test_enum_with_false_does_not_match0.py test/test_enum_with_true_does_not_match1.py test/test_enums_in_properties.py -test/test_heterogeneous_enum_validation.py -test/test_heterogeneous_enum_with_null_validation.py -test/test_integer_type_matches_integers.py -test/test_invalid_string_value_for_default.py -test/test_invalid_type_for_default.py test/test_nul_characters_in_strings.py -test/test_null_type_matches_only_the_null_object.py -test/test_number_type_matches_numbers.py test/test_simple_enum_validation.py -test/test_string_type_matches_strings.py -test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py tox.ini unit_test_api/__init__.py unit_test_api/api/__init__.py @@ -62,29 +32,14 @@ unit_test_api/apis/__init__.py unit_test_api/configuration.py unit_test_api/exceptions.py unit_test_api/model/__init__.py -unit_test_api/model/additionalproperties_allows_a_schema_which_should_validate.py -unit_test_api/model/additionalproperties_are_allowed_by_default.py -unit_test_api/model/additionalproperties_can_exist_by_itself.py -unit_test_api/model/additionalproperties_should_not_look_in_applicators.py -unit_test_api/model/array_type_matches_arrays.py -unit_test_api/model/boolean_type_matches_booleans.py unit_test_api/model/enum_with0_does_not_match_false.py unit_test_api/model/enum_with1_does_not_match_true.py unit_test_api/model/enum_with_escaped_characters.py unit_test_api/model/enum_with_false_does_not_match0.py unit_test_api/model/enum_with_true_does_not_match1.py unit_test_api/model/enums_in_properties.py -unit_test_api/model/heterogeneous_enum_validation.py -unit_test_api/model/heterogeneous_enum_with_null_validation.py -unit_test_api/model/integer_type_matches_integers.py -unit_test_api/model/invalid_string_value_for_default.py -unit_test_api/model/invalid_type_for_default.py unit_test_api/model/nul_characters_in_strings.py -unit_test_api/model/null_type_matches_only_the_null_object.py -unit_test_api/model/number_type_matches_numbers.py unit_test_api/model/simple_enum_validation.py -unit_test_api/model/string_type_matches_strings.py -unit_test_api/model/the_default_keyword_does_not_do_anything_if_the_property_is_missing.py unit_test_api/models/__init__.py unit_test_api/rest.py unit_test_api/schemas.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md index 2f3bf8ce284..1a7f5d04161 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md @@ -62,29 +62,14 @@ Class | Method | HTTP request | Description ## Documentation For Models - - [AdditionalpropertiesAllowsASchemaWhichShouldValidate](docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md) - - [AdditionalpropertiesAreAllowedByDefault](docs/AdditionalpropertiesAreAllowedByDefault.md) - - [AdditionalpropertiesCanExistByItself](docs/AdditionalpropertiesCanExistByItself.md) - - [AdditionalpropertiesShouldNotLookInApplicators](docs/AdditionalpropertiesShouldNotLookInApplicators.md) - - [ArrayTypeMatchesArrays](docs/ArrayTypeMatchesArrays.md) - - [BooleanTypeMatchesBooleans](docs/BooleanTypeMatchesBooleans.md) - [EnumWith0DoesNotMatchFalse](docs/EnumWith0DoesNotMatchFalse.md) - [EnumWith1DoesNotMatchTrue](docs/EnumWith1DoesNotMatchTrue.md) - [EnumWithEscapedCharacters](docs/EnumWithEscapedCharacters.md) - [EnumWithFalseDoesNotMatch0](docs/EnumWithFalseDoesNotMatch0.md) - [EnumWithTrueDoesNotMatch1](docs/EnumWithTrueDoesNotMatch1.md) - [EnumsInProperties](docs/EnumsInProperties.md) - - [HeterogeneousEnumValidation](docs/HeterogeneousEnumValidation.md) - - [HeterogeneousEnumWithNullValidation](docs/HeterogeneousEnumWithNullValidation.md) - - [IntegerTypeMatchesIntegers](docs/IntegerTypeMatchesIntegers.md) - - [InvalidStringValueForDefault](docs/InvalidStringValueForDefault.md) - - [InvalidTypeForDefault](docs/InvalidTypeForDefault.md) - [NulCharactersInStrings](docs/NulCharactersInStrings.md) - - [NullTypeMatchesOnlyTheNullObject](docs/NullTypeMatchesOnlyTheNullObject.md) - - [NumberTypeMatchesNumbers](docs/NumberTypeMatchesNumbers.md) - [SimpleEnumValidation](docs/SimpleEnumValidation.md) - - [StringTypeMatchesStrings](docs/StringTypeMatchesStrings.md) - - [TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing](docs/TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md) ## Documentation For Authorization diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md deleted file mode 100644 index d9981bf45a7..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md +++ /dev/null @@ -1,11 +0,0 @@ -# AdditionalpropertiesAllowsASchemaWhichShouldValidate - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**foo** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] -**bar** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] -**any string name** | **bool** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAreAllowedByDefault.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAreAllowedByDefault.md deleted file mode 100644 index d5e7d2747ee..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAreAllowedByDefault.md +++ /dev/null @@ -1,11 +0,0 @@ -# AdditionalpropertiesAreAllowedByDefault - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**foo** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] -**bar** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesCanExistByItself.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesCanExistByItself.md deleted file mode 100644 index 72b091b888a..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesCanExistByItself.md +++ /dev/null @@ -1,9 +0,0 @@ -# AdditionalpropertiesCanExistByItself - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesShouldNotLookInApplicators.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesShouldNotLookInApplicators.md deleted file mode 100644 index 31efeb974b1..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesShouldNotLookInApplicators.md +++ /dev/null @@ -1,9 +0,0 @@ -# AdditionalpropertiesShouldNotLookInApplicators - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ArrayTypeMatchesArrays.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ArrayTypeMatchesArrays.md deleted file mode 100644 index bf72f2c35bc..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ArrayTypeMatchesArrays.md +++ /dev/null @@ -1,8 +0,0 @@ -# ArrayTypeMatchesArrays - -Type | Description | Notes -------------- | ------------- | ------------- -**[bool, date, datetime, dict, float, int, list, str, none_type]** | | - -[[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/3_0_3_unit_test/python-experimental/docs/BooleanTypeMatchesBooleans.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/BooleanTypeMatchesBooleans.md deleted file mode 100644 index fa68a60fd2b..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/BooleanTypeMatchesBooleans.md +++ /dev/null @@ -1,8 +0,0 @@ -# BooleanTypeMatchesBooleans - -Type | Description | Notes -------------- | ------------- | ------------- -**bool** | | - -[[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/3_0_3_unit_test/python-experimental/docs/HeterogeneousEnumValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/HeterogeneousEnumValidation.md deleted file mode 100644 index c3e14087519..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/HeterogeneousEnumValidation.md +++ /dev/null @@ -1,8 +0,0 @@ -# HeterogeneousEnumValidation - -Type | Description | Notes -------------- | ------------- | ------------- -**float** | | must be one of [6, foo, [], true, {"foo":12}, ] - -[[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/3_0_3_unit_test/python-experimental/docs/HeterogeneousEnumWithNullValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/HeterogeneousEnumWithNullValidation.md deleted file mode 100644 index bfaacb346c0..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/HeterogeneousEnumWithNullValidation.md +++ /dev/null @@ -1,8 +0,0 @@ -# HeterogeneousEnumWithNullValidation - -Type | Description | Notes -------------- | ------------- | ------------- -**float** | | must be one of [6, null, ] - -[[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/3_0_3_unit_test/python-experimental/docs/IntegerTypeMatchesIntegers.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/IntegerTypeMatchesIntegers.md deleted file mode 100644 index 141e17fd9ae..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/IntegerTypeMatchesIntegers.md +++ /dev/null @@ -1,8 +0,0 @@ -# IntegerTypeMatchesIntegers - -Type | Description | Notes -------------- | ------------- | ------------- -**int** | | - -[[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/3_0_3_unit_test/python-experimental/docs/InvalidStringValueForDefault.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidStringValueForDefault.md deleted file mode 100644 index ae129438132..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidStringValueForDefault.md +++ /dev/null @@ -1,10 +0,0 @@ -# InvalidStringValueForDefault - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**bar** | **str** | | [optional] if omitted the server will use the default value of "bad" -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidTypeForDefault.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidTypeForDefault.md deleted file mode 100644 index a251e2dc515..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidTypeForDefault.md +++ /dev/null @@ -1,10 +0,0 @@ -# InvalidTypeForDefault - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**foo** | **int** | | [optional] -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NulCharactersInStrings.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NulCharactersInStrings.md index 762e662d872c71c292a4ba7b620d99d62b4e630b..d90b761591ae0f0d61b4f423cdc1ca73f9a697e3 100644 GIT binary patch delta 14 VcmdnSw3BH<J4;N3fx*O%bpR*Q1&ROw delta 11 ScmdnVw2f&(J0ruy?sWhe9t2hZ diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NullTypeMatchesOnlyTheNullObject.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NullTypeMatchesOnlyTheNullObject.md deleted file mode 100644 index 54a530d1d33..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NullTypeMatchesOnlyTheNullObject.md +++ /dev/null @@ -1,8 +0,0 @@ -# NullTypeMatchesOnlyTheNullObject - -Type | Description | Notes -------------- | ------------- | ------------- -**none_type** | | - -[[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/3_0_3_unit_test/python-experimental/docs/NumberTypeMatchesNumbers.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NumberTypeMatchesNumbers.md deleted file mode 100644 index 8348aeef2bc..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NumberTypeMatchesNumbers.md +++ /dev/null @@ -1,8 +0,0 @@ -# NumberTypeMatchesNumbers - -Type | Description | Notes -------------- | ------------- | ------------- -**float** | | - -[[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/3_0_3_unit_test/python-experimental/docs/StringTypeMatchesStrings.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/StringTypeMatchesStrings.md deleted file mode 100644 index cd1125671ab..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/StringTypeMatchesStrings.md +++ /dev/null @@ -1,8 +0,0 @@ -# StringTypeMatchesStrings - -Type | Description | Notes -------------- | ------------- | ------------- -**str** | | - -[[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/3_0_3_unit_test/python-experimental/docs/TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md deleted file mode 100644 index 61162c71aa0..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md +++ /dev/null @@ -1,10 +0,0 @@ -# TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**alpha** | **int, float** | | [optional] if omitted the server will use the default value of 5 -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py deleted file mode 100644 index 3efa9239a1b..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py +++ /dev/null @@ -1,60 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.additionalproperties_allows_a_schema_which_should_validate import AdditionalpropertiesAllowsASchemaWhichShouldValidate - - -class TestAdditionalpropertiesAllowsASchemaWhichShouldValidate(unittest.TestCase): - """AdditionalpropertiesAllowsASchemaWhichShouldValidate unit test stubs""" - - def test_no_additional_properties_is_valid_passes(self): - # no additional properties is valid - AdditionalpropertiesAllowsASchemaWhichShouldValidate( - **{ - "foo": - 1, - } - ) - - def test_an_additional_invalid_property_is_invalid_fails(self): - # an additional invalid property is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - AdditionalpropertiesAllowsASchemaWhichShouldValidate( - **{ - "foo": - 1, - "bar": - 2, - "quux": - 12, - } - ) - - def test_an_additional_valid_property_is_valid_passes(self): - # an additional valid property is valid - AdditionalpropertiesAllowsASchemaWhichShouldValidate( - **{ - "foo": - 1, - "bar": - 2, - "quux": - - True, - } - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py deleted file mode 100644 index 6a87df188f9..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py +++ /dev/null @@ -1,37 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.additionalproperties_are_allowed_by_default import AdditionalpropertiesAreAllowedByDefault - - -class TestAdditionalpropertiesAreAllowedByDefault(unittest.TestCase): - """AdditionalpropertiesAreAllowedByDefault unit test stubs""" - - def test_additional_properties_are_allowed_passes(self): - # additional properties are allowed - AdditionalpropertiesAreAllowedByDefault( - **{ - "foo": - 1, - "bar": - 2, - "quux": - - True, - } - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py deleted file mode 100644 index 968b9449901..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py +++ /dev/null @@ -1,43 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.additionalproperties_can_exist_by_itself import AdditionalpropertiesCanExistByItself - - -class TestAdditionalpropertiesCanExistByItself(unittest.TestCase): - """AdditionalpropertiesCanExistByItself unit test stubs""" - - def test_an_additional_invalid_property_is_invalid_fails(self): - # an additional invalid property is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - AdditionalpropertiesCanExistByItself( - **{ - "foo": - 1, - } - ) - - def test_an_additional_valid_property_is_valid_passes(self): - # an additional valid property is valid - AdditionalpropertiesCanExistByItself( - **{ - "foo": - - True, - } - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py deleted file mode 100644 index e46111271d3..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py +++ /dev/null @@ -1,36 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.additionalproperties_should_not_look_in_applicators import AdditionalpropertiesShouldNotLookInApplicators - - -class TestAdditionalpropertiesShouldNotLookInApplicators(unittest.TestCase): - """AdditionalpropertiesShouldNotLookInApplicators unit test stubs""" - - def test_properties_defined_in_allof_are_not_examined_fails(self): - # properties defined in allOf are not examined - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - AdditionalpropertiesShouldNotLookInApplicators( - **{ - "foo": - 1, - "bar": - - True, - } - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py deleted file mode 100644 index 695efa692be..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py +++ /dev/null @@ -1,71 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.array_type_matches_arrays import ArrayTypeMatchesArrays - - -class TestArrayTypeMatchesArrays(unittest.TestCase): - """ArrayTypeMatchesArrays unit test stubs""" - - def test_a_float_is_not_an_array_fails(self): - # a float is not an array - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - ArrayTypeMatchesArrays( - 1.1 ) - - def test_a_boolean_is_not_an_array_fails(self): - # a boolean is not an array - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - ArrayTypeMatchesArrays( - - True ) - - def test_null_is_not_an_array_fails(self): - # null is not an array - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - ArrayTypeMatchesArrays( - - None ) - - def test_an_object_is_not_an_array_fails(self): - # an object is not an array - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - ArrayTypeMatchesArrays( - { - } - ) - - def test_a_string_is_not_an_array_fails(self): - # a string is not an array - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - ArrayTypeMatchesArrays( - - "foo" ) - - def test_an_array_is_an_array_passes(self): - # an array is an array - ArrayTypeMatchesArrays( - [ - ] - ) - - def test_an_integer_is_not_an_array_fails(self): - # an integer is not an array - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - ArrayTypeMatchesArrays( - 1 ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py deleted file mode 100644 index 3ce46c5e25b..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py +++ /dev/null @@ -1,90 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.boolean_type_matches_booleans import BooleanTypeMatchesBooleans - - -class TestBooleanTypeMatchesBooleans(unittest.TestCase): - """BooleanTypeMatchesBooleans unit test stubs""" - - def test_an_empty_string_is_not_a_boolean_fails(self): - # an empty string is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - BooleanTypeMatchesBooleans( - - "" ) - - def test_a_float_is_not_a_boolean_fails(self): - # a float is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - BooleanTypeMatchesBooleans( - 1.1 ) - - def test_null_is_not_a_boolean_fails(self): - # null is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - BooleanTypeMatchesBooleans( - - None ) - - def test_zero_is_not_a_boolean_fails(self): - # zero is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - BooleanTypeMatchesBooleans( - 0 ) - - def test_an_array_is_not_a_boolean_fails(self): - # an array is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - BooleanTypeMatchesBooleans( - [ - ] - ) - - def test_a_string_is_not_a_boolean_fails(self): - # a string is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - BooleanTypeMatchesBooleans( - - "foo" ) - - def test_false_is_a_boolean_passes(self): - # false is a boolean - BooleanTypeMatchesBooleans( - - False ) - - def test_an_integer_is_not_a_boolean_fails(self): - # an integer is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - BooleanTypeMatchesBooleans( - 1 ) - - def test_true_is_a_boolean_passes(self): - # true is a boolean - BooleanTypeMatchesBooleans( - - True ) - - def test_an_object_is_not_a_boolean_fails(self): - # an object is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - BooleanTypeMatchesBooleans( - { - } - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_escaped_characters.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_escaped_characters.py index 539f8ae21f3..0ac6333d802 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_escaped_characters.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_escaped_characters.py @@ -22,14 +22,14 @@ class TestEnumWithEscapedCharacters(unittest.TestCase): # member 2 is valid EnumWithEscapedCharacters( - "foo bar" ) + """foo bar""" ) def test_member1_is_valid_passes(self): # member 1 is valid EnumWithEscapedCharacters( - "foo -bar" ) + """foo +bar""" ) def test_another_string_is_invalid_fails(self): # another string is invalid diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_heterogeneous_enum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_heterogeneous_enum_validation.py deleted file mode 100644 index 8d32aa4554d..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_heterogeneous_enum_validation.py +++ /dev/null @@ -1,69 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.heterogeneous_enum_validation import HeterogeneousEnumValidation - - -class TestHeterogeneousEnumValidation(unittest.TestCase): - """HeterogeneousEnumValidation unit test stubs""" - - def test_extra_properties_in_object_is_invalid_fails(self): - # extra properties in object is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - HeterogeneousEnumValidation( - **{ - "foo": - 12, - "boo": - 42, - } - ) - - def test_something_else_is_invalid_fails(self): - # something else is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - HeterogeneousEnumValidation( - - None ) - - def test_objects_are_deep_compared_fails(self): - # objects are deep compared - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - HeterogeneousEnumValidation( - **{ - "foo": - - False, - } - ) - - def test_one_of_the_enum_is_valid_passes(self): - # one of the enum is valid - HeterogeneousEnumValidation( - [ - ] - ) - - def test_valid_object_matches_passes(self): - # valid object matches - HeterogeneousEnumValidation( - **{ - "foo": - 12, - } - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_heterogeneous_enum_with_null_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_heterogeneous_enum_with_null_validation.py deleted file mode 100644 index b486826a038..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_heterogeneous_enum_with_null_validation.py +++ /dev/null @@ -1,41 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.heterogeneous_enum_with_null_validation import HeterogeneousEnumWithNullValidation - - -class TestHeterogeneousEnumWithNullValidation(unittest.TestCase): - """HeterogeneousEnumWithNullValidation unit test stubs""" - - def test_null_is_valid_passes(self): - # null is valid - HeterogeneousEnumWithNullValidation( - - None ) - - def test_number_is_valid_passes(self): - # number is valid - HeterogeneousEnumWithNullValidation( - 6 ) - - def test_something_else_is_invalid_fails(self): - # something else is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - HeterogeneousEnumWithNullValidation( - - "test" ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py deleted file mode 100644 index 4478fe8a01f..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py +++ /dev/null @@ -1,83 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.integer_type_matches_integers import IntegerTypeMatchesIntegers - - -class TestIntegerTypeMatchesIntegers(unittest.TestCase): - """IntegerTypeMatchesIntegers unit test stubs""" - - def test_an_object_is_not_an_integer_fails(self): - # an object is not an integer - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - IntegerTypeMatchesIntegers( - { - } - ) - - def test_a_string_is_not_an_integer_fails(self): - # a string is not an integer - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - IntegerTypeMatchesIntegers( - - "foo" ) - - def test_null_is_not_an_integer_fails(self): - # null is not an integer - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - IntegerTypeMatchesIntegers( - - None ) - - def test_a_float_with_zero_fractional_part_is_an_integer_passes(self): - # a float with zero fractional part is an integer - IntegerTypeMatchesIntegers( - 1.0 ) - - def test_a_float_is_not_an_integer_fails(self): - # a float is not an integer - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - IntegerTypeMatchesIntegers( - 1.1 ) - - def test_a_boolean_is_not_an_integer_fails(self): - # a boolean is not an integer - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - IntegerTypeMatchesIntegers( - - True ) - - def test_an_integer_is_an_integer_passes(self): - # an integer is an integer - IntegerTypeMatchesIntegers( - 1 ) - - def test_a_string_is_still_not_an_integer_even_if_it_looks_like_one_fails(self): - # a string is still not an integer, even if it looks like one - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - IntegerTypeMatchesIntegers( - - "1" ) - - def test_an_array_is_not_an_integer_fails(self): - # an array is not an integer - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - IntegerTypeMatchesIntegers( - [ - ] - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_string_value_for_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_string_value_for_default.py deleted file mode 100644 index 9d375f8edfb..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_string_value_for_default.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.invalid_string_value_for_default import InvalidStringValueForDefault - - -class TestInvalidStringValueForDefault(unittest.TestCase): - """InvalidStringValueForDefault unit test stubs""" - - def test_valid_when_property_is_specified_passes(self): - # valid when property is specified - InvalidStringValueForDefault( - **{ - "bar": - - "good", - } - ) - - def test_still_valid_when_the_invalid_default_is_used_passes(self): - # still valid when the invalid default is used - InvalidStringValueForDefault( - { - } - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_type_for_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_type_for_default.py deleted file mode 100644 index 669b1754510..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_type_for_default.py +++ /dev/null @@ -1,39 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.invalid_type_for_default import InvalidTypeForDefault - - -class TestInvalidTypeForDefault(unittest.TestCase): - """InvalidTypeForDefault unit test stubs""" - - def test_valid_when_property_is_specified_passes(self): - # valid when property is specified - InvalidTypeForDefault( - **{ - "foo": - 13, - } - ) - - def test_still_valid_when_the_invalid_default_is_used_passes(self): - # still valid when the invalid default is used - InvalidTypeForDefault( - { - } - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nul_characters_in_strings.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nul_characters_in_strings.py index 43f8d9d7ae4e8dab44ec155558143e34fc0660d1..13e23eca482cd960c322b7b87d1d1854066c5bc5 100644 GIT binary patch delta 17 YcmX@ievExXIulDwg@M8545nyC05-Y>VgLXD delta 14 VcmX@cewckjIuj$q=4_^DMgS!&1TFvo diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py deleted file mode 100644 index 3db8e2c3c56..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py +++ /dev/null @@ -1,91 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.null_type_matches_only_the_null_object import NullTypeMatchesOnlyTheNullObject - - -class TestNullTypeMatchesOnlyTheNullObject(unittest.TestCase): - """NullTypeMatchesOnlyTheNullObject unit test stubs""" - - def test_a_float_is_not_null_fails(self): - # a float is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NullTypeMatchesOnlyTheNullObject( - 1.1 ) - - def test_an_object_is_not_null_fails(self): - # an object is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NullTypeMatchesOnlyTheNullObject( - { - } - ) - - def test_false_is_not_null_fails(self): - # false is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NullTypeMatchesOnlyTheNullObject( - - False ) - - def test_an_integer_is_not_null_fails(self): - # an integer is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NullTypeMatchesOnlyTheNullObject( - 1 ) - - def test_true_is_not_null_fails(self): - # true is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NullTypeMatchesOnlyTheNullObject( - - True ) - - def test_zero_is_not_null_fails(self): - # zero is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NullTypeMatchesOnlyTheNullObject( - 0 ) - - def test_an_empty_string_is_not_null_fails(self): - # an empty string is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NullTypeMatchesOnlyTheNullObject( - - "" ) - - def test_null_is_null_passes(self): - # null is null - NullTypeMatchesOnlyTheNullObject( - - None ) - - def test_an_array_is_not_null_fails(self): - # an array is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NullTypeMatchesOnlyTheNullObject( - [ - ] - ) - - def test_a_string_is_not_null_fails(self): - # a string is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NullTypeMatchesOnlyTheNullObject( - - "foo" ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py deleted file mode 100644 index 8c5af6e240f..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py +++ /dev/null @@ -1,82 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.number_type_matches_numbers import NumberTypeMatchesNumbers - - -class TestNumberTypeMatchesNumbers(unittest.TestCase): - """NumberTypeMatchesNumbers unit test stubs""" - - def test_an_array_is_not_a_number_fails(self): - # an array is not a number - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NumberTypeMatchesNumbers( - [ - ] - ) - - def test_null_is_not_a_number_fails(self): - # null is not a number - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NumberTypeMatchesNumbers( - - None ) - - def test_an_object_is_not_a_number_fails(self): - # an object is not a number - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NumberTypeMatchesNumbers( - { - } - ) - - def test_a_boolean_is_not_a_number_fails(self): - # a boolean is not a number - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NumberTypeMatchesNumbers( - - True ) - - def test_a_float_is_a_number_passes(self): - # a float is a number - NumberTypeMatchesNumbers( - 1.1 ) - - def test_a_string_is_still_not_a_number_even_if_it_looks_like_one_fails(self): - # a string is still not a number, even if it looks like one - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NumberTypeMatchesNumbers( - - "1" ) - - def test_a_string_is_not_a_number_fails(self): - # a string is not a number - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NumberTypeMatchesNumbers( - - "foo" ) - - def test_an_integer_is_a_number_passes(self): - # an integer is a number - NumberTypeMatchesNumbers( - 1 ) - - def test_a_float_with_zero_fractional_part_is_a_number_and_an_integer_passes(self): - # a float with zero fractional part is a number (and an integer) - NumberTypeMatchesNumbers( - 1.0 ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py deleted file mode 100644 index 6b2b76e2b8a..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py +++ /dev/null @@ -1,83 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.string_type_matches_strings import StringTypeMatchesStrings - - -class TestStringTypeMatchesStrings(unittest.TestCase): - """StringTypeMatchesStrings unit test stubs""" - - def test_1_is_not_a_string_fails(self): - # 1 is not a string - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - StringTypeMatchesStrings( - 1 ) - - def test_a_string_is_still_a_string_even_if_it_looks_like_a_number_passes(self): - # a string is still a string, even if it looks like a number - StringTypeMatchesStrings( - - "1" ) - - def test_an_empty_string_is_still_a_string_passes(self): - # an empty string is still a string - StringTypeMatchesStrings( - - "" ) - - def test_a_float_is_not_a_string_fails(self): - # a float is not a string - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - StringTypeMatchesStrings( - 1.1 ) - - def test_an_object_is_not_a_string_fails(self): - # an object is not a string - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - StringTypeMatchesStrings( - { - } - ) - - def test_an_array_is_not_a_string_fails(self): - # an array is not a string - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - StringTypeMatchesStrings( - [ - ] - ) - - def test_a_boolean_is_not_a_string_fails(self): - # a boolean is not a string - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - StringTypeMatchesStrings( - - True ) - - def test_null_is_not_a_string_fails(self): - # null is not a string - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - StringTypeMatchesStrings( - - None ) - - def test_a_string_is_a_string_passes(self): - # a string is a string - StringTypeMatchesStrings( - - "foo" ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py deleted file mode 100644 index 63eb2bf6bc2..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py +++ /dev/null @@ -1,49 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.the_default_keyword_does_not_do_anything_if_the_property_is_missing import TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing - - -class TestTheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing(unittest.TestCase): - """TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing unit test stubs""" - - def test_missing_properties_are_not_filled_in_with_the_default_passes(self): - # missing properties are not filled in with the default - TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing( - { - } - ) - - def test_an_explicit_property_value_is_checked_against_maximum_passing_passes(self): - # an explicit property value is checked against maximum (passing) - TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing( - **{ - "alpha": - 1, - } - ) - - def test_an_explicit_property_value_is_checked_against_maximum_failing_fails(self): - # an explicit property value is checked against maximum (failing) - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing( - **{ - "alpha": - 5, - } - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_allows_a_schema_which_should_validate.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_allows_a_schema_which_should_validate.py deleted file mode 100644 index 8e986da86fc..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_allows_a_schema_which_should_validate.py +++ /dev/null @@ -1,97 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class AdditionalpropertiesAllowsASchemaWhichShouldValidate( - DictSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - foo = AnyTypeSchema - bar = AnyTypeSchema - _additional_properties = BoolSchema - - - def __new__( - cls, - *args: typing.Union[dict, frozendict, ], - foo: typing.Union[foo, Unset] = unset, - bar: typing.Union[bar, Unset] = unset, - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'AdditionalpropertiesAllowsASchemaWhichShouldValidate': - return super().__new__( - cls, - *args, - foo=foo, - bar=bar, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_are_allowed_by_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_are_allowed_by_default.py deleted file mode 100644 index 2251b2f815a..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_are_allowed_by_default.py +++ /dev/null @@ -1,95 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class AdditionalpropertiesAreAllowedByDefault( - AnyTypeSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - foo = AnyTypeSchema - bar = AnyTypeSchema - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - foo: typing.Union[foo, Unset] = unset, - bar: typing.Union[bar, Unset] = unset, - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'AdditionalpropertiesAreAllowedByDefault': - return super().__new__( - cls, - *args, - foo=foo, - bar=bar, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_can_exist_by_itself.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_can_exist_by_itself.py deleted file mode 100644 index 383a01af174..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_can_exist_by_itself.py +++ /dev/null @@ -1,91 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class AdditionalpropertiesCanExistByItself( - DictSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - _additional_properties = BoolSchema - - - def __new__( - cls, - *args: typing.Union[dict, frozendict, ], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'AdditionalpropertiesCanExistByItself': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_should_not_look_in_applicators.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_should_not_look_in_applicators.py deleted file mode 100644 index 66547528189..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_should_not_look_in_applicators.py +++ /dev/null @@ -1,114 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class AdditionalpropertiesShouldNotLookInApplicators( - ComposedSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - _additional_properties = BoolSchema - - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 - allOf_0 = AnyTypeSchema - return { - 'allOf': [ - allOf_0, - ], - 'oneOf': [ - ], - 'anyOf': [ - ], - 'not': - None - } - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'AdditionalpropertiesShouldNotLookInApplicators': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/array_type_matches_arrays.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/array_type_matches_arrays.py deleted file mode 100644 index 583f9843b64..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/array_type_matches_arrays.py +++ /dev/null @@ -1,77 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class ArrayTypeMatchesArrays( - ListSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - _items = AnyTypeSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/boolean_type_matches_booleans.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/boolean_type_matches_booleans.py deleted file mode 100644 index 93cd0a0505f..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/boolean_type_matches_booleans.py +++ /dev/null @@ -1,67 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) -BooleanTypeMatchesBooleans = BoolSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/heterogeneous_enum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/heterogeneous_enum_validation.py deleted file mode 100644 index 40802e0637d..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/heterogeneous_enum_validation.py +++ /dev/null @@ -1,110 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class HeterogeneousEnumValidation( - _SchemaEnumMaker( - enum_value_to_name={ - 6: "POSITIVE_6", - foo: "FOO", - []: "LEFT_SQUARE_BRACKETRIGHT_SQUARE_BRACKET", - true: "TRUE", - {"foo":12}: "FOO12", - } - ), - NumberSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - def POSITIVE_6(cls): - return cls(6) - - @classmethod - @property - def FOO(cls): - return cls(foo) - - @classmethod - @property - def LEFT_SQUARE_BRACKETRIGHT_SQUARE_BRACKET(cls): - return cls([]) - - @classmethod - @property - def TRUE(cls): - return cls(true) - - @classmethod - @property - def FOO12(cls): - return cls({"foo":12}) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/heterogeneous_enum_with_null_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/heterogeneous_enum_with_null_validation.py deleted file mode 100644 index 77973c578f9..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/heterogeneous_enum_with_null_validation.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class HeterogeneousEnumWithNullValidation( - _SchemaEnumMaker( - enum_value_to_name={ - 6: "POSITIVE_6", - null: "NULL", - } - ), - NumberSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - def POSITIVE_6(cls): - return cls(6) - - @classmethod - @property - def NULL(cls): - return cls(null) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/integer_type_matches_integers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/integer_type_matches_integers.py deleted file mode 100644 index 472bd37aa71..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/integer_type_matches_integers.py +++ /dev/null @@ -1,67 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) -IntegerTypeMatchesIntegers = IntSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_string_value_for_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_string_value_for_default.py deleted file mode 100644 index 07ad386d3b8..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_string_value_for_default.py +++ /dev/null @@ -1,100 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class InvalidStringValueForDefault( - AnyTypeSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - - class bar( - _SchemaValidator( - min_length=4, - ), - StrSchema - ): - pass - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - bar: typing.Union[bar, Unset] = unset, - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'InvalidStringValueForDefault': - return super().__new__( - cls, - *args, - bar=bar, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_type_for_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_type_for_default.py deleted file mode 100644 index bffccf32de0..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_type_for_default.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class InvalidTypeForDefault( - AnyTypeSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - foo = IntSchema - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - foo: typing.Union[foo, Unset] = unset, - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'InvalidTypeForDefault': - return super().__new__( - cls, - *args, - foo=foo, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nul_characters_in_strings.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nul_characters_in_strings.py index e5a3bf5a390472c90e99c9549f56bfb30d1985bb..04ff26fd643fd14e36f73611f565716e69ebc9fd 100644 GIT binary patch delta 30 jcmbQiJCAomHY-a^g@M8599CsU9uTV}Bef`1Ns|izjeH26 delta 24 fcmbQoJA-#aHY+2;=6qIVMoxy3jMSo3B~2~>RF4KT diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/null_type_matches_only_the_null_object.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/null_type_matches_only_the_null_object.py deleted file mode 100644 index 3ed5b3d6b3b..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/null_type_matches_only_the_null_object.py +++ /dev/null @@ -1,67 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) -NullTypeMatchesOnlyTheNullObject = NoneSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/number_type_matches_numbers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/number_type_matches_numbers.py deleted file mode 100644 index 3b33c38f4cd..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/number_type_matches_numbers.py +++ /dev/null @@ -1,67 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) -NumberTypeMatchesNumbers = NumberSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/string_type_matches_strings.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/string_type_matches_strings.py deleted file mode 100644 index f1c3c9a0302..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/string_type_matches_strings.py +++ /dev/null @@ -1,67 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) -StringTypeMatchesStrings = StrSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/the_default_keyword_does_not_do_anything_if_the_property_is_missing.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/the_default_keyword_does_not_do_anything_if_the_property_is_missing.py deleted file mode 100644 index d59150db52b..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/the_default_keyword_does_not_do_anything_if_the_property_is_missing.py +++ /dev/null @@ -1,101 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing( - DictSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - - class alpha( - _SchemaValidator( - inclusive_maximum=3, - ), - NumberSchema - ): - pass - - - def __new__( - cls, - *args: typing.Union[dict, frozendict, ], - alpha: typing.Union[alpha, Unset] = unset, - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing': - return super().__new__( - cls, - *args, - alpha=alpha, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py index ad09599a5de..f6921ceae2f 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py @@ -11,26 +11,11 @@ # import sys # sys.setrecursionlimit(n) -from unit_test_api.model.additionalproperties_allows_a_schema_which_should_validate import AdditionalpropertiesAllowsASchemaWhichShouldValidate -from unit_test_api.model.additionalproperties_are_allowed_by_default import AdditionalpropertiesAreAllowedByDefault -from unit_test_api.model.additionalproperties_can_exist_by_itself import AdditionalpropertiesCanExistByItself -from unit_test_api.model.additionalproperties_should_not_look_in_applicators import AdditionalpropertiesShouldNotLookInApplicators -from unit_test_api.model.array_type_matches_arrays import ArrayTypeMatchesArrays -from unit_test_api.model.boolean_type_matches_booleans import BooleanTypeMatchesBooleans from unit_test_api.model.enum_with0_does_not_match_false import EnumWith0DoesNotMatchFalse from unit_test_api.model.enum_with1_does_not_match_true import EnumWith1DoesNotMatchTrue from unit_test_api.model.enum_with_escaped_characters import EnumWithEscapedCharacters from unit_test_api.model.enum_with_false_does_not_match0 import EnumWithFalseDoesNotMatch0 from unit_test_api.model.enum_with_true_does_not_match1 import EnumWithTrueDoesNotMatch1 from unit_test_api.model.enums_in_properties import EnumsInProperties -from unit_test_api.model.heterogeneous_enum_validation import HeterogeneousEnumValidation -from unit_test_api.model.heterogeneous_enum_with_null_validation import HeterogeneousEnumWithNullValidation -from unit_test_api.model.integer_type_matches_integers import IntegerTypeMatchesIntegers -from unit_test_api.model.invalid_string_value_for_default import InvalidStringValueForDefault -from unit_test_api.model.invalid_type_for_default import InvalidTypeForDefault from unit_test_api.model.nul_characters_in_strings import NulCharactersInStrings -from unit_test_api.model.null_type_matches_only_the_null_object import NullTypeMatchesOnlyTheNullObject -from unit_test_api.model.number_type_matches_numbers import NumberTypeMatchesNumbers from unit_test_api.model.simple_enum_validation import SimpleEnumValidation -from unit_test_api.model.string_type_matches_strings import StringTypeMatchesStrings -from unit_test_api.model.the_default_keyword_does_not_do_anything_if_the_property_is_missing import TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing -- GitLab From 81c894c5c02c5fbff98ffb7f87dd287d640be698 Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Sun, 26 Jun 2022 15:19:28 -0700 Subject: [PATCH 09/43] Turns on all of themissing tests --- .../3_0/unit_test_spec/spec_writer.py | 18 +- .../resources/3_0/unit_test_spec/type.yaml | 384 ++++++++++++++++++ .../.openapi-generator/FILES | 39 ++ .../python-experimental/README.md | 13 + ...pertiesAllowsASchemaWhichShouldValidate.md | 11 + ...AdditionalpropertiesAreAllowedByDefault.md | 11 + .../AdditionalpropertiesCanExistByItself.md | 9 + ...nalpropertiesShouldNotLookInApplicators.md | 9 + .../docs/ArrayTypeMatchesArrays.md | 8 + .../docs/BooleanTypeMatchesBooleans.md | 8 + .../docs/IntegerTypeMatchesIntegers.md | 8 + .../docs/InvalidStringValueForDefault.md | 10 + .../docs/InvalidTypeForDefault.md | 10 + .../docs/NullTypeMatchesOnlyTheNullObject.md | 8 + .../docs/NumberTypeMatchesNumbers.md | 8 + .../docs/StringTypeMatchesStrings.md | 8 + ...DoesNotDoAnythingIfThePropertyIsMissing.md | 10 + ...s_allows_a_schema_which_should_validate.py | 60 +++ ...tionalproperties_are_allowed_by_default.py | 37 ++ ...dditionalproperties_can_exist_by_itself.py | 43 ++ ...operties_should_not_look_in_applicators.py | 36 ++ .../test/test_array_type_matches_arrays.py | 71 ++++ .../test_boolean_type_matches_booleans.py | 90 ++++ .../test_integer_type_matches_integers.py | 83 ++++ .../test_invalid_string_value_for_default.py | 40 ++ .../test/test_invalid_type_for_default.py | 39 ++ ..._null_type_matches_only_the_null_object.py | 91 +++++ .../test/test_number_type_matches_numbers.py | 82 ++++ .../test/test_string_type_matches_strings.py | 83 ++++ ..._do_anything_if_the_property_is_missing.py | 49 +++ ...s_allows_a_schema_which_should_validate.py | 97 +++++ ...tionalproperties_are_allowed_by_default.py | 95 +++++ ...dditionalproperties_can_exist_by_itself.py | 91 +++++ ...operties_should_not_look_in_applicators.py | 114 ++++++ .../model/array_type_matches_arrays.py | 77 ++++ .../model/boolean_type_matches_booleans.py | 67 +++ .../model/integer_type_matches_integers.py | 67 +++ .../model/invalid_string_value_for_default.py | 100 +++++ .../model/invalid_type_for_default.py | 92 +++++ .../null_type_matches_only_the_null_object.py | 67 +++ .../model/number_type_matches_numbers.py | 67 +++ .../model/string_type_matches_strings.py | 67 +++ ..._do_anything_if_the_property_is_missing.py | 101 +++++ .../unit_test_api/models/__init__.py | 13 + 44 files changed, 2482 insertions(+), 9 deletions(-) create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAreAllowedByDefault.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesCanExistByItself.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesShouldNotLookInApplicators.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ArrayTypeMatchesArrays.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/BooleanTypeMatchesBooleans.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/IntegerTypeMatchesIntegers.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidStringValueForDefault.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidTypeForDefault.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NullTypeMatchesOnlyTheNullObject.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NumberTypeMatchesNumbers.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/StringTypeMatchesStrings.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_string_value_for_default.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_type_for_default.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_allows_a_schema_which_should_validate.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_are_allowed_by_default.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_can_exist_by_itself.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_should_not_look_in_applicators.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/array_type_matches_arrays.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/boolean_type_matches_booleans.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/integer_type_matches_integers.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_string_value_for_default.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_type_for_default.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/null_type_matches_only_the_null_object.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/number_type_matches_numbers.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/string_type_matches_strings.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/the_default_keyword_does_not_do_anything_if_the_property_is_missing.py diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index aadcb8e13ce..eafbee851a1 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -117,17 +117,17 @@ FILEPATH_TO_EXCLUDE_REASON = { openapi_additions = 'openapi_additions' JSON_SCHEMA_TEST_FILE_TO_FOLDERS = { -# 'type.json': (json_schema_test_draft, openapi_additions), -# 'additionalItems.json': (json_schema_test_draft,), -# 'additionalProperties.json': (json_schema_test_draft,), + 'type.json': (json_schema_test_draft, openapi_additions), + 'additionalItems.json': (json_schema_test_draft,), + 'additionalProperties.json': (json_schema_test_draft,), # 'allOf.json': (json_schema_test_draft,), # activate later after fixing composition processing # 'anyOf.json': (json_schema_test_draft,), # activate later after fixing composition processing -# 'boolean_schema.json': (json_schema_test_draft,), -# 'const.json': (json_schema_test_draft,), -# 'contains.json': (json_schema_test_draft,), -# 'default.json': (json_schema_test_draft,), -# 'definitions.json': (json_schema_test_draft,), -# 'dependencies.json': (json_schema_test_draft,), + 'boolean_schema.json': (json_schema_test_draft,), + 'const.json': (json_schema_test_draft,), + 'contains.json': (json_schema_test_draft,), + 'default.json': (json_schema_test_draft,), + 'definitions.json': (json_schema_test_draft,), + 'dependencies.json': (json_schema_test_draft,), 'enum.json': (json_schema_test_draft,), } diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml index 060a2926c05..57e56774604 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml @@ -7,6 +7,58 @@ info: paths: {} components: schemas: + IntegerTypeMatchesIntegers: + type: integer + NumberTypeMatchesNumbers: + type: number + StringTypeMatchesStrings: + type: string + ObjectTypeMatchesObjects: + type: object + BooleanTypeMatchesBooleans: + type: boolean + NullTypeMatchesOnlyTheNullObject: + type: 'null' + ArrayTypeMatchesArrays: + type: array + items: {} + AdditionalpropertiesAllowsASchemaWhichShouldValidate: + properties: + foo: {} + bar: {} + additionalProperties: + type: boolean + AdditionalpropertiesCanExistByItself: + additionalProperties: + type: boolean + AdditionalpropertiesAreAllowedByDefault: + properties: + foo: {} + bar: {} + AdditionalpropertiesShouldNotLookInApplicators: + allOf: + - properties: + foo: {} + additionalProperties: + type: boolean + InvalidTypeForDefault: + properties: + foo: + type: integer + default: [] + InvalidStringValueForDefault: + properties: + bar: + type: string + minLength: 4 + default: bad + TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing: + type: object + properties: + alpha: + type: number + maximum: 3 + default: 5 SimpleEnumValidation: enum: - 1 @@ -45,6 +97,338 @@ components: enum: - "hello\0there" x-schema-test-examples: + IntegerTypeMatchesIntegers: + AnIntegerIsAnInteger: + description: an integer is an integer + data: 1 + valid: true + AFloatWithZeroFractionalPartIsAnInteger: + description: a float with zero fractional part is an integer + data: 1.0 + valid: true + AFloatIsNotAnInteger: + description: a float is not an integer + data: 1.1 + valid: false + AStringIsNotAnInteger: + description: a string is not an integer + data: foo + valid: false + AStringIsStillNotAnIntegerEvenIfItLooksLikeOne: + description: a string is still not an integer, even if it looks like one + data: '1' + valid: false + AnObjectIsNotAnInteger: + description: an object is not an integer + data: {} + valid: false + AnArrayIsNotAnInteger: + description: an array is not an integer + data: [] + valid: false + ABooleanIsNotAnInteger: + description: a boolean is not an integer + data: true + valid: false + NullIsNotAnInteger: + description: null is not an integer + data: null + valid: false + NumberTypeMatchesNumbers: + AnIntegerIsANumber: + description: an integer is a number + data: 1 + valid: true + AFloatWithZeroFractionalPartIsANumberAndAnInteger: + description: a float with zero fractional part is a number (and an integer) + data: 1.0 + valid: true + AFloatIsANumber: + description: a float is a number + data: 1.1 + valid: true + AStringIsNotANumber: + description: a string is not a number + data: foo + valid: false + AStringIsStillNotANumberEvenIfItLooksLikeOne: + description: a string is still not a number, even if it looks like one + data: '1' + valid: false + AnObjectIsNotANumber: + description: an object is not a number + data: {} + valid: false + AnArrayIsNotANumber: + description: an array is not a number + data: [] + valid: false + ABooleanIsNotANumber: + description: a boolean is not a number + data: true + valid: false + NullIsNotANumber: + description: null is not a number + data: null + valid: false + StringTypeMatchesStrings: + 1IsNotAString: + description: 1 is not a string + data: 1 + valid: false + AFloatIsNotAString: + description: a float is not a string + data: 1.1 + valid: false + AStringIsAString: + description: a string is a string + data: foo + valid: true + AStringIsStillAStringEvenIfItLooksLikeANumber: + description: a string is still a string, even if it looks like a number + data: '1' + valid: true + AnEmptyStringIsStillAString: + description: an empty string is still a string + data: '' + valid: true + AnObjectIsNotAString: + description: an object is not a string + data: {} + valid: false + AnArrayIsNotAString: + description: an array is not a string + data: [] + valid: false + ABooleanIsNotAString: + description: a boolean is not a string + data: true + valid: false + NullIsNotAString: + description: null is not a string + data: null + valid: false + ObjectTypeMatchesObjects: + AnIntegerIsNotAnObject: + description: an integer is not an object + data: 1 + valid: false + AFloatIsNotAnObject: + description: a float is not an object + data: 1.1 + valid: false + AStringIsNotAnObject: + description: a string is not an object + data: foo + valid: false + AnObjectIsAnObject: + description: an object is an object + data: {} + valid: true + AnArrayIsNotAnObject: + description: an array is not an object + data: [] + valid: false + ABooleanIsNotAnObject: + description: a boolean is not an object + data: true + valid: false + NullIsNotAnObject: + description: null is not an object + data: null + valid: false + BooleanTypeMatchesBooleans: + AnIntegerIsNotABoolean: + description: an integer is not a boolean + data: 1 + valid: false + ZeroIsNotABoolean: + description: zero is not a boolean + data: 0 + valid: false + AFloatIsNotABoolean: + description: a float is not a boolean + data: 1.1 + valid: false + AStringIsNotABoolean: + description: a string is not a boolean + data: foo + valid: false + AnEmptyStringIsNotABoolean: + description: an empty string is not a boolean + data: '' + valid: false + AnObjectIsNotABoolean: + description: an object is not a boolean + data: {} + valid: false + AnArrayIsNotABoolean: + description: an array is not a boolean + data: [] + valid: false + TrueIsABoolean: + description: true is a boolean + data: true + valid: true + FalseIsABoolean: + description: false is a boolean + data: false + valid: true + NullIsNotABoolean: + description: null is not a boolean + data: null + valid: false + NullTypeMatchesOnlyTheNullObject: + AnIntegerIsNotNull: + description: an integer is not null + data: 1 + valid: false + AFloatIsNotNull: + description: a float is not null + data: 1.1 + valid: false + ZeroIsNotNull: + description: zero is not null + data: 0 + valid: false + AStringIsNotNull: + description: a string is not null + data: foo + valid: false + AnEmptyStringIsNotNull: + description: an empty string is not null + data: '' + valid: false + AnObjectIsNotNull: + description: an object is not null + data: {} + valid: false + AnArrayIsNotNull: + description: an array is not null + data: [] + valid: false + TrueIsNotNull: + description: true is not null + data: true + valid: false + FalseIsNotNull: + description: false is not null + data: false + valid: false + NullIsNull: + description: null is null + data: null + valid: true + ArrayTypeMatchesArrays: + AnIntegerIsNotAnArray: + description: an integer is not an array + data: 1 + valid: false + AFloatIsNotAnArray: + description: a float is not an array + data: 1.1 + valid: false + AStringIsNotAnArray: + description: a string is not an array + data: foo + valid: false + AnObjectIsNotAnArray: + description: an object is not an array + data: {} + valid: false + AnArrayIsAnArray: + description: an array is an array + data: [] + valid: true + ABooleanIsNotAnArray: + description: a boolean is not an array + data: true + valid: false + NullIsNotAnArray: + description: null is not an array + data: null + valid: false + AdditionalpropertiesAllowsASchemaWhichShouldValidate: + NoAdditionalPropertiesIsValid: + description: no additional properties is valid + data: + foo: 1 + valid: true + AnAdditionalValidPropertyIsValid: + description: an additional valid property is valid + data: + foo: 1 + bar: 2 + quux: true + valid: true + AnAdditionalInvalidPropertyIsInvalid: + description: an additional invalid property is invalid + data: + foo: 1 + bar: 2 + quux: 12 + valid: false + AdditionalpropertiesCanExistByItself: + AnAdditionalValidPropertyIsValid: + description: an additional valid property is valid + data: + foo: true + valid: true + AnAdditionalInvalidPropertyIsInvalid: + description: an additional invalid property is invalid + data: + foo: 1 + valid: false + AdditionalpropertiesAreAllowedByDefault: + AdditionalPropertiesAreAllowed: + description: additional properties are allowed + data: + foo: 1 + bar: 2 + quux: true + valid: true + AdditionalpropertiesShouldNotLookInApplicators: + PropertiesDefinedInAllofAreNotExamined: + description: properties defined in allOf are not examined + data: + foo: 1 + bar: true + valid: false + InvalidTypeForDefault: + ValidWhenPropertyIsSpecified: + description: valid when property is specified + data: + foo: 13 + valid: true + StillValidWhenTheInvalidDefaultIsUsed: + description: still valid when the invalid default is used + data: {} + valid: true + InvalidStringValueForDefault: + ValidWhenPropertyIsSpecified: + description: valid when property is specified + data: + bar: good + valid: true + StillValidWhenTheInvalidDefaultIsUsed: + description: still valid when the invalid default is used + data: {} + valid: true + TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing: + AnExplicitPropertyValueIsCheckedAgainstMaximumPassing: + description: an explicit property value is checked against maximum (passing) + data: + alpha: 1 + valid: true + AnExplicitPropertyValueIsCheckedAgainstMaximumFailing: + description: an explicit property value is checked against maximum (failing) + data: + alpha: 5 + valid: false + MissingPropertiesAreNotFilledInWithTheDefault: + description: missing properties are not filled in with the default + data: {} + valid: true SimpleEnumValidation: OneOfTheEnumIsValid: description: one of the enum is valid diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index 877d29dd9f6..f375c2685bb 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -2,28 +2,54 @@ .gitlab-ci.yml .travis.yml README.md +docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md +docs/AdditionalpropertiesAreAllowedByDefault.md +docs/AdditionalpropertiesCanExistByItself.md +docs/AdditionalpropertiesShouldNotLookInApplicators.md +docs/ArrayTypeMatchesArrays.md +docs/BooleanTypeMatchesBooleans.md docs/EnumWith0DoesNotMatchFalse.md docs/EnumWith1DoesNotMatchTrue.md docs/EnumWithEscapedCharacters.md docs/EnumWithFalseDoesNotMatch0.md docs/EnumWithTrueDoesNotMatch1.md docs/EnumsInProperties.md +docs/IntegerTypeMatchesIntegers.md +docs/InvalidStringValueForDefault.md +docs/InvalidTypeForDefault.md docs/NulCharactersInStrings.md +docs/NullTypeMatchesOnlyTheNullObject.md +docs/NumberTypeMatchesNumbers.md docs/SimpleEnumValidation.md +docs/StringTypeMatchesStrings.md +docs/TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md git_push.sh requirements.txt setup.cfg setup.py test-requirements.txt test/__init__.py +test/test_additionalproperties_allows_a_schema_which_should_validate.py +test/test_additionalproperties_are_allowed_by_default.py +test/test_additionalproperties_can_exist_by_itself.py +test/test_additionalproperties_should_not_look_in_applicators.py +test/test_array_type_matches_arrays.py +test/test_boolean_type_matches_booleans.py test/test_enum_with0_does_not_match_false.py test/test_enum_with1_does_not_match_true.py test/test_enum_with_escaped_characters.py test/test_enum_with_false_does_not_match0.py test/test_enum_with_true_does_not_match1.py test/test_enums_in_properties.py +test/test_integer_type_matches_integers.py +test/test_invalid_string_value_for_default.py +test/test_invalid_type_for_default.py test/test_nul_characters_in_strings.py +test/test_null_type_matches_only_the_null_object.py +test/test_number_type_matches_numbers.py test/test_simple_enum_validation.py +test/test_string_type_matches_strings.py +test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py tox.ini unit_test_api/__init__.py unit_test_api/api/__init__.py @@ -32,14 +58,27 @@ unit_test_api/apis/__init__.py unit_test_api/configuration.py unit_test_api/exceptions.py unit_test_api/model/__init__.py +unit_test_api/model/additionalproperties_allows_a_schema_which_should_validate.py +unit_test_api/model/additionalproperties_are_allowed_by_default.py +unit_test_api/model/additionalproperties_can_exist_by_itself.py +unit_test_api/model/additionalproperties_should_not_look_in_applicators.py +unit_test_api/model/array_type_matches_arrays.py +unit_test_api/model/boolean_type_matches_booleans.py unit_test_api/model/enum_with0_does_not_match_false.py unit_test_api/model/enum_with1_does_not_match_true.py unit_test_api/model/enum_with_escaped_characters.py unit_test_api/model/enum_with_false_does_not_match0.py unit_test_api/model/enum_with_true_does_not_match1.py unit_test_api/model/enums_in_properties.py +unit_test_api/model/integer_type_matches_integers.py +unit_test_api/model/invalid_string_value_for_default.py +unit_test_api/model/invalid_type_for_default.py unit_test_api/model/nul_characters_in_strings.py +unit_test_api/model/null_type_matches_only_the_null_object.py +unit_test_api/model/number_type_matches_numbers.py unit_test_api/model/simple_enum_validation.py +unit_test_api/model/string_type_matches_strings.py +unit_test_api/model/the_default_keyword_does_not_do_anything_if_the_property_is_missing.py unit_test_api/models/__init__.py unit_test_api/rest.py unit_test_api/schemas.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md index 1a7f5d04161..2d5017e5247 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md @@ -62,14 +62,27 @@ Class | Method | HTTP request | Description ## Documentation For Models + - [AdditionalpropertiesAllowsASchemaWhichShouldValidate](docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md) + - [AdditionalpropertiesAreAllowedByDefault](docs/AdditionalpropertiesAreAllowedByDefault.md) + - [AdditionalpropertiesCanExistByItself](docs/AdditionalpropertiesCanExistByItself.md) + - [AdditionalpropertiesShouldNotLookInApplicators](docs/AdditionalpropertiesShouldNotLookInApplicators.md) + - [ArrayTypeMatchesArrays](docs/ArrayTypeMatchesArrays.md) + - [BooleanTypeMatchesBooleans](docs/BooleanTypeMatchesBooleans.md) - [EnumWith0DoesNotMatchFalse](docs/EnumWith0DoesNotMatchFalse.md) - [EnumWith1DoesNotMatchTrue](docs/EnumWith1DoesNotMatchTrue.md) - [EnumWithEscapedCharacters](docs/EnumWithEscapedCharacters.md) - [EnumWithFalseDoesNotMatch0](docs/EnumWithFalseDoesNotMatch0.md) - [EnumWithTrueDoesNotMatch1](docs/EnumWithTrueDoesNotMatch1.md) - [EnumsInProperties](docs/EnumsInProperties.md) + - [IntegerTypeMatchesIntegers](docs/IntegerTypeMatchesIntegers.md) + - [InvalidStringValueForDefault](docs/InvalidStringValueForDefault.md) + - [InvalidTypeForDefault](docs/InvalidTypeForDefault.md) - [NulCharactersInStrings](docs/NulCharactersInStrings.md) + - [NullTypeMatchesOnlyTheNullObject](docs/NullTypeMatchesOnlyTheNullObject.md) + - [NumberTypeMatchesNumbers](docs/NumberTypeMatchesNumbers.md) - [SimpleEnumValidation](docs/SimpleEnumValidation.md) + - [StringTypeMatchesStrings](docs/StringTypeMatchesStrings.md) + - [TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing](docs/TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md) ## Documentation For Authorization diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md new file mode 100644 index 00000000000..d9981bf45a7 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md @@ -0,0 +1,11 @@ +# AdditionalpropertiesAllowsASchemaWhichShouldValidate + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**foo** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] +**bar** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] +**any string name** | **bool** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAreAllowedByDefault.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAreAllowedByDefault.md new file mode 100644 index 00000000000..d5e7d2747ee --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAreAllowedByDefault.md @@ -0,0 +1,11 @@ +# AdditionalpropertiesAreAllowedByDefault + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**foo** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] +**bar** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesCanExistByItself.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesCanExistByItself.md new file mode 100644 index 00000000000..72b091b888a --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesCanExistByItself.md @@ -0,0 +1,9 @@ +# AdditionalpropertiesCanExistByItself + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesShouldNotLookInApplicators.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesShouldNotLookInApplicators.md new file mode 100644 index 00000000000..31efeb974b1 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesShouldNotLookInApplicators.md @@ -0,0 +1,9 @@ +# AdditionalpropertiesShouldNotLookInApplicators + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ArrayTypeMatchesArrays.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ArrayTypeMatchesArrays.md new file mode 100644 index 00000000000..bf72f2c35bc --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ArrayTypeMatchesArrays.md @@ -0,0 +1,8 @@ +# ArrayTypeMatchesArrays + +Type | Description | Notes +------------- | ------------- | ------------- +**[bool, date, datetime, dict, float, int, list, str, none_type]** | | + +[[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/3_0_3_unit_test/python-experimental/docs/BooleanTypeMatchesBooleans.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/BooleanTypeMatchesBooleans.md new file mode 100644 index 00000000000..fa68a60fd2b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/BooleanTypeMatchesBooleans.md @@ -0,0 +1,8 @@ +# BooleanTypeMatchesBooleans + +Type | Description | Notes +------------- | ------------- | ------------- +**bool** | | + +[[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/3_0_3_unit_test/python-experimental/docs/IntegerTypeMatchesIntegers.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/IntegerTypeMatchesIntegers.md new file mode 100644 index 00000000000..141e17fd9ae --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/IntegerTypeMatchesIntegers.md @@ -0,0 +1,8 @@ +# IntegerTypeMatchesIntegers + +Type | Description | Notes +------------- | ------------- | ------------- +**int** | | + +[[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/3_0_3_unit_test/python-experimental/docs/InvalidStringValueForDefault.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidStringValueForDefault.md new file mode 100644 index 00000000000..ae129438132 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidStringValueForDefault.md @@ -0,0 +1,10 @@ +# InvalidStringValueForDefault + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**bar** | **str** | | [optional] if omitted the server will use the default value of "bad" +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidTypeForDefault.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidTypeForDefault.md new file mode 100644 index 00000000000..a251e2dc515 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidTypeForDefault.md @@ -0,0 +1,10 @@ +# InvalidTypeForDefault + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**foo** | **int** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NullTypeMatchesOnlyTheNullObject.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NullTypeMatchesOnlyTheNullObject.md new file mode 100644 index 00000000000..54a530d1d33 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NullTypeMatchesOnlyTheNullObject.md @@ -0,0 +1,8 @@ +# NullTypeMatchesOnlyTheNullObject + +Type | Description | Notes +------------- | ------------- | ------------- +**none_type** | | + +[[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/3_0_3_unit_test/python-experimental/docs/NumberTypeMatchesNumbers.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NumberTypeMatchesNumbers.md new file mode 100644 index 00000000000..8348aeef2bc --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NumberTypeMatchesNumbers.md @@ -0,0 +1,8 @@ +# NumberTypeMatchesNumbers + +Type | Description | Notes +------------- | ------------- | ------------- +**float** | | + +[[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/3_0_3_unit_test/python-experimental/docs/StringTypeMatchesStrings.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/StringTypeMatchesStrings.md new file mode 100644 index 00000000000..cd1125671ab --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/StringTypeMatchesStrings.md @@ -0,0 +1,8 @@ +# StringTypeMatchesStrings + +Type | Description | Notes +------------- | ------------- | ------------- +**str** | | + +[[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/3_0_3_unit_test/python-experimental/docs/TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md new file mode 100644 index 00000000000..61162c71aa0 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md @@ -0,0 +1,10 @@ +# TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**alpha** | **int, float** | | [optional] if omitted the server will use the default value of 5 +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py new file mode 100644 index 00000000000..3efa9239a1b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py @@ -0,0 +1,60 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.additionalproperties_allows_a_schema_which_should_validate import AdditionalpropertiesAllowsASchemaWhichShouldValidate + + +class TestAdditionalpropertiesAllowsASchemaWhichShouldValidate(unittest.TestCase): + """AdditionalpropertiesAllowsASchemaWhichShouldValidate unit test stubs""" + + def test_no_additional_properties_is_valid_passes(self): + # no additional properties is valid + AdditionalpropertiesAllowsASchemaWhichShouldValidate( + **{ + "foo": + 1, + } + ) + + def test_an_additional_invalid_property_is_invalid_fails(self): + # an additional invalid property is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + AdditionalpropertiesAllowsASchemaWhichShouldValidate( + **{ + "foo": + 1, + "bar": + 2, + "quux": + 12, + } + ) + + def test_an_additional_valid_property_is_valid_passes(self): + # an additional valid property is valid + AdditionalpropertiesAllowsASchemaWhichShouldValidate( + **{ + "foo": + 1, + "bar": + 2, + "quux": + + True, + } + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py new file mode 100644 index 00000000000..6a87df188f9 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.additionalproperties_are_allowed_by_default import AdditionalpropertiesAreAllowedByDefault + + +class TestAdditionalpropertiesAreAllowedByDefault(unittest.TestCase): + """AdditionalpropertiesAreAllowedByDefault unit test stubs""" + + def test_additional_properties_are_allowed_passes(self): + # additional properties are allowed + AdditionalpropertiesAreAllowedByDefault( + **{ + "foo": + 1, + "bar": + 2, + "quux": + + True, + } + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py new file mode 100644 index 00000000000..968b9449901 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py @@ -0,0 +1,43 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.additionalproperties_can_exist_by_itself import AdditionalpropertiesCanExistByItself + + +class TestAdditionalpropertiesCanExistByItself(unittest.TestCase): + """AdditionalpropertiesCanExistByItself unit test stubs""" + + def test_an_additional_invalid_property_is_invalid_fails(self): + # an additional invalid property is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + AdditionalpropertiesCanExistByItself( + **{ + "foo": + 1, + } + ) + + def test_an_additional_valid_property_is_valid_passes(self): + # an additional valid property is valid + AdditionalpropertiesCanExistByItself( + **{ + "foo": + + True, + } + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py new file mode 100644 index 00000000000..e46111271d3 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py @@ -0,0 +1,36 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.additionalproperties_should_not_look_in_applicators import AdditionalpropertiesShouldNotLookInApplicators + + +class TestAdditionalpropertiesShouldNotLookInApplicators(unittest.TestCase): + """AdditionalpropertiesShouldNotLookInApplicators unit test stubs""" + + def test_properties_defined_in_allof_are_not_examined_fails(self): + # properties defined in allOf are not examined + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + AdditionalpropertiesShouldNotLookInApplicators( + **{ + "foo": + 1, + "bar": + + True, + } + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py new file mode 100644 index 00000000000..695efa692be --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py @@ -0,0 +1,71 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.array_type_matches_arrays import ArrayTypeMatchesArrays + + +class TestArrayTypeMatchesArrays(unittest.TestCase): + """ArrayTypeMatchesArrays unit test stubs""" + + def test_a_float_is_not_an_array_fails(self): + # a float is not an array + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + ArrayTypeMatchesArrays( + 1.1 ) + + def test_a_boolean_is_not_an_array_fails(self): + # a boolean is not an array + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + ArrayTypeMatchesArrays( + + True ) + + def test_null_is_not_an_array_fails(self): + # null is not an array + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + ArrayTypeMatchesArrays( + + None ) + + def test_an_object_is_not_an_array_fails(self): + # an object is not an array + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + ArrayTypeMatchesArrays( + { + } + ) + + def test_a_string_is_not_an_array_fails(self): + # a string is not an array + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + ArrayTypeMatchesArrays( + + "foo" ) + + def test_an_array_is_an_array_passes(self): + # an array is an array + ArrayTypeMatchesArrays( + [ + ] + ) + + def test_an_integer_is_not_an_array_fails(self): + # an integer is not an array + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + ArrayTypeMatchesArrays( + 1 ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py new file mode 100644 index 00000000000..3ce46c5e25b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py @@ -0,0 +1,90 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.boolean_type_matches_booleans import BooleanTypeMatchesBooleans + + +class TestBooleanTypeMatchesBooleans(unittest.TestCase): + """BooleanTypeMatchesBooleans unit test stubs""" + + def test_an_empty_string_is_not_a_boolean_fails(self): + # an empty string is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + BooleanTypeMatchesBooleans( + + "" ) + + def test_a_float_is_not_a_boolean_fails(self): + # a float is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + BooleanTypeMatchesBooleans( + 1.1 ) + + def test_null_is_not_a_boolean_fails(self): + # null is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + BooleanTypeMatchesBooleans( + + None ) + + def test_zero_is_not_a_boolean_fails(self): + # zero is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + BooleanTypeMatchesBooleans( + 0 ) + + def test_an_array_is_not_a_boolean_fails(self): + # an array is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + BooleanTypeMatchesBooleans( + [ + ] + ) + + def test_a_string_is_not_a_boolean_fails(self): + # a string is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + BooleanTypeMatchesBooleans( + + "foo" ) + + def test_false_is_a_boolean_passes(self): + # false is a boolean + BooleanTypeMatchesBooleans( + + False ) + + def test_an_integer_is_not_a_boolean_fails(self): + # an integer is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + BooleanTypeMatchesBooleans( + 1 ) + + def test_true_is_a_boolean_passes(self): + # true is a boolean + BooleanTypeMatchesBooleans( + + True ) + + def test_an_object_is_not_a_boolean_fails(self): + # an object is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + BooleanTypeMatchesBooleans( + { + } + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py new file mode 100644 index 00000000000..4478fe8a01f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py @@ -0,0 +1,83 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.integer_type_matches_integers import IntegerTypeMatchesIntegers + + +class TestIntegerTypeMatchesIntegers(unittest.TestCase): + """IntegerTypeMatchesIntegers unit test stubs""" + + def test_an_object_is_not_an_integer_fails(self): + # an object is not an integer + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + IntegerTypeMatchesIntegers( + { + } + ) + + def test_a_string_is_not_an_integer_fails(self): + # a string is not an integer + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + IntegerTypeMatchesIntegers( + + "foo" ) + + def test_null_is_not_an_integer_fails(self): + # null is not an integer + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + IntegerTypeMatchesIntegers( + + None ) + + def test_a_float_with_zero_fractional_part_is_an_integer_passes(self): + # a float with zero fractional part is an integer + IntegerTypeMatchesIntegers( + 1.0 ) + + def test_a_float_is_not_an_integer_fails(self): + # a float is not an integer + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + IntegerTypeMatchesIntegers( + 1.1 ) + + def test_a_boolean_is_not_an_integer_fails(self): + # a boolean is not an integer + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + IntegerTypeMatchesIntegers( + + True ) + + def test_an_integer_is_an_integer_passes(self): + # an integer is an integer + IntegerTypeMatchesIntegers( + 1 ) + + def test_a_string_is_still_not_an_integer_even_if_it_looks_like_one_fails(self): + # a string is still not an integer, even if it looks like one + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + IntegerTypeMatchesIntegers( + + "1" ) + + def test_an_array_is_not_an_integer_fails(self): + # an array is not an integer + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + IntegerTypeMatchesIntegers( + [ + ] + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_string_value_for_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_string_value_for_default.py new file mode 100644 index 00000000000..9d375f8edfb --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_string_value_for_default.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.invalid_string_value_for_default import InvalidStringValueForDefault + + +class TestInvalidStringValueForDefault(unittest.TestCase): + """InvalidStringValueForDefault unit test stubs""" + + def test_valid_when_property_is_specified_passes(self): + # valid when property is specified + InvalidStringValueForDefault( + **{ + "bar": + + "good", + } + ) + + def test_still_valid_when_the_invalid_default_is_used_passes(self): + # still valid when the invalid default is used + InvalidStringValueForDefault( + { + } + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_type_for_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_type_for_default.py new file mode 100644 index 00000000000..669b1754510 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_type_for_default.py @@ -0,0 +1,39 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.invalid_type_for_default import InvalidTypeForDefault + + +class TestInvalidTypeForDefault(unittest.TestCase): + """InvalidTypeForDefault unit test stubs""" + + def test_valid_when_property_is_specified_passes(self): + # valid when property is specified + InvalidTypeForDefault( + **{ + "foo": + 13, + } + ) + + def test_still_valid_when_the_invalid_default_is_used_passes(self): + # still valid when the invalid default is used + InvalidTypeForDefault( + { + } + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py new file mode 100644 index 00000000000..3db8e2c3c56 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py @@ -0,0 +1,91 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.null_type_matches_only_the_null_object import NullTypeMatchesOnlyTheNullObject + + +class TestNullTypeMatchesOnlyTheNullObject(unittest.TestCase): + """NullTypeMatchesOnlyTheNullObject unit test stubs""" + + def test_a_float_is_not_null_fails(self): + # a float is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NullTypeMatchesOnlyTheNullObject( + 1.1 ) + + def test_an_object_is_not_null_fails(self): + # an object is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NullTypeMatchesOnlyTheNullObject( + { + } + ) + + def test_false_is_not_null_fails(self): + # false is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NullTypeMatchesOnlyTheNullObject( + + False ) + + def test_an_integer_is_not_null_fails(self): + # an integer is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NullTypeMatchesOnlyTheNullObject( + 1 ) + + def test_true_is_not_null_fails(self): + # true is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NullTypeMatchesOnlyTheNullObject( + + True ) + + def test_zero_is_not_null_fails(self): + # zero is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NullTypeMatchesOnlyTheNullObject( + 0 ) + + def test_an_empty_string_is_not_null_fails(self): + # an empty string is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NullTypeMatchesOnlyTheNullObject( + + "" ) + + def test_null_is_null_passes(self): + # null is null + NullTypeMatchesOnlyTheNullObject( + + None ) + + def test_an_array_is_not_null_fails(self): + # an array is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NullTypeMatchesOnlyTheNullObject( + [ + ] + ) + + def test_a_string_is_not_null_fails(self): + # a string is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NullTypeMatchesOnlyTheNullObject( + + "foo" ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py new file mode 100644 index 00000000000..8c5af6e240f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py @@ -0,0 +1,82 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.number_type_matches_numbers import NumberTypeMatchesNumbers + + +class TestNumberTypeMatchesNumbers(unittest.TestCase): + """NumberTypeMatchesNumbers unit test stubs""" + + def test_an_array_is_not_a_number_fails(self): + # an array is not a number + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NumberTypeMatchesNumbers( + [ + ] + ) + + def test_null_is_not_a_number_fails(self): + # null is not a number + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NumberTypeMatchesNumbers( + + None ) + + def test_an_object_is_not_a_number_fails(self): + # an object is not a number + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NumberTypeMatchesNumbers( + { + } + ) + + def test_a_boolean_is_not_a_number_fails(self): + # a boolean is not a number + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NumberTypeMatchesNumbers( + + True ) + + def test_a_float_is_a_number_passes(self): + # a float is a number + NumberTypeMatchesNumbers( + 1.1 ) + + def test_a_string_is_still_not_a_number_even_if_it_looks_like_one_fails(self): + # a string is still not a number, even if it looks like one + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NumberTypeMatchesNumbers( + + "1" ) + + def test_a_string_is_not_a_number_fails(self): + # a string is not a number + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NumberTypeMatchesNumbers( + + "foo" ) + + def test_an_integer_is_a_number_passes(self): + # an integer is a number + NumberTypeMatchesNumbers( + 1 ) + + def test_a_float_with_zero_fractional_part_is_a_number_and_an_integer_passes(self): + # a float with zero fractional part is a number (and an integer) + NumberTypeMatchesNumbers( + 1.0 ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py new file mode 100644 index 00000000000..6b2b76e2b8a --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py @@ -0,0 +1,83 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.string_type_matches_strings import StringTypeMatchesStrings + + +class TestStringTypeMatchesStrings(unittest.TestCase): + """StringTypeMatchesStrings unit test stubs""" + + def test_1_is_not_a_string_fails(self): + # 1 is not a string + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + StringTypeMatchesStrings( + 1 ) + + def test_a_string_is_still_a_string_even_if_it_looks_like_a_number_passes(self): + # a string is still a string, even if it looks like a number + StringTypeMatchesStrings( + + "1" ) + + def test_an_empty_string_is_still_a_string_passes(self): + # an empty string is still a string + StringTypeMatchesStrings( + + "" ) + + def test_a_float_is_not_a_string_fails(self): + # a float is not a string + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + StringTypeMatchesStrings( + 1.1 ) + + def test_an_object_is_not_a_string_fails(self): + # an object is not a string + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + StringTypeMatchesStrings( + { + } + ) + + def test_an_array_is_not_a_string_fails(self): + # an array is not a string + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + StringTypeMatchesStrings( + [ + ] + ) + + def test_a_boolean_is_not_a_string_fails(self): + # a boolean is not a string + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + StringTypeMatchesStrings( + + True ) + + def test_null_is_not_a_string_fails(self): + # null is not a string + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + StringTypeMatchesStrings( + + None ) + + def test_a_string_is_a_string_passes(self): + # a string is a string + StringTypeMatchesStrings( + + "foo" ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py new file mode 100644 index 00000000000..63eb2bf6bc2 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py @@ -0,0 +1,49 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.the_default_keyword_does_not_do_anything_if_the_property_is_missing import TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing + + +class TestTheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing(unittest.TestCase): + """TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing unit test stubs""" + + def test_missing_properties_are_not_filled_in_with_the_default_passes(self): + # missing properties are not filled in with the default + TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing( + { + } + ) + + def test_an_explicit_property_value_is_checked_against_maximum_passing_passes(self): + # an explicit property value is checked against maximum (passing) + TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing( + **{ + "alpha": + 1, + } + ) + + def test_an_explicit_property_value_is_checked_against_maximum_failing_fails(self): + # an explicit property value is checked against maximum (failing) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing( + **{ + "alpha": + 5, + } + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_allows_a_schema_which_should_validate.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_allows_a_schema_which_should_validate.py new file mode 100644 index 00000000000..8e986da86fc --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_allows_a_schema_which_should_validate.py @@ -0,0 +1,97 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class AdditionalpropertiesAllowsASchemaWhichShouldValidate( + DictSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + foo = AnyTypeSchema + bar = AnyTypeSchema + _additional_properties = BoolSchema + + + def __new__( + cls, + *args: typing.Union[dict, frozendict, ], + foo: typing.Union[foo, Unset] = unset, + bar: typing.Union[bar, Unset] = unset, + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'AdditionalpropertiesAllowsASchemaWhichShouldValidate': + return super().__new__( + cls, + *args, + foo=foo, + bar=bar, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_are_allowed_by_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_are_allowed_by_default.py new file mode 100644 index 00000000000..2251b2f815a --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_are_allowed_by_default.py @@ -0,0 +1,95 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class AdditionalpropertiesAreAllowedByDefault( + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + foo = AnyTypeSchema + bar = AnyTypeSchema + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + foo: typing.Union[foo, Unset] = unset, + bar: typing.Union[bar, Unset] = unset, + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'AdditionalpropertiesAreAllowedByDefault': + return super().__new__( + cls, + *args, + foo=foo, + bar=bar, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_can_exist_by_itself.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_can_exist_by_itself.py new file mode 100644 index 00000000000..383a01af174 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_can_exist_by_itself.py @@ -0,0 +1,91 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class AdditionalpropertiesCanExistByItself( + DictSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + _additional_properties = BoolSchema + + + def __new__( + cls, + *args: typing.Union[dict, frozendict, ], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'AdditionalpropertiesCanExistByItself': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_should_not_look_in_applicators.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_should_not_look_in_applicators.py new file mode 100644 index 00000000000..66547528189 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_should_not_look_in_applicators.py @@ -0,0 +1,114 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class AdditionalpropertiesShouldNotLookInApplicators( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + _additional_properties = BoolSchema + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 + allOf_0 = AnyTypeSchema + return { + 'allOf': [ + allOf_0, + ], + 'oneOf': [ + ], + 'anyOf': [ + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'AdditionalpropertiesShouldNotLookInApplicators': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/array_type_matches_arrays.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/array_type_matches_arrays.py new file mode 100644 index 00000000000..583f9843b64 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/array_type_matches_arrays.py @@ -0,0 +1,77 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class ArrayTypeMatchesArrays( + ListSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + _items = AnyTypeSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/boolean_type_matches_booleans.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/boolean_type_matches_booleans.py new file mode 100644 index 00000000000..93cd0a0505f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/boolean_type_matches_booleans.py @@ -0,0 +1,67 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) +BooleanTypeMatchesBooleans = BoolSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/integer_type_matches_integers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/integer_type_matches_integers.py new file mode 100644 index 00000000000..472bd37aa71 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/integer_type_matches_integers.py @@ -0,0 +1,67 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) +IntegerTypeMatchesIntegers = IntSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_string_value_for_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_string_value_for_default.py new file mode 100644 index 00000000000..07ad386d3b8 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_string_value_for_default.py @@ -0,0 +1,100 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class InvalidStringValueForDefault( + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + + class bar( + _SchemaValidator( + min_length=4, + ), + StrSchema + ): + pass + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + bar: typing.Union[bar, Unset] = unset, + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'InvalidStringValueForDefault': + return super().__new__( + cls, + *args, + bar=bar, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_type_for_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_type_for_default.py new file mode 100644 index 00000000000..bffccf32de0 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_type_for_default.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class InvalidTypeForDefault( + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + foo = IntSchema + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + foo: typing.Union[foo, Unset] = unset, + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'InvalidTypeForDefault': + return super().__new__( + cls, + *args, + foo=foo, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/null_type_matches_only_the_null_object.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/null_type_matches_only_the_null_object.py new file mode 100644 index 00000000000..3ed5b3d6b3b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/null_type_matches_only_the_null_object.py @@ -0,0 +1,67 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) +NullTypeMatchesOnlyTheNullObject = NoneSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/number_type_matches_numbers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/number_type_matches_numbers.py new file mode 100644 index 00000000000..3b33c38f4cd --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/number_type_matches_numbers.py @@ -0,0 +1,67 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) +NumberTypeMatchesNumbers = NumberSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/string_type_matches_strings.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/string_type_matches_strings.py new file mode 100644 index 00000000000..f1c3c9a0302 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/string_type_matches_strings.py @@ -0,0 +1,67 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) +StringTypeMatchesStrings = StrSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/the_default_keyword_does_not_do_anything_if_the_property_is_missing.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/the_default_keyword_does_not_do_anything_if_the_property_is_missing.py new file mode 100644 index 00000000000..d59150db52b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/the_default_keyword_does_not_do_anything_if_the_property_is_missing.py @@ -0,0 +1,101 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing( + DictSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + + class alpha( + _SchemaValidator( + inclusive_maximum=3, + ), + NumberSchema + ): + pass + + + def __new__( + cls, + *args: typing.Union[dict, frozendict, ], + alpha: typing.Union[alpha, Unset] = unset, + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing': + return super().__new__( + cls, + *args, + alpha=alpha, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py index f6921ceae2f..7c56ec55ecf 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py @@ -11,11 +11,24 @@ # import sys # sys.setrecursionlimit(n) +from unit_test_api.model.additionalproperties_allows_a_schema_which_should_validate import AdditionalpropertiesAllowsASchemaWhichShouldValidate +from unit_test_api.model.additionalproperties_are_allowed_by_default import AdditionalpropertiesAreAllowedByDefault +from unit_test_api.model.additionalproperties_can_exist_by_itself import AdditionalpropertiesCanExistByItself +from unit_test_api.model.additionalproperties_should_not_look_in_applicators import AdditionalpropertiesShouldNotLookInApplicators +from unit_test_api.model.array_type_matches_arrays import ArrayTypeMatchesArrays +from unit_test_api.model.boolean_type_matches_booleans import BooleanTypeMatchesBooleans from unit_test_api.model.enum_with0_does_not_match_false import EnumWith0DoesNotMatchFalse from unit_test_api.model.enum_with1_does_not_match_true import EnumWith1DoesNotMatchTrue from unit_test_api.model.enum_with_escaped_characters import EnumWithEscapedCharacters from unit_test_api.model.enum_with_false_does_not_match0 import EnumWithFalseDoesNotMatch0 from unit_test_api.model.enum_with_true_does_not_match1 import EnumWithTrueDoesNotMatch1 from unit_test_api.model.enums_in_properties import EnumsInProperties +from unit_test_api.model.integer_type_matches_integers import IntegerTypeMatchesIntegers +from unit_test_api.model.invalid_string_value_for_default import InvalidStringValueForDefault +from unit_test_api.model.invalid_type_for_default import InvalidTypeForDefault from unit_test_api.model.nul_characters_in_strings import NulCharactersInStrings +from unit_test_api.model.null_type_matches_only_the_null_object import NullTypeMatchesOnlyTheNullObject +from unit_test_api.model.number_type_matches_numbers import NumberTypeMatchesNumbers from unit_test_api.model.simple_enum_validation import SimpleEnumValidation +from unit_test_api.model.string_type_matches_strings import StringTypeMatchesStrings +from unit_test_api.model.the_default_keyword_does_not_do_anything_if_the_property_is_missing import TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing -- GitLab From 79b1d2a9968cdcf3560fb473cdaacf20dfb51667 Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Sun, 26 Jun 2022 16:06:59 -0700 Subject: [PATCH 10/43] Adds exclmax and min exclusion reasons --- .../3_0/unit_test_spec/spec_writer.py | 28 +- .../resources/3_0/unit_test_spec/type.yaml | 543 +----------------- .../.openapi-generator/FILES | 63 -- .../python-experimental/README.md | 21 - ...pertiesAllowsASchemaWhichShouldValidate.md | 11 - ...AdditionalpropertiesAreAllowedByDefault.md | 11 - .../AdditionalpropertiesCanExistByItself.md | 9 - ...nalpropertiesShouldNotLookInApplicators.md | 9 - .../docs/ArrayTypeMatchesArrays.md | 8 - .../docs/BooleanTypeMatchesBooleans.md | 8 - .../docs/EnumWith0DoesNotMatchFalse.md | 8 - .../docs/EnumWith1DoesNotMatchTrue.md | 8 - .../docs/EnumWithEscapedCharacters.md | 9 - .../docs/EnumWithFalseDoesNotMatch0.md | 8 - .../docs/EnumWithTrueDoesNotMatch1.md | 8 - .../docs/EnumsInProperties.md | 11 - .../docs/IntegerTypeMatchesIntegers.md | 8 - .../docs/InvalidStringValueForDefault.md | 10 - .../docs/InvalidTypeForDefault.md | 10 - .../docs/NulCharactersInStrings.md | 8 - .../docs/NullTypeMatchesOnlyTheNullObject.md | 8 - .../docs/NumberTypeMatchesNumbers.md | 8 - .../docs/SimpleEnumValidation.md | 8 - .../docs/StringTypeMatchesStrings.md | 8 - ...DoesNotDoAnythingIfThePropertyIsMissing.md | 10 - ...s_allows_a_schema_which_should_validate.py | 60 -- ...tionalproperties_are_allowed_by_default.py | 37 -- ...dditionalproperties_can_exist_by_itself.py | 43 -- ...operties_should_not_look_in_applicators.py | 36 -- .../test/test_array_type_matches_arrays.py | 71 --- .../test_boolean_type_matches_booleans.py | 90 --- .../test_enum_with0_does_not_match_false.py | 40 -- .../test_enum_with1_does_not_match_true.py | 40 -- .../test/test_enum_with_escaped_characters.py | 43 -- .../test_enum_with_false_does_not_match0.py | 41 -- .../test_enum_with_true_does_not_match1.py | 41 -- .../test/test_enums_in_properties.py | 93 --- .../test_integer_type_matches_integers.py | 83 --- .../test_invalid_string_value_for_default.py | 40 -- .../test/test_invalid_type_for_default.py | 39 -- .../test/test_nul_characters_in_strings.py | 36 -- ..._null_type_matches_only_the_null_object.py | 91 --- .../test/test_number_type_matches_numbers.py | 82 --- .../test/test_simple_enum_validation.py | 34 -- .../test/test_string_type_matches_strings.py | 83 --- ..._do_anything_if_the_property_is_missing.py | 49 -- ...s_allows_a_schema_which_should_validate.py | 97 ---- ...tionalproperties_are_allowed_by_default.py | 95 --- ...dditionalproperties_can_exist_by_itself.py | 91 --- ...operties_should_not_look_in_applicators.py | 114 ---- .../model/array_type_matches_arrays.py | 77 --- .../model/boolean_type_matches_booleans.py | 67 --- .../model/enum_with0_does_not_match_false.py | 86 --- .../model/enum_with1_does_not_match_true.py | 86 --- .../model/enum_with_escaped_characters.py | 94 --- .../model/enum_with_false_does_not_match0.py | 86 --- .../model/enum_with_true_does_not_match1.py | 86 --- .../model/enums_in_properties.py | 127 ---- .../model/integer_type_matches_integers.py | 67 --- .../model/invalid_string_value_for_default.py | 100 ---- .../model/invalid_type_for_default.py | 92 --- .../model/nul_characters_in_strings.py | 86 --- .../null_type_matches_only_the_null_object.py | 67 --- .../model/number_type_matches_numbers.py | 67 --- .../model/simple_enum_validation.py | 98 ---- .../model/string_type_matches_strings.py | 67 --- ..._do_anything_if_the_property_is_missing.py | 101 ---- .../unit_test_api/models/__init__.py | 21 - 68 files changed, 18 insertions(+), 3867 deletions(-) delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAreAllowedByDefault.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesCanExistByItself.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesShouldNotLookInApplicators.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ArrayTypeMatchesArrays.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/BooleanTypeMatchesBooleans.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWith0DoesNotMatchFalse.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWith1DoesNotMatchTrue.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithEscapedCharacters.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithFalseDoesNotMatch0.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithTrueDoesNotMatch1.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumsInProperties.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/IntegerTypeMatchesIntegers.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidStringValueForDefault.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidTypeForDefault.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NulCharactersInStrings.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NullTypeMatchesOnlyTheNullObject.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NumberTypeMatchesNumbers.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/SimpleEnumValidation.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/StringTypeMatchesStrings.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with0_does_not_match_false.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with1_does_not_match_true.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_escaped_characters.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_false_does_not_match0.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_true_does_not_match1.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enums_in_properties.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_string_value_for_default.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_type_for_default.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nul_characters_in_strings.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_simple_enum_validation.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_allows_a_schema_which_should_validate.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_are_allowed_by_default.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_can_exist_by_itself.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_should_not_look_in_applicators.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/array_type_matches_arrays.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/boolean_type_matches_booleans.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with0_does_not_match_false.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with1_does_not_match_true.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_escaped_characters.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_false_does_not_match0.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_true_does_not_match1.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enums_in_properties.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/integer_type_matches_integers.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_string_value_for_default.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_type_for_default.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nul_characters_in_strings.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/null_type_matches_only_the_null_object.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/number_type_matches_numbers.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/simple_enum_validation.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/string_type_matches_strings.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/the_default_keyword_does_not_do_anything_if_the_property_is_missing.py diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index eafbee851a1..c01891e8553 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -85,6 +85,7 @@ class ExclusionReason: v303_does_not_support_definitions = 'v3.0.3 does not support the definitions keyword' v303_does_not_support_dependencies = 'v3.0.3 does not support the dependencies keyword' swagger_parser_enum_type_bug = "swagger-parser has a bug where schema type is incorrectly set for an enum, https://github.com/swagger-api/swagger-parser/issues/1761" + swagger_parser_validation_missing_bug = 'swagger-parser has a bug where validations are unset, https://github.com/swagger-api/swagger-parser/issues/1762' json_schema_test_draft = 'draft6' FILEPATH_TO_EXCLUDED_CASE_AND_REASON = { @@ -99,11 +100,10 @@ FILEPATH_TO_EXCLUDED_CASE_AND_REASON = { 'heterogeneous enum validation': ExclusionReason.swagger_parser_enum_type_bug, 'heterogeneous enum-with-null validation': ExclusionReason.swagger_parser_enum_type_bug, }, - (json_schema_test_draft, 'additionalProperties.json'): { 'non-ASCII pattern with additionalProperties': ExclusionReason.v303_does_not_support_patternProperties, 'additionalProperties being false does not allow other properties': ExclusionReason.v303_does_not_support_patternProperties, - } + }, } FILEPATH_TO_EXCLUDE_REASON = { (json_schema_test_draft, 'additionalItems.json'): ExclusionReason.v303_does_not_support_additionalItems, @@ -112,23 +112,27 @@ FILEPATH_TO_EXCLUDE_REASON = { (json_schema_test_draft, 'contains.json'): ExclusionReason.v303_does_not_support_contains, (json_schema_test_draft, 'definitions.json'): ExclusionReason.v303_does_not_support_definitions, (json_schema_test_draft, 'dependencies.json'): ExclusionReason.v303_does_not_support_dependencies, + (json_schema_test_draft, 'exclusiveMaximum.json'): ExclusionReason.swagger_parser_validation_missing_bug, + (json_schema_test_draft, 'exclusiveMinimum.json'): ExclusionReason.swagger_parser_validation_missing_bug, } openapi_additions = 'openapi_additions' JSON_SCHEMA_TEST_FILE_TO_FOLDERS = { - 'type.json': (json_schema_test_draft, openapi_additions), - 'additionalItems.json': (json_schema_test_draft,), - 'additionalProperties.json': (json_schema_test_draft,), +# 'type.json': (json_schema_test_draft, openapi_additions), +# 'additionalItems.json': (json_schema_test_draft,), +# 'additionalProperties.json': (json_schema_test_draft,), # 'allOf.json': (json_schema_test_draft,), # activate later after fixing composition processing # 'anyOf.json': (json_schema_test_draft,), # activate later after fixing composition processing - 'boolean_schema.json': (json_schema_test_draft,), - 'const.json': (json_schema_test_draft,), - 'contains.json': (json_schema_test_draft,), - 'default.json': (json_schema_test_draft,), - 'definitions.json': (json_schema_test_draft,), - 'dependencies.json': (json_schema_test_draft,), - 'enum.json': (json_schema_test_draft,), +# 'boolean_schema.json': (json_schema_test_draft,), +# 'const.json': (json_schema_test_draft,), +# 'contains.json': (json_schema_test_draft,), +# 'default.json': (json_schema_test_draft,), +# 'definitions.json': (json_schema_test_draft,), +# 'dependencies.json': (json_schema_test_draft,), +# 'enum.json': (json_schema_test_draft,), + 'exclusiveMaximum.json': (json_schema_test_draft,), + 'exclusiveMinimum.json': (json_schema_test_draft,), } def get_json_schema_test_schemas(file_path: typing.Tuple[str]) -> typing.List[JsonSchemaTestSchema]: diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml index 57e56774604..2a0b920f0b7 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml @@ -6,544 +6,5 @@ info: version: 0.0.1 paths: {} components: - schemas: - IntegerTypeMatchesIntegers: - type: integer - NumberTypeMatchesNumbers: - type: number - StringTypeMatchesStrings: - type: string - ObjectTypeMatchesObjects: - type: object - BooleanTypeMatchesBooleans: - type: boolean - NullTypeMatchesOnlyTheNullObject: - type: 'null' - ArrayTypeMatchesArrays: - type: array - items: {} - AdditionalpropertiesAllowsASchemaWhichShouldValidate: - properties: - foo: {} - bar: {} - additionalProperties: - type: boolean - AdditionalpropertiesCanExistByItself: - additionalProperties: - type: boolean - AdditionalpropertiesAreAllowedByDefault: - properties: - foo: {} - bar: {} - AdditionalpropertiesShouldNotLookInApplicators: - allOf: - - properties: - foo: {} - additionalProperties: - type: boolean - InvalidTypeForDefault: - properties: - foo: - type: integer - default: [] - InvalidStringValueForDefault: - properties: - bar: - type: string - minLength: 4 - default: bad - TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing: - type: object - properties: - alpha: - type: number - maximum: 3 - default: 5 - SimpleEnumValidation: - enum: - - 1 - - 2 - - 3 - EnumsInProperties: - type: object - properties: - foo: - enum: - - foo - bar: - enum: - - bar - required: - - bar - EnumWithEscapedCharacters: - enum: - - 'foo - - bar' - - "foo\rbar" - EnumWithFalseDoesNotMatch0: - enum: - - false - EnumWithTrueDoesNotMatch1: - enum: - - true - EnumWith0DoesNotMatchFalse: - enum: - - 0 - EnumWith1DoesNotMatchTrue: - enum: - - 1 - NulCharactersInStrings: - enum: - - "hello\0there" - x-schema-test-examples: - IntegerTypeMatchesIntegers: - AnIntegerIsAnInteger: - description: an integer is an integer - data: 1 - valid: true - AFloatWithZeroFractionalPartIsAnInteger: - description: a float with zero fractional part is an integer - data: 1.0 - valid: true - AFloatIsNotAnInteger: - description: a float is not an integer - data: 1.1 - valid: false - AStringIsNotAnInteger: - description: a string is not an integer - data: foo - valid: false - AStringIsStillNotAnIntegerEvenIfItLooksLikeOne: - description: a string is still not an integer, even if it looks like one - data: '1' - valid: false - AnObjectIsNotAnInteger: - description: an object is not an integer - data: {} - valid: false - AnArrayIsNotAnInteger: - description: an array is not an integer - data: [] - valid: false - ABooleanIsNotAnInteger: - description: a boolean is not an integer - data: true - valid: false - NullIsNotAnInteger: - description: null is not an integer - data: null - valid: false - NumberTypeMatchesNumbers: - AnIntegerIsANumber: - description: an integer is a number - data: 1 - valid: true - AFloatWithZeroFractionalPartIsANumberAndAnInteger: - description: a float with zero fractional part is a number (and an integer) - data: 1.0 - valid: true - AFloatIsANumber: - description: a float is a number - data: 1.1 - valid: true - AStringIsNotANumber: - description: a string is not a number - data: foo - valid: false - AStringIsStillNotANumberEvenIfItLooksLikeOne: - description: a string is still not a number, even if it looks like one - data: '1' - valid: false - AnObjectIsNotANumber: - description: an object is not a number - data: {} - valid: false - AnArrayIsNotANumber: - description: an array is not a number - data: [] - valid: false - ABooleanIsNotANumber: - description: a boolean is not a number - data: true - valid: false - NullIsNotANumber: - description: null is not a number - data: null - valid: false - StringTypeMatchesStrings: - 1IsNotAString: - description: 1 is not a string - data: 1 - valid: false - AFloatIsNotAString: - description: a float is not a string - data: 1.1 - valid: false - AStringIsAString: - description: a string is a string - data: foo - valid: true - AStringIsStillAStringEvenIfItLooksLikeANumber: - description: a string is still a string, even if it looks like a number - data: '1' - valid: true - AnEmptyStringIsStillAString: - description: an empty string is still a string - data: '' - valid: true - AnObjectIsNotAString: - description: an object is not a string - data: {} - valid: false - AnArrayIsNotAString: - description: an array is not a string - data: [] - valid: false - ABooleanIsNotAString: - description: a boolean is not a string - data: true - valid: false - NullIsNotAString: - description: null is not a string - data: null - valid: false - ObjectTypeMatchesObjects: - AnIntegerIsNotAnObject: - description: an integer is not an object - data: 1 - valid: false - AFloatIsNotAnObject: - description: a float is not an object - data: 1.1 - valid: false - AStringIsNotAnObject: - description: a string is not an object - data: foo - valid: false - AnObjectIsAnObject: - description: an object is an object - data: {} - valid: true - AnArrayIsNotAnObject: - description: an array is not an object - data: [] - valid: false - ABooleanIsNotAnObject: - description: a boolean is not an object - data: true - valid: false - NullIsNotAnObject: - description: null is not an object - data: null - valid: false - BooleanTypeMatchesBooleans: - AnIntegerIsNotABoolean: - description: an integer is not a boolean - data: 1 - valid: false - ZeroIsNotABoolean: - description: zero is not a boolean - data: 0 - valid: false - AFloatIsNotABoolean: - description: a float is not a boolean - data: 1.1 - valid: false - AStringIsNotABoolean: - description: a string is not a boolean - data: foo - valid: false - AnEmptyStringIsNotABoolean: - description: an empty string is not a boolean - data: '' - valid: false - AnObjectIsNotABoolean: - description: an object is not a boolean - data: {} - valid: false - AnArrayIsNotABoolean: - description: an array is not a boolean - data: [] - valid: false - TrueIsABoolean: - description: true is a boolean - data: true - valid: true - FalseIsABoolean: - description: false is a boolean - data: false - valid: true - NullIsNotABoolean: - description: null is not a boolean - data: null - valid: false - NullTypeMatchesOnlyTheNullObject: - AnIntegerIsNotNull: - description: an integer is not null - data: 1 - valid: false - AFloatIsNotNull: - description: a float is not null - data: 1.1 - valid: false - ZeroIsNotNull: - description: zero is not null - data: 0 - valid: false - AStringIsNotNull: - description: a string is not null - data: foo - valid: false - AnEmptyStringIsNotNull: - description: an empty string is not null - data: '' - valid: false - AnObjectIsNotNull: - description: an object is not null - data: {} - valid: false - AnArrayIsNotNull: - description: an array is not null - data: [] - valid: false - TrueIsNotNull: - description: true is not null - data: true - valid: false - FalseIsNotNull: - description: false is not null - data: false - valid: false - NullIsNull: - description: null is null - data: null - valid: true - ArrayTypeMatchesArrays: - AnIntegerIsNotAnArray: - description: an integer is not an array - data: 1 - valid: false - AFloatIsNotAnArray: - description: a float is not an array - data: 1.1 - valid: false - AStringIsNotAnArray: - description: a string is not an array - data: foo - valid: false - AnObjectIsNotAnArray: - description: an object is not an array - data: {} - valid: false - AnArrayIsAnArray: - description: an array is an array - data: [] - valid: true - ABooleanIsNotAnArray: - description: a boolean is not an array - data: true - valid: false - NullIsNotAnArray: - description: null is not an array - data: null - valid: false - AdditionalpropertiesAllowsASchemaWhichShouldValidate: - NoAdditionalPropertiesIsValid: - description: no additional properties is valid - data: - foo: 1 - valid: true - AnAdditionalValidPropertyIsValid: - description: an additional valid property is valid - data: - foo: 1 - bar: 2 - quux: true - valid: true - AnAdditionalInvalidPropertyIsInvalid: - description: an additional invalid property is invalid - data: - foo: 1 - bar: 2 - quux: 12 - valid: false - AdditionalpropertiesCanExistByItself: - AnAdditionalValidPropertyIsValid: - description: an additional valid property is valid - data: - foo: true - valid: true - AnAdditionalInvalidPropertyIsInvalid: - description: an additional invalid property is invalid - data: - foo: 1 - valid: false - AdditionalpropertiesAreAllowedByDefault: - AdditionalPropertiesAreAllowed: - description: additional properties are allowed - data: - foo: 1 - bar: 2 - quux: true - valid: true - AdditionalpropertiesShouldNotLookInApplicators: - PropertiesDefinedInAllofAreNotExamined: - description: properties defined in allOf are not examined - data: - foo: 1 - bar: true - valid: false - InvalidTypeForDefault: - ValidWhenPropertyIsSpecified: - description: valid when property is specified - data: - foo: 13 - valid: true - StillValidWhenTheInvalidDefaultIsUsed: - description: still valid when the invalid default is used - data: {} - valid: true - InvalidStringValueForDefault: - ValidWhenPropertyIsSpecified: - description: valid when property is specified - data: - bar: good - valid: true - StillValidWhenTheInvalidDefaultIsUsed: - description: still valid when the invalid default is used - data: {} - valid: true - TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing: - AnExplicitPropertyValueIsCheckedAgainstMaximumPassing: - description: an explicit property value is checked against maximum (passing) - data: - alpha: 1 - valid: true - AnExplicitPropertyValueIsCheckedAgainstMaximumFailing: - description: an explicit property value is checked against maximum (failing) - data: - alpha: 5 - valid: false - MissingPropertiesAreNotFilledInWithTheDefault: - description: missing properties are not filled in with the default - data: {} - valid: true - SimpleEnumValidation: - OneOfTheEnumIsValid: - description: one of the enum is valid - data: 1 - valid: true - SomethingElseIsInvalid: - description: something else is invalid - data: 4 - valid: false - EnumsInProperties: - BothPropertiesAreValid: - description: both properties are valid - data: - foo: foo - bar: bar - valid: true - WrongFooValue: - description: wrong foo value - data: - foo: foot - bar: bar - valid: false - WrongBarValue: - description: wrong bar value - data: - foo: foo - bar: bart - valid: false - MissingOptionalPropertyIsValid: - description: missing optional property is valid - data: - bar: bar - valid: true - MissingRequiredPropertyIsInvalid: - description: missing required property is invalid - data: - foo: foo - valid: false - MissingAllPropertiesIsInvalid: - description: missing all properties is invalid - data: {} - valid: false - EnumWithEscapedCharacters: - Member1IsValid: - description: member 1 is valid - data: 'foo - - bar' - valid: true - Member2IsValid: - description: member 2 is valid - data: "foo\rbar" - valid: true - AnotherStringIsInvalid: - description: another string is invalid - data: abc - valid: false - EnumWithFalseDoesNotMatch0: - FalseIsValid: - description: false is valid - data: false - valid: true - IntegerZeroIsInvalid: - description: integer zero is invalid - data: 0 - valid: false - FloatZeroIsInvalid: - description: float zero is invalid - data: 0.0 - valid: false - EnumWithTrueDoesNotMatch1: - TrueIsValid: - description: true is valid - data: true - valid: true - IntegerOneIsInvalid: - description: integer one is invalid - data: 1 - valid: false - FloatOneIsInvalid: - description: float one is invalid - data: 1.0 - valid: false - EnumWith0DoesNotMatchFalse: - FalseIsInvalid: - description: false is invalid - data: false - valid: false - IntegerZeroIsValid: - description: integer zero is valid - data: 0 - valid: true - FloatZeroIsValid: - description: float zero is valid - data: 0.0 - valid: true - EnumWith1DoesNotMatchTrue: - TrueIsInvalid: - description: true is invalid - data: true - valid: false - IntegerOneIsValid: - description: integer one is valid - data: 1 - valid: true - FloatOneIsValid: - description: float one is valid - data: 1.0 - valid: true - NulCharactersInStrings: - MatchStringWithNul: - description: match string with nul - data: "hello\0there" - valid: true - DoNotMatchStringLackingNul: - description: do not match string lacking nul - data: hellothere - valid: false + schemas: {} + x-schema-test-examples: {} diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index f375c2685bb..a5c70c8904f 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -2,54 +2,12 @@ .gitlab-ci.yml .travis.yml README.md -docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md -docs/AdditionalpropertiesAreAllowedByDefault.md -docs/AdditionalpropertiesCanExistByItself.md -docs/AdditionalpropertiesShouldNotLookInApplicators.md -docs/ArrayTypeMatchesArrays.md -docs/BooleanTypeMatchesBooleans.md -docs/EnumWith0DoesNotMatchFalse.md -docs/EnumWith1DoesNotMatchTrue.md -docs/EnumWithEscapedCharacters.md -docs/EnumWithFalseDoesNotMatch0.md -docs/EnumWithTrueDoesNotMatch1.md -docs/EnumsInProperties.md -docs/IntegerTypeMatchesIntegers.md -docs/InvalidStringValueForDefault.md -docs/InvalidTypeForDefault.md -docs/NulCharactersInStrings.md -docs/NullTypeMatchesOnlyTheNullObject.md -docs/NumberTypeMatchesNumbers.md -docs/SimpleEnumValidation.md -docs/StringTypeMatchesStrings.md -docs/TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md git_push.sh requirements.txt setup.cfg setup.py test-requirements.txt test/__init__.py -test/test_additionalproperties_allows_a_schema_which_should_validate.py -test/test_additionalproperties_are_allowed_by_default.py -test/test_additionalproperties_can_exist_by_itself.py -test/test_additionalproperties_should_not_look_in_applicators.py -test/test_array_type_matches_arrays.py -test/test_boolean_type_matches_booleans.py -test/test_enum_with0_does_not_match_false.py -test/test_enum_with1_does_not_match_true.py -test/test_enum_with_escaped_characters.py -test/test_enum_with_false_does_not_match0.py -test/test_enum_with_true_does_not_match1.py -test/test_enums_in_properties.py -test/test_integer_type_matches_integers.py -test/test_invalid_string_value_for_default.py -test/test_invalid_type_for_default.py -test/test_nul_characters_in_strings.py -test/test_null_type_matches_only_the_null_object.py -test/test_number_type_matches_numbers.py -test/test_simple_enum_validation.py -test/test_string_type_matches_strings.py -test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py tox.ini unit_test_api/__init__.py unit_test_api/api/__init__.py @@ -58,27 +16,6 @@ unit_test_api/apis/__init__.py unit_test_api/configuration.py unit_test_api/exceptions.py unit_test_api/model/__init__.py -unit_test_api/model/additionalproperties_allows_a_schema_which_should_validate.py -unit_test_api/model/additionalproperties_are_allowed_by_default.py -unit_test_api/model/additionalproperties_can_exist_by_itself.py -unit_test_api/model/additionalproperties_should_not_look_in_applicators.py -unit_test_api/model/array_type_matches_arrays.py -unit_test_api/model/boolean_type_matches_booleans.py -unit_test_api/model/enum_with0_does_not_match_false.py -unit_test_api/model/enum_with1_does_not_match_true.py -unit_test_api/model/enum_with_escaped_characters.py -unit_test_api/model/enum_with_false_does_not_match0.py -unit_test_api/model/enum_with_true_does_not_match1.py -unit_test_api/model/enums_in_properties.py -unit_test_api/model/integer_type_matches_integers.py -unit_test_api/model/invalid_string_value_for_default.py -unit_test_api/model/invalid_type_for_default.py -unit_test_api/model/nul_characters_in_strings.py -unit_test_api/model/null_type_matches_only_the_null_object.py -unit_test_api/model/number_type_matches_numbers.py -unit_test_api/model/simple_enum_validation.py -unit_test_api/model/string_type_matches_strings.py -unit_test_api/model/the_default_keyword_does_not_do_anything_if_the_property_is_missing.py unit_test_api/models/__init__.py unit_test_api/rest.py unit_test_api/schemas.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md index 2d5017e5247..162b9a6acb5 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md @@ -62,27 +62,6 @@ Class | Method | HTTP request | Description ## Documentation For Models - - [AdditionalpropertiesAllowsASchemaWhichShouldValidate](docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md) - - [AdditionalpropertiesAreAllowedByDefault](docs/AdditionalpropertiesAreAllowedByDefault.md) - - [AdditionalpropertiesCanExistByItself](docs/AdditionalpropertiesCanExistByItself.md) - - [AdditionalpropertiesShouldNotLookInApplicators](docs/AdditionalpropertiesShouldNotLookInApplicators.md) - - [ArrayTypeMatchesArrays](docs/ArrayTypeMatchesArrays.md) - - [BooleanTypeMatchesBooleans](docs/BooleanTypeMatchesBooleans.md) - - [EnumWith0DoesNotMatchFalse](docs/EnumWith0DoesNotMatchFalse.md) - - [EnumWith1DoesNotMatchTrue](docs/EnumWith1DoesNotMatchTrue.md) - - [EnumWithEscapedCharacters](docs/EnumWithEscapedCharacters.md) - - [EnumWithFalseDoesNotMatch0](docs/EnumWithFalseDoesNotMatch0.md) - - [EnumWithTrueDoesNotMatch1](docs/EnumWithTrueDoesNotMatch1.md) - - [EnumsInProperties](docs/EnumsInProperties.md) - - [IntegerTypeMatchesIntegers](docs/IntegerTypeMatchesIntegers.md) - - [InvalidStringValueForDefault](docs/InvalidStringValueForDefault.md) - - [InvalidTypeForDefault](docs/InvalidTypeForDefault.md) - - [NulCharactersInStrings](docs/NulCharactersInStrings.md) - - [NullTypeMatchesOnlyTheNullObject](docs/NullTypeMatchesOnlyTheNullObject.md) - - [NumberTypeMatchesNumbers](docs/NumberTypeMatchesNumbers.md) - - [SimpleEnumValidation](docs/SimpleEnumValidation.md) - - [StringTypeMatchesStrings](docs/StringTypeMatchesStrings.md) - - [TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing](docs/TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md) ## Documentation For Authorization diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md deleted file mode 100644 index d9981bf45a7..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md +++ /dev/null @@ -1,11 +0,0 @@ -# AdditionalpropertiesAllowsASchemaWhichShouldValidate - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**foo** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] -**bar** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] -**any string name** | **bool** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAreAllowedByDefault.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAreAllowedByDefault.md deleted file mode 100644 index d5e7d2747ee..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAreAllowedByDefault.md +++ /dev/null @@ -1,11 +0,0 @@ -# AdditionalpropertiesAreAllowedByDefault - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**foo** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] -**bar** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesCanExistByItself.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesCanExistByItself.md deleted file mode 100644 index 72b091b888a..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesCanExistByItself.md +++ /dev/null @@ -1,9 +0,0 @@ -# AdditionalpropertiesCanExistByItself - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesShouldNotLookInApplicators.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesShouldNotLookInApplicators.md deleted file mode 100644 index 31efeb974b1..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesShouldNotLookInApplicators.md +++ /dev/null @@ -1,9 +0,0 @@ -# AdditionalpropertiesShouldNotLookInApplicators - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ArrayTypeMatchesArrays.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ArrayTypeMatchesArrays.md deleted file mode 100644 index bf72f2c35bc..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ArrayTypeMatchesArrays.md +++ /dev/null @@ -1,8 +0,0 @@ -# ArrayTypeMatchesArrays - -Type | Description | Notes -------------- | ------------- | ------------- -**[bool, date, datetime, dict, float, int, list, str, none_type]** | | - -[[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/3_0_3_unit_test/python-experimental/docs/BooleanTypeMatchesBooleans.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/BooleanTypeMatchesBooleans.md deleted file mode 100644 index fa68a60fd2b..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/BooleanTypeMatchesBooleans.md +++ /dev/null @@ -1,8 +0,0 @@ -# BooleanTypeMatchesBooleans - -Type | Description | Notes -------------- | ------------- | ------------- -**bool** | | - -[[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/3_0_3_unit_test/python-experimental/docs/EnumWith0DoesNotMatchFalse.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWith0DoesNotMatchFalse.md deleted file mode 100644 index d5a6a187010..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWith0DoesNotMatchFalse.md +++ /dev/null @@ -1,8 +0,0 @@ -# EnumWith0DoesNotMatchFalse - -Type | Description | Notes -------------- | ------------- | ------------- -**float** | | must be one of [0, ] - -[[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/3_0_3_unit_test/python-experimental/docs/EnumWith1DoesNotMatchTrue.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWith1DoesNotMatchTrue.md deleted file mode 100644 index 302b358dc61..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWith1DoesNotMatchTrue.md +++ /dev/null @@ -1,8 +0,0 @@ -# EnumWith1DoesNotMatchTrue - -Type | Description | Notes -------------- | ------------- | ------------- -**float** | | must be one of [1, ] - -[[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/3_0_3_unit_test/python-experimental/docs/EnumWithEscapedCharacters.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithEscapedCharacters.md deleted file mode 100644 index d13b6ca704f..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithEscapedCharacters.md +++ /dev/null @@ -1,9 +0,0 @@ -# EnumWithEscapedCharacters - -Type | Description | Notes -------------- | ------------- | ------------- -**str** | | must be one of ['''foo -bar''', '''foo bar''', ] - -[[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/3_0_3_unit_test/python-experimental/docs/EnumWithFalseDoesNotMatch0.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithFalseDoesNotMatch0.md deleted file mode 100644 index f1cef961444..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithFalseDoesNotMatch0.md +++ /dev/null @@ -1,8 +0,0 @@ -# EnumWithFalseDoesNotMatch0 - -Type | Description | Notes -------------- | ------------- | ------------- -**bool** | | must be one of [False, ] - -[[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/3_0_3_unit_test/python-experimental/docs/EnumWithTrueDoesNotMatch1.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithTrueDoesNotMatch1.md deleted file mode 100644 index 09723bcb68c..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithTrueDoesNotMatch1.md +++ /dev/null @@ -1,8 +0,0 @@ -# EnumWithTrueDoesNotMatch1 - -Type | Description | Notes -------------- | ------------- | ------------- -**bool** | | must be one of [True, ] - -[[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/3_0_3_unit_test/python-experimental/docs/EnumsInProperties.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumsInProperties.md deleted file mode 100644 index 7b058dabb44..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumsInProperties.md +++ /dev/null @@ -1,11 +0,0 @@ -# EnumsInProperties - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**foo** | **str** | | [optional] -**bar** | **str** | | -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/IntegerTypeMatchesIntegers.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/IntegerTypeMatchesIntegers.md deleted file mode 100644 index 141e17fd9ae..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/IntegerTypeMatchesIntegers.md +++ /dev/null @@ -1,8 +0,0 @@ -# IntegerTypeMatchesIntegers - -Type | Description | Notes -------------- | ------------- | ------------- -**int** | | - -[[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/3_0_3_unit_test/python-experimental/docs/InvalidStringValueForDefault.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidStringValueForDefault.md deleted file mode 100644 index ae129438132..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidStringValueForDefault.md +++ /dev/null @@ -1,10 +0,0 @@ -# InvalidStringValueForDefault - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**bar** | **str** | | [optional] if omitted the server will use the default value of "bad" -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidTypeForDefault.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidTypeForDefault.md deleted file mode 100644 index a251e2dc515..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidTypeForDefault.md +++ /dev/null @@ -1,10 +0,0 @@ -# InvalidTypeForDefault - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**foo** | **int** | | [optional] -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NulCharactersInStrings.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NulCharactersInStrings.md deleted file mode 100644 index d90b761591a..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NulCharactersInStrings.md +++ /dev/null @@ -1,8 +0,0 @@ -# NulCharactersInStrings - -Type | Description | Notes -------------- | ------------- | ------------- -**str** | | must be one of ["hello\x00there", ] - -[[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/3_0_3_unit_test/python-experimental/docs/NullTypeMatchesOnlyTheNullObject.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NullTypeMatchesOnlyTheNullObject.md deleted file mode 100644 index 54a530d1d33..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NullTypeMatchesOnlyTheNullObject.md +++ /dev/null @@ -1,8 +0,0 @@ -# NullTypeMatchesOnlyTheNullObject - -Type | Description | Notes -------------- | ------------- | ------------- -**none_type** | | - -[[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/3_0_3_unit_test/python-experimental/docs/NumberTypeMatchesNumbers.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NumberTypeMatchesNumbers.md deleted file mode 100644 index 8348aeef2bc..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NumberTypeMatchesNumbers.md +++ /dev/null @@ -1,8 +0,0 @@ -# NumberTypeMatchesNumbers - -Type | Description | Notes -------------- | ------------- | ------------- -**float** | | - -[[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/3_0_3_unit_test/python-experimental/docs/SimpleEnumValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/SimpleEnumValidation.md deleted file mode 100644 index 81e6b4f5e6c..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/SimpleEnumValidation.md +++ /dev/null @@ -1,8 +0,0 @@ -# SimpleEnumValidation - -Type | Description | Notes -------------- | ------------- | ------------- -**float** | | must be one of [1, 2, 3, ] - -[[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/3_0_3_unit_test/python-experimental/docs/StringTypeMatchesStrings.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/StringTypeMatchesStrings.md deleted file mode 100644 index cd1125671ab..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/StringTypeMatchesStrings.md +++ /dev/null @@ -1,8 +0,0 @@ -# StringTypeMatchesStrings - -Type | Description | Notes -------------- | ------------- | ------------- -**str** | | - -[[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/3_0_3_unit_test/python-experimental/docs/TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md deleted file mode 100644 index 61162c71aa0..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md +++ /dev/null @@ -1,10 +0,0 @@ -# TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**alpha** | **int, float** | | [optional] if omitted the server will use the default value of 5 -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py deleted file mode 100644 index 3efa9239a1b..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py +++ /dev/null @@ -1,60 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.additionalproperties_allows_a_schema_which_should_validate import AdditionalpropertiesAllowsASchemaWhichShouldValidate - - -class TestAdditionalpropertiesAllowsASchemaWhichShouldValidate(unittest.TestCase): - """AdditionalpropertiesAllowsASchemaWhichShouldValidate unit test stubs""" - - def test_no_additional_properties_is_valid_passes(self): - # no additional properties is valid - AdditionalpropertiesAllowsASchemaWhichShouldValidate( - **{ - "foo": - 1, - } - ) - - def test_an_additional_invalid_property_is_invalid_fails(self): - # an additional invalid property is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - AdditionalpropertiesAllowsASchemaWhichShouldValidate( - **{ - "foo": - 1, - "bar": - 2, - "quux": - 12, - } - ) - - def test_an_additional_valid_property_is_valid_passes(self): - # an additional valid property is valid - AdditionalpropertiesAllowsASchemaWhichShouldValidate( - **{ - "foo": - 1, - "bar": - 2, - "quux": - - True, - } - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py deleted file mode 100644 index 6a87df188f9..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py +++ /dev/null @@ -1,37 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.additionalproperties_are_allowed_by_default import AdditionalpropertiesAreAllowedByDefault - - -class TestAdditionalpropertiesAreAllowedByDefault(unittest.TestCase): - """AdditionalpropertiesAreAllowedByDefault unit test stubs""" - - def test_additional_properties_are_allowed_passes(self): - # additional properties are allowed - AdditionalpropertiesAreAllowedByDefault( - **{ - "foo": - 1, - "bar": - 2, - "quux": - - True, - } - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py deleted file mode 100644 index 968b9449901..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py +++ /dev/null @@ -1,43 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.additionalproperties_can_exist_by_itself import AdditionalpropertiesCanExistByItself - - -class TestAdditionalpropertiesCanExistByItself(unittest.TestCase): - """AdditionalpropertiesCanExistByItself unit test stubs""" - - def test_an_additional_invalid_property_is_invalid_fails(self): - # an additional invalid property is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - AdditionalpropertiesCanExistByItself( - **{ - "foo": - 1, - } - ) - - def test_an_additional_valid_property_is_valid_passes(self): - # an additional valid property is valid - AdditionalpropertiesCanExistByItself( - **{ - "foo": - - True, - } - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py deleted file mode 100644 index e46111271d3..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py +++ /dev/null @@ -1,36 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.additionalproperties_should_not_look_in_applicators import AdditionalpropertiesShouldNotLookInApplicators - - -class TestAdditionalpropertiesShouldNotLookInApplicators(unittest.TestCase): - """AdditionalpropertiesShouldNotLookInApplicators unit test stubs""" - - def test_properties_defined_in_allof_are_not_examined_fails(self): - # properties defined in allOf are not examined - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - AdditionalpropertiesShouldNotLookInApplicators( - **{ - "foo": - 1, - "bar": - - True, - } - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py deleted file mode 100644 index 695efa692be..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py +++ /dev/null @@ -1,71 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.array_type_matches_arrays import ArrayTypeMatchesArrays - - -class TestArrayTypeMatchesArrays(unittest.TestCase): - """ArrayTypeMatchesArrays unit test stubs""" - - def test_a_float_is_not_an_array_fails(self): - # a float is not an array - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - ArrayTypeMatchesArrays( - 1.1 ) - - def test_a_boolean_is_not_an_array_fails(self): - # a boolean is not an array - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - ArrayTypeMatchesArrays( - - True ) - - def test_null_is_not_an_array_fails(self): - # null is not an array - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - ArrayTypeMatchesArrays( - - None ) - - def test_an_object_is_not_an_array_fails(self): - # an object is not an array - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - ArrayTypeMatchesArrays( - { - } - ) - - def test_a_string_is_not_an_array_fails(self): - # a string is not an array - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - ArrayTypeMatchesArrays( - - "foo" ) - - def test_an_array_is_an_array_passes(self): - # an array is an array - ArrayTypeMatchesArrays( - [ - ] - ) - - def test_an_integer_is_not_an_array_fails(self): - # an integer is not an array - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - ArrayTypeMatchesArrays( - 1 ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py deleted file mode 100644 index 3ce46c5e25b..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py +++ /dev/null @@ -1,90 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.boolean_type_matches_booleans import BooleanTypeMatchesBooleans - - -class TestBooleanTypeMatchesBooleans(unittest.TestCase): - """BooleanTypeMatchesBooleans unit test stubs""" - - def test_an_empty_string_is_not_a_boolean_fails(self): - # an empty string is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - BooleanTypeMatchesBooleans( - - "" ) - - def test_a_float_is_not_a_boolean_fails(self): - # a float is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - BooleanTypeMatchesBooleans( - 1.1 ) - - def test_null_is_not_a_boolean_fails(self): - # null is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - BooleanTypeMatchesBooleans( - - None ) - - def test_zero_is_not_a_boolean_fails(self): - # zero is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - BooleanTypeMatchesBooleans( - 0 ) - - def test_an_array_is_not_a_boolean_fails(self): - # an array is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - BooleanTypeMatchesBooleans( - [ - ] - ) - - def test_a_string_is_not_a_boolean_fails(self): - # a string is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - BooleanTypeMatchesBooleans( - - "foo" ) - - def test_false_is_a_boolean_passes(self): - # false is a boolean - BooleanTypeMatchesBooleans( - - False ) - - def test_an_integer_is_not_a_boolean_fails(self): - # an integer is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - BooleanTypeMatchesBooleans( - 1 ) - - def test_true_is_a_boolean_passes(self): - # true is a boolean - BooleanTypeMatchesBooleans( - - True ) - - def test_an_object_is_not_a_boolean_fails(self): - # an object is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - BooleanTypeMatchesBooleans( - { - } - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with0_does_not_match_false.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with0_does_not_match_false.py deleted file mode 100644 index 1e4ee2ff3f8..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with0_does_not_match_false.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.enum_with0_does_not_match_false import EnumWith0DoesNotMatchFalse - - -class TestEnumWith0DoesNotMatchFalse(unittest.TestCase): - """EnumWith0DoesNotMatchFalse unit test stubs""" - - def test_integer_zero_is_valid_passes(self): - # integer zero is valid - EnumWith0DoesNotMatchFalse( - 0 ) - - def test_float_zero_is_valid_passes(self): - # float zero is valid - EnumWith0DoesNotMatchFalse( - 0.0 ) - - def test_false_is_invalid_fails(self): - # false is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - EnumWith0DoesNotMatchFalse( - - False ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with1_does_not_match_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with1_does_not_match_true.py deleted file mode 100644 index 7f99ceb96b9..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with1_does_not_match_true.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.enum_with1_does_not_match_true import EnumWith1DoesNotMatchTrue - - -class TestEnumWith1DoesNotMatchTrue(unittest.TestCase): - """EnumWith1DoesNotMatchTrue unit test stubs""" - - def test_true_is_invalid_fails(self): - # true is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - EnumWith1DoesNotMatchTrue( - - True ) - - def test_integer_one_is_valid_passes(self): - # integer one is valid - EnumWith1DoesNotMatchTrue( - 1 ) - - def test_float_one_is_valid_passes(self): - # float one is valid - EnumWith1DoesNotMatchTrue( - 1.0 ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_escaped_characters.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_escaped_characters.py deleted file mode 100644 index 0ac6333d802..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_escaped_characters.py +++ /dev/null @@ -1,43 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.enum_with_escaped_characters import EnumWithEscapedCharacters - - -class TestEnumWithEscapedCharacters(unittest.TestCase): - """EnumWithEscapedCharacters unit test stubs""" - - def test_member2_is_valid_passes(self): - # member 2 is valid - EnumWithEscapedCharacters( - - """foo bar""" ) - - def test_member1_is_valid_passes(self): - # member 1 is valid - EnumWithEscapedCharacters( - - """foo -bar""" ) - - def test_another_string_is_invalid_fails(self): - # another string is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - EnumWithEscapedCharacters( - - "abc" ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_false_does_not_match0.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_false_does_not_match0.py deleted file mode 100644 index 06dc149a143..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_false_does_not_match0.py +++ /dev/null @@ -1,41 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.enum_with_false_does_not_match0 import EnumWithFalseDoesNotMatch0 - - -class TestEnumWithFalseDoesNotMatch0(unittest.TestCase): - """EnumWithFalseDoesNotMatch0 unit test stubs""" - - def test_false_is_valid_passes(self): - # false is valid - EnumWithFalseDoesNotMatch0( - - False ) - - def test_float_zero_is_invalid_fails(self): - # float zero is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - EnumWithFalseDoesNotMatch0( - 0.0 ) - - def test_integer_zero_is_invalid_fails(self): - # integer zero is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - EnumWithFalseDoesNotMatch0( - 0 ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_true_does_not_match1.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_true_does_not_match1.py deleted file mode 100644 index e9a3e6c80f9..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_true_does_not_match1.py +++ /dev/null @@ -1,41 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.enum_with_true_does_not_match1 import EnumWithTrueDoesNotMatch1 - - -class TestEnumWithTrueDoesNotMatch1(unittest.TestCase): - """EnumWithTrueDoesNotMatch1 unit test stubs""" - - def test_float_one_is_invalid_fails(self): - # float one is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - EnumWithTrueDoesNotMatch1( - 1.0 ) - - def test_true_is_valid_passes(self): - # true is valid - EnumWithTrueDoesNotMatch1( - - True ) - - def test_integer_one_is_invalid_fails(self): - # integer one is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - EnumWithTrueDoesNotMatch1( - 1 ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enums_in_properties.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enums_in_properties.py deleted file mode 100644 index 813311ff2b8..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enums_in_properties.py +++ /dev/null @@ -1,93 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.enums_in_properties import EnumsInProperties - - -class TestEnumsInProperties(unittest.TestCase): - """EnumsInProperties unit test stubs""" - - def test_missing_optional_property_is_valid_passes(self): - # missing optional property is valid - EnumsInProperties( - **{ - "bar": - - "bar", - } - ) - - def test_wrong_foo_value_fails(self): - # wrong foo value - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - EnumsInProperties( - **{ - "foo": - - "foot", - "bar": - - "bar", - } - ) - - def test_both_properties_are_valid_passes(self): - # both properties are valid - EnumsInProperties( - **{ - "foo": - - "foo", - "bar": - - "bar", - } - ) - - def test_wrong_bar_value_fails(self): - # wrong bar value - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - EnumsInProperties( - **{ - "foo": - - "foo", - "bar": - - "bart", - } - ) - - def test_missing_all_properties_is_invalid_fails(self): - # missing all properties is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - EnumsInProperties( - { - } - ) - - def test_missing_required_property_is_invalid_fails(self): - # missing required property is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - EnumsInProperties( - **{ - "foo": - - "foo", - } - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py deleted file mode 100644 index 4478fe8a01f..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py +++ /dev/null @@ -1,83 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.integer_type_matches_integers import IntegerTypeMatchesIntegers - - -class TestIntegerTypeMatchesIntegers(unittest.TestCase): - """IntegerTypeMatchesIntegers unit test stubs""" - - def test_an_object_is_not_an_integer_fails(self): - # an object is not an integer - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - IntegerTypeMatchesIntegers( - { - } - ) - - def test_a_string_is_not_an_integer_fails(self): - # a string is not an integer - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - IntegerTypeMatchesIntegers( - - "foo" ) - - def test_null_is_not_an_integer_fails(self): - # null is not an integer - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - IntegerTypeMatchesIntegers( - - None ) - - def test_a_float_with_zero_fractional_part_is_an_integer_passes(self): - # a float with zero fractional part is an integer - IntegerTypeMatchesIntegers( - 1.0 ) - - def test_a_float_is_not_an_integer_fails(self): - # a float is not an integer - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - IntegerTypeMatchesIntegers( - 1.1 ) - - def test_a_boolean_is_not_an_integer_fails(self): - # a boolean is not an integer - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - IntegerTypeMatchesIntegers( - - True ) - - def test_an_integer_is_an_integer_passes(self): - # an integer is an integer - IntegerTypeMatchesIntegers( - 1 ) - - def test_a_string_is_still_not_an_integer_even_if_it_looks_like_one_fails(self): - # a string is still not an integer, even if it looks like one - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - IntegerTypeMatchesIntegers( - - "1" ) - - def test_an_array_is_not_an_integer_fails(self): - # an array is not an integer - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - IntegerTypeMatchesIntegers( - [ - ] - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_string_value_for_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_string_value_for_default.py deleted file mode 100644 index 9d375f8edfb..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_string_value_for_default.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.invalid_string_value_for_default import InvalidStringValueForDefault - - -class TestInvalidStringValueForDefault(unittest.TestCase): - """InvalidStringValueForDefault unit test stubs""" - - def test_valid_when_property_is_specified_passes(self): - # valid when property is specified - InvalidStringValueForDefault( - **{ - "bar": - - "good", - } - ) - - def test_still_valid_when_the_invalid_default_is_used_passes(self): - # still valid when the invalid default is used - InvalidStringValueForDefault( - { - } - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_type_for_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_type_for_default.py deleted file mode 100644 index 669b1754510..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_type_for_default.py +++ /dev/null @@ -1,39 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.invalid_type_for_default import InvalidTypeForDefault - - -class TestInvalidTypeForDefault(unittest.TestCase): - """InvalidTypeForDefault unit test stubs""" - - def test_valid_when_property_is_specified_passes(self): - # valid when property is specified - InvalidTypeForDefault( - **{ - "foo": - 13, - } - ) - - def test_still_valid_when_the_invalid_default_is_used_passes(self): - # still valid when the invalid default is used - InvalidTypeForDefault( - { - } - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nul_characters_in_strings.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nul_characters_in_strings.py deleted file mode 100644 index 13e23eca482..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nul_characters_in_strings.py +++ /dev/null @@ -1,36 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.nul_characters_in_strings import NulCharactersInStrings - - -class TestNulCharactersInStrings(unittest.TestCase): - """NulCharactersInStrings unit test stubs""" - - def test_match_string_with_nul_passes(self): - # match string with nul - NulCharactersInStrings( - - "hello\x00there" ) - - def test_do_not_match_string_lacking_nul_fails(self): - # do not match string lacking nul - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NulCharactersInStrings( - - "hellothere" ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py deleted file mode 100644 index 3db8e2c3c56..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py +++ /dev/null @@ -1,91 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.null_type_matches_only_the_null_object import NullTypeMatchesOnlyTheNullObject - - -class TestNullTypeMatchesOnlyTheNullObject(unittest.TestCase): - """NullTypeMatchesOnlyTheNullObject unit test stubs""" - - def test_a_float_is_not_null_fails(self): - # a float is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NullTypeMatchesOnlyTheNullObject( - 1.1 ) - - def test_an_object_is_not_null_fails(self): - # an object is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NullTypeMatchesOnlyTheNullObject( - { - } - ) - - def test_false_is_not_null_fails(self): - # false is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NullTypeMatchesOnlyTheNullObject( - - False ) - - def test_an_integer_is_not_null_fails(self): - # an integer is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NullTypeMatchesOnlyTheNullObject( - 1 ) - - def test_true_is_not_null_fails(self): - # true is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NullTypeMatchesOnlyTheNullObject( - - True ) - - def test_zero_is_not_null_fails(self): - # zero is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NullTypeMatchesOnlyTheNullObject( - 0 ) - - def test_an_empty_string_is_not_null_fails(self): - # an empty string is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NullTypeMatchesOnlyTheNullObject( - - "" ) - - def test_null_is_null_passes(self): - # null is null - NullTypeMatchesOnlyTheNullObject( - - None ) - - def test_an_array_is_not_null_fails(self): - # an array is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NullTypeMatchesOnlyTheNullObject( - [ - ] - ) - - def test_a_string_is_not_null_fails(self): - # a string is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NullTypeMatchesOnlyTheNullObject( - - "foo" ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py deleted file mode 100644 index 8c5af6e240f..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py +++ /dev/null @@ -1,82 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.number_type_matches_numbers import NumberTypeMatchesNumbers - - -class TestNumberTypeMatchesNumbers(unittest.TestCase): - """NumberTypeMatchesNumbers unit test stubs""" - - def test_an_array_is_not_a_number_fails(self): - # an array is not a number - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NumberTypeMatchesNumbers( - [ - ] - ) - - def test_null_is_not_a_number_fails(self): - # null is not a number - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NumberTypeMatchesNumbers( - - None ) - - def test_an_object_is_not_a_number_fails(self): - # an object is not a number - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NumberTypeMatchesNumbers( - { - } - ) - - def test_a_boolean_is_not_a_number_fails(self): - # a boolean is not a number - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NumberTypeMatchesNumbers( - - True ) - - def test_a_float_is_a_number_passes(self): - # a float is a number - NumberTypeMatchesNumbers( - 1.1 ) - - def test_a_string_is_still_not_a_number_even_if_it_looks_like_one_fails(self): - # a string is still not a number, even if it looks like one - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NumberTypeMatchesNumbers( - - "1" ) - - def test_a_string_is_not_a_number_fails(self): - # a string is not a number - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NumberTypeMatchesNumbers( - - "foo" ) - - def test_an_integer_is_a_number_passes(self): - # an integer is a number - NumberTypeMatchesNumbers( - 1 ) - - def test_a_float_with_zero_fractional_part_is_a_number_and_an_integer_passes(self): - # a float with zero fractional part is a number (and an integer) - NumberTypeMatchesNumbers( - 1.0 ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_simple_enum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_simple_enum_validation.py deleted file mode 100644 index 48b1efc5794..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_simple_enum_validation.py +++ /dev/null @@ -1,34 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.simple_enum_validation import SimpleEnumValidation - - -class TestSimpleEnumValidation(unittest.TestCase): - """SimpleEnumValidation unit test stubs""" - - def test_something_else_is_invalid_fails(self): - # something else is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - SimpleEnumValidation( - 4 ) - - def test_one_of_the_enum_is_valid_passes(self): - # one of the enum is valid - SimpleEnumValidation( - 1 ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py deleted file mode 100644 index 6b2b76e2b8a..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py +++ /dev/null @@ -1,83 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.string_type_matches_strings import StringTypeMatchesStrings - - -class TestStringTypeMatchesStrings(unittest.TestCase): - """StringTypeMatchesStrings unit test stubs""" - - def test_1_is_not_a_string_fails(self): - # 1 is not a string - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - StringTypeMatchesStrings( - 1 ) - - def test_a_string_is_still_a_string_even_if_it_looks_like_a_number_passes(self): - # a string is still a string, even if it looks like a number - StringTypeMatchesStrings( - - "1" ) - - def test_an_empty_string_is_still_a_string_passes(self): - # an empty string is still a string - StringTypeMatchesStrings( - - "" ) - - def test_a_float_is_not_a_string_fails(self): - # a float is not a string - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - StringTypeMatchesStrings( - 1.1 ) - - def test_an_object_is_not_a_string_fails(self): - # an object is not a string - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - StringTypeMatchesStrings( - { - } - ) - - def test_an_array_is_not_a_string_fails(self): - # an array is not a string - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - StringTypeMatchesStrings( - [ - ] - ) - - def test_a_boolean_is_not_a_string_fails(self): - # a boolean is not a string - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - StringTypeMatchesStrings( - - True ) - - def test_null_is_not_a_string_fails(self): - # null is not a string - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - StringTypeMatchesStrings( - - None ) - - def test_a_string_is_a_string_passes(self): - # a string is a string - StringTypeMatchesStrings( - - "foo" ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py deleted file mode 100644 index 63eb2bf6bc2..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py +++ /dev/null @@ -1,49 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.the_default_keyword_does_not_do_anything_if_the_property_is_missing import TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing - - -class TestTheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing(unittest.TestCase): - """TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing unit test stubs""" - - def test_missing_properties_are_not_filled_in_with_the_default_passes(self): - # missing properties are not filled in with the default - TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing( - { - } - ) - - def test_an_explicit_property_value_is_checked_against_maximum_passing_passes(self): - # an explicit property value is checked against maximum (passing) - TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing( - **{ - "alpha": - 1, - } - ) - - def test_an_explicit_property_value_is_checked_against_maximum_failing_fails(self): - # an explicit property value is checked against maximum (failing) - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing( - **{ - "alpha": - 5, - } - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_allows_a_schema_which_should_validate.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_allows_a_schema_which_should_validate.py deleted file mode 100644 index 8e986da86fc..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_allows_a_schema_which_should_validate.py +++ /dev/null @@ -1,97 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class AdditionalpropertiesAllowsASchemaWhichShouldValidate( - DictSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - foo = AnyTypeSchema - bar = AnyTypeSchema - _additional_properties = BoolSchema - - - def __new__( - cls, - *args: typing.Union[dict, frozendict, ], - foo: typing.Union[foo, Unset] = unset, - bar: typing.Union[bar, Unset] = unset, - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'AdditionalpropertiesAllowsASchemaWhichShouldValidate': - return super().__new__( - cls, - *args, - foo=foo, - bar=bar, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_are_allowed_by_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_are_allowed_by_default.py deleted file mode 100644 index 2251b2f815a..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_are_allowed_by_default.py +++ /dev/null @@ -1,95 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class AdditionalpropertiesAreAllowedByDefault( - AnyTypeSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - foo = AnyTypeSchema - bar = AnyTypeSchema - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - foo: typing.Union[foo, Unset] = unset, - bar: typing.Union[bar, Unset] = unset, - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'AdditionalpropertiesAreAllowedByDefault': - return super().__new__( - cls, - *args, - foo=foo, - bar=bar, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_can_exist_by_itself.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_can_exist_by_itself.py deleted file mode 100644 index 383a01af174..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_can_exist_by_itself.py +++ /dev/null @@ -1,91 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class AdditionalpropertiesCanExistByItself( - DictSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - _additional_properties = BoolSchema - - - def __new__( - cls, - *args: typing.Union[dict, frozendict, ], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'AdditionalpropertiesCanExistByItself': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_should_not_look_in_applicators.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_should_not_look_in_applicators.py deleted file mode 100644 index 66547528189..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_should_not_look_in_applicators.py +++ /dev/null @@ -1,114 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class AdditionalpropertiesShouldNotLookInApplicators( - ComposedSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - _additional_properties = BoolSchema - - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 - allOf_0 = AnyTypeSchema - return { - 'allOf': [ - allOf_0, - ], - 'oneOf': [ - ], - 'anyOf': [ - ], - 'not': - None - } - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'AdditionalpropertiesShouldNotLookInApplicators': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/array_type_matches_arrays.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/array_type_matches_arrays.py deleted file mode 100644 index 583f9843b64..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/array_type_matches_arrays.py +++ /dev/null @@ -1,77 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class ArrayTypeMatchesArrays( - ListSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - _items = AnyTypeSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/boolean_type_matches_booleans.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/boolean_type_matches_booleans.py deleted file mode 100644 index 93cd0a0505f..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/boolean_type_matches_booleans.py +++ /dev/null @@ -1,67 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) -BooleanTypeMatchesBooleans = BoolSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with0_does_not_match_false.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with0_does_not_match_false.py deleted file mode 100644 index 6cb61f6f053..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with0_does_not_match_false.py +++ /dev/null @@ -1,86 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class EnumWith0DoesNotMatchFalse( - _SchemaEnumMaker( - enum_value_to_name={ - 0: "POSITIVE_0", - } - ), - NumberSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - def POSITIVE_0(cls): - return cls(0) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with1_does_not_match_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with1_does_not_match_true.py deleted file mode 100644 index 6904cda7fa3..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with1_does_not_match_true.py +++ /dev/null @@ -1,86 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class EnumWith1DoesNotMatchTrue( - _SchemaEnumMaker( - enum_value_to_name={ - 1: "POSITIVE_1", - } - ), - NumberSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - def POSITIVE_1(cls): - return cls(1) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_escaped_characters.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_escaped_characters.py deleted file mode 100644 index 3354101f399..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_escaped_characters.py +++ /dev/null @@ -1,94 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class EnumWithEscapedCharacters( - _SchemaEnumMaker( - enum_value_to_name={ - '''foo -bar''': "FOO_BAR", - '''foo bar''': "FOO_BAR", - } - ), - StrSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - def FOO_BAR(cls): - return cls('''foo -bar''') - - @classmethod - @property - def FOO_BAR(cls): - return cls('''foo bar''') diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_false_does_not_match0.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_false_does_not_match0.py deleted file mode 100644 index 223022bb57b..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_false_does_not_match0.py +++ /dev/null @@ -1,86 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class EnumWithFalseDoesNotMatch0( - _SchemaEnumMaker( - enum_value_to_name={ - False: "FALSE", - } - ), - BoolSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - def FALSE(cls): - return cls(False) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_true_does_not_match1.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_true_does_not_match1.py deleted file mode 100644 index 6e997008625..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_true_does_not_match1.py +++ /dev/null @@ -1,86 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class EnumWithTrueDoesNotMatch1( - _SchemaEnumMaker( - enum_value_to_name={ - True: "TRUE", - } - ), - BoolSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - def TRUE(cls): - return cls(True) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enums_in_properties.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enums_in_properties.py deleted file mode 100644 index 192305479fc..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enums_in_properties.py +++ /dev/null @@ -1,127 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class EnumsInProperties( - DictSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - _required_property_names = set(( - 'bar', - )) - - - class foo( - _SchemaEnumMaker( - enum_value_to_name={ - "foo": "FOO", - } - ), - StrSchema - ): - - @classmethod - @property - def FOO(cls): - return cls("foo") - - - class bar( - _SchemaEnumMaker( - enum_value_to_name={ - "bar": "BAR", - } - ), - StrSchema - ): - - @classmethod - @property - def BAR(cls): - return cls("bar") - - - def __new__( - cls, - *args: typing.Union[dict, frozendict, ], - bar: bar, - foo: typing.Union[foo, Unset] = unset, - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'EnumsInProperties': - return super().__new__( - cls, - *args, - bar=bar, - foo=foo, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/integer_type_matches_integers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/integer_type_matches_integers.py deleted file mode 100644 index 472bd37aa71..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/integer_type_matches_integers.py +++ /dev/null @@ -1,67 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) -IntegerTypeMatchesIntegers = IntSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_string_value_for_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_string_value_for_default.py deleted file mode 100644 index 07ad386d3b8..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_string_value_for_default.py +++ /dev/null @@ -1,100 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class InvalidStringValueForDefault( - AnyTypeSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - - class bar( - _SchemaValidator( - min_length=4, - ), - StrSchema - ): - pass - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - bar: typing.Union[bar, Unset] = unset, - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'InvalidStringValueForDefault': - return super().__new__( - cls, - *args, - bar=bar, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_type_for_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_type_for_default.py deleted file mode 100644 index bffccf32de0..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_type_for_default.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class InvalidTypeForDefault( - AnyTypeSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - foo = IntSchema - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - foo: typing.Union[foo, Unset] = unset, - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'InvalidTypeForDefault': - return super().__new__( - cls, - *args, - foo=foo, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nul_characters_in_strings.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nul_characters_in_strings.py deleted file mode 100644 index 04ff26fd643..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nul_characters_in_strings.py +++ /dev/null @@ -1,86 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class NulCharactersInStrings( - _SchemaEnumMaker( - enum_value_to_name={ - "hello\x00there": "HELLOTHERE", - } - ), - StrSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - def HELLOTHERE(cls): - return cls("hello\x00there") diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/null_type_matches_only_the_null_object.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/null_type_matches_only_the_null_object.py deleted file mode 100644 index 3ed5b3d6b3b..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/null_type_matches_only_the_null_object.py +++ /dev/null @@ -1,67 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) -NullTypeMatchesOnlyTheNullObject = NoneSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/number_type_matches_numbers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/number_type_matches_numbers.py deleted file mode 100644 index 3b33c38f4cd..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/number_type_matches_numbers.py +++ /dev/null @@ -1,67 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) -NumberTypeMatchesNumbers = NumberSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/simple_enum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/simple_enum_validation.py deleted file mode 100644 index 86f28a9dae3..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/simple_enum_validation.py +++ /dev/null @@ -1,98 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class SimpleEnumValidation( - _SchemaEnumMaker( - enum_value_to_name={ - 1: "POSITIVE_1", - 2: "POSITIVE_2", - 3: "POSITIVE_3", - } - ), - NumberSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - def POSITIVE_1(cls): - return cls(1) - - @classmethod - @property - def POSITIVE_2(cls): - return cls(2) - - @classmethod - @property - def POSITIVE_3(cls): - return cls(3) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/string_type_matches_strings.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/string_type_matches_strings.py deleted file mode 100644 index f1c3c9a0302..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/string_type_matches_strings.py +++ /dev/null @@ -1,67 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) -StringTypeMatchesStrings = StrSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/the_default_keyword_does_not_do_anything_if_the_property_is_missing.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/the_default_keyword_does_not_do_anything_if_the_property_is_missing.py deleted file mode 100644 index d59150db52b..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/the_default_keyword_does_not_do_anything_if_the_property_is_missing.py +++ /dev/null @@ -1,101 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing( - DictSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - - class alpha( - _SchemaValidator( - inclusive_maximum=3, - ), - NumberSchema - ): - pass - - - def __new__( - cls, - *args: typing.Union[dict, frozendict, ], - alpha: typing.Union[alpha, Unset] = unset, - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing': - return super().__new__( - cls, - *args, - alpha=alpha, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py index 7c56ec55ecf..f986d1632e4 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py @@ -11,24 +11,3 @@ # import sys # sys.setrecursionlimit(n) -from unit_test_api.model.additionalproperties_allows_a_schema_which_should_validate import AdditionalpropertiesAllowsASchemaWhichShouldValidate -from unit_test_api.model.additionalproperties_are_allowed_by_default import AdditionalpropertiesAreAllowedByDefault -from unit_test_api.model.additionalproperties_can_exist_by_itself import AdditionalpropertiesCanExistByItself -from unit_test_api.model.additionalproperties_should_not_look_in_applicators import AdditionalpropertiesShouldNotLookInApplicators -from unit_test_api.model.array_type_matches_arrays import ArrayTypeMatchesArrays -from unit_test_api.model.boolean_type_matches_booleans import BooleanTypeMatchesBooleans -from unit_test_api.model.enum_with0_does_not_match_false import EnumWith0DoesNotMatchFalse -from unit_test_api.model.enum_with1_does_not_match_true import EnumWith1DoesNotMatchTrue -from unit_test_api.model.enum_with_escaped_characters import EnumWithEscapedCharacters -from unit_test_api.model.enum_with_false_does_not_match0 import EnumWithFalseDoesNotMatch0 -from unit_test_api.model.enum_with_true_does_not_match1 import EnumWithTrueDoesNotMatch1 -from unit_test_api.model.enums_in_properties import EnumsInProperties -from unit_test_api.model.integer_type_matches_integers import IntegerTypeMatchesIntegers -from unit_test_api.model.invalid_string_value_for_default import InvalidStringValueForDefault -from unit_test_api.model.invalid_type_for_default import InvalidTypeForDefault -from unit_test_api.model.nul_characters_in_strings import NulCharactersInStrings -from unit_test_api.model.null_type_matches_only_the_null_object import NullTypeMatchesOnlyTheNullObject -from unit_test_api.model.number_type_matches_numbers import NumberTypeMatchesNumbers -from unit_test_api.model.simple_enum_validation import SimpleEnumValidation -from unit_test_api.model.string_type_matches_strings import StringTypeMatchesStrings -from unit_test_api.model.the_default_keyword_does_not_do_anything_if_the_property_is_missing import TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing -- GitLab From a09b2421dbfbcf5cc1a8833af44edf8be1df0eae Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Sun, 26 Jun 2022 23:52:27 -0700 Subject: [PATCH 11/43] Adds items test cases --- .../PythonExperimentalClientCodegen.java | 2 +- .../payload_renderer.handlebars | 2 +- .../3_0/unit_test_spec/spec_writer.py | 20 ++- .../resources/3_0/unit_test_spec/type.yaml | 45 ++++- .../.openapi-generator/FILES | 3 + .../python-experimental/README.md | 1 + .../python-experimental/docs/NestedItems.md | 8 + .../test/test_nested_items.py | 155 ++++++++++++++++++ .../unit_test_api/model/nested_items.py | 92 +++++++++++ .../unit_test_api/models/__init__.py | 1 + 10 files changed, 323 insertions(+), 6 deletions(-) create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedItems.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_items.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_items.py diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java index 2b4647fda74..44ae9750c2d 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java @@ -1181,7 +1181,7 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen { ArrayList<Object> fixedValues = (ArrayList<Object>) value; for (int i = 0; i < fixedValues.size(); i++) { Object item = processTestExampleData(fixedValues.get(i)); - fixedValues.add(i, item); + fixedValues.set(i, item); } return fixedValues; } else if (value == null) { diff --git a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars index ab5a0d5eec5..b6b1a63cea3 100644 --- a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars +++ b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars @@ -1,7 +1,7 @@ {{#if isArray}} [ {{#each value}} - {{> model_templates/payload_renderer }} + {{> model_templates/payload_renderer }}, {{/each}} ] {{else}} diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index c01891e8553..d0bab9c496e 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -80,12 +80,14 @@ class ExclusionReason: v303_does_not_support_additionalItems = 'v3.0.3 does not support the additionalItems keyword' v303_does_not_support_patternProperties = 'v3.0.3 does not support the patternProperties keyword' v303_does_not_support_const = 'v3.0.3 does not support the const keyword' - v303_does_not_support_boolean_schemas_in_components = 'v3.0.3 does not support boolean schemas in components' + v303_does_not_support_boolean_schemas_in_location = 'v3.0.3 does not support boolean schemas in location' v303_does_not_support_contains = 'v3.0.3 does not support the contains keyword' v303_does_not_support_definitions = 'v3.0.3 does not support the definitions keyword' v303_does_not_support_dependencies = 'v3.0.3 does not support the dependencies keyword' swagger_parser_enum_type_bug = "swagger-parser has a bug where schema type is incorrectly set for an enum, https://github.com/swagger-api/swagger-parser/issues/1761" swagger_parser_validation_missing_bug = 'swagger-parser has a bug where validations are unset, https://github.com/swagger-api/swagger-parser/issues/1762' + swagger_parser_items_type_bug = "swagger-parser has a bug where schema type is incorrectly set with items, https://github.com/swagger-api/swagger-parser/issues/1763" + v303_does_not_support_id = 'v3.0.3 does not support the $id keyword' json_schema_test_draft = 'draft6' FILEPATH_TO_EXCLUDED_CASE_AND_REASON = { @@ -104,16 +106,26 @@ FILEPATH_TO_EXCLUDED_CASE_AND_REASON = { 'non-ASCII pattern with additionalProperties': ExclusionReason.v303_does_not_support_patternProperties, 'additionalProperties being false does not allow other properties': ExclusionReason.v303_does_not_support_patternProperties, }, + (json_schema_test_draft, 'items.json'): { + 'an array of schemas for items': ExclusionReason.v303_does_not_support_array_of_types, + 'items and subitems': ExclusionReason.v303_does_not_support_definitions, + 'items with boolean schema (true)': ExclusionReason.v303_does_not_support_boolean_schemas_in_location, + 'items with boolean schemas': ExclusionReason.v303_does_not_support_boolean_schemas_in_location, + 'items with boolean schema (false)': ExclusionReason.v303_does_not_support_boolean_schemas_in_location, + 'items with boolean schema (false)': ExclusionReason.v303_does_not_support_boolean_schemas_in_location, + 'a schema given for items': ExclusionReason.swagger_parser_items_type_bug, + }, } FILEPATH_TO_EXCLUDE_REASON = { (json_schema_test_draft, 'additionalItems.json'): ExclusionReason.v303_does_not_support_additionalItems, (json_schema_test_draft, 'const.json'): ExclusionReason.v303_does_not_support_const, - (json_schema_test_draft, 'boolean_schema.json'): ExclusionReason.v303_does_not_support_boolean_schemas_in_components, + (json_schema_test_draft, 'boolean_schema.json'): ExclusionReason.v303_does_not_support_boolean_schemas_in_location, (json_schema_test_draft, 'contains.json'): ExclusionReason.v303_does_not_support_contains, (json_schema_test_draft, 'definitions.json'): ExclusionReason.v303_does_not_support_definitions, (json_schema_test_draft, 'dependencies.json'): ExclusionReason.v303_does_not_support_dependencies, (json_schema_test_draft, 'exclusiveMaximum.json'): ExclusionReason.swagger_parser_validation_missing_bug, (json_schema_test_draft, 'exclusiveMinimum.json'): ExclusionReason.swagger_parser_validation_missing_bug, + (json_schema_test_draft, 'id.json'): ExclusionReason.v303_does_not_support_id, } openapi_additions = 'openapi_additions' @@ -133,6 +145,10 @@ JSON_SCHEMA_TEST_FILE_TO_FOLDERS = { # 'enum.json': (json_schema_test_draft,), 'exclusiveMaximum.json': (json_schema_test_draft,), 'exclusiveMinimum.json': (json_schema_test_draft,), +# 'format.json': (json_schema_test_draft,), + 'id.json': (json_schema_test_draft,), +# 'infinite-loop-detection.json': (json_schema_test_draft,), # activate after fixing this + 'items.json': (json_schema_test_draft,), } def get_json_schema_test_schemas(file_path: typing.Tuple[str]) -> typing.List[JsonSchemaTestSchema]: diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml index 2a0b920f0b7..64ce778581a 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml @@ -6,5 +6,46 @@ info: version: 0.0.1 paths: {} components: - schemas: {} - x-schema-test-examples: {} + schemas: + NestedItems: + type: array + items: + type: array + items: + type: array + items: + type: array + items: + type: number + x-schema-test-examples: + NestedItems: + ValidNestedArray: + description: valid nested array + data: + - - - - 1 + - - - 2 + - - 3 + - - - - 4 + - - 5 + - - 6 + valid: true + NestedArrayWithInvalidType: + description: nested array with invalid type + data: + - - - - '1' + - - - 2 + - - 3 + - - - - 4 + - - 5 + - - 6 + valid: false + NotDeepEnough: + description: not deep enough + data: + - - - 1 + - - 2 + - - 3 + - - - 4 + - - 5 + - - 6 + valid: false diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index a5c70c8904f..86663cc585e 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -2,12 +2,14 @@ .gitlab-ci.yml .travis.yml README.md +docs/NestedItems.md git_push.sh requirements.txt setup.cfg setup.py test-requirements.txt test/__init__.py +test/test_nested_items.py tox.ini unit_test_api/__init__.py unit_test_api/api/__init__.py @@ -16,6 +18,7 @@ unit_test_api/apis/__init__.py unit_test_api/configuration.py unit_test_api/exceptions.py unit_test_api/model/__init__.py +unit_test_api/model/nested_items.py unit_test_api/models/__init__.py unit_test_api/rest.py unit_test_api/schemas.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md index 162b9a6acb5..0bc7898fa3c 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md @@ -62,6 +62,7 @@ Class | Method | HTTP request | Description ## Documentation For Models + - [NestedItems](docs/NestedItems.md) ## Documentation For Authorization diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedItems.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedItems.md new file mode 100644 index 00000000000..c64b37b1669 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedItems.md @@ -0,0 +1,8 @@ +# NestedItems + +Type | Description | Notes +------------- | ------------- | ------------- +**[[[[int, float]]]]** | | + +[[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/3_0_3_unit_test/python-experimental/test/test_nested_items.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_items.py new file mode 100644 index 00000000000..fcc30124458 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_items.py @@ -0,0 +1,155 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.nested_items import NestedItems + + +class TestNestedItems(unittest.TestCase): + """NestedItems unit test stubs""" + + def test_valid_nested_array_passes(self): + # valid nested array + NestedItems( + [ + [ + [ + [ + 1, + ] +, + ] +, + [ + [ + 2, + ] +, + [ + 3, + ] +, + ] +, + ] +, + [ + [ + [ + 4, + ] +, + [ + 5, + ] +, + [ + 6, + ] +, + ] +, + ] +, + ] + ) + + def test_nested_array_with_invalid_type_fails(self): + # nested array with invalid type + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NestedItems( + [ + [ + [ + [ + + "1", + ] +, + ] +, + [ + [ + 2, + ] +, + [ + 3, + ] +, + ] +, + ] +, + [ + [ + [ + 4, + ] +, + [ + 5, + ] +, + [ + 6, + ] +, + ] +, + ] +, + ] + ) + + def test_not_deep_enough_fails(self): + # not deep enough + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NestedItems( + [ + [ + [ + 1, + ] +, + [ + 2, + ] +, + [ + 3, + ] +, + ] +, + [ + [ + 4, + ] +, + [ + 5, + ] +, + [ + 6, + ] +, + ] +, + ] + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_items.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_items.py new file mode 100644 index 00000000000..9b5e65ef0a3 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_items.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class NestedItems( + ListSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + + class _items( + ListSchema + ): + + + class _items( + ListSchema + ): + + + class _items( + ListSchema + ): + _items = NumberSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py index f986d1632e4..e1757fd1aec 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py @@ -11,3 +11,4 @@ # import sys # sys.setrecursionlimit(n) +from unit_test_api.model.nested_items import NestedItems -- GitLab From ac1cabc9fee2c46812bcf5863d5aead1e94f19f6 Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Sun, 26 Jun 2022 23:57:55 -0700 Subject: [PATCH 12/43] Adds maximum --- .../3_0/unit_test_spec/spec_writer.py | 3 +- .../resources/3_0/unit_test_spec/type.yaml | 73 ++++----- .../.openapi-generator/FILES | 9 +- .../python-experimental/README.md | 3 +- .../docs/MaximumValidation.md | 9 + .../MaximumValidationWithUnsignedInteger.md | 9 + .../python-experimental/docs/NestedItems.md | 8 - .../test/test_maximum_validation.py | 45 +++++ ...aximum_validation_with_unsigned_integer.py | 44 +++++ .../test/test_nested_items.py | 155 ------------------ ...{nested_items.py => maximum_validation.py} | 36 ++-- ...aximum_validation_with_unsigned_integer.py | 92 +++++++++++ .../unit_test_api/models/__init__.py | 3 +- 13 files changed, 264 insertions(+), 225 deletions(-) create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaximumValidation.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaximumValidationWithUnsignedInteger.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedItems.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation_with_unsigned_integer.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_items.py rename samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/{nested_items.py => maximum_validation.py} (73%) create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maximum_validation_with_unsigned_integer.py diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index d0bab9c496e..41975c10521 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -148,7 +148,8 @@ JSON_SCHEMA_TEST_FILE_TO_FOLDERS = { # 'format.json': (json_schema_test_draft,), 'id.json': (json_schema_test_draft,), # 'infinite-loop-detection.json': (json_schema_test_draft,), # activate after fixing this - 'items.json': (json_schema_test_draft,), +# 'items.json': (json_schema_test_draft,), + 'maximum.json': (json_schema_test_draft,), } def get_json_schema_test_schemas(file_path: typing.Tuple[str]) -> typing.List[JsonSchemaTestSchema]: diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml index 64ce778581a..924a11b35a3 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml @@ -7,45 +7,42 @@ info: paths: {} components: schemas: - NestedItems: - type: array - items: - type: array - items: - type: array - items: - type: array - items: - type: number + MaximumValidation: + maximum: 3.0 + MaximumValidationWithUnsignedInteger: + maximum: 300 x-schema-test-examples: - NestedItems: - ValidNestedArray: - description: valid nested array - data: - - - - - 1 - - - - 2 - - - 3 - - - - - 4 - - - 5 - - - 6 + MaximumValidation: + BelowTheMaximumIsValid: + description: below the maximum is valid + data: 2.6 valid: true - NestedArrayWithInvalidType: - description: nested array with invalid type - data: - - - - - '1' - - - - 2 - - - 3 - - - - - 4 - - - 5 - - - 6 + BoundaryPointIsValid: + description: boundary point is valid + data: 3.0 + valid: true + AboveTheMaximumIsInvalid: + description: above the maximum is invalid + data: 3.5 valid: false - NotDeepEnough: - description: not deep enough - data: - - - - 1 - - - 2 - - - 3 - - - - 4 - - - 5 - - - 6 + IgnoresNonNumbers: + description: ignores non-numbers + data: x + valid: true + MaximumValidationWithUnsignedInteger: + BelowTheMaximumIsInvalid: + description: below the maximum is invalid + data: 299.97 + valid: true + BoundaryPointIntegerIsValid: + description: boundary point integer is valid + data: 300 + valid: true + BoundaryPointFloatIsValid: + description: boundary point float is valid + data: 300.0 + valid: true + AboveTheMaximumIsInvalid: + description: above the maximum is invalid + data: 300.5 valid: false diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index 86663cc585e..6d4ba00a5a2 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -2,14 +2,16 @@ .gitlab-ci.yml .travis.yml README.md -docs/NestedItems.md +docs/MaximumValidation.md +docs/MaximumValidationWithUnsignedInteger.md git_push.sh requirements.txt setup.cfg setup.py test-requirements.txt test/__init__.py -test/test_nested_items.py +test/test_maximum_validation.py +test/test_maximum_validation_with_unsigned_integer.py tox.ini unit_test_api/__init__.py unit_test_api/api/__init__.py @@ -18,7 +20,8 @@ unit_test_api/apis/__init__.py unit_test_api/configuration.py unit_test_api/exceptions.py unit_test_api/model/__init__.py -unit_test_api/model/nested_items.py +unit_test_api/model/maximum_validation.py +unit_test_api/model/maximum_validation_with_unsigned_integer.py unit_test_api/models/__init__.py unit_test_api/rest.py unit_test_api/schemas.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md index 0bc7898fa3c..6c49bff9b4b 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md @@ -62,7 +62,8 @@ Class | Method | HTTP request | Description ## Documentation For Models - - [NestedItems](docs/NestedItems.md) + - [MaximumValidation](docs/MaximumValidation.md) + - [MaximumValidationWithUnsignedInteger](docs/MaximumValidationWithUnsignedInteger.md) ## Documentation For Authorization diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaximumValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaximumValidation.md new file mode 100644 index 00000000000..2060e3a0d40 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaximumValidation.md @@ -0,0 +1,9 @@ +# MaximumValidation + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaximumValidationWithUnsignedInteger.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaximumValidationWithUnsignedInteger.md new file mode 100644 index 00000000000..9a20b4b7bc9 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaximumValidationWithUnsignedInteger.md @@ -0,0 +1,9 @@ +# MaximumValidationWithUnsignedInteger + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedItems.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedItems.md deleted file mode 100644 index c64b37b1669..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedItems.md +++ /dev/null @@ -1,8 +0,0 @@ -# NestedItems - -Type | Description | Notes -------------- | ------------- | ------------- -**[[[[int, float]]]]** | | - -[[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/3_0_3_unit_test/python-experimental/test/test_maximum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation.py new file mode 100644 index 00000000000..733be5ebae1 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation.py @@ -0,0 +1,45 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.maximum_validation import MaximumValidation + + +class TestMaximumValidation(unittest.TestCase): + """MaximumValidation unit test stubs""" + + def test_below_the_maximum_is_valid_passes(self): + # below the maximum is valid + MaximumValidation( + 2.6 ) + + def test_boundary_point_is_valid_passes(self): + # boundary point is valid + MaximumValidation( + 3.0 ) + + def test_above_the_maximum_is_invalid_fails(self): + # above the maximum is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + MaximumValidation( + 3.5 ) + + def test_ignores_non_numbers_passes(self): + # ignores non-numbers + MaximumValidation( + + "x" ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation_with_unsigned_integer.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation_with_unsigned_integer.py new file mode 100644 index 00000000000..7bc13a7c299 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation_with_unsigned_integer.py @@ -0,0 +1,44 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.maximum_validation_with_unsigned_integer import MaximumValidationWithUnsignedInteger + + +class TestMaximumValidationWithUnsignedInteger(unittest.TestCase): + """MaximumValidationWithUnsignedInteger unit test stubs""" + + def test_below_the_maximum_is_invalid_passes(self): + # below the maximum is invalid + MaximumValidationWithUnsignedInteger( + 299.97 ) + + def test_above_the_maximum_is_invalid_fails(self): + # above the maximum is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + MaximumValidationWithUnsignedInteger( + 300.5 ) + + def test_boundary_point_integer_is_valid_passes(self): + # boundary point integer is valid + MaximumValidationWithUnsignedInteger( + 300 ) + + def test_boundary_point_float_is_valid_passes(self): + # boundary point float is valid + MaximumValidationWithUnsignedInteger( + 300.0 ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_items.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_items.py deleted file mode 100644 index fcc30124458..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_items.py +++ /dev/null @@ -1,155 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.nested_items import NestedItems - - -class TestNestedItems(unittest.TestCase): - """NestedItems unit test stubs""" - - def test_valid_nested_array_passes(self): - # valid nested array - NestedItems( - [ - [ - [ - [ - 1, - ] -, - ] -, - [ - [ - 2, - ] -, - [ - 3, - ] -, - ] -, - ] -, - [ - [ - [ - 4, - ] -, - [ - 5, - ] -, - [ - 6, - ] -, - ] -, - ] -, - ] - ) - - def test_nested_array_with_invalid_type_fails(self): - # nested array with invalid type - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NestedItems( - [ - [ - [ - [ - - "1", - ] -, - ] -, - [ - [ - 2, - ] -, - [ - 3, - ] -, - ] -, - ] -, - [ - [ - [ - 4, - ] -, - [ - 5, - ] -, - [ - 6, - ] -, - ] -, - ] -, - ] - ) - - def test_not_deep_enough_fails(self): - # not deep enough - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NestedItems( - [ - [ - [ - 1, - ] -, - [ - 2, - ] -, - [ - 3, - ] -, - ] -, - [ - [ - 4, - ] -, - [ - 5, - ] -, - [ - 6, - ] -, - ] -, - ] - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_items.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maximum_validation.py similarity index 73% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_items.py rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maximum_validation.py index 9b5e65ef0a3..155a514da50 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_items.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maximum_validation.py @@ -66,27 +66,27 @@ from unit_test_api.schemas import ( # noqa: F401 ) -class NestedItems( - ListSchema +class MaximumValidation( + _SchemaValidator( + inclusive_maximum=3.0, + ), + AnyTypeSchema ): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. """ - - - class _items( - ListSchema - ): - - - class _items( - ListSchema - ): - - - class _items( - ListSchema - ): - _items = NumberSchema + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'MaximumValidation': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maximum_validation_with_unsigned_integer.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maximum_validation_with_unsigned_integer.py new file mode 100644 index 00000000000..0aa1cb53eb9 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maximum_validation_with_unsigned_integer.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class MaximumValidationWithUnsignedInteger( + _SchemaValidator( + inclusive_maximum=300, + ), + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'MaximumValidationWithUnsignedInteger': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py index e1757fd1aec..569197594c4 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py @@ -11,4 +11,5 @@ # import sys # sys.setrecursionlimit(n) -from unit_test_api.model.nested_items import NestedItems +from unit_test_api.model.maximum_validation import MaximumValidation +from unit_test_api.model.maximum_validation_with_unsigned_integer import MaximumValidationWithUnsignedInteger -- GitLab From 29d80a80d3b5c121627f6bffdf0ded99da69177f Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Mon, 27 Jun 2022 00:03:21 -0700 Subject: [PATCH 13/43] Adds maxItems --- .../3_0/unit_test_spec/spec_writer.py | 3 +- .../resources/3_0/unit_test_spec/type.yaml | 55 +++++------ .../.openapi-generator/FILES | 9 +- .../python-experimental/README.md | 3 +- .../MaximumValidationWithUnsignedInteger.md | 9 -- ...mumValidation.md => MaxitemsValidation.md} | 2 +- .../test/test_maximum_validation.py | 45 --------- ...aximum_validation_with_unsigned_integer.py | 44 --------- .../test/test_maxitems_validation.py | 57 ++++++++++++ ...aximum_validation_with_unsigned_integer.py | 92 ------------------- ...m_validation.py => maxitems_validation.py} | 6 +- .../unit_test_api/models/__init__.py | 3 +- 12 files changed, 89 insertions(+), 239 deletions(-) delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaximumValidationWithUnsignedInteger.md rename samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/{MaximumValidation.md => MaxitemsValidation.md} (95%) delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation_with_unsigned_integer.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxitems_validation.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maximum_validation_with_unsigned_integer.py rename samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/{maximum_validation.py => maxitems_validation.py} (95%) diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index 41975c10521..daa999ed2c0 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -149,7 +149,8 @@ JSON_SCHEMA_TEST_FILE_TO_FOLDERS = { 'id.json': (json_schema_test_draft,), # 'infinite-loop-detection.json': (json_schema_test_draft,), # activate after fixing this # 'items.json': (json_schema_test_draft,), - 'maximum.json': (json_schema_test_draft,), +# 'maximum.json': (json_schema_test_draft,), + 'maxItems.json': (json_schema_test_draft,), } def get_json_schema_test_schemas(file_path: typing.Tuple[str]) -> typing.List[JsonSchemaTestSchema]: diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml index 924a11b35a3..0b4ec5dd84f 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml @@ -7,42 +7,29 @@ info: paths: {} components: schemas: - MaximumValidation: - maximum: 3.0 - MaximumValidationWithUnsignedInteger: - maximum: 300 + MaxitemsValidation: + maxItems: 2 x-schema-test-examples: - MaximumValidation: - BelowTheMaximumIsValid: - description: below the maximum is valid - data: 2.6 + MaxitemsValidation: + ShorterIsValid: + description: shorter is valid + data: + - 1 valid: true - BoundaryPointIsValid: - description: boundary point is valid - data: 3.0 + ExactLengthIsValid: + description: exact length is valid + data: + - 1 + - 2 valid: true - AboveTheMaximumIsInvalid: - description: above the maximum is invalid - data: 3.5 + TooLongIsInvalid: + description: too long is invalid + data: + - 1 + - 2 + - 3 valid: false - IgnoresNonNumbers: - description: ignores non-numbers - data: x + IgnoresNonArrays: + description: ignores non-arrays + data: foobar valid: true - MaximumValidationWithUnsignedInteger: - BelowTheMaximumIsInvalid: - description: below the maximum is invalid - data: 299.97 - valid: true - BoundaryPointIntegerIsValid: - description: boundary point integer is valid - data: 300 - valid: true - BoundaryPointFloatIsValid: - description: boundary point float is valid - data: 300.0 - valid: true - AboveTheMaximumIsInvalid: - description: above the maximum is invalid - data: 300.5 - valid: false diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index 6d4ba00a5a2..c954668400c 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -2,16 +2,14 @@ .gitlab-ci.yml .travis.yml README.md -docs/MaximumValidation.md -docs/MaximumValidationWithUnsignedInteger.md +docs/MaxitemsValidation.md git_push.sh requirements.txt setup.cfg setup.py test-requirements.txt test/__init__.py -test/test_maximum_validation.py -test/test_maximum_validation_with_unsigned_integer.py +test/test_maxitems_validation.py tox.ini unit_test_api/__init__.py unit_test_api/api/__init__.py @@ -20,8 +18,7 @@ unit_test_api/apis/__init__.py unit_test_api/configuration.py unit_test_api/exceptions.py unit_test_api/model/__init__.py -unit_test_api/model/maximum_validation.py -unit_test_api/model/maximum_validation_with_unsigned_integer.py +unit_test_api/model/maxitems_validation.py unit_test_api/models/__init__.py unit_test_api/rest.py unit_test_api/schemas.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md index 6c49bff9b4b..4885347b588 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md @@ -62,8 +62,7 @@ Class | Method | HTTP request | Description ## Documentation For Models - - [MaximumValidation](docs/MaximumValidation.md) - - [MaximumValidationWithUnsignedInteger](docs/MaximumValidationWithUnsignedInteger.md) + - [MaxitemsValidation](docs/MaxitemsValidation.md) ## Documentation For Authorization diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaximumValidationWithUnsignedInteger.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaximumValidationWithUnsignedInteger.md deleted file mode 100644 index 9a20b4b7bc9..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaximumValidationWithUnsignedInteger.md +++ /dev/null @@ -1,9 +0,0 @@ -# MaximumValidationWithUnsignedInteger - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaximumValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxitemsValidation.md similarity index 95% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaximumValidation.md rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxitemsValidation.md index 2060e3a0d40..8c60872ae01 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaximumValidation.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxitemsValidation.md @@ -1,4 +1,4 @@ -# MaximumValidation +# MaxitemsValidation #### Properties Name | Type | Description | Notes diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation.py deleted file mode 100644 index 733be5ebae1..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation.py +++ /dev/null @@ -1,45 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.maximum_validation import MaximumValidation - - -class TestMaximumValidation(unittest.TestCase): - """MaximumValidation unit test stubs""" - - def test_below_the_maximum_is_valid_passes(self): - # below the maximum is valid - MaximumValidation( - 2.6 ) - - def test_boundary_point_is_valid_passes(self): - # boundary point is valid - MaximumValidation( - 3.0 ) - - def test_above_the_maximum_is_invalid_fails(self): - # above the maximum is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - MaximumValidation( - 3.5 ) - - def test_ignores_non_numbers_passes(self): - # ignores non-numbers - MaximumValidation( - - "x" ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation_with_unsigned_integer.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation_with_unsigned_integer.py deleted file mode 100644 index 7bc13a7c299..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation_with_unsigned_integer.py +++ /dev/null @@ -1,44 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.maximum_validation_with_unsigned_integer import MaximumValidationWithUnsignedInteger - - -class TestMaximumValidationWithUnsignedInteger(unittest.TestCase): - """MaximumValidationWithUnsignedInteger unit test stubs""" - - def test_below_the_maximum_is_invalid_passes(self): - # below the maximum is invalid - MaximumValidationWithUnsignedInteger( - 299.97 ) - - def test_above_the_maximum_is_invalid_fails(self): - # above the maximum is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - MaximumValidationWithUnsignedInteger( - 300.5 ) - - def test_boundary_point_integer_is_valid_passes(self): - # boundary point integer is valid - MaximumValidationWithUnsignedInteger( - 300 ) - - def test_boundary_point_float_is_valid_passes(self): - # boundary point float is valid - MaximumValidationWithUnsignedInteger( - 300.0 ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxitems_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxitems_validation.py new file mode 100644 index 00000000000..f2e63979240 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxitems_validation.py @@ -0,0 +1,57 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.maxitems_validation import MaxitemsValidation + + +class TestMaxitemsValidation(unittest.TestCase): + """MaxitemsValidation unit test stubs""" + + def test_too_long_is_invalid_fails(self): + # too long is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + MaxitemsValidation( + [ + 1, + 2, + 3, + ] + ) + + def test_ignores_non_arrays_passes(self): + # ignores non-arrays + MaxitemsValidation( + + "foobar" ) + + def test_shorter_is_valid_passes(self): + # shorter is valid + MaxitemsValidation( + [ + 1, + ] + ) + + def test_exact_length_is_valid_passes(self): + # exact length is valid + MaxitemsValidation( + [ + 1, + 2, + ] + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maximum_validation_with_unsigned_integer.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maximum_validation_with_unsigned_integer.py deleted file mode 100644 index 0aa1cb53eb9..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maximum_validation_with_unsigned_integer.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class MaximumValidationWithUnsignedInteger( - _SchemaValidator( - inclusive_maximum=300, - ), - AnyTypeSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'MaximumValidationWithUnsignedInteger': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maximum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxitems_validation.py similarity index 95% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maximum_validation.py rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxitems_validation.py index 155a514da50..20b1c37f9fc 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maximum_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxitems_validation.py @@ -66,9 +66,9 @@ from unit_test_api.schemas import ( # noqa: F401 ) -class MaximumValidation( +class MaxitemsValidation( _SchemaValidator( - inclusive_maximum=3.0, + max_items=2, ), AnyTypeSchema ): @@ -83,7 +83,7 @@ class MaximumValidation( *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Type[Schema], - ) -> 'MaximumValidation': + ) -> 'MaxitemsValidation': return super().__new__( cls, *args, diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py index 569197594c4..35250ad56a3 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py @@ -11,5 +11,4 @@ # import sys # sys.setrecursionlimit(n) -from unit_test_api.model.maximum_validation import MaximumValidation -from unit_test_api.model.maximum_validation_with_unsigned_integer import MaximumValidationWithUnsignedInteger +from unit_test_api.model.maxitems_validation import MaxitemsValidation -- GitLab From 95e7e1136c00b318878590aa753ba3555a0e5d25 Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Mon, 27 Jun 2022 00:06:47 -0700 Subject: [PATCH 14/43] Adds maxLength --- .../3_0/unit_test_spec/spec_writer.py | 3 +- .../resources/3_0/unit_test_spec/type.yaml | 28 +++++---- .../.openapi-generator/FILES | 6 +- .../python-experimental/README.md | 2 +- ...msValidation.md => MaxlengthValidation.md} | 2 +- .../test/test_maxitems_validation.py | 57 ------------------- .../test/test_maxlength_validation.py | 53 +++++++++++++++++ ..._validation.py => maxlength_validation.py} | 6 +- .../unit_test_api/models/__init__.py | 2 +- 9 files changed, 77 insertions(+), 82 deletions(-) rename samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/{MaxitemsValidation.md => MaxlengthValidation.md} (95%) delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxitems_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxlength_validation.py rename samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/{maxitems_validation.py => maxlength_validation.py} (95%) diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index daa999ed2c0..e780086790a 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -150,7 +150,8 @@ JSON_SCHEMA_TEST_FILE_TO_FOLDERS = { # 'infinite-loop-detection.json': (json_schema_test_draft,), # activate after fixing this # 'items.json': (json_schema_test_draft,), # 'maximum.json': (json_schema_test_draft,), - 'maxItems.json': (json_schema_test_draft,), +# 'maxItems.json': (json_schema_test_draft,), + 'maxLength.json': (json_schema_test_draft,), } def get_json_schema_test_schemas(file_path: typing.Tuple[str]) -> typing.List[JsonSchemaTestSchema]: diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml index 0b4ec5dd84f..a4923352be8 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml @@ -7,29 +7,27 @@ info: paths: {} components: schemas: - MaxitemsValidation: - maxItems: 2 + MaxlengthValidation: + maxLength: 2 x-schema-test-examples: - MaxitemsValidation: + MaxlengthValidation: ShorterIsValid: description: shorter is valid - data: - - 1 + data: f valid: true ExactLengthIsValid: description: exact length is valid - data: - - 1 - - 2 + data: fo valid: true TooLongIsInvalid: description: too long is invalid - data: - - 1 - - 2 - - 3 + data: foo valid: false - IgnoresNonArrays: - description: ignores non-arrays - data: foobar + IgnoresNonStrings: + description: ignores non-strings + data: 100 + valid: true + TwoSupplementaryUnicodeCodePointsIsLongEnough: + description: two supplementary Unicode code points is long enough + data: "\U0001F4A9\U0001F4A9" valid: true diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index c954668400c..e69db0f74a5 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -2,14 +2,14 @@ .gitlab-ci.yml .travis.yml README.md -docs/MaxitemsValidation.md +docs/MaxlengthValidation.md git_push.sh requirements.txt setup.cfg setup.py test-requirements.txt test/__init__.py -test/test_maxitems_validation.py +test/test_maxlength_validation.py tox.ini unit_test_api/__init__.py unit_test_api/api/__init__.py @@ -18,7 +18,7 @@ unit_test_api/apis/__init__.py unit_test_api/configuration.py unit_test_api/exceptions.py unit_test_api/model/__init__.py -unit_test_api/model/maxitems_validation.py +unit_test_api/model/maxlength_validation.py unit_test_api/models/__init__.py unit_test_api/rest.py unit_test_api/schemas.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md index 4885347b588..83a27fb8393 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md @@ -62,7 +62,7 @@ Class | Method | HTTP request | Description ## Documentation For Models - - [MaxitemsValidation](docs/MaxitemsValidation.md) + - [MaxlengthValidation](docs/MaxlengthValidation.md) ## Documentation For Authorization diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxitemsValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxlengthValidation.md similarity index 95% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxitemsValidation.md rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxlengthValidation.md index 8c60872ae01..0f9d27bd44f 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxitemsValidation.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxlengthValidation.md @@ -1,4 +1,4 @@ -# MaxitemsValidation +# MaxlengthValidation #### Properties Name | Type | Description | Notes diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxitems_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxitems_validation.py deleted file mode 100644 index f2e63979240..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxitems_validation.py +++ /dev/null @@ -1,57 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.maxitems_validation import MaxitemsValidation - - -class TestMaxitemsValidation(unittest.TestCase): - """MaxitemsValidation unit test stubs""" - - def test_too_long_is_invalid_fails(self): - # too long is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - MaxitemsValidation( - [ - 1, - 2, - 3, - ] - ) - - def test_ignores_non_arrays_passes(self): - # ignores non-arrays - MaxitemsValidation( - - "foobar" ) - - def test_shorter_is_valid_passes(self): - # shorter is valid - MaxitemsValidation( - [ - 1, - ] - ) - - def test_exact_length_is_valid_passes(self): - # exact length is valid - MaxitemsValidation( - [ - 1, - 2, - ] - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxlength_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxlength_validation.py new file mode 100644 index 00000000000..52520cdfe34 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxlength_validation.py @@ -0,0 +1,53 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.maxlength_validation import MaxlengthValidation + + +class TestMaxlengthValidation(unittest.TestCase): + """MaxlengthValidation unit test stubs""" + + def test_too_long_is_invalid_fails(self): + # too long is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + MaxlengthValidation( + + "foo" ) + + def test_ignores_non_strings_passes(self): + # ignores non-strings + MaxlengthValidation( + 100 ) + + def test_shorter_is_valid_passes(self): + # shorter is valid + MaxlengthValidation( + + "f" ) + + def test_two_supplementary_unicode_code_points_is_long_enough_passes(self): + # two supplementary Unicode code points is long enough + MaxlengthValidation( + + "💩💩" ) + + def test_exact_length_is_valid_passes(self): + # exact length is valid + MaxlengthValidation( + + "fo" ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxitems_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxlength_validation.py similarity index 95% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxitems_validation.py rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxlength_validation.py index 20b1c37f9fc..daf2ce82f75 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxitems_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxlength_validation.py @@ -66,9 +66,9 @@ from unit_test_api.schemas import ( # noqa: F401 ) -class MaxitemsValidation( +class MaxlengthValidation( _SchemaValidator( - max_items=2, + max_length=2, ), AnyTypeSchema ): @@ -83,7 +83,7 @@ class MaxitemsValidation( *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Type[Schema], - ) -> 'MaxitemsValidation': + ) -> 'MaxlengthValidation': return super().__new__( cls, *args, diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py index 35250ad56a3..12debaa9875 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py @@ -11,4 +11,4 @@ # import sys # sys.setrecursionlimit(n) -from unit_test_api.model.maxitems_validation import MaxitemsValidation +from unit_test_api.model.maxlength_validation import MaxlengthValidation -- GitLab From 5453d1a4a22797b56a0bcca0d7a2058464c890fd Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Mon, 27 Jun 2022 00:22:29 -0700 Subject: [PATCH 15/43] Adds maxProperties --- .../model_templates/validations.handlebars | 4 +- .../3_0/unit_test_spec/spec_writer.py | 1 + .../resources/3_0/unit_test_spec/type.yaml | 48 ++++++++++ .../.openapi-generator/FILES | 6 ++ .../python-experimental/README.md | 2 + .../Maxproperties0MeansTheObjectIsEmpty.md | 9 ++ .../docs/MaxpropertiesValidation.md | 9 ++ ...axproperties0_means_the_object_is_empty.py | 40 ++++++++ .../test/test_maxproperties_validation.py | 78 ++++++++++++++++ ...axproperties0_means_the_object_is_empty.py | 92 +++++++++++++++++++ .../model/maxproperties_validation.py | 92 +++++++++++++++++++ .../unit_test_api/models/__init__.py | 2 + 12 files changed, 381 insertions(+), 2 deletions(-) create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Maxproperties0MeansTheObjectIsEmpty.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxpropertiesValidation.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties0_means_the_object_is_empty.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxproperties0_means_the_object_is_empty.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxproperties_validation.py diff --git a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/validations.handlebars b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/validations.handlebars index 2384ac063d2..ab8dc2e0435 100644 --- a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/validations.handlebars +++ b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/validations.handlebars @@ -14,9 +14,9 @@ _SchemaValidator( {{#if minItems}} min_items={{minItems}}, {{/if}} -{{#if maxProperties}} +{{#neq maxProperties null }} max_properties={{maxProperties}}, -{{/if}} +{{/neq}} {{#if minProperties}} min_properties={{minProperties}}, {{/if}} diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index e780086790a..8ae72a48aff 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -152,6 +152,7 @@ JSON_SCHEMA_TEST_FILE_TO_FOLDERS = { # 'maximum.json': (json_schema_test_draft,), # 'maxItems.json': (json_schema_test_draft,), 'maxLength.json': (json_schema_test_draft,), + 'maxProperties.json': (json_schema_test_draft,), } def get_json_schema_test_schemas(file_path: typing.Tuple[str]) -> typing.List[JsonSchemaTestSchema]: diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml index a4923352be8..626708cf741 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml @@ -9,6 +9,10 @@ components: schemas: MaxlengthValidation: maxLength: 2 + MaxpropertiesValidation: + maxProperties: 2 + Maxproperties0MeansTheObjectIsEmpty: + maxProperties: 0 x-schema-test-examples: MaxlengthValidation: ShorterIsValid: @@ -31,3 +35,47 @@ components: description: two supplementary Unicode code points is long enough data: "\U0001F4A9\U0001F4A9" valid: true + MaxpropertiesValidation: + ShorterIsValid: + description: shorter is valid + data: + foo: 1 + valid: true + ExactLengthIsValid: + description: exact length is valid + data: + foo: 1 + bar: 2 + valid: true + TooLongIsInvalid: + description: too long is invalid + data: + foo: 1 + bar: 2 + baz: 3 + valid: false + IgnoresArrays: + description: ignores arrays + data: + - 1 + - 2 + - 3 + valid: true + IgnoresStrings: + description: ignores strings + data: foobar + valid: true + IgnoresOtherNonObjects: + description: ignores other non-objects + data: 12 + valid: true + Maxproperties0MeansTheObjectIsEmpty: + NoPropertiesIsValid: + description: no properties is valid + data: {} + valid: true + OnePropertyIsInvalid: + description: one property is invalid + data: + foo: 1 + valid: false diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index e69db0f74a5..a651e568040 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -3,6 +3,8 @@ .travis.yml README.md docs/MaxlengthValidation.md +docs/Maxproperties0MeansTheObjectIsEmpty.md +docs/MaxpropertiesValidation.md git_push.sh requirements.txt setup.cfg @@ -10,6 +12,8 @@ setup.py test-requirements.txt test/__init__.py test/test_maxlength_validation.py +test/test_maxproperties0_means_the_object_is_empty.py +test/test_maxproperties_validation.py tox.ini unit_test_api/__init__.py unit_test_api/api/__init__.py @@ -19,6 +23,8 @@ unit_test_api/configuration.py unit_test_api/exceptions.py unit_test_api/model/__init__.py unit_test_api/model/maxlength_validation.py +unit_test_api/model/maxproperties0_means_the_object_is_empty.py +unit_test_api/model/maxproperties_validation.py unit_test_api/models/__init__.py unit_test_api/rest.py unit_test_api/schemas.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md index 83a27fb8393..853527d937d 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md @@ -63,6 +63,8 @@ Class | Method | HTTP request | Description ## Documentation For Models - [MaxlengthValidation](docs/MaxlengthValidation.md) + - [Maxproperties0MeansTheObjectIsEmpty](docs/Maxproperties0MeansTheObjectIsEmpty.md) + - [MaxpropertiesValidation](docs/MaxpropertiesValidation.md) ## Documentation For Authorization diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Maxproperties0MeansTheObjectIsEmpty.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Maxproperties0MeansTheObjectIsEmpty.md new file mode 100644 index 00000000000..ed97994d653 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Maxproperties0MeansTheObjectIsEmpty.md @@ -0,0 +1,9 @@ +# Maxproperties0MeansTheObjectIsEmpty + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxpropertiesValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxpropertiesValidation.md new file mode 100644 index 00000000000..d92c1f77f9c --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxpropertiesValidation.md @@ -0,0 +1,9 @@ +# MaxpropertiesValidation + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties0_means_the_object_is_empty.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties0_means_the_object_is_empty.py new file mode 100644 index 00000000000..0a374e3e441 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties0_means_the_object_is_empty.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.maxproperties0_means_the_object_is_empty import Maxproperties0MeansTheObjectIsEmpty + + +class TestMaxproperties0MeansTheObjectIsEmpty(unittest.TestCase): + """Maxproperties0MeansTheObjectIsEmpty unit test stubs""" + + def test_no_properties_is_valid_passes(self): + # no properties is valid + Maxproperties0MeansTheObjectIsEmpty( + { + } + ) + + def test_one_property_is_invalid_fails(self): + # one property is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + Maxproperties0MeansTheObjectIsEmpty( + **{ + "foo": + 1, + } + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties_validation.py new file mode 100644 index 00000000000..9d3094ec447 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties_validation.py @@ -0,0 +1,78 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.maxproperties_validation import MaxpropertiesValidation + + +class TestMaxpropertiesValidation(unittest.TestCase): + """MaxpropertiesValidation unit test stubs""" + + def test_too_long_is_invalid_fails(self): + # too long is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + MaxpropertiesValidation( + **{ + "foo": + 1, + "bar": + 2, + "baz": + 3, + } + ) + + def test_ignores_arrays_passes(self): + # ignores arrays + MaxpropertiesValidation( + [ + 1, + 2, + 3, + ] + ) + + def test_ignores_other_non_objects_passes(self): + # ignores other non-objects + MaxpropertiesValidation( + 12 ) + + def test_ignores_strings_passes(self): + # ignores strings + MaxpropertiesValidation( + + "foobar" ) + + def test_shorter_is_valid_passes(self): + # shorter is valid + MaxpropertiesValidation( + **{ + "foo": + 1, + } + ) + + def test_exact_length_is_valid_passes(self): + # exact length is valid + MaxpropertiesValidation( + **{ + "foo": + 1, + "bar": + 2, + } + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxproperties0_means_the_object_is_empty.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxproperties0_means_the_object_is_empty.py new file mode 100644 index 00000000000..12231672ec2 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxproperties0_means_the_object_is_empty.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class Maxproperties0MeansTheObjectIsEmpty( + _SchemaValidator( + max_properties=0, + ), + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'Maxproperties0MeansTheObjectIsEmpty': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxproperties_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxproperties_validation.py new file mode 100644 index 00000000000..30b4e4d2158 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxproperties_validation.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class MaxpropertiesValidation( + _SchemaValidator( + max_properties=2, + ), + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'MaxpropertiesValidation': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py index 12debaa9875..19f1e6bb55b 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py @@ -12,3 +12,5 @@ # sys.setrecursionlimit(n) from unit_test_api.model.maxlength_validation import MaxlengthValidation +from unit_test_api.model.maxproperties0_means_the_object_is_empty import Maxproperties0MeansTheObjectIsEmpty +from unit_test_api.model.maxproperties_validation import MaxpropertiesValidation -- GitLab From 45cd0186e15bdddd436586f75fc673f881464921 Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Mon, 27 Jun 2022 00:25:52 -0700 Subject: [PATCH 16/43] Adds minimum --- .../3_0/unit_test_spec/spec_writer.py | 5 +- .../resources/3_0/unit_test_spec/type.yaml | 115 +++++++----------- .../.openapi-generator/FILES | 15 +-- .../python-experimental/README.md | 5 +- .../Maxproperties0MeansTheObjectIsEmpty.md | 9 -- ...ngthValidation.md => MinimumValidation.md} | 2 +- ... => MinimumValidationWithSignedInteger.md} | 2 +- .../test/test_maxlength_validation.py | 53 -------- ...axproperties0_means_the_object_is_empty.py | 40 ------ .../test/test_maxproperties_validation.py | 78 ------------ .../test/test_minimum_validation.py | 45 +++++++ ..._minimum_validation_with_signed_integer.py | 61 ++++++++++ ...axproperties0_means_the_object_is_empty.py | 92 -------------- ...th_validation.py => minimum_validation.py} | 6 +- ...minimum_validation_with_signed_integer.py} | 6 +- .../unit_test_api/models/__init__.py | 5 +- 16 files changed, 174 insertions(+), 365 deletions(-) delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Maxproperties0MeansTheObjectIsEmpty.md rename samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/{MaxlengthValidation.md => MinimumValidation.md} (95%) rename samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/{MaxpropertiesValidation.md => MinimumValidationWithSignedInteger.md} (92%) delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxlength_validation.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties0_means_the_object_is_empty.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation_with_signed_integer.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxproperties0_means_the_object_is_empty.py rename samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/{maxlength_validation.py => minimum_validation.py} (95%) rename samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/{maxproperties_validation.py => minimum_validation_with_signed_integer.py} (94%) diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index 8ae72a48aff..6c17d0decfb 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -151,8 +151,9 @@ JSON_SCHEMA_TEST_FILE_TO_FOLDERS = { # 'items.json': (json_schema_test_draft,), # 'maximum.json': (json_schema_test_draft,), # 'maxItems.json': (json_schema_test_draft,), - 'maxLength.json': (json_schema_test_draft,), - 'maxProperties.json': (json_schema_test_draft,), +# 'maxLength.json': (json_schema_test_draft,), +# 'maxProperties.json': (json_schema_test_draft,), + 'minimum.json': (json_schema_test_draft,), } def get_json_schema_test_schemas(file_path: typing.Tuple[str]) -> typing.List[JsonSchemaTestSchema]: diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml index 626708cf741..0de62f07dbc 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml @@ -7,75 +7,54 @@ info: paths: {} components: schemas: - MaxlengthValidation: - maxLength: 2 - MaxpropertiesValidation: - maxProperties: 2 - Maxproperties0MeansTheObjectIsEmpty: - maxProperties: 0 + MinimumValidation: + minimum: 1.1 + MinimumValidationWithSignedInteger: + minimum: -2 x-schema-test-examples: - MaxlengthValidation: - ShorterIsValid: - description: shorter is valid - data: f - valid: true - ExactLengthIsValid: - description: exact length is valid - data: fo - valid: true - TooLongIsInvalid: - description: too long is invalid - data: foo + MinimumValidation: + AboveTheMinimumIsValid: + description: above the minimum is valid + data: 2.6 + valid: true + BoundaryPointIsValid: + description: boundary point is valid + data: 1.1 + valid: true + BelowTheMinimumIsInvalid: + description: below the minimum is invalid + data: 0.6 valid: false - IgnoresNonStrings: - description: ignores non-strings - data: 100 - valid: true - TwoSupplementaryUnicodeCodePointsIsLongEnough: - description: two supplementary Unicode code points is long enough - data: "\U0001F4A9\U0001F4A9" - valid: true - MaxpropertiesValidation: - ShorterIsValid: - description: shorter is valid - data: - foo: 1 - valid: true - ExactLengthIsValid: - description: exact length is valid - data: - foo: 1 - bar: 2 - valid: true - TooLongIsInvalid: - description: too long is invalid - data: - foo: 1 - bar: 2 - baz: 3 + IgnoresNonNumbers: + description: ignores non-numbers + data: x + valid: true + MinimumValidationWithSignedInteger: + NegativeAboveTheMinimumIsValid: + description: negative above the minimum is valid + data: -1 + valid: true + PositiveAboveTheMinimumIsValid: + description: positive above the minimum is valid + data: 0 + valid: true + BoundaryPointIsValid: + description: boundary point is valid + data: -2 + valid: true + BoundaryPointWithFloatIsValid: + description: boundary point with float is valid + data: -2.0 + valid: true + FloatBelowTheMinimumIsInvalid: + description: float below the minimum is invalid + data: -2.0001 valid: false - IgnoresArrays: - description: ignores arrays - data: - - 1 - - 2 - - 3 - valid: true - IgnoresStrings: - description: ignores strings - data: foobar - valid: true - IgnoresOtherNonObjects: - description: ignores other non-objects - data: 12 - valid: true - Maxproperties0MeansTheObjectIsEmpty: - NoPropertiesIsValid: - description: no properties is valid - data: {} - valid: true - OnePropertyIsInvalid: - description: one property is invalid - data: - foo: 1 + IntBelowTheMinimumIsInvalid: + description: int below the minimum is invalid + data: -3 valid: false + IgnoresNonNumbers: + description: ignores non-numbers + data: x + valid: true diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index a651e568040..df2620ed289 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -2,18 +2,16 @@ .gitlab-ci.yml .travis.yml README.md -docs/MaxlengthValidation.md -docs/Maxproperties0MeansTheObjectIsEmpty.md -docs/MaxpropertiesValidation.md +docs/MinimumValidation.md +docs/MinimumValidationWithSignedInteger.md git_push.sh requirements.txt setup.cfg setup.py test-requirements.txt test/__init__.py -test/test_maxlength_validation.py -test/test_maxproperties0_means_the_object_is_empty.py -test/test_maxproperties_validation.py +test/test_minimum_validation.py +test/test_minimum_validation_with_signed_integer.py tox.ini unit_test_api/__init__.py unit_test_api/api/__init__.py @@ -22,9 +20,8 @@ unit_test_api/apis/__init__.py unit_test_api/configuration.py unit_test_api/exceptions.py unit_test_api/model/__init__.py -unit_test_api/model/maxlength_validation.py -unit_test_api/model/maxproperties0_means_the_object_is_empty.py -unit_test_api/model/maxproperties_validation.py +unit_test_api/model/minimum_validation.py +unit_test_api/model/minimum_validation_with_signed_integer.py unit_test_api/models/__init__.py unit_test_api/rest.py unit_test_api/schemas.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md index 853527d937d..57a53f343ef 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md @@ -62,9 +62,8 @@ Class | Method | HTTP request | Description ## Documentation For Models - - [MaxlengthValidation](docs/MaxlengthValidation.md) - - [Maxproperties0MeansTheObjectIsEmpty](docs/Maxproperties0MeansTheObjectIsEmpty.md) - - [MaxpropertiesValidation](docs/MaxpropertiesValidation.md) + - [MinimumValidation](docs/MinimumValidation.md) + - [MinimumValidationWithSignedInteger](docs/MinimumValidationWithSignedInteger.md) ## Documentation For Authorization diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Maxproperties0MeansTheObjectIsEmpty.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Maxproperties0MeansTheObjectIsEmpty.md deleted file mode 100644 index ed97994d653..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Maxproperties0MeansTheObjectIsEmpty.md +++ /dev/null @@ -1,9 +0,0 @@ -# Maxproperties0MeansTheObjectIsEmpty - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxlengthValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinimumValidation.md similarity index 95% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxlengthValidation.md rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinimumValidation.md index 0f9d27bd44f..0a787d59fe5 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxlengthValidation.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinimumValidation.md @@ -1,4 +1,4 @@ -# MaxlengthValidation +# MinimumValidation #### Properties Name | Type | Description | Notes diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxpropertiesValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinimumValidationWithSignedInteger.md similarity index 92% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxpropertiesValidation.md rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinimumValidationWithSignedInteger.md index d92c1f77f9c..e43ddb81712 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxpropertiesValidation.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinimumValidationWithSignedInteger.md @@ -1,4 +1,4 @@ -# MaxpropertiesValidation +# MinimumValidationWithSignedInteger #### Properties Name | Type | Description | Notes diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxlength_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxlength_validation.py deleted file mode 100644 index 52520cdfe34..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxlength_validation.py +++ /dev/null @@ -1,53 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.maxlength_validation import MaxlengthValidation - - -class TestMaxlengthValidation(unittest.TestCase): - """MaxlengthValidation unit test stubs""" - - def test_too_long_is_invalid_fails(self): - # too long is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - MaxlengthValidation( - - "foo" ) - - def test_ignores_non_strings_passes(self): - # ignores non-strings - MaxlengthValidation( - 100 ) - - def test_shorter_is_valid_passes(self): - # shorter is valid - MaxlengthValidation( - - "f" ) - - def test_two_supplementary_unicode_code_points_is_long_enough_passes(self): - # two supplementary Unicode code points is long enough - MaxlengthValidation( - - "💩💩" ) - - def test_exact_length_is_valid_passes(self): - # exact length is valid - MaxlengthValidation( - - "fo" ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties0_means_the_object_is_empty.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties0_means_the_object_is_empty.py deleted file mode 100644 index 0a374e3e441..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties0_means_the_object_is_empty.py +++ /dev/null @@ -1,40 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.maxproperties0_means_the_object_is_empty import Maxproperties0MeansTheObjectIsEmpty - - -class TestMaxproperties0MeansTheObjectIsEmpty(unittest.TestCase): - """Maxproperties0MeansTheObjectIsEmpty unit test stubs""" - - def test_no_properties_is_valid_passes(self): - # no properties is valid - Maxproperties0MeansTheObjectIsEmpty( - { - } - ) - - def test_one_property_is_invalid_fails(self): - # one property is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - Maxproperties0MeansTheObjectIsEmpty( - **{ - "foo": - 1, - } - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties_validation.py deleted file mode 100644 index 9d3094ec447..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties_validation.py +++ /dev/null @@ -1,78 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.maxproperties_validation import MaxpropertiesValidation - - -class TestMaxpropertiesValidation(unittest.TestCase): - """MaxpropertiesValidation unit test stubs""" - - def test_too_long_is_invalid_fails(self): - # too long is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - MaxpropertiesValidation( - **{ - "foo": - 1, - "bar": - 2, - "baz": - 3, - } - ) - - def test_ignores_arrays_passes(self): - # ignores arrays - MaxpropertiesValidation( - [ - 1, - 2, - 3, - ] - ) - - def test_ignores_other_non_objects_passes(self): - # ignores other non-objects - MaxpropertiesValidation( - 12 ) - - def test_ignores_strings_passes(self): - # ignores strings - MaxpropertiesValidation( - - "foobar" ) - - def test_shorter_is_valid_passes(self): - # shorter is valid - MaxpropertiesValidation( - **{ - "foo": - 1, - } - ) - - def test_exact_length_is_valid_passes(self): - # exact length is valid - MaxpropertiesValidation( - **{ - "foo": - 1, - "bar": - 2, - } - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation.py new file mode 100644 index 00000000000..0a2448b32c7 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation.py @@ -0,0 +1,45 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.minimum_validation import MinimumValidation + + +class TestMinimumValidation(unittest.TestCase): + """MinimumValidation unit test stubs""" + + def test_boundary_point_is_valid_passes(self): + # boundary point is valid + MinimumValidation( + 1.1 ) + + def test_below_the_minimum_is_invalid_fails(self): + # below the minimum is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + MinimumValidation( + 0.6 ) + + def test_above_the_minimum_is_valid_passes(self): + # above the minimum is valid + MinimumValidation( + 2.6 ) + + def test_ignores_non_numbers_passes(self): + # ignores non-numbers + MinimumValidation( + + "x" ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation_with_signed_integer.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation_with_signed_integer.py new file mode 100644 index 00000000000..58eb28e6d18 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation_with_signed_integer.py @@ -0,0 +1,61 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.minimum_validation_with_signed_integer import MinimumValidationWithSignedInteger + + +class TestMinimumValidationWithSignedInteger(unittest.TestCase): + """MinimumValidationWithSignedInteger unit test stubs""" + + def test_boundary_point_is_valid_passes(self): + # boundary point is valid + MinimumValidationWithSignedInteger( + -2 ) + + def test_positive_above_the_minimum_is_valid_passes(self): + # positive above the minimum is valid + MinimumValidationWithSignedInteger( + 0 ) + + def test_int_below_the_minimum_is_invalid_fails(self): + # int below the minimum is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + MinimumValidationWithSignedInteger( + -3 ) + + def test_float_below_the_minimum_is_invalid_fails(self): + # float below the minimum is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + MinimumValidationWithSignedInteger( + -2.0001 ) + + def test_boundary_point_with_float_is_valid_passes(self): + # boundary point with float is valid + MinimumValidationWithSignedInteger( + -2.0 ) + + def test_negative_above_the_minimum_is_valid_passes(self): + # negative above the minimum is valid + MinimumValidationWithSignedInteger( + -1 ) + + def test_ignores_non_numbers_passes(self): + # ignores non-numbers + MinimumValidationWithSignedInteger( + + "x" ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxproperties0_means_the_object_is_empty.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxproperties0_means_the_object_is_empty.py deleted file mode 100644 index 12231672ec2..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxproperties0_means_the_object_is_empty.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class Maxproperties0MeansTheObjectIsEmpty( - _SchemaValidator( - max_properties=0, - ), - AnyTypeSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'Maxproperties0MeansTheObjectIsEmpty': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxlength_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minimum_validation.py similarity index 95% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxlength_validation.py rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minimum_validation.py index daf2ce82f75..bbe4414e080 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxlength_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minimum_validation.py @@ -66,9 +66,9 @@ from unit_test_api.schemas import ( # noqa: F401 ) -class MaxlengthValidation( +class MinimumValidation( _SchemaValidator( - max_length=2, + inclusive_minimum=1.1, ), AnyTypeSchema ): @@ -83,7 +83,7 @@ class MaxlengthValidation( *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Type[Schema], - ) -> 'MaxlengthValidation': + ) -> 'MinimumValidation': return super().__new__( cls, *args, diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxproperties_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minimum_validation_with_signed_integer.py similarity index 94% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxproperties_validation.py rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minimum_validation_with_signed_integer.py index 30b4e4d2158..c0996a1a84b 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxproperties_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minimum_validation_with_signed_integer.py @@ -66,9 +66,9 @@ from unit_test_api.schemas import ( # noqa: F401 ) -class MaxpropertiesValidation( +class MinimumValidationWithSignedInteger( _SchemaValidator( - max_properties=2, + inclusive_minimum=-2, ), AnyTypeSchema ): @@ -83,7 +83,7 @@ class MaxpropertiesValidation( *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Type[Schema], - ) -> 'MaxpropertiesValidation': + ) -> 'MinimumValidationWithSignedInteger': return super().__new__( cls, *args, diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py index 19f1e6bb55b..84ab443a848 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py @@ -11,6 +11,5 @@ # import sys # sys.setrecursionlimit(n) -from unit_test_api.model.maxlength_validation import MaxlengthValidation -from unit_test_api.model.maxproperties0_means_the_object_is_empty import Maxproperties0MeansTheObjectIsEmpty -from unit_test_api.model.maxproperties_validation import MaxpropertiesValidation +from unit_test_api.model.minimum_validation import MinimumValidation +from unit_test_api.model.minimum_validation_with_signed_integer import MinimumValidationWithSignedInteger -- GitLab From 6a6127b5a6fd3e21f0ec73232215dfb26a3c090a Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Mon, 27 Jun 2022 00:30:35 -0700 Subject: [PATCH 17/43] Adds minItems --- .../3_0/unit_test_spec/spec_writer.py | 3 +- .../resources/3_0/unit_test_spec/type.yaml | 68 ++++---------- .../.openapi-generator/FILES | 9 +- .../python-experimental/README.md | 3 +- .../MinimumValidationWithSignedInteger.md | 9 -- ...mumValidation.md => MinitemsValidation.md} | 2 +- .../test/test_minimum_validation.py | 45 --------- ..._minimum_validation_with_signed_integer.py | 61 ------------ .../test/test_minitems_validation.py | 54 +++++++++++ .../minimum_validation_with_signed_integer.py | 92 ------------------- ...m_validation.py => minitems_validation.py} | 6 +- .../unit_test_api/models/__init__.py | 3 +- 12 files changed, 85 insertions(+), 270 deletions(-) delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinimumValidationWithSignedInteger.md rename samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/{MinimumValidation.md => MinitemsValidation.md} (95%) delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation_with_signed_integer.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minitems_validation.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minimum_validation_with_signed_integer.py rename samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/{minimum_validation.py => minitems_validation.py} (95%) diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index 6c17d0decfb..bc322b56c74 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -153,7 +153,8 @@ JSON_SCHEMA_TEST_FILE_TO_FOLDERS = { # 'maxItems.json': (json_schema_test_draft,), # 'maxLength.json': (json_schema_test_draft,), # 'maxProperties.json': (json_schema_test_draft,), - 'minimum.json': (json_schema_test_draft,), +# 'minimum.json': (json_schema_test_draft,), + 'minItems.json': (json_schema_test_draft,), } def get_json_schema_test_schemas(file_path: typing.Tuple[str]) -> typing.List[JsonSchemaTestSchema]: diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml index 0de62f07dbc..e13c817b6d3 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml @@ -7,54 +7,26 @@ info: paths: {} components: schemas: - MinimumValidation: - minimum: 1.1 - MinimumValidationWithSignedInteger: - minimum: -2 + MinitemsValidation: + minItems: 1 x-schema-test-examples: - MinimumValidation: - AboveTheMinimumIsValid: - description: above the minimum is valid - data: 2.6 - valid: true - BoundaryPointIsValid: - description: boundary point is valid - data: 1.1 - valid: true - BelowTheMinimumIsInvalid: - description: below the minimum is invalid - data: 0.6 - valid: false - IgnoresNonNumbers: - description: ignores non-numbers - data: x - valid: true - MinimumValidationWithSignedInteger: - NegativeAboveTheMinimumIsValid: - description: negative above the minimum is valid - data: -1 - valid: true - PositiveAboveTheMinimumIsValid: - description: positive above the minimum is valid - data: 0 - valid: true - BoundaryPointIsValid: - description: boundary point is valid - data: -2 - valid: true - BoundaryPointWithFloatIsValid: - description: boundary point with float is valid - data: -2.0 - valid: true - FloatBelowTheMinimumIsInvalid: - description: float below the minimum is invalid - data: -2.0001 - valid: false - IntBelowTheMinimumIsInvalid: - description: int below the minimum is invalid - data: -3 + MinitemsValidation: + LongerIsValid: + description: longer is valid + data: + - 1 + - 2 + valid: true + ExactLengthIsValid: + description: exact length is valid + data: + - 1 + valid: true + TooShortIsInvalid: + description: too short is invalid + data: [] valid: false - IgnoresNonNumbers: - description: ignores non-numbers - data: x + IgnoresNonArrays: + description: ignores non-arrays + data: '' valid: true diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index df2620ed289..e03f7704b94 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -2,16 +2,14 @@ .gitlab-ci.yml .travis.yml README.md -docs/MinimumValidation.md -docs/MinimumValidationWithSignedInteger.md +docs/MinitemsValidation.md git_push.sh requirements.txt setup.cfg setup.py test-requirements.txt test/__init__.py -test/test_minimum_validation.py -test/test_minimum_validation_with_signed_integer.py +test/test_minitems_validation.py tox.ini unit_test_api/__init__.py unit_test_api/api/__init__.py @@ -20,8 +18,7 @@ unit_test_api/apis/__init__.py unit_test_api/configuration.py unit_test_api/exceptions.py unit_test_api/model/__init__.py -unit_test_api/model/minimum_validation.py -unit_test_api/model/minimum_validation_with_signed_integer.py +unit_test_api/model/minitems_validation.py unit_test_api/models/__init__.py unit_test_api/rest.py unit_test_api/schemas.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md index 57a53f343ef..4456da735c5 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md @@ -62,8 +62,7 @@ Class | Method | HTTP request | Description ## Documentation For Models - - [MinimumValidation](docs/MinimumValidation.md) - - [MinimumValidationWithSignedInteger](docs/MinimumValidationWithSignedInteger.md) + - [MinitemsValidation](docs/MinitemsValidation.md) ## Documentation For Authorization diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinimumValidationWithSignedInteger.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinimumValidationWithSignedInteger.md deleted file mode 100644 index e43ddb81712..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinimumValidationWithSignedInteger.md +++ /dev/null @@ -1,9 +0,0 @@ -# MinimumValidationWithSignedInteger - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinimumValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinitemsValidation.md similarity index 95% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinimumValidation.md rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinitemsValidation.md index 0a787d59fe5..14e1884d056 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinimumValidation.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinitemsValidation.md @@ -1,4 +1,4 @@ -# MinimumValidation +# MinitemsValidation #### Properties Name | Type | Description | Notes diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation.py deleted file mode 100644 index 0a2448b32c7..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation.py +++ /dev/null @@ -1,45 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.minimum_validation import MinimumValidation - - -class TestMinimumValidation(unittest.TestCase): - """MinimumValidation unit test stubs""" - - def test_boundary_point_is_valid_passes(self): - # boundary point is valid - MinimumValidation( - 1.1 ) - - def test_below_the_minimum_is_invalid_fails(self): - # below the minimum is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - MinimumValidation( - 0.6 ) - - def test_above_the_minimum_is_valid_passes(self): - # above the minimum is valid - MinimumValidation( - 2.6 ) - - def test_ignores_non_numbers_passes(self): - # ignores non-numbers - MinimumValidation( - - "x" ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation_with_signed_integer.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation_with_signed_integer.py deleted file mode 100644 index 58eb28e6d18..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation_with_signed_integer.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.minimum_validation_with_signed_integer import MinimumValidationWithSignedInteger - - -class TestMinimumValidationWithSignedInteger(unittest.TestCase): - """MinimumValidationWithSignedInteger unit test stubs""" - - def test_boundary_point_is_valid_passes(self): - # boundary point is valid - MinimumValidationWithSignedInteger( - -2 ) - - def test_positive_above_the_minimum_is_valid_passes(self): - # positive above the minimum is valid - MinimumValidationWithSignedInteger( - 0 ) - - def test_int_below_the_minimum_is_invalid_fails(self): - # int below the minimum is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - MinimumValidationWithSignedInteger( - -3 ) - - def test_float_below_the_minimum_is_invalid_fails(self): - # float below the minimum is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - MinimumValidationWithSignedInteger( - -2.0001 ) - - def test_boundary_point_with_float_is_valid_passes(self): - # boundary point with float is valid - MinimumValidationWithSignedInteger( - -2.0 ) - - def test_negative_above_the_minimum_is_valid_passes(self): - # negative above the minimum is valid - MinimumValidationWithSignedInteger( - -1 ) - - def test_ignores_non_numbers_passes(self): - # ignores non-numbers - MinimumValidationWithSignedInteger( - - "x" ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minitems_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minitems_validation.py new file mode 100644 index 00000000000..6182de397da --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minitems_validation.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.minitems_validation import MinitemsValidation + + +class TestMinitemsValidation(unittest.TestCase): + """MinitemsValidation unit test stubs""" + + def test_too_short_is_invalid_fails(self): + # too short is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + MinitemsValidation( + [ + ] + ) + + def test_ignores_non_arrays_passes(self): + # ignores non-arrays + MinitemsValidation( + + "" ) + + def test_longer_is_valid_passes(self): + # longer is valid + MinitemsValidation( + [ + 1, + 2, + ] + ) + + def test_exact_length_is_valid_passes(self): + # exact length is valid + MinitemsValidation( + [ + 1, + ] + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minimum_validation_with_signed_integer.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minimum_validation_with_signed_integer.py deleted file mode 100644 index c0996a1a84b..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minimum_validation_with_signed_integer.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class MinimumValidationWithSignedInteger( - _SchemaValidator( - inclusive_minimum=-2, - ), - AnyTypeSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'MinimumValidationWithSignedInteger': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minimum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minitems_validation.py similarity index 95% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minimum_validation.py rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minitems_validation.py index bbe4414e080..14a07dd3414 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minimum_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minitems_validation.py @@ -66,9 +66,9 @@ from unit_test_api.schemas import ( # noqa: F401 ) -class MinimumValidation( +class MinitemsValidation( _SchemaValidator( - inclusive_minimum=1.1, + min_items=1, ), AnyTypeSchema ): @@ -83,7 +83,7 @@ class MinimumValidation( *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Type[Schema], - ) -> 'MinimumValidation': + ) -> 'MinitemsValidation': return super().__new__( cls, *args, diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py index 84ab443a848..dad27768558 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py @@ -11,5 +11,4 @@ # import sys # sys.setrecursionlimit(n) -from unit_test_api.model.minimum_validation import MinimumValidation -from unit_test_api.model.minimum_validation_with_signed_integer import MinimumValidationWithSignedInteger +from unit_test_api.model.minitems_validation import MinitemsValidation -- GitLab From bcc6f498ef239063995c37d87564cba2453c292f Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Mon, 27 Jun 2022 00:40:08 -0700 Subject: [PATCH 18/43] Adds minLength --- .../3_0/unit_test_spec/spec_writer.py | 9 ++-- .../resources/3_0/unit_test_spec/type.yaml | 25 ++++----- .../.openapi-generator/FILES | 6 +-- .../python-experimental/README.md | 2 +- ...msValidation.md => MinlengthValidation.md} | 2 +- .../test/test_minitems_validation.py | 54 ------------------- .../test/test_minlength_validation.py | 54 +++++++++++++++++++ ..._validation.py => minlength_validation.py} | 6 +-- .../unit_test_api/models/__init__.py | 2 +- 9 files changed, 81 insertions(+), 79 deletions(-) rename samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/{MinitemsValidation.md => MinlengthValidation.md} (95%) delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minitems_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minlength_validation.py rename samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/{minitems_validation.py => minlength_validation.py} (95%) diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index bc322b56c74..a279480fa41 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -143,10 +143,10 @@ JSON_SCHEMA_TEST_FILE_TO_FOLDERS = { # 'definitions.json': (json_schema_test_draft,), # 'dependencies.json': (json_schema_test_draft,), # 'enum.json': (json_schema_test_draft,), - 'exclusiveMaximum.json': (json_schema_test_draft,), - 'exclusiveMinimum.json': (json_schema_test_draft,), +# 'exclusiveMaximum.json': (json_schema_test_draft,), +# 'exclusiveMinimum.json': (json_schema_test_draft,), # 'format.json': (json_schema_test_draft,), - 'id.json': (json_schema_test_draft,), +# 'id.json': (json_schema_test_draft,), # 'infinite-loop-detection.json': (json_schema_test_draft,), # activate after fixing this # 'items.json': (json_schema_test_draft,), # 'maximum.json': (json_schema_test_draft,), @@ -154,7 +154,8 @@ JSON_SCHEMA_TEST_FILE_TO_FOLDERS = { # 'maxLength.json': (json_schema_test_draft,), # 'maxProperties.json': (json_schema_test_draft,), # 'minimum.json': (json_schema_test_draft,), - 'minItems.json': (json_schema_test_draft,), +# 'minItems.json': (json_schema_test_draft,), + 'minLength.json': (json_schema_test_draft,), } def get_json_schema_test_schemas(file_path: typing.Tuple[str]) -> typing.List[JsonSchemaTestSchema]: diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml index e13c817b6d3..d71fd80e0e8 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml @@ -7,26 +7,27 @@ info: paths: {} components: schemas: - MinitemsValidation: - minItems: 1 + MinlengthValidation: + minLength: 2 x-schema-test-examples: - MinitemsValidation: + MinlengthValidation: LongerIsValid: description: longer is valid - data: - - 1 - - 2 + data: foo valid: true ExactLengthIsValid: description: exact length is valid - data: - - 1 + data: fo valid: true TooShortIsInvalid: description: too short is invalid - data: [] + data: f valid: false - IgnoresNonArrays: - description: ignores non-arrays - data: '' + IgnoresNonStrings: + description: ignores non-strings + data: 1 valid: true + OneSupplementaryUnicodeCodePointIsNotLongEnough: + description: one supplementary Unicode code point is not long enough + data: "\U0001F4A9" + valid: false diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index e03f7704b94..3b32dd5018d 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -2,14 +2,14 @@ .gitlab-ci.yml .travis.yml README.md -docs/MinitemsValidation.md +docs/MinlengthValidation.md git_push.sh requirements.txt setup.cfg setup.py test-requirements.txt test/__init__.py -test/test_minitems_validation.py +test/test_minlength_validation.py tox.ini unit_test_api/__init__.py unit_test_api/api/__init__.py @@ -18,7 +18,7 @@ unit_test_api/apis/__init__.py unit_test_api/configuration.py unit_test_api/exceptions.py unit_test_api/model/__init__.py -unit_test_api/model/minitems_validation.py +unit_test_api/model/minlength_validation.py unit_test_api/models/__init__.py unit_test_api/rest.py unit_test_api/schemas.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md index 4456da735c5..ca2a973acf7 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md @@ -62,7 +62,7 @@ Class | Method | HTTP request | Description ## Documentation For Models - - [MinitemsValidation](docs/MinitemsValidation.md) + - [MinlengthValidation](docs/MinlengthValidation.md) ## Documentation For Authorization diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinitemsValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinlengthValidation.md similarity index 95% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinitemsValidation.md rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinlengthValidation.md index 14e1884d056..c914c02f01b 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinitemsValidation.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinlengthValidation.md @@ -1,4 +1,4 @@ -# MinitemsValidation +# MinlengthValidation #### Properties Name | Type | Description | Notes diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minitems_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minitems_validation.py deleted file mode 100644 index 6182de397da..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minitems_validation.py +++ /dev/null @@ -1,54 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.minitems_validation import MinitemsValidation - - -class TestMinitemsValidation(unittest.TestCase): - """MinitemsValidation unit test stubs""" - - def test_too_short_is_invalid_fails(self): - # too short is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - MinitemsValidation( - [ - ] - ) - - def test_ignores_non_arrays_passes(self): - # ignores non-arrays - MinitemsValidation( - - "" ) - - def test_longer_is_valid_passes(self): - # longer is valid - MinitemsValidation( - [ - 1, - 2, - ] - ) - - def test_exact_length_is_valid_passes(self): - # exact length is valid - MinitemsValidation( - [ - 1, - ] - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minlength_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minlength_validation.py new file mode 100644 index 00000000000..9f3af39ea7f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minlength_validation.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.minlength_validation import MinlengthValidation + + +class TestMinlengthValidation(unittest.TestCase): + """MinlengthValidation unit test stubs""" + + def test_too_short_is_invalid_fails(self): + # too short is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + MinlengthValidation( + + "f" ) + + def test_one_supplementary_unicode_code_point_is_not_long_enough_fails(self): + # one supplementary Unicode code point is not long enough + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + MinlengthValidation( + + "💩" ) + + def test_longer_is_valid_passes(self): + # longer is valid + MinlengthValidation( + + "foo" ) + + def test_ignores_non_strings_passes(self): + # ignores non-strings + MinlengthValidation( + 1 ) + + def test_exact_length_is_valid_passes(self): + # exact length is valid + MinlengthValidation( + + "fo" ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minitems_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minlength_validation.py similarity index 95% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minitems_validation.py rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minlength_validation.py index 14a07dd3414..a4ac28a41cb 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minitems_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minlength_validation.py @@ -66,9 +66,9 @@ from unit_test_api.schemas import ( # noqa: F401 ) -class MinitemsValidation( +class MinlengthValidation( _SchemaValidator( - min_items=1, + min_length=2, ), AnyTypeSchema ): @@ -83,7 +83,7 @@ class MinitemsValidation( *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Type[Schema], - ) -> 'MinitemsValidation': + ) -> 'MinlengthValidation': return super().__new__( cls, *args, diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py index dad27768558..62297262700 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py @@ -11,4 +11,4 @@ # import sys # sys.setrecursionlimit(n) -from unit_test_api.model.minitems_validation import MinitemsValidation +from unit_test_api.model.minlength_validation import MinlengthValidation -- GitLab From 9ed01c9db6987f7a424e04353181b82447d17766 Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Mon, 27 Jun 2022 00:43:50 -0700 Subject: [PATCH 19/43] Adds minProperties --- .../3_0/unit_test_spec/spec_writer.py | 3 +- .../resources/3_0/unit_test_spec/type.yaml | 33 +++++---- .../.openapi-generator/FILES | 6 +- .../python-experimental/README.md | 2 +- ...lidation.md => MinpropertiesValidation.md} | 2 +- .../test/test_minlength_validation.py | 54 --------------- .../test/test_minproperties_validation.py | 69 +++++++++++++++++++ ...idation.py => minproperties_validation.py} | 6 +- .../unit_test_api/models/__init__.py | 2 +- 9 files changed, 100 insertions(+), 77 deletions(-) rename samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/{MinlengthValidation.md => MinpropertiesValidation.md} (94%) delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minlength_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minproperties_validation.py rename samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/{minlength_validation.py => minproperties_validation.py} (95%) diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index a279480fa41..be490ba9792 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -155,7 +155,8 @@ JSON_SCHEMA_TEST_FILE_TO_FOLDERS = { # 'maxProperties.json': (json_schema_test_draft,), # 'minimum.json': (json_schema_test_draft,), # 'minItems.json': (json_schema_test_draft,), - 'minLength.json': (json_schema_test_draft,), +# 'minLength.json': (json_schema_test_draft,), + 'minProperties.json': (json_schema_test_draft,), } def get_json_schema_test_schemas(file_path: typing.Tuple[str]) -> typing.List[JsonSchemaTestSchema]: diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml index d71fd80e0e8..27454948271 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml @@ -7,27 +7,34 @@ info: paths: {} components: schemas: - MinlengthValidation: - minLength: 2 + MinpropertiesValidation: + minProperties: 1 x-schema-test-examples: - MinlengthValidation: + MinpropertiesValidation: LongerIsValid: description: longer is valid - data: foo + data: + foo: 1 + bar: 2 valid: true ExactLengthIsValid: description: exact length is valid - data: fo + data: + foo: 1 valid: true TooShortIsInvalid: description: too short is invalid - data: f + data: {} valid: false - IgnoresNonStrings: - description: ignores non-strings - data: 1 + IgnoresArrays: + description: ignores arrays + data: [] + valid: true + IgnoresStrings: + description: ignores strings + data: '' + valid: true + IgnoresOtherNonObjects: + description: ignores other non-objects + data: 12 valid: true - OneSupplementaryUnicodeCodePointIsNotLongEnough: - description: one supplementary Unicode code point is not long enough - data: "\U0001F4A9" - valid: false diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index 3b32dd5018d..c8109f41cac 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -2,14 +2,14 @@ .gitlab-ci.yml .travis.yml README.md -docs/MinlengthValidation.md +docs/MinpropertiesValidation.md git_push.sh requirements.txt setup.cfg setup.py test-requirements.txt test/__init__.py -test/test_minlength_validation.py +test/test_minproperties_validation.py tox.ini unit_test_api/__init__.py unit_test_api/api/__init__.py @@ -18,7 +18,7 @@ unit_test_api/apis/__init__.py unit_test_api/configuration.py unit_test_api/exceptions.py unit_test_api/model/__init__.py -unit_test_api/model/minlength_validation.py +unit_test_api/model/minproperties_validation.py unit_test_api/models/__init__.py unit_test_api/rest.py unit_test_api/schemas.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md index ca2a973acf7..b7476d41dd9 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md @@ -62,7 +62,7 @@ Class | Method | HTTP request | Description ## Documentation For Models - - [MinlengthValidation](docs/MinlengthValidation.md) + - [MinpropertiesValidation](docs/MinpropertiesValidation.md) ## Documentation For Authorization diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinlengthValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinpropertiesValidation.md similarity index 94% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinlengthValidation.md rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinpropertiesValidation.md index c914c02f01b..b549f694557 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinlengthValidation.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinpropertiesValidation.md @@ -1,4 +1,4 @@ -# MinlengthValidation +# MinpropertiesValidation #### Properties Name | Type | Description | Notes diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minlength_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minlength_validation.py deleted file mode 100644 index 9f3af39ea7f..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minlength_validation.py +++ /dev/null @@ -1,54 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.minlength_validation import MinlengthValidation - - -class TestMinlengthValidation(unittest.TestCase): - """MinlengthValidation unit test stubs""" - - def test_too_short_is_invalid_fails(self): - # too short is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - MinlengthValidation( - - "f" ) - - def test_one_supplementary_unicode_code_point_is_not_long_enough_fails(self): - # one supplementary Unicode code point is not long enough - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - MinlengthValidation( - - "💩" ) - - def test_longer_is_valid_passes(self): - # longer is valid - MinlengthValidation( - - "foo" ) - - def test_ignores_non_strings_passes(self): - # ignores non-strings - MinlengthValidation( - 1 ) - - def test_exact_length_is_valid_passes(self): - # exact length is valid - MinlengthValidation( - - "fo" ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minproperties_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minproperties_validation.py new file mode 100644 index 00000000000..0a8aa8a2f52 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minproperties_validation.py @@ -0,0 +1,69 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.minproperties_validation import MinpropertiesValidation + + +class TestMinpropertiesValidation(unittest.TestCase): + """MinpropertiesValidation unit test stubs""" + + def test_ignores_arrays_passes(self): + # ignores arrays + MinpropertiesValidation( + [ + ] + ) + + def test_ignores_other_non_objects_passes(self): + # ignores other non-objects + MinpropertiesValidation( + 12 ) + + def test_too_short_is_invalid_fails(self): + # too short is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + MinpropertiesValidation( + { + } + ) + + def test_ignores_strings_passes(self): + # ignores strings + MinpropertiesValidation( + + "" ) + + def test_longer_is_valid_passes(self): + # longer is valid + MinpropertiesValidation( + **{ + "foo": + 1, + "bar": + 2, + } + ) + + def test_exact_length_is_valid_passes(self): + # exact length is valid + MinpropertiesValidation( + **{ + "foo": + 1, + } + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minlength_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minproperties_validation.py similarity index 95% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minlength_validation.py rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minproperties_validation.py index a4ac28a41cb..74861d0b1ff 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minlength_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minproperties_validation.py @@ -66,9 +66,9 @@ from unit_test_api.schemas import ( # noqa: F401 ) -class MinlengthValidation( +class MinpropertiesValidation( _SchemaValidator( - min_length=2, + min_properties=1, ), AnyTypeSchema ): @@ -83,7 +83,7 @@ class MinlengthValidation( *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Type[Schema], - ) -> 'MinlengthValidation': + ) -> 'MinpropertiesValidation': return super().__new__( cls, *args, diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py index 62297262700..8004a4b2093 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py @@ -11,4 +11,4 @@ # import sys # sys.setrecursionlimit(n) -from unit_test_api.model.minlength_validation import MinlengthValidation +from unit_test_api.model.minproperties_validation import MinpropertiesValidation -- GitLab From 3af670eb8fa2d78aa6ac2479f93e012f15264028 Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Mon, 27 Jun 2022 00:49:02 -0700 Subject: [PATCH 20/43] Adds multipleOf --- .../3_0/unit_test_spec/spec_writer.py | 3 +- .../resources/3_0/unit_test_spec/type.yaml | 70 +++++++++----- .../.openapi-generator/FILES | 15 ++- .../python-experimental/README.md | 5 +- .../{MinpropertiesValidation.md => ByInt.md} | 2 +- .../python-experimental/docs/ByNumber.md | 9 ++ .../python-experimental/docs/BySmallNumber.md | 9 ++ ...ShouldNotRaiseErrorWhenFloatDivisionInf.md | 8 ++ .../python-experimental/test/test_by_int.py | 40 ++++++++ .../test/test_by_number.py | 39 ++++++++ .../test/test_by_small_number.py | 34 +++++++ ...not_raise_error_when_float_division_inf.py | 29 ++++++ .../test/test_minproperties_validation.py | 69 -------------- ...{minproperties_validation.py => by_int.py} | 6 +- .../unit_test_api/model/by_number.py | 92 +++++++++++++++++++ .../unit_test_api/model/by_small_number.py | 92 +++++++++++++++++++ ...not_raise_error_when_float_division_inf.py | 80 ++++++++++++++++ .../unit_test_api/models/__init__.py | 5 +- 18 files changed, 503 insertions(+), 104 deletions(-) rename samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/{MinpropertiesValidation.md => ByInt.md} (94%) create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ByNumber.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/BySmallNumber.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_int.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_number.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_small_number.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_instance_should_not_raise_error_when_float_division_inf.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minproperties_validation.py rename samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/{minproperties_validation.py => by_int.py} (95%) create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_number.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_small_number.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_instance_should_not_raise_error_when_float_division_inf.py diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index be490ba9792..807f44863ce 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -156,7 +156,8 @@ JSON_SCHEMA_TEST_FILE_TO_FOLDERS = { # 'minimum.json': (json_schema_test_draft,), # 'minItems.json': (json_schema_test_draft,), # 'minLength.json': (json_schema_test_draft,), - 'minProperties.json': (json_schema_test_draft,), +# 'minProperties.json': (json_schema_test_draft,), + 'multipleOf.json': (json_schema_test_draft,), } def get_json_schema_test_schemas(file_path: typing.Tuple[str]) -> typing.List[JsonSchemaTestSchema]: diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml index 27454948271..a5b4367eb16 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml @@ -7,34 +7,54 @@ info: paths: {} components: schemas: - MinpropertiesValidation: - minProperties: 1 + ByInt: + multipleOf: 2 + ByNumber: + multipleOf: 1.5 + BySmallNumber: + multipleOf: 0.0001 + InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf: + type: integer + multipleOf: 0.123456789 x-schema-test-examples: - MinpropertiesValidation: - LongerIsValid: - description: longer is valid - data: - foo: 1 - bar: 2 + ByInt: + IntByInt: + description: int by int + data: 10 valid: true - ExactLengthIsValid: - description: exact length is valid - data: - foo: 1 - valid: true - TooShortIsInvalid: - description: too short is invalid - data: {} + IntByIntFail: + description: int by int fail + data: 7 valid: false - IgnoresArrays: - description: ignores arrays - data: [] + IgnoresNonNumbers: + description: ignores non-numbers + data: foo + valid: true + ByNumber: + ZeroIsMultipleOfAnything: + description: zero is multiple of anything + data: 0 valid: true - IgnoresStrings: - description: ignores strings - data: '' + 45IsMultipleOf15: + description: 4.5 is multiple of 1.5 + data: 4.5 valid: true - IgnoresOtherNonObjects: - description: ignores other non-objects - data: 12 + 35IsNotMultipleOf15: + description: 35 is not multiple of 1.5 + data: 35 + valid: false + BySmallNumber: + 00075IsMultipleOf00001: + description: 0.0075 is multiple of 0.0001 + data: 0.0075 valid: true + 000751IsNotMultipleOf00001: + description: 0.00751 is not multiple of 0.0001 + data: 0.00751 + valid: false + InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf: + AlwaysInvalidButNaiveImplementationsMayRaiseAnOverflowError: + description: always invalid, but naive implementations may raise an overflow + error + data: 1.0e+308 + valid: false diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index c8109f41cac..99832e6fcf0 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -2,14 +2,20 @@ .gitlab-ci.yml .travis.yml README.md -docs/MinpropertiesValidation.md +docs/ByInt.md +docs/ByNumber.md +docs/BySmallNumber.md +docs/InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf.md git_push.sh requirements.txt setup.cfg setup.py test-requirements.txt test/__init__.py -test/test_minproperties_validation.py +test/test_by_int.py +test/test_by_number.py +test/test_by_small_number.py +test/test_invalid_instance_should_not_raise_error_when_float_division_inf.py tox.ini unit_test_api/__init__.py unit_test_api/api/__init__.py @@ -18,7 +24,10 @@ unit_test_api/apis/__init__.py unit_test_api/configuration.py unit_test_api/exceptions.py unit_test_api/model/__init__.py -unit_test_api/model/minproperties_validation.py +unit_test_api/model/by_int.py +unit_test_api/model/by_number.py +unit_test_api/model/by_small_number.py +unit_test_api/model/invalid_instance_should_not_raise_error_when_float_division_inf.py unit_test_api/models/__init__.py unit_test_api/rest.py unit_test_api/schemas.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md index b7476d41dd9..2d9bb7af9a5 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md @@ -62,7 +62,10 @@ Class | Method | HTTP request | Description ## Documentation For Models - - [MinpropertiesValidation](docs/MinpropertiesValidation.md) + - [ByInt](docs/ByInt.md) + - [ByNumber](docs/ByNumber.md) + - [BySmallNumber](docs/BySmallNumber.md) + - [InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf](docs/InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf.md) ## Documentation For Authorization diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinpropertiesValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ByInt.md similarity index 94% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinpropertiesValidation.md rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ByInt.md index b549f694557..7e089ed79bb 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinpropertiesValidation.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ByInt.md @@ -1,4 +1,4 @@ -# MinpropertiesValidation +# ByInt #### Properties Name | Type | Description | Notes diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ByNumber.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ByNumber.md new file mode 100644 index 00000000000..8c272d66b6d --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ByNumber.md @@ -0,0 +1,9 @@ +# ByNumber + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/BySmallNumber.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/BySmallNumber.md new file mode 100644 index 00000000000..3671c33f9c9 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/BySmallNumber.md @@ -0,0 +1,9 @@ +# BySmallNumber + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf.md new file mode 100644 index 00000000000..9acc3f6353a --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf.md @@ -0,0 +1,8 @@ +# InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf + +Type | Description | Notes +------------- | ------------- | ------------- +**int** | | + +[[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/3_0_3_unit_test/python-experimental/test/test_by_int.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_int.py new file mode 100644 index 00000000000..2c69ea2abbd --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_int.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.by_int import ByInt + + +class TestByInt(unittest.TestCase): + """ByInt unit test stubs""" + + def test_int_by_int_fail_fails(self): + # int by int fail + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + ByInt( + 7 ) + + def test_int_by_int_passes(self): + # int by int + ByInt( + 10 ) + + def test_ignores_non_numbers_passes(self): + # ignores non-numbers + ByInt( + + "foo" ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_number.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_number.py new file mode 100644 index 00000000000..8586265edb2 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_number.py @@ -0,0 +1,39 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.by_number import ByNumber + + +class TestByNumber(unittest.TestCase): + """ByNumber unit test stubs""" + + def test_45_is_multiple_of15_passes(self): + # 4.5 is multiple of 1.5 + ByNumber( + 4.5 ) + + def test_35_is_not_multiple_of15_fails(self): + # 35 is not multiple of 1.5 + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + ByNumber( + 35 ) + + def test_zero_is_multiple_of_anything_passes(self): + # zero is multiple of anything + ByNumber( + 0 ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_small_number.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_small_number.py new file mode 100644 index 00000000000..6bd83fdd952 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_small_number.py @@ -0,0 +1,34 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.by_small_number import BySmallNumber + + +class TestBySmallNumber(unittest.TestCase): + """BySmallNumber unit test stubs""" + + def test_000751_is_not_multiple_of00001_fails(self): + # 0.00751 is not multiple of 0.0001 + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + BySmallNumber( + 0.00751 ) + + def test_00075_is_multiple_of00001_passes(self): + # 0.0075 is multiple of 0.0001 + BySmallNumber( + 0.0075 ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_instance_should_not_raise_error_when_float_division_inf.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_instance_should_not_raise_error_when_float_division_inf.py new file mode 100644 index 00000000000..9fc22a445ca --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_instance_should_not_raise_error_when_float_division_inf.py @@ -0,0 +1,29 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.invalid_instance_should_not_raise_error_when_float_division_inf import InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf + + +class TestInvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf(unittest.TestCase): + """InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf unit test stubs""" + + def test_always_invalid_but_naive_implementations_may_raise_an_overflow_error_fails(self): + # always invalid, but naive implementations may raise an overflow error + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf( + 1.0E308 ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minproperties_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minproperties_validation.py deleted file mode 100644 index 0a8aa8a2f52..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minproperties_validation.py +++ /dev/null @@ -1,69 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.minproperties_validation import MinpropertiesValidation - - -class TestMinpropertiesValidation(unittest.TestCase): - """MinpropertiesValidation unit test stubs""" - - def test_ignores_arrays_passes(self): - # ignores arrays - MinpropertiesValidation( - [ - ] - ) - - def test_ignores_other_non_objects_passes(self): - # ignores other non-objects - MinpropertiesValidation( - 12 ) - - def test_too_short_is_invalid_fails(self): - # too short is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - MinpropertiesValidation( - { - } - ) - - def test_ignores_strings_passes(self): - # ignores strings - MinpropertiesValidation( - - "" ) - - def test_longer_is_valid_passes(self): - # longer is valid - MinpropertiesValidation( - **{ - "foo": - 1, - "bar": - 2, - } - ) - - def test_exact_length_is_valid_passes(self): - # exact length is valid - MinpropertiesValidation( - **{ - "foo": - 1, - } - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minproperties_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_int.py similarity index 95% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minproperties_validation.py rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_int.py index 74861d0b1ff..c5c44fbdc31 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minproperties_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_int.py @@ -66,9 +66,9 @@ from unit_test_api.schemas import ( # noqa: F401 ) -class MinpropertiesValidation( +class ByInt( _SchemaValidator( - min_properties=1, + multiple_of=[2], ), AnyTypeSchema ): @@ -83,7 +83,7 @@ class MinpropertiesValidation( *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Type[Schema], - ) -> 'MinpropertiesValidation': + ) -> 'ByInt': return super().__new__( cls, *args, diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_number.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_number.py new file mode 100644 index 00000000000..3bab9445575 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_number.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class ByNumber( + _SchemaValidator( + multiple_of=[1.5], + ), + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'ByNumber': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_small_number.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_small_number.py new file mode 100644 index 00000000000..5f96f0cdbdb --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_small_number.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class BySmallNumber( + _SchemaValidator( + multiple_of=[0.00010], + ), + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'BySmallNumber': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_instance_should_not_raise_error_when_float_division_inf.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_instance_should_not_raise_error_when_float_division_inf.py new file mode 100644 index 00000000000..84dcad131b2 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_instance_should_not_raise_error_when_float_division_inf.py @@ -0,0 +1,80 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf( + _SchemaValidator( + multiple_of=[0.123456789], + ), + IntSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + pass diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py index 8004a4b2093..c57122e465f 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py @@ -11,4 +11,7 @@ # import sys # sys.setrecursionlimit(n) -from unit_test_api.model.minproperties_validation import MinpropertiesValidation +from unit_test_api.model.by_int import ByInt +from unit_test_api.model.by_number import ByNumber +from unit_test_api.model.by_small_number import BySmallNumber +from unit_test_api.model.invalid_instance_should_not_raise_error_when_float_division_inf import InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf -- GitLab From f5c1a1a6649fd2bb9d8b97c2a20ddef83a3ff551 Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Mon, 27 Jun 2022 00:57:34 -0700 Subject: [PATCH 21/43] Adds not --- .../3_0/unit_test_spec/spec_writer.py | 8 +- .../resources/3_0/unit_test_spec/type.yaml | 88 +++++++++---------- .../.openapi-generator/FILES | 21 ++--- .../python-experimental/README.md | 7 +- ...{BySmallNumber.md => ForbiddenProperty.md} | 3 +- ...ShouldNotRaiseErrorWhenFloatDivisionInf.md | 8 -- .../docs/{ByInt.md => ModelNot.md} | 2 +- .../{ByNumber.md => NotMoreComplexSchema.md} | 2 +- .../test/test_by_number.py | 39 -------- .../test/test_by_small_number.py | 34 ------- .../test/test_forbidden_property.py | 46 ++++++++++ ...not_raise_error_when_float_division_inf.py | 29 ------ .../{test_by_int.py => test_model_not.py} | 29 +++--- .../test/test_not_more_complex_schema.py | 48 ++++++++++ ..._small_number.py => forbidden_property.py} | 50 +++++++++-- ...not_raise_error_when_float_division_inf.py | 80 ----------------- .../model/{by_int.py => model_not.py} | 32 +++++-- ...y_number.py => not_more_complex_schema.py} | 53 +++++++++-- .../unit_test_api/models/__init__.py | 7 +- 19 files changed, 294 insertions(+), 292 deletions(-) rename samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/{BySmallNumber.md => ForbiddenProperty.md} (79%) delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf.md rename samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/{ByInt.md => ModelNot.md} (97%) rename samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/{ByNumber.md => NotMoreComplexSchema.md} (95%) delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_number.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_small_number.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_forbidden_property.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_instance_should_not_raise_error_when_float_division_inf.py rename samples/openapi3/client/3_0_3_unit_test/python-experimental/test/{test_by_int.py => test_model_not.py} (53%) create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_not_more_complex_schema.py rename samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/{by_small_number.py => forbidden_property.py} (55%) delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_instance_should_not_raise_error_when_float_division_inf.py rename samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/{by_int.py => model_not.py} (69%) rename samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/{by_number.py => not_more_complex_schema.py} (56%) diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index 807f44863ce..b402ec5e50e 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -115,6 +115,11 @@ FILEPATH_TO_EXCLUDED_CASE_AND_REASON = { 'items with boolean schema (false)': ExclusionReason.v303_does_not_support_boolean_schemas_in_location, 'a schema given for items': ExclusionReason.swagger_parser_items_type_bug, }, + (json_schema_test_draft, 'not.json'): { + 'not with boolean schema true': ExclusionReason.v303_does_not_support_boolean_schemas_in_location, + 'not with boolean schema false': ExclusionReason.v303_does_not_support_boolean_schemas_in_location, + 'not multiple types': ExclusionReason.v303_does_not_support_array_of_types, + }, } FILEPATH_TO_EXCLUDE_REASON = { (json_schema_test_draft, 'additionalItems.json'): ExclusionReason.v303_does_not_support_additionalItems, @@ -157,7 +162,8 @@ JSON_SCHEMA_TEST_FILE_TO_FOLDERS = { # 'minItems.json': (json_schema_test_draft,), # 'minLength.json': (json_schema_test_draft,), # 'minProperties.json': (json_schema_test_draft,), - 'multipleOf.json': (json_schema_test_draft,), +# 'multipleOf.json': (json_schema_test_draft,), + 'not.json': (json_schema_test_draft,), } def get_json_schema_test_schemas(file_path: typing.Tuple[str]) -> typing.List[JsonSchemaTestSchema]: diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml index a5b4367eb16..2a1ce39adc3 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml @@ -7,54 +7,54 @@ info: paths: {} components: schemas: - ByInt: - multipleOf: 2 - ByNumber: - multipleOf: 1.5 - BySmallNumber: - multipleOf: 0.0001 - InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf: - type: integer - multipleOf: 0.123456789 + Not: + not: + type: integer + NotMoreComplexSchema: + not: + type: object + properties: + foo: + type: string + ForbiddenProperty: + properties: + foo: + not: {} x-schema-test-examples: - ByInt: - IntByInt: - description: int by int - data: 10 - valid: true - IntByIntFail: - description: int by int fail - data: 7 - valid: false - IgnoresNonNumbers: - description: ignores non-numbers + Not: + Allowed: + description: allowed data: foo valid: true - ByNumber: - ZeroIsMultipleOfAnything: - description: zero is multiple of anything - data: 0 - valid: true - 45IsMultipleOf15: - description: 4.5 is multiple of 1.5 - data: 4.5 - valid: true - 35IsNotMultipleOf15: - description: 35 is not multiple of 1.5 - data: 35 + Disallowed: + description: disallowed + data: 1 valid: false - BySmallNumber: - 00075IsMultipleOf00001: - description: 0.0075 is multiple of 0.0001 - data: 0.0075 + NotMoreComplexSchema: + Match: + description: match + data: 1 + valid: true + OtherMatch: + description: other match + data: + foo: 1 valid: true - 000751IsNotMultipleOf00001: - description: 0.00751 is not multiple of 0.0001 - data: 0.00751 + Mismatch: + description: mismatch + data: + foo: bar valid: false - InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf: - AlwaysInvalidButNaiveImplementationsMayRaiseAnOverflowError: - description: always invalid, but naive implementations may raise an overflow - error - data: 1.0e+308 + ForbiddenProperty: + PropertyPresent: + description: property present + data: + foo: 1 + bar: 2 valid: false + PropertyAbsent: + description: property absent + data: + bar: 1 + baz: 2 + valid: true diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index 99832e6fcf0..678fb6cf6b4 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -2,20 +2,18 @@ .gitlab-ci.yml .travis.yml README.md -docs/ByInt.md -docs/ByNumber.md -docs/BySmallNumber.md -docs/InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf.md +docs/ForbiddenProperty.md +docs/ModelNot.md +docs/NotMoreComplexSchema.md git_push.sh requirements.txt setup.cfg setup.py test-requirements.txt test/__init__.py -test/test_by_int.py -test/test_by_number.py -test/test_by_small_number.py -test/test_invalid_instance_should_not_raise_error_when_float_division_inf.py +test/test_forbidden_property.py +test/test_model_not.py +test/test_not_more_complex_schema.py tox.ini unit_test_api/__init__.py unit_test_api/api/__init__.py @@ -24,10 +22,9 @@ unit_test_api/apis/__init__.py unit_test_api/configuration.py unit_test_api/exceptions.py unit_test_api/model/__init__.py -unit_test_api/model/by_int.py -unit_test_api/model/by_number.py -unit_test_api/model/by_small_number.py -unit_test_api/model/invalid_instance_should_not_raise_error_when_float_division_inf.py +unit_test_api/model/forbidden_property.py +unit_test_api/model/model_not.py +unit_test_api/model/not_more_complex_schema.py unit_test_api/models/__init__.py unit_test_api/rest.py unit_test_api/schemas.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md index 2d9bb7af9a5..32954125cac 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md @@ -62,10 +62,9 @@ Class | Method | HTTP request | Description ## Documentation For Models - - [ByInt](docs/ByInt.md) - - [ByNumber](docs/ByNumber.md) - - [BySmallNumber](docs/BySmallNumber.md) - - [InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf](docs/InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf.md) + - [ForbiddenProperty](docs/ForbiddenProperty.md) + - [ModelNot](docs/ModelNot.md) + - [NotMoreComplexSchema](docs/NotMoreComplexSchema.md) ## Documentation For Authorization diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/BySmallNumber.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ForbiddenProperty.md similarity index 79% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/BySmallNumber.md rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ForbiddenProperty.md index 3671c33f9c9..acb9f23b22f 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/BySmallNumber.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ForbiddenProperty.md @@ -1,8 +1,9 @@ -# BySmallNumber +# ForbiddenProperty #### Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**foo** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] **any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf.md deleted file mode 100644 index 9acc3f6353a..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf.md +++ /dev/null @@ -1,8 +0,0 @@ -# InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf - -Type | Description | Notes -------------- | ------------- | ------------- -**int** | | - -[[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/3_0_3_unit_test/python-experimental/docs/ByInt.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ModelNot.md similarity index 97% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ByInt.md rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ModelNot.md index 7e089ed79bb..bac67e76808 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ByInt.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ModelNot.md @@ -1,4 +1,4 @@ -# ByInt +# ModelNot #### Properties Name | Type | Description | Notes diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ByNumber.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NotMoreComplexSchema.md similarity index 95% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ByNumber.md rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NotMoreComplexSchema.md index 8c272d66b6d..2ea5b209ccd 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ByNumber.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NotMoreComplexSchema.md @@ -1,4 +1,4 @@ -# ByNumber +# NotMoreComplexSchema #### Properties Name | Type | Description | Notes diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_number.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_number.py deleted file mode 100644 index 8586265edb2..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_number.py +++ /dev/null @@ -1,39 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.by_number import ByNumber - - -class TestByNumber(unittest.TestCase): - """ByNumber unit test stubs""" - - def test_45_is_multiple_of15_passes(self): - # 4.5 is multiple of 1.5 - ByNumber( - 4.5 ) - - def test_35_is_not_multiple_of15_fails(self): - # 35 is not multiple of 1.5 - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - ByNumber( - 35 ) - - def test_zero_is_multiple_of_anything_passes(self): - # zero is multiple of anything - ByNumber( - 0 ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_small_number.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_small_number.py deleted file mode 100644 index 6bd83fdd952..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_small_number.py +++ /dev/null @@ -1,34 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.by_small_number import BySmallNumber - - -class TestBySmallNumber(unittest.TestCase): - """BySmallNumber unit test stubs""" - - def test_000751_is_not_multiple_of00001_fails(self): - # 0.00751 is not multiple of 0.0001 - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - BySmallNumber( - 0.00751 ) - - def test_00075_is_multiple_of00001_passes(self): - # 0.0075 is multiple of 0.0001 - BySmallNumber( - 0.0075 ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_forbidden_property.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_forbidden_property.py new file mode 100644 index 00000000000..12dbfe8fa2e --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_forbidden_property.py @@ -0,0 +1,46 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.forbidden_property import ForbiddenProperty + + +class TestForbiddenProperty(unittest.TestCase): + """ForbiddenProperty unit test stubs""" + + def test_property_present_fails(self): + # property present + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + ForbiddenProperty( + **{ + "foo": + 1, + "bar": + 2, + } + ) + + def test_property_absent_passes(self): + # property absent + ForbiddenProperty( + **{ + "bar": + 1, + "baz": + 2, + } + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_instance_should_not_raise_error_when_float_division_inf.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_instance_should_not_raise_error_when_float_division_inf.py deleted file mode 100644 index 9fc22a445ca..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_instance_should_not_raise_error_when_float_division_inf.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.invalid_instance_should_not_raise_error_when_float_division_inf import InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf - - -class TestInvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf(unittest.TestCase): - """InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf unit test stubs""" - - def test_always_invalid_but_naive_implementations_may_raise_an_overflow_error_fails(self): - # always invalid, but naive implementations may raise an overflow error - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf( - 1.0E308 ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_int.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_model_not.py similarity index 53% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_int.py rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_model_not.py index 2c69ea2abbd..cfd6a728aea 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_int.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_model_not.py @@ -12,29 +12,24 @@ import unittest import unit_test_api -from unit_test_api.model.by_int import ByInt +from unit_test_api.model.model_not import ModelNot -class TestByInt(unittest.TestCase): - """ByInt unit test stubs""" +class TestModelNot(unittest.TestCase): + """ModelNot unit test stubs""" - def test_int_by_int_fail_fails(self): - # int by int fail - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - ByInt( - 7 ) - - def test_int_by_int_passes(self): - # int by int - ByInt( - 10 ) - - def test_ignores_non_numbers_passes(self): - # ignores non-numbers - ByInt( + def test_allowed_passes(self): + # allowed + ModelNot( "foo" ) + def test_disallowed_fails(self): + # disallowed + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + ModelNot( + 1 ) + if __name__ == '__main__': unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_not_more_complex_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_not_more_complex_schema.py new file mode 100644 index 00000000000..9bb82954f5b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_not_more_complex_schema.py @@ -0,0 +1,48 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.not_more_complex_schema import NotMoreComplexSchema + + +class TestNotMoreComplexSchema(unittest.TestCase): + """NotMoreComplexSchema unit test stubs""" + + def test_other_match_passes(self): + # other match + NotMoreComplexSchema( + **{ + "foo": + 1, + } + ) + + def test_mismatch_fails(self): + # mismatch + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NotMoreComplexSchema( + **{ + "foo": + + "bar", + } + ) + + def test_match_passes(self): + # match + NotMoreComplexSchema( + 1 ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_small_number.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/forbidden_property.py similarity index 55% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_small_number.py rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/forbidden_property.py index 5f96f0cdbdb..0b1dc6f6a5d 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_small_number.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/forbidden_property.py @@ -66,10 +66,7 @@ from unit_test_api.schemas import ( # noqa: F401 ) -class BySmallNumber( - _SchemaValidator( - multiple_of=[0.00010], - ), +class ForbiddenProperty( AnyTypeSchema ): """NOTE: This class is auto generated by OpenAPI Generator. @@ -77,16 +74,59 @@ class BySmallNumber( Do not edit the class manually. """ + + + class foo( + ComposedSchema + ): + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 + NotSchema = AnyTypeSchema + return { + 'allOf': [ + ], + 'oneOf': [ + ], + 'anyOf': [ + ], + 'not': + NotSchema + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'foo': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) def __new__( cls, *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + foo: typing.Union[foo, Unset] = unset, _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Type[Schema], - ) -> 'BySmallNumber': + ) -> 'ForbiddenProperty': return super().__new__( cls, *args, + foo=foo, _configuration=_configuration, **kwargs, ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_instance_should_not_raise_error_when_float_division_inf.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_instance_should_not_raise_error_when_float_division_inf.py deleted file mode 100644 index 84dcad131b2..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_instance_should_not_raise_error_when_float_division_inf.py +++ /dev/null @@ -1,80 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf( - _SchemaValidator( - multiple_of=[0.123456789], - ), - IntSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - pass diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_int.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/model_not.py similarity index 69% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_int.py rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/model_not.py index c5c44fbdc31..1b1c92f096d 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_int.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/model_not.py @@ -66,11 +66,8 @@ from unit_test_api.schemas import ( # noqa: F401 ) -class ByInt( - _SchemaValidator( - multiple_of=[2], - ), - AnyTypeSchema +class ModelNot( + ComposedSchema ): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech @@ -78,12 +75,35 @@ class ByInt( Do not edit the class manually. """ + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 + NotSchema = IntSchema + return { + 'allOf': [ + ], + 'oneOf': [ + ], + 'anyOf': [ + ], + 'not': + NotSchema + } + def __new__( cls, *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Type[Schema], - ) -> 'ByInt': + ) -> 'ModelNot': return super().__new__( cls, *args, diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_number.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/not_more_complex_schema.py similarity index 56% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_number.py rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/not_more_complex_schema.py index 3bab9445575..66f38098b51 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_number.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/not_more_complex_schema.py @@ -66,11 +66,8 @@ from unit_test_api.schemas import ( # noqa: F401 ) -class ByNumber( - _SchemaValidator( - multiple_of=[1.5], - ), - AnyTypeSchema +class NotMoreComplexSchema( + ComposedSchema ): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech @@ -78,12 +75,56 @@ class ByNumber( Do not edit the class manually. """ + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 + + + class NotSchema( + DictSchema + ): + foo = StrSchema + + + def __new__( + cls, + *args: typing.Union[dict, frozendict, ], + foo: typing.Union[foo, Unset] = unset, + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'NotSchema': + return super().__new__( + cls, + *args, + foo=foo, + _configuration=_configuration, + **kwargs, + ) + return { + 'allOf': [ + ], + 'oneOf': [ + ], + 'anyOf': [ + ], + 'not': + NotSchema + } + def __new__( cls, *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Type[Schema], - ) -> 'ByNumber': + ) -> 'NotMoreComplexSchema': return super().__new__( cls, *args, diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py index c57122e465f..62341c772de 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py @@ -11,7 +11,6 @@ # import sys # sys.setrecursionlimit(n) -from unit_test_api.model.by_int import ByInt -from unit_test_api.model.by_number import ByNumber -from unit_test_api.model.by_small_number import BySmallNumber -from unit_test_api.model.invalid_instance_should_not_raise_error_when_float_division_inf import InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf +from unit_test_api.model.forbidden_property import ForbiddenProperty +from unit_test_api.model.model_not import ModelNot +from unit_test_api.model.not_more_complex_schema import NotMoreComplexSchema -- GitLab From 6e0be9ba8e8ff8fbfa6cf40d5082520c42641f0a Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Mon, 27 Jun 2022 18:35:46 -0700 Subject: [PATCH 22/43] Adds oneOf --- .../3_0/unit_test_spec/spec_writer.py | 6 +- .../resources/3_0/unit_test_spec/type.yaml | 194 ++++++++++++++---- .../.openapi-generator/FILES | 39 +++- .../python-experimental/README.md | 13 +- ... NestedOneofToCheckValidationSemantics.md} | 3 +- .../docs/{ModelNot.md => Oneof.md} | 2 +- ...eComplexSchema.md => OneofComplexTypes.md} | 2 +- .../docs/OneofWithBaseSchema.md | 8 + .../docs/OneofWithBooleanSchemasAllFalse.md | 9 + .../docs/OneofWithBooleanSchemasAllTrue.md | 9 + .../OneofWithBooleanSchemasMoreThanOneTrue.md | 9 + .../docs/OneofWithBooleanSchemasOneTrue.md | 9 + .../docs/OneofWithEmptySchema.md | 9 + .../docs/OneofWithRequired.md | 9 + .../test/test_forbidden_property.py | 46 ----- ...ted_oneof_to_check_validation_semantics.py | 35 ++++ .../test/test_not_more_complex_schema.py | 48 ----- .../python-experimental/test/test_oneof.py | 45 ++++ .../test/test_oneof_complex_types.py | 68 ++++++ .../test/test_oneof_with_base_schema.py | 42 ++++ ...st_oneof_with_boolean_schemas_all_false.py | 30 +++ ...st_oneof_with_boolean_schemas_all_true.py} | 21 +- ...with_boolean_schemas_more_than_one_true.py | 30 +++ ...est_oneof_with_boolean_schemas_one_true.py | 29 +++ .../test/test_oneof_with_empty_schema.py | 35 ++++ .../test/test_oneof_with_required.py | 69 +++++++ ...ed_oneof_to_check_validation_semantics.py} | 30 +-- .../model/{forbidden_property.py => oneof.py} | 75 +++---- .../model/oneof_complex_types.py | 115 +++++++++++ .../model/oneof_with_base_schema.py | 114 ++++++++++ .../oneof_with_boolean_schemas_all_false.py | 111 ++++++++++ ...=> oneof_with_boolean_schemas_all_true.py} | 7 +- ...with_boolean_schemas_more_than_one_true.py | 111 ++++++++++ .../oneof_with_boolean_schemas_one_true.py | 111 ++++++++++ .../model/oneof_with_empty_schema.py | 115 +++++++++++ .../model/oneof_with_required.py | 116 +++++++++++ .../unit_test_api/models/__init__.py | 13 +- 37 files changed, 1500 insertions(+), 237 deletions(-) rename samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/{ForbiddenProperty.md => NestedOneofToCheckValidationSemantics.md} (79%) rename samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/{ModelNot.md => Oneof.md} (97%) rename samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/{NotMoreComplexSchema.md => OneofComplexTypes.md} (95%) create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBaseSchema.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasAllFalse.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasAllTrue.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasMoreThanOneTrue.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasOneTrue.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithEmptySchema.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithRequired.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_forbidden_property.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_oneof_to_check_validation_semantics.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_not_more_complex_schema.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_complex_types.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_base_schema.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_all_false.py rename samples/openapi3/client/3_0_3_unit_test/python-experimental/test/{test_model_not.py => test_oneof_with_boolean_schemas_all_true.py} (54%) create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_more_than_one_true.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_one_true.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_empty_schema.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_required.py rename samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/{not_more_complex_schema.py => nested_oneof_to_check_validation_semantics.py} (77%) rename samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/{forbidden_property.py => oneof.py} (55%) create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_complex_types.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_base_schema.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_boolean_schemas_all_false.py rename samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/{model_not.py => oneof_with_boolean_schemas_all_true.py} (96%) create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_boolean_schemas_more_than_one_true.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_boolean_schemas_one_true.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_empty_schema.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_required.py diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index b402ec5e50e..e8b776a2e25 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -120,6 +120,9 @@ FILEPATH_TO_EXCLUDED_CASE_AND_REASON = { 'not with boolean schema false': ExclusionReason.v303_does_not_support_boolean_schemas_in_location, 'not multiple types': ExclusionReason.v303_does_not_support_array_of_types, }, + (json_schema_test_draft, 'oneOf.json'): { + 'oneOf with missing optional property': ExclusionReason.v303_does_not_support_boolean_schemas_in_location, + }, } FILEPATH_TO_EXCLUDE_REASON = { (json_schema_test_draft, 'additionalItems.json'): ExclusionReason.v303_does_not_support_additionalItems, @@ -163,7 +166,8 @@ JSON_SCHEMA_TEST_FILE_TO_FOLDERS = { # 'minLength.json': (json_schema_test_draft,), # 'minProperties.json': (json_schema_test_draft,), # 'multipleOf.json': (json_schema_test_draft,), - 'not.json': (json_schema_test_draft,), +# 'not.json': (json_schema_test_draft,), +# 'oneOf.json': (json_schema_test_draft,), # activate after fixing this } def get_json_schema_test_schemas(file_path: typing.Tuple[str]) -> typing.List[JsonSchemaTestSchema]: diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml index 2a1ce39adc3..57a9ab8a972 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml @@ -7,54 +7,178 @@ info: paths: {} components: schemas: - Not: - not: - type: integer - NotMoreComplexSchema: - not: - type: object - properties: + Oneof: + oneOf: + - type: integer + - minimum: 2 + OneofWithBaseSchema: + type: string + oneOf: + - minLength: 2 + - maxLength: 4 + OneofWithBooleanSchemasAllTrue: + oneOf: + - true + - true + - true + OneofWithBooleanSchemasOneTrue: + oneOf: + - true + - false + - false + OneofWithBooleanSchemasMoreThanOneTrue: + oneOf: + - true + - true + - false + OneofWithBooleanSchemasAllFalse: + oneOf: + - false + - false + - false + OneofComplexTypes: + oneOf: + - properties: + bar: + type: integer + required: + - bar + - properties: foo: type: string - ForbiddenProperty: - properties: - foo: - not: {} + required: + - foo + OneofWithEmptySchema: + oneOf: + - type: number + - {} + OneofWithRequired: + type: object + oneOf: + - required: + - foo + - bar + - required: + - foo + - baz + NestedOneofToCheckValidationSemantics: + oneOf: + - oneOf: + - type: 'null' x-schema-test-examples: - Not: - Allowed: - description: allowed + Oneof: + FirstOneofValid: + description: first oneOf valid + data: 1 + valid: true + SecondOneofValid: + description: second oneOf valid + data: 2.5 + valid: true + BothOneofValid: + description: both oneOf valid + data: 3 + valid: false + NeitherOneofValid: + description: neither oneOf valid + data: 1.5 + valid: false + OneofWithBaseSchema: + MismatchBaseSchema: + description: mismatch base schema + data: 3 + valid: false + OneOneofValid: + description: one oneOf valid + data: foobar + valid: true + BothOneofValid: + description: both oneOf valid + data: foo + valid: false + OneofWithBooleanSchemasAllTrue: + AnyValueIsInvalid: + description: any value is invalid + data: foo + valid: false + OneofWithBooleanSchemasOneTrue: + AnyValueIsValid: + description: any value is valid data: foo valid: true - Disallowed: - description: disallowed - data: 1 + OneofWithBooleanSchemasMoreThanOneTrue: + AnyValueIsInvalid: + description: any value is invalid + data: foo valid: false - NotMoreComplexSchema: - Match: - description: match - data: 1 + OneofWithBooleanSchemasAllFalse: + AnyValueIsInvalid: + description: any value is invalid + data: foo + valid: false + OneofComplexTypes: + FirstOneofValidComplex: + description: first oneOf valid (complex) + data: + bar: 2 valid: true - OtherMatch: - description: other match + SecondOneofValidComplex: + description: second oneOf valid (complex) data: - foo: 1 + foo: baz valid: true - Mismatch: - description: mismatch + BothOneofValidComplex: + description: both oneOf valid (complex) data: - foo: bar + foo: baz + bar: 2 valid: false - ForbiddenProperty: - PropertyPresent: - description: property present + NeitherOneofValidComplex: + description: neither oneOf valid (complex) + data: + foo: 2 + bar: quux + valid: false + OneofWithEmptySchema: + OneValidValid: + description: one valid - valid + data: foo + valid: true + BothValidInvalid: + description: both valid - invalid + data: 123 + valid: false + OneofWithRequired: + BothInvalidInvalid: + description: both invalid - invalid data: - foo: 1 bar: 2 valid: false - PropertyAbsent: - description: property absent + FirstValidValid: + description: first valid - valid + data: + foo: 1 + bar: 2 + valid: true + SecondValidValid: + description: second valid - valid data: - bar: 1 - baz: 2 + foo: 1 + baz: 3 valid: true + BothValidInvalid: + description: both valid - invalid + data: + foo: 1 + bar: 2 + baz: 3 + valid: false + NestedOneofToCheckValidationSemantics: + NullIsValid: + description: null is valid + data: null + valid: true + AnythingNonNullIsInvalid: + description: anything non-null is invalid + data: 123 + valid: false diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index 678fb6cf6b4..34abd48111c 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -2,18 +2,32 @@ .gitlab-ci.yml .travis.yml README.md -docs/ForbiddenProperty.md -docs/ModelNot.md -docs/NotMoreComplexSchema.md +docs/NestedOneofToCheckValidationSemantics.md +docs/Oneof.md +docs/OneofComplexTypes.md +docs/OneofWithBaseSchema.md +docs/OneofWithBooleanSchemasAllFalse.md +docs/OneofWithBooleanSchemasAllTrue.md +docs/OneofWithBooleanSchemasMoreThanOneTrue.md +docs/OneofWithBooleanSchemasOneTrue.md +docs/OneofWithEmptySchema.md +docs/OneofWithRequired.md git_push.sh requirements.txt setup.cfg setup.py test-requirements.txt test/__init__.py -test/test_forbidden_property.py -test/test_model_not.py -test/test_not_more_complex_schema.py +test/test_nested_oneof_to_check_validation_semantics.py +test/test_oneof.py +test/test_oneof_complex_types.py +test/test_oneof_with_base_schema.py +test/test_oneof_with_boolean_schemas_all_false.py +test/test_oneof_with_boolean_schemas_all_true.py +test/test_oneof_with_boolean_schemas_more_than_one_true.py +test/test_oneof_with_boolean_schemas_one_true.py +test/test_oneof_with_empty_schema.py +test/test_oneof_with_required.py tox.ini unit_test_api/__init__.py unit_test_api/api/__init__.py @@ -22,9 +36,16 @@ unit_test_api/apis/__init__.py unit_test_api/configuration.py unit_test_api/exceptions.py unit_test_api/model/__init__.py -unit_test_api/model/forbidden_property.py -unit_test_api/model/model_not.py -unit_test_api/model/not_more_complex_schema.py +unit_test_api/model/nested_oneof_to_check_validation_semantics.py +unit_test_api/model/oneof.py +unit_test_api/model/oneof_complex_types.py +unit_test_api/model/oneof_with_base_schema.py +unit_test_api/model/oneof_with_boolean_schemas_all_false.py +unit_test_api/model/oneof_with_boolean_schemas_all_true.py +unit_test_api/model/oneof_with_boolean_schemas_more_than_one_true.py +unit_test_api/model/oneof_with_boolean_schemas_one_true.py +unit_test_api/model/oneof_with_empty_schema.py +unit_test_api/model/oneof_with_required.py unit_test_api/models/__init__.py unit_test_api/rest.py unit_test_api/schemas.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md index 32954125cac..ed8581dd126 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md @@ -62,9 +62,16 @@ Class | Method | HTTP request | Description ## Documentation For Models - - [ForbiddenProperty](docs/ForbiddenProperty.md) - - [ModelNot](docs/ModelNot.md) - - [NotMoreComplexSchema](docs/NotMoreComplexSchema.md) + - [NestedOneofToCheckValidationSemantics](docs/NestedOneofToCheckValidationSemantics.md) + - [Oneof](docs/Oneof.md) + - [OneofComplexTypes](docs/OneofComplexTypes.md) + - [OneofWithBaseSchema](docs/OneofWithBaseSchema.md) + - [OneofWithBooleanSchemasAllFalse](docs/OneofWithBooleanSchemasAllFalse.md) + - [OneofWithBooleanSchemasAllTrue](docs/OneofWithBooleanSchemasAllTrue.md) + - [OneofWithBooleanSchemasMoreThanOneTrue](docs/OneofWithBooleanSchemasMoreThanOneTrue.md) + - [OneofWithBooleanSchemasOneTrue](docs/OneofWithBooleanSchemasOneTrue.md) + - [OneofWithEmptySchema](docs/OneofWithEmptySchema.md) + - [OneofWithRequired](docs/OneofWithRequired.md) ## Documentation For Authorization diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ForbiddenProperty.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedOneofToCheckValidationSemantics.md similarity index 79% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ForbiddenProperty.md rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedOneofToCheckValidationSemantics.md index acb9f23b22f..06ba0d5e9e4 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ForbiddenProperty.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedOneofToCheckValidationSemantics.md @@ -1,9 +1,8 @@ -# ForbiddenProperty +# NestedOneofToCheckValidationSemantics #### Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**foo** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] **any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ModelNot.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Oneof.md similarity index 97% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ModelNot.md rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Oneof.md index bac67e76808..e42f38aff34 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ModelNot.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Oneof.md @@ -1,4 +1,4 @@ -# ModelNot +# Oneof #### Properties Name | Type | Description | Notes diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NotMoreComplexSchema.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofComplexTypes.md similarity index 95% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NotMoreComplexSchema.md rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofComplexTypes.md index 2ea5b209ccd..e26c501afdc 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NotMoreComplexSchema.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofComplexTypes.md @@ -1,4 +1,4 @@ -# NotMoreComplexSchema +# OneofComplexTypes #### Properties Name | Type | Description | Notes diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBaseSchema.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBaseSchema.md new file mode 100644 index 00000000000..f80a4e8b657 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBaseSchema.md @@ -0,0 +1,8 @@ +# OneofWithBaseSchema + +Type | Description | Notes +------------- | ------------- | ------------- +**str** | | + +[[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/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasAllFalse.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasAllFalse.md new file mode 100644 index 00000000000..4260a0d0178 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasAllFalse.md @@ -0,0 +1,9 @@ +# OneofWithBooleanSchemasAllFalse + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasAllTrue.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasAllTrue.md new file mode 100644 index 00000000000..b5174df5279 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasAllTrue.md @@ -0,0 +1,9 @@ +# OneofWithBooleanSchemasAllTrue + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasMoreThanOneTrue.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasMoreThanOneTrue.md new file mode 100644 index 00000000000..2cea78847e2 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasMoreThanOneTrue.md @@ -0,0 +1,9 @@ +# OneofWithBooleanSchemasMoreThanOneTrue + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasOneTrue.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasOneTrue.md new file mode 100644 index 00000000000..87db06ea0b8 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasOneTrue.md @@ -0,0 +1,9 @@ +# OneofWithBooleanSchemasOneTrue + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithEmptySchema.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithEmptySchema.md new file mode 100644 index 00000000000..1310a70f303 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithEmptySchema.md @@ -0,0 +1,9 @@ +# OneofWithEmptySchema + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithRequired.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithRequired.md new file mode 100644 index 00000000000..419b1df2d34 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithRequired.md @@ -0,0 +1,9 @@ +# OneofWithRequired + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_forbidden_property.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_forbidden_property.py deleted file mode 100644 index 12dbfe8fa2e..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_forbidden_property.py +++ /dev/null @@ -1,46 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.forbidden_property import ForbiddenProperty - - -class TestForbiddenProperty(unittest.TestCase): - """ForbiddenProperty unit test stubs""" - - def test_property_present_fails(self): - # property present - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - ForbiddenProperty( - **{ - "foo": - 1, - "bar": - 2, - } - ) - - def test_property_absent_passes(self): - # property absent - ForbiddenProperty( - **{ - "bar": - 1, - "baz": - 2, - } - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_oneof_to_check_validation_semantics.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_oneof_to_check_validation_semantics.py new file mode 100644 index 00000000000..421a3a37a1c --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_oneof_to_check_validation_semantics.py @@ -0,0 +1,35 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.nested_oneof_to_check_validation_semantics import NestedOneofToCheckValidationSemantics + + +class TestNestedOneofToCheckValidationSemantics(unittest.TestCase): + """NestedOneofToCheckValidationSemantics unit test stubs""" + + def test_anything_non_null_is_invalid_fails(self): + # anything non-null is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NestedOneofToCheckValidationSemantics( + 123 ) + + def test_null_is_valid_passes(self): + # null is valid + NestedOneofToCheckValidationSemantics( + + None ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_not_more_complex_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_not_more_complex_schema.py deleted file mode 100644 index 9bb82954f5b..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_not_more_complex_schema.py +++ /dev/null @@ -1,48 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.not_more_complex_schema import NotMoreComplexSchema - - -class TestNotMoreComplexSchema(unittest.TestCase): - """NotMoreComplexSchema unit test stubs""" - - def test_other_match_passes(self): - # other match - NotMoreComplexSchema( - **{ - "foo": - 1, - } - ) - - def test_mismatch_fails(self): - # mismatch - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NotMoreComplexSchema( - **{ - "foo": - - "bar", - } - ) - - def test_match_passes(self): - # match - NotMoreComplexSchema( - 1 ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof.py new file mode 100644 index 00000000000..d9fbff2f161 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof.py @@ -0,0 +1,45 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.oneof import Oneof + + +class TestOneof(unittest.TestCase): + """Oneof unit test stubs""" + + def test_second_oneof_valid_passes(self): + # second oneOf valid + Oneof( + 2.5 ) + + def test_both_oneof_valid_fails(self): + # both oneOf valid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + Oneof( + 3 ) + + def test_first_oneof_valid_passes(self): + # first oneOf valid + Oneof( + 1 ) + + def test_neither_oneof_valid_fails(self): + # neither oneOf valid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + Oneof( + 1.5 ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_complex_types.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_complex_types.py new file mode 100644 index 00000000000..977a92aa127 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_complex_types.py @@ -0,0 +1,68 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.oneof_complex_types import OneofComplexTypes + + +class TestOneofComplexTypes(unittest.TestCase): + """OneofComplexTypes unit test stubs""" + + def test_first_oneof_valid_complex_passes(self): + # first oneOf valid (complex) + OneofComplexTypes( + **{ + "bar": + 2, + } + ) + + def test_neither_oneof_valid_complex_fails(self): + # neither oneOf valid (complex) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + OneofComplexTypes( + **{ + "foo": + 2, + "bar": + + "quux", + } + ) + + def test_both_oneof_valid_complex_fails(self): + # both oneOf valid (complex) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + OneofComplexTypes( + **{ + "foo": + + "baz", + "bar": + 2, + } + ) + + def test_second_oneof_valid_complex_passes(self): + # second oneOf valid (complex) + OneofComplexTypes( + **{ + "foo": + + "baz", + } + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_base_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_base_schema.py new file mode 100644 index 00000000000..ef5c6e9782d --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_base_schema.py @@ -0,0 +1,42 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.oneof_with_base_schema import OneofWithBaseSchema + + +class TestOneofWithBaseSchema(unittest.TestCase): + """OneofWithBaseSchema unit test stubs""" + + def test_both_oneof_valid_fails(self): + # both oneOf valid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + OneofWithBaseSchema( + + "foo" ) + + def test_mismatch_base_schema_fails(self): + # mismatch base schema + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + OneofWithBaseSchema( + 3 ) + + def test_one_oneof_valid_passes(self): + # one oneOf valid + OneofWithBaseSchema( + + "foobar" ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_all_false.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_all_false.py new file mode 100644 index 00000000000..6960d47ea68 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_all_false.py @@ -0,0 +1,30 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.oneof_with_boolean_schemas_all_false import OneofWithBooleanSchemasAllFalse + + +class TestOneofWithBooleanSchemasAllFalse(unittest.TestCase): + """OneofWithBooleanSchemasAllFalse unit test stubs""" + + def test_any_value_is_invalid_fails(self): + # any value is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + OneofWithBooleanSchemasAllFalse( + + "foo" ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_model_not.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_all_true.py similarity index 54% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_model_not.py rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_all_true.py index cfd6a728aea..99a9e888f1e 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_model_not.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_all_true.py @@ -12,23 +12,18 @@ import unittest import unit_test_api -from unit_test_api.model.model_not import ModelNot +from unit_test_api.model.oneof_with_boolean_schemas_all_true import OneofWithBooleanSchemasAllTrue -class TestModelNot(unittest.TestCase): - """ModelNot unit test stubs""" +class TestOneofWithBooleanSchemasAllTrue(unittest.TestCase): + """OneofWithBooleanSchemasAllTrue unit test stubs""" - def test_allowed_passes(self): - # allowed - ModelNot( - - "foo" ) - - def test_disallowed_fails(self): - # disallowed + def test_any_value_is_invalid_fails(self): + # any value is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - ModelNot( - 1 ) + OneofWithBooleanSchemasAllTrue( + + "foo" ) if __name__ == '__main__': diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_more_than_one_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_more_than_one_true.py new file mode 100644 index 00000000000..368bec5002c --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_more_than_one_true.py @@ -0,0 +1,30 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.oneof_with_boolean_schemas_more_than_one_true import OneofWithBooleanSchemasMoreThanOneTrue + + +class TestOneofWithBooleanSchemasMoreThanOneTrue(unittest.TestCase): + """OneofWithBooleanSchemasMoreThanOneTrue unit test stubs""" + + def test_any_value_is_invalid_fails(self): + # any value is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + OneofWithBooleanSchemasMoreThanOneTrue( + + "foo" ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_one_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_one_true.py new file mode 100644 index 00000000000..c645a5a2924 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_one_true.py @@ -0,0 +1,29 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.oneof_with_boolean_schemas_one_true import OneofWithBooleanSchemasOneTrue + + +class TestOneofWithBooleanSchemasOneTrue(unittest.TestCase): + """OneofWithBooleanSchemasOneTrue unit test stubs""" + + def test_any_value_is_valid_passes(self): + # any value is valid + OneofWithBooleanSchemasOneTrue( + + "foo" ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_empty_schema.py new file mode 100644 index 00000000000..f858f55d6a6 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_empty_schema.py @@ -0,0 +1,35 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.oneof_with_empty_schema import OneofWithEmptySchema + + +class TestOneofWithEmptySchema(unittest.TestCase): + """OneofWithEmptySchema unit test stubs""" + + def test_both_valid_invalid_fails(self): + # both valid - invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + OneofWithEmptySchema( + 123 ) + + def test_one_valid_valid_passes(self): + # one valid - valid + OneofWithEmptySchema( + + "foo" ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_required.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_required.py new file mode 100644 index 00000000000..91687aa06a7 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_required.py @@ -0,0 +1,69 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.oneof_with_required import OneofWithRequired + + +class TestOneofWithRequired(unittest.TestCase): + """OneofWithRequired unit test stubs""" + + def test_both_valid_invalid_fails(self): + # both valid - invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + OneofWithRequired( + **{ + "foo": + 1, + "bar": + 2, + "baz": + 3, + } + ) + + def test_both_invalid_invalid_fails(self): + # both invalid - invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + OneofWithRequired( + **{ + "bar": + 2, + } + ) + + def test_first_valid_valid_passes(self): + # first valid - valid + OneofWithRequired( + **{ + "foo": + 1, + "bar": + 2, + } + ) + + def test_second_valid_valid_passes(self): + # second valid - valid + OneofWithRequired( + **{ + "foo": + 1, + "baz": + 3, + } + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/not_more_complex_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_oneof_to_check_validation_semantics.py similarity index 77% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/not_more_complex_schema.py rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_oneof_to_check_validation_semantics.py index 66f38098b51..3cce9a1433e 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/not_more_complex_schema.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_oneof_to_check_validation_semantics.py @@ -66,7 +66,7 @@ from unit_test_api.schemas import ( # noqa: F401 ) -class NotMoreComplexSchema( +class NestedOneofToCheckValidationSemantics( ComposedSchema ): """NOTE: This class is auto generated by OpenAPI Generator. @@ -86,37 +86,17 @@ class NotMoreComplexSchema( # code would be run when this module is imported, and these composed # classes don't exist yet because their module has not finished # loading - - - class NotSchema( - DictSchema - ): - foo = StrSchema - - - def __new__( - cls, - *args: typing.Union[dict, frozendict, ], - foo: typing.Union[foo, Unset] = unset, - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'NotSchema': - return super().__new__( - cls, - *args, - foo=foo, - _configuration=_configuration, - **kwargs, - ) + oneOf_0 = AnyTypeSchema return { 'allOf': [ ], 'oneOf': [ + oneOf_0, ], 'anyOf': [ ], 'not': - NotSchema + None } def __new__( @@ -124,7 +104,7 @@ class NotMoreComplexSchema( *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Type[Schema], - ) -> 'NotMoreComplexSchema': + ) -> 'NestedOneofToCheckValidationSemantics': return super().__new__( cls, *args, diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/forbidden_property.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof.py similarity index 55% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/forbidden_property.py rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof.py index 0b1dc6f6a5d..b3c930e87a9 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/forbidden_property.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof.py @@ -66,67 +66,50 @@ from unit_test_api.schemas import ( # noqa: F401 ) -class ForbiddenProperty( - AnyTypeSchema +class Oneof( + ComposedSchema ): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. """ - - - class foo( - ComposedSchema - ): - - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 - NotSchema = AnyTypeSchema - return { - 'allOf': [ - ], - 'oneOf': [ - ], - 'anyOf': [ - ], - 'not': - NotSchema - } - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'foo': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 + oneOf_0 = IntSchema + oneOf_1 = AnyTypeSchema + return { + 'allOf': [ + ], + 'oneOf': [ + oneOf_0, + oneOf_1, + ], + 'anyOf': [ + ], + 'not': + None + } def __new__( cls, *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - foo: typing.Union[foo, Unset] = unset, _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Type[Schema], - ) -> 'ForbiddenProperty': + ) -> 'Oneof': return super().__new__( cls, *args, - foo=foo, _configuration=_configuration, **kwargs, ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_complex_types.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_complex_types.py new file mode 100644 index 00000000000..9c1656403e7 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_complex_types.py @@ -0,0 +1,115 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class OneofComplexTypes( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 + oneOf_0 = AnyTypeSchema + oneOf_1 = AnyTypeSchema + return { + 'allOf': [ + ], + 'oneOf': [ + oneOf_0, + oneOf_1, + ], + 'anyOf': [ + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'OneofComplexTypes': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_base_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_base_schema.py new file mode 100644 index 00000000000..5ea665a24df --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_base_schema.py @@ -0,0 +1,114 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class OneofWithBaseSchema( + ComposedBase, + StrSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 + oneOf_0 = AnyTypeSchema + oneOf_1 = AnyTypeSchema + return { + 'allOf': [ + ], + 'oneOf': [ + oneOf_0, + oneOf_1, + ], + 'anyOf': [ + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[str, ], + _configuration: typing.Optional[Configuration] = None, + ) -> 'OneofWithBaseSchema': + return super().__new__( + cls, + *args, + _configuration=_configuration, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_boolean_schemas_all_false.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_boolean_schemas_all_false.py new file mode 100644 index 00000000000..12e8b34a323 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_boolean_schemas_all_false.py @@ -0,0 +1,111 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class OneofWithBooleanSchemasAllFalse( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 { + 'allOf': [ + ], + 'oneOf': [ + ], + 'anyOf': [ + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'OneofWithBooleanSchemasAllFalse': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/model_not.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_boolean_schemas_all_true.py similarity index 96% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/model_not.py rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_boolean_schemas_all_true.py index 1b1c92f096d..36b8e70cc98 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/model_not.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_boolean_schemas_all_true.py @@ -66,7 +66,7 @@ from unit_test_api.schemas import ( # noqa: F401 ) -class ModelNot( +class OneofWithBooleanSchemasAllTrue( ComposedSchema ): """NOTE: This class is auto generated by OpenAPI Generator. @@ -86,7 +86,6 @@ class ModelNot( # code would be run when this module is imported, and these composed # classes don't exist yet because their module has not finished # loading - NotSchema = IntSchema return { 'allOf': [ ], @@ -95,7 +94,7 @@ class ModelNot( 'anyOf': [ ], 'not': - NotSchema + None } def __new__( @@ -103,7 +102,7 @@ class ModelNot( *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Type[Schema], - ) -> 'ModelNot': + ) -> 'OneofWithBooleanSchemasAllTrue': return super().__new__( cls, *args, diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_boolean_schemas_more_than_one_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_boolean_schemas_more_than_one_true.py new file mode 100644 index 00000000000..20b72e702cf --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_boolean_schemas_more_than_one_true.py @@ -0,0 +1,111 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class OneofWithBooleanSchemasMoreThanOneTrue( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 { + 'allOf': [ + ], + 'oneOf': [ + ], + 'anyOf': [ + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'OneofWithBooleanSchemasMoreThanOneTrue': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_boolean_schemas_one_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_boolean_schemas_one_true.py new file mode 100644 index 00000000000..3f576a4e7b9 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_boolean_schemas_one_true.py @@ -0,0 +1,111 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class OneofWithBooleanSchemasOneTrue( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 { + 'allOf': [ + ], + 'oneOf': [ + ], + 'anyOf': [ + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'OneofWithBooleanSchemasOneTrue': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_empty_schema.py new file mode 100644 index 00000000000..015d651ae83 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_empty_schema.py @@ -0,0 +1,115 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class OneofWithEmptySchema( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 + oneOf_0 = NumberSchema + oneOf_1 = AnyTypeSchema + return { + 'allOf': [ + ], + 'oneOf': [ + oneOf_0, + oneOf_1, + ], + 'anyOf': [ + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'OneofWithEmptySchema': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_required.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_required.py new file mode 100644 index 00000000000..62eace35ebc --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_required.py @@ -0,0 +1,116 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class OneofWithRequired( + ComposedBase, + DictSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 + oneOf_0 = AnyTypeSchema + oneOf_1 = AnyTypeSchema + return { + 'allOf': [ + ], + 'oneOf': [ + oneOf_0, + oneOf_1, + ], + 'anyOf': [ + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, ], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'OneofWithRequired': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py index 62341c772de..d705b44b88b 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py @@ -11,6 +11,13 @@ # import sys # sys.setrecursionlimit(n) -from unit_test_api.model.forbidden_property import ForbiddenProperty -from unit_test_api.model.model_not import ModelNot -from unit_test_api.model.not_more_complex_schema import NotMoreComplexSchema +from unit_test_api.model.nested_oneof_to_check_validation_semantics import NestedOneofToCheckValidationSemantics +from unit_test_api.model.oneof import Oneof +from unit_test_api.model.oneof_complex_types import OneofComplexTypes +from unit_test_api.model.oneof_with_base_schema import OneofWithBaseSchema +from unit_test_api.model.oneof_with_boolean_schemas_all_false import OneofWithBooleanSchemasAllFalse +from unit_test_api.model.oneof_with_boolean_schemas_all_true import OneofWithBooleanSchemasAllTrue +from unit_test_api.model.oneof_with_boolean_schemas_more_than_one_true import OneofWithBooleanSchemasMoreThanOneTrue +from unit_test_api.model.oneof_with_boolean_schemas_one_true import OneofWithBooleanSchemasOneTrue +from unit_test_api.model.oneof_with_empty_schema import OneofWithEmptySchema +from unit_test_api.model.oneof_with_required import OneofWithRequired -- GitLab From c54eb15e4d06c54b7bfcc14af710f248aba3021a Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Mon, 27 Jun 2022 18:39:55 -0700 Subject: [PATCH 23/43] Adds pattern --- .../3_0/unit_test_spec/spec_writer.py | 1 + .../resources/3_0/unit_test_spec/type.yaml | 198 +++--------------- .../.openapi-generator/FILES | 36 +--- .../python-experimental/README.md | 12 +- .../NestedOneofToCheckValidationSemantics.md | 9 - .../docs/OneofComplexTypes.md | 9 - .../docs/OneofWithBaseSchema.md | 8 - .../docs/OneofWithBooleanSchemasAllFalse.md | 9 - .../docs/OneofWithBooleanSchemasAllTrue.md | 9 - .../OneofWithBooleanSchemasMoreThanOneTrue.md | 9 - .../docs/OneofWithBooleanSchemasOneTrue.md | 9 - .../docs/OneofWithRequired.md | 9 - ...EmptySchema.md => PatternIsNotAnchored.md} | 2 +- .../docs/{Oneof.md => PatternValidation.md} | 2 +- ...ted_oneof_to_check_validation_semantics.py | 35 ---- .../python-experimental/test/test_oneof.py | 45 ---- .../test/test_oneof_complex_types.py | 68 ------ .../test/test_oneof_with_base_schema.py | 42 ---- ...st_oneof_with_boolean_schemas_all_false.py | 30 --- ...est_oneof_with_boolean_schemas_all_true.py | 30 --- ...with_boolean_schemas_more_than_one_true.py | 30 --- ...est_oneof_with_boolean_schemas_one_true.py | 29 --- .../test/test_oneof_with_empty_schema.py | 35 ---- .../test/test_oneof_with_required.py | 69 ------ .../test/test_pattern_is_not_anchored.py | 29 +++ .../test/test_pattern_validation.py | 72 +++++++ ...ted_oneof_to_check_validation_semantics.py | 113 ---------- .../unit_test_api/model/oneof.py | 115 ---------- .../model/oneof_complex_types.py | 115 ---------- .../model/oneof_with_base_schema.py | 114 ---------- .../oneof_with_boolean_schemas_all_false.py | 111 ---------- ...with_boolean_schemas_more_than_one_true.py | 111 ---------- .../model/oneof_with_empty_schema.py | 115 ---------- .../model/oneof_with_required.py | 116 ---------- ...all_true.py => pattern_is_not_anchored.py} | 33 +-- ...emas_one_true.py => pattern_validation.py} | 33 +-- .../unit_test_api/models/__init__.py | 12 +- 37 files changed, 163 insertions(+), 1661 deletions(-) delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedOneofToCheckValidationSemantics.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofComplexTypes.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBaseSchema.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasAllFalse.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasAllTrue.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasMoreThanOneTrue.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasOneTrue.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithRequired.md rename samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/{OneofWithEmptySchema.md => PatternIsNotAnchored.md} (95%) rename samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/{Oneof.md => PatternValidation.md} (95%) delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_oneof_to_check_validation_semantics.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_complex_types.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_base_schema.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_all_false.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_all_true.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_more_than_one_true.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_one_true.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_empty_schema.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_required.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_is_not_anchored.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_validation.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_oneof_to_check_validation_semantics.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_complex_types.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_base_schema.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_boolean_schemas_all_false.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_boolean_schemas_more_than_one_true.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_empty_schema.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_required.py rename samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/{oneof_with_boolean_schemas_all_true.py => pattern_is_not_anchored.py} (69%) rename samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/{oneof_with_boolean_schemas_one_true.py => pattern_validation.py} (69%) diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index e8b776a2e25..cb56ee18d94 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -168,6 +168,7 @@ JSON_SCHEMA_TEST_FILE_TO_FOLDERS = { # 'multipleOf.json': (json_schema_test_draft,), # 'not.json': (json_schema_test_draft,), # 'oneOf.json': (json_schema_test_draft,), # activate after fixing this + 'pattern.json': (json_schema_test_draft,), } def get_json_schema_test_schemas(file_path: typing.Tuple[str]) -> typing.List[JsonSchemaTestSchema]: diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml index 57a9ab8a972..c6ac6794681 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml @@ -7,178 +7,46 @@ info: paths: {} components: schemas: - Oneof: - oneOf: - - type: integer - - minimum: 2 - OneofWithBaseSchema: - type: string - oneOf: - - minLength: 2 - - maxLength: 4 - OneofWithBooleanSchemasAllTrue: - oneOf: - - true - - true - - true - OneofWithBooleanSchemasOneTrue: - oneOf: - - true - - false - - false - OneofWithBooleanSchemasMoreThanOneTrue: - oneOf: - - true - - true - - false - OneofWithBooleanSchemasAllFalse: - oneOf: - - false - - false - - false - OneofComplexTypes: - oneOf: - - properties: - bar: - type: integer - required: - - bar - - properties: - foo: - type: string - required: - - foo - OneofWithEmptySchema: - oneOf: - - type: number - - {} - OneofWithRequired: - type: object - oneOf: - - required: - - foo - - bar - - required: - - foo - - baz - NestedOneofToCheckValidationSemantics: - oneOf: - - oneOf: - - type: 'null' + PatternValidation: + pattern: ^a*$ + PatternIsNotAnchored: + pattern: a+ x-schema-test-examples: - Oneof: - FirstOneofValid: - description: first oneOf valid - data: 1 + PatternValidation: + AMatchingPatternIsValid: + description: a matching pattern is valid + data: aaa valid: true - SecondOneofValid: - description: second oneOf valid - data: 2.5 - valid: true - BothOneofValid: - description: both oneOf valid - data: 3 - valid: false - NeitherOneofValid: - description: neither oneOf valid - data: 1.5 - valid: false - OneofWithBaseSchema: - MismatchBaseSchema: - description: mismatch base schema - data: 3 + ANonMatchingPatternIsInvalid: + description: a non-matching pattern is invalid + data: abc valid: false - OneOneofValid: - description: one oneOf valid - data: foobar + IgnoresBooleans: + description: ignores booleans + data: true valid: true - BothOneofValid: - description: both oneOf valid - data: foo - valid: false - OneofWithBooleanSchemasAllTrue: - AnyValueIsInvalid: - description: any value is invalid - data: foo - valid: false - OneofWithBooleanSchemasOneTrue: - AnyValueIsValid: - description: any value is valid - data: foo + IgnoresIntegers: + description: ignores integers + data: 123 valid: true - OneofWithBooleanSchemasMoreThanOneTrue: - AnyValueIsInvalid: - description: any value is invalid - data: foo - valid: false - OneofWithBooleanSchemasAllFalse: - AnyValueIsInvalid: - description: any value is invalid - data: foo - valid: false - OneofComplexTypes: - FirstOneofValidComplex: - description: first oneOf valid (complex) - data: - bar: 2 + IgnoresFloats: + description: ignores floats + data: 1.0 valid: true - SecondOneofValidComplex: - description: second oneOf valid (complex) - data: - foo: baz + IgnoresObjects: + description: ignores objects + data: {} valid: true - BothOneofValidComplex: - description: both oneOf valid (complex) - data: - foo: baz - bar: 2 - valid: false - NeitherOneofValidComplex: - description: neither oneOf valid (complex) - data: - foo: 2 - bar: quux - valid: false - OneofWithEmptySchema: - OneValidValid: - description: one valid - valid - data: foo + IgnoresArrays: + description: ignores arrays + data: [] valid: true - BothValidInvalid: - description: both valid - invalid - data: 123 - valid: false - OneofWithRequired: - BothInvalidInvalid: - description: both invalid - invalid - data: - bar: 2 - valid: false - FirstValidValid: - description: first valid - valid - data: - foo: 1 - bar: 2 - valid: true - SecondValidValid: - description: second valid - valid - data: - foo: 1 - baz: 3 - valid: true - BothValidInvalid: - description: both valid - invalid - data: - foo: 1 - bar: 2 - baz: 3 - valid: false - NestedOneofToCheckValidationSemantics: - NullIsValid: - description: null is valid + IgnoresNull: + description: ignores null data: null valid: true - AnythingNonNullIsInvalid: - description: anything non-null is invalid - data: 123 - valid: false + PatternIsNotAnchored: + MatchesASubstring: + description: matches a substring + data: xxaayy + valid: true diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index 34abd48111c..64a999b8b6e 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -2,32 +2,16 @@ .gitlab-ci.yml .travis.yml README.md -docs/NestedOneofToCheckValidationSemantics.md -docs/Oneof.md -docs/OneofComplexTypes.md -docs/OneofWithBaseSchema.md -docs/OneofWithBooleanSchemasAllFalse.md -docs/OneofWithBooleanSchemasAllTrue.md -docs/OneofWithBooleanSchemasMoreThanOneTrue.md -docs/OneofWithBooleanSchemasOneTrue.md -docs/OneofWithEmptySchema.md -docs/OneofWithRequired.md +docs/PatternIsNotAnchored.md +docs/PatternValidation.md git_push.sh requirements.txt setup.cfg setup.py test-requirements.txt test/__init__.py -test/test_nested_oneof_to_check_validation_semantics.py -test/test_oneof.py -test/test_oneof_complex_types.py -test/test_oneof_with_base_schema.py -test/test_oneof_with_boolean_schemas_all_false.py -test/test_oneof_with_boolean_schemas_all_true.py -test/test_oneof_with_boolean_schemas_more_than_one_true.py -test/test_oneof_with_boolean_schemas_one_true.py -test/test_oneof_with_empty_schema.py -test/test_oneof_with_required.py +test/test_pattern_is_not_anchored.py +test/test_pattern_validation.py tox.ini unit_test_api/__init__.py unit_test_api/api/__init__.py @@ -36,16 +20,8 @@ unit_test_api/apis/__init__.py unit_test_api/configuration.py unit_test_api/exceptions.py unit_test_api/model/__init__.py -unit_test_api/model/nested_oneof_to_check_validation_semantics.py -unit_test_api/model/oneof.py -unit_test_api/model/oneof_complex_types.py -unit_test_api/model/oneof_with_base_schema.py -unit_test_api/model/oneof_with_boolean_schemas_all_false.py -unit_test_api/model/oneof_with_boolean_schemas_all_true.py -unit_test_api/model/oneof_with_boolean_schemas_more_than_one_true.py -unit_test_api/model/oneof_with_boolean_schemas_one_true.py -unit_test_api/model/oneof_with_empty_schema.py -unit_test_api/model/oneof_with_required.py +unit_test_api/model/pattern_is_not_anchored.py +unit_test_api/model/pattern_validation.py unit_test_api/models/__init__.py unit_test_api/rest.py unit_test_api/schemas.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md index ed8581dd126..341ac90f843 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md @@ -62,16 +62,8 @@ Class | Method | HTTP request | Description ## Documentation For Models - - [NestedOneofToCheckValidationSemantics](docs/NestedOneofToCheckValidationSemantics.md) - - [Oneof](docs/Oneof.md) - - [OneofComplexTypes](docs/OneofComplexTypes.md) - - [OneofWithBaseSchema](docs/OneofWithBaseSchema.md) - - [OneofWithBooleanSchemasAllFalse](docs/OneofWithBooleanSchemasAllFalse.md) - - [OneofWithBooleanSchemasAllTrue](docs/OneofWithBooleanSchemasAllTrue.md) - - [OneofWithBooleanSchemasMoreThanOneTrue](docs/OneofWithBooleanSchemasMoreThanOneTrue.md) - - [OneofWithBooleanSchemasOneTrue](docs/OneofWithBooleanSchemasOneTrue.md) - - [OneofWithEmptySchema](docs/OneofWithEmptySchema.md) - - [OneofWithRequired](docs/OneofWithRequired.md) + - [PatternIsNotAnchored](docs/PatternIsNotAnchored.md) + - [PatternValidation](docs/PatternValidation.md) ## Documentation For Authorization diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedOneofToCheckValidationSemantics.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedOneofToCheckValidationSemantics.md deleted file mode 100644 index 06ba0d5e9e4..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedOneofToCheckValidationSemantics.md +++ /dev/null @@ -1,9 +0,0 @@ -# NestedOneofToCheckValidationSemantics - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofComplexTypes.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofComplexTypes.md deleted file mode 100644 index e26c501afdc..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofComplexTypes.md +++ /dev/null @@ -1,9 +0,0 @@ -# OneofComplexTypes - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBaseSchema.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBaseSchema.md deleted file mode 100644 index f80a4e8b657..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBaseSchema.md +++ /dev/null @@ -1,8 +0,0 @@ -# OneofWithBaseSchema - -Type | Description | Notes -------------- | ------------- | ------------- -**str** | | - -[[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/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasAllFalse.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasAllFalse.md deleted file mode 100644 index 4260a0d0178..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasAllFalse.md +++ /dev/null @@ -1,9 +0,0 @@ -# OneofWithBooleanSchemasAllFalse - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasAllTrue.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasAllTrue.md deleted file mode 100644 index b5174df5279..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasAllTrue.md +++ /dev/null @@ -1,9 +0,0 @@ -# OneofWithBooleanSchemasAllTrue - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasMoreThanOneTrue.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasMoreThanOneTrue.md deleted file mode 100644 index 2cea78847e2..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasMoreThanOneTrue.md +++ /dev/null @@ -1,9 +0,0 @@ -# OneofWithBooleanSchemasMoreThanOneTrue - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasOneTrue.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasOneTrue.md deleted file mode 100644 index 87db06ea0b8..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithBooleanSchemasOneTrue.md +++ /dev/null @@ -1,9 +0,0 @@ -# OneofWithBooleanSchemasOneTrue - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithRequired.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithRequired.md deleted file mode 100644 index 419b1df2d34..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithRequired.md +++ /dev/null @@ -1,9 +0,0 @@ -# OneofWithRequired - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithEmptySchema.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PatternIsNotAnchored.md similarity index 95% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithEmptySchema.md rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PatternIsNotAnchored.md index 1310a70f303..bca3d004ba4 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/OneofWithEmptySchema.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PatternIsNotAnchored.md @@ -1,4 +1,4 @@ -# OneofWithEmptySchema +# PatternIsNotAnchored #### Properties Name | Type | Description | Notes diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Oneof.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PatternValidation.md similarity index 95% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Oneof.md rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PatternValidation.md index e42f38aff34..ed358b81563 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Oneof.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PatternValidation.md @@ -1,4 +1,4 @@ -# Oneof +# PatternValidation #### Properties Name | Type | Description | Notes diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_oneof_to_check_validation_semantics.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_oneof_to_check_validation_semantics.py deleted file mode 100644 index 421a3a37a1c..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_oneof_to_check_validation_semantics.py +++ /dev/null @@ -1,35 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.nested_oneof_to_check_validation_semantics import NestedOneofToCheckValidationSemantics - - -class TestNestedOneofToCheckValidationSemantics(unittest.TestCase): - """NestedOneofToCheckValidationSemantics unit test stubs""" - - def test_anything_non_null_is_invalid_fails(self): - # anything non-null is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - NestedOneofToCheckValidationSemantics( - 123 ) - - def test_null_is_valid_passes(self): - # null is valid - NestedOneofToCheckValidationSemantics( - - None ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof.py deleted file mode 100644 index d9fbff2f161..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof.py +++ /dev/null @@ -1,45 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.oneof import Oneof - - -class TestOneof(unittest.TestCase): - """Oneof unit test stubs""" - - def test_second_oneof_valid_passes(self): - # second oneOf valid - Oneof( - 2.5 ) - - def test_both_oneof_valid_fails(self): - # both oneOf valid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - Oneof( - 3 ) - - def test_first_oneof_valid_passes(self): - # first oneOf valid - Oneof( - 1 ) - - def test_neither_oneof_valid_fails(self): - # neither oneOf valid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - Oneof( - 1.5 ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_complex_types.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_complex_types.py deleted file mode 100644 index 977a92aa127..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_complex_types.py +++ /dev/null @@ -1,68 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.oneof_complex_types import OneofComplexTypes - - -class TestOneofComplexTypes(unittest.TestCase): - """OneofComplexTypes unit test stubs""" - - def test_first_oneof_valid_complex_passes(self): - # first oneOf valid (complex) - OneofComplexTypes( - **{ - "bar": - 2, - } - ) - - def test_neither_oneof_valid_complex_fails(self): - # neither oneOf valid (complex) - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - OneofComplexTypes( - **{ - "foo": - 2, - "bar": - - "quux", - } - ) - - def test_both_oneof_valid_complex_fails(self): - # both oneOf valid (complex) - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - OneofComplexTypes( - **{ - "foo": - - "baz", - "bar": - 2, - } - ) - - def test_second_oneof_valid_complex_passes(self): - # second oneOf valid (complex) - OneofComplexTypes( - **{ - "foo": - - "baz", - } - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_base_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_base_schema.py deleted file mode 100644 index ef5c6e9782d..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_base_schema.py +++ /dev/null @@ -1,42 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.oneof_with_base_schema import OneofWithBaseSchema - - -class TestOneofWithBaseSchema(unittest.TestCase): - """OneofWithBaseSchema unit test stubs""" - - def test_both_oneof_valid_fails(self): - # both oneOf valid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - OneofWithBaseSchema( - - "foo" ) - - def test_mismatch_base_schema_fails(self): - # mismatch base schema - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - OneofWithBaseSchema( - 3 ) - - def test_one_oneof_valid_passes(self): - # one oneOf valid - OneofWithBaseSchema( - - "foobar" ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_all_false.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_all_false.py deleted file mode 100644 index 6960d47ea68..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_all_false.py +++ /dev/null @@ -1,30 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.oneof_with_boolean_schemas_all_false import OneofWithBooleanSchemasAllFalse - - -class TestOneofWithBooleanSchemasAllFalse(unittest.TestCase): - """OneofWithBooleanSchemasAllFalse unit test stubs""" - - def test_any_value_is_invalid_fails(self): - # any value is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - OneofWithBooleanSchemasAllFalse( - - "foo" ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_all_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_all_true.py deleted file mode 100644 index 99a9e888f1e..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_all_true.py +++ /dev/null @@ -1,30 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.oneof_with_boolean_schemas_all_true import OneofWithBooleanSchemasAllTrue - - -class TestOneofWithBooleanSchemasAllTrue(unittest.TestCase): - """OneofWithBooleanSchemasAllTrue unit test stubs""" - - def test_any_value_is_invalid_fails(self): - # any value is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - OneofWithBooleanSchemasAllTrue( - - "foo" ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_more_than_one_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_more_than_one_true.py deleted file mode 100644 index 368bec5002c..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_more_than_one_true.py +++ /dev/null @@ -1,30 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.oneof_with_boolean_schemas_more_than_one_true import OneofWithBooleanSchemasMoreThanOneTrue - - -class TestOneofWithBooleanSchemasMoreThanOneTrue(unittest.TestCase): - """OneofWithBooleanSchemasMoreThanOneTrue unit test stubs""" - - def test_any_value_is_invalid_fails(self): - # any value is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - OneofWithBooleanSchemasMoreThanOneTrue( - - "foo" ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_one_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_one_true.py deleted file mode 100644 index c645a5a2924..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_boolean_schemas_one_true.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.oneof_with_boolean_schemas_one_true import OneofWithBooleanSchemasOneTrue - - -class TestOneofWithBooleanSchemasOneTrue(unittest.TestCase): - """OneofWithBooleanSchemasOneTrue unit test stubs""" - - def test_any_value_is_valid_passes(self): - # any value is valid - OneofWithBooleanSchemasOneTrue( - - "foo" ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_empty_schema.py deleted file mode 100644 index f858f55d6a6..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_empty_schema.py +++ /dev/null @@ -1,35 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.oneof_with_empty_schema import OneofWithEmptySchema - - -class TestOneofWithEmptySchema(unittest.TestCase): - """OneofWithEmptySchema unit test stubs""" - - def test_both_valid_invalid_fails(self): - # both valid - invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - OneofWithEmptySchema( - 123 ) - - def test_one_valid_valid_passes(self): - # one valid - valid - OneofWithEmptySchema( - - "foo" ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_required.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_required.py deleted file mode 100644 index 91687aa06a7..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_oneof_with_required.py +++ /dev/null @@ -1,69 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.oneof_with_required import OneofWithRequired - - -class TestOneofWithRequired(unittest.TestCase): - """OneofWithRequired unit test stubs""" - - def test_both_valid_invalid_fails(self): - # both valid - invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - OneofWithRequired( - **{ - "foo": - 1, - "bar": - 2, - "baz": - 3, - } - ) - - def test_both_invalid_invalid_fails(self): - # both invalid - invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - OneofWithRequired( - **{ - "bar": - 2, - } - ) - - def test_first_valid_valid_passes(self): - # first valid - valid - OneofWithRequired( - **{ - "foo": - 1, - "bar": - 2, - } - ) - - def test_second_valid_valid_passes(self): - # second valid - valid - OneofWithRequired( - **{ - "foo": - 1, - "baz": - 3, - } - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_is_not_anchored.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_is_not_anchored.py new file mode 100644 index 00000000000..d78e6fcfab8 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_is_not_anchored.py @@ -0,0 +1,29 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.pattern_is_not_anchored import PatternIsNotAnchored + + +class TestPatternIsNotAnchored(unittest.TestCase): + """PatternIsNotAnchored unit test stubs""" + + def test_matches_a_substring_passes(self): + # matches a substring + PatternIsNotAnchored( + + "xxaayy" ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_validation.py new file mode 100644 index 00000000000..3bc3bd740f7 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_validation.py @@ -0,0 +1,72 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.pattern_validation import PatternValidation + + +class TestPatternValidation(unittest.TestCase): + """PatternValidation unit test stubs""" + + def test_ignores_arrays_passes(self): + # ignores arrays + PatternValidation( + [ + ] + ) + + def test_ignores_objects_passes(self): + # ignores objects + PatternValidation( + { + } + ) + + def test_ignores_null_passes(self): + # ignores null + PatternValidation( + + None ) + + def test_ignores_floats_passes(self): + # ignores floats + PatternValidation( + 1.0 ) + + def test_a_non_matching_pattern_is_invalid_fails(self): + # a non-matching pattern is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + PatternValidation( + + "abc" ) + + def test_ignores_booleans_passes(self): + # ignores booleans + PatternValidation( + + True ) + + def test_a_matching_pattern_is_valid_passes(self): + # a matching pattern is valid + PatternValidation( + + "aaa" ) + + def test_ignores_integers_passes(self): + # ignores integers + PatternValidation( + 123 ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_oneof_to_check_validation_semantics.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_oneof_to_check_validation_semantics.py deleted file mode 100644 index 3cce9a1433e..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_oneof_to_check_validation_semantics.py +++ /dev/null @@ -1,113 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class NestedOneofToCheckValidationSemantics( - ComposedSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 - oneOf_0 = AnyTypeSchema - return { - 'allOf': [ - ], - 'oneOf': [ - oneOf_0, - ], - 'anyOf': [ - ], - 'not': - None - } - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'NestedOneofToCheckValidationSemantics': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof.py deleted file mode 100644 index b3c930e87a9..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof.py +++ /dev/null @@ -1,115 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class Oneof( - ComposedSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 - oneOf_0 = IntSchema - oneOf_1 = AnyTypeSchema - return { - 'allOf': [ - ], - 'oneOf': [ - oneOf_0, - oneOf_1, - ], - 'anyOf': [ - ], - 'not': - None - } - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'Oneof': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_complex_types.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_complex_types.py deleted file mode 100644 index 9c1656403e7..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_complex_types.py +++ /dev/null @@ -1,115 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class OneofComplexTypes( - ComposedSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 - oneOf_0 = AnyTypeSchema - oneOf_1 = AnyTypeSchema - return { - 'allOf': [ - ], - 'oneOf': [ - oneOf_0, - oneOf_1, - ], - 'anyOf': [ - ], - 'not': - None - } - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'OneofComplexTypes': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_base_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_base_schema.py deleted file mode 100644 index 5ea665a24df..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_base_schema.py +++ /dev/null @@ -1,114 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class OneofWithBaseSchema( - ComposedBase, - StrSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 - oneOf_0 = AnyTypeSchema - oneOf_1 = AnyTypeSchema - return { - 'allOf': [ - ], - 'oneOf': [ - oneOf_0, - oneOf_1, - ], - 'anyOf': [ - ], - 'not': - None - } - - def __new__( - cls, - *args: typing.Union[str, ], - _configuration: typing.Optional[Configuration] = None, - ) -> 'OneofWithBaseSchema': - return super().__new__( - cls, - *args, - _configuration=_configuration, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_boolean_schemas_all_false.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_boolean_schemas_all_false.py deleted file mode 100644 index 12e8b34a323..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_boolean_schemas_all_false.py +++ /dev/null @@ -1,111 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class OneofWithBooleanSchemasAllFalse( - ComposedSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 { - 'allOf': [ - ], - 'oneOf': [ - ], - 'anyOf': [ - ], - 'not': - None - } - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'OneofWithBooleanSchemasAllFalse': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_boolean_schemas_more_than_one_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_boolean_schemas_more_than_one_true.py deleted file mode 100644 index 20b72e702cf..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_boolean_schemas_more_than_one_true.py +++ /dev/null @@ -1,111 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class OneofWithBooleanSchemasMoreThanOneTrue( - ComposedSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 { - 'allOf': [ - ], - 'oneOf': [ - ], - 'anyOf': [ - ], - 'not': - None - } - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'OneofWithBooleanSchemasMoreThanOneTrue': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_empty_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_empty_schema.py deleted file mode 100644 index 015d651ae83..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_empty_schema.py +++ /dev/null @@ -1,115 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class OneofWithEmptySchema( - ComposedSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 - oneOf_0 = NumberSchema - oneOf_1 = AnyTypeSchema - return { - 'allOf': [ - ], - 'oneOf': [ - oneOf_0, - oneOf_1, - ], - 'anyOf': [ - ], - 'not': - None - } - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'OneofWithEmptySchema': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_required.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_required.py deleted file mode 100644 index 62eace35ebc..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_required.py +++ /dev/null @@ -1,116 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class OneofWithRequired( - ComposedBase, - DictSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 - oneOf_0 = AnyTypeSchema - oneOf_1 = AnyTypeSchema - return { - 'allOf': [ - ], - 'oneOf': [ - oneOf_0, - oneOf_1, - ], - 'anyOf': [ - ], - 'not': - None - } - - def __new__( - cls, - *args: typing.Union[dict, frozendict, ], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'OneofWithRequired': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_boolean_schemas_all_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/pattern_is_not_anchored.py similarity index 69% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_boolean_schemas_all_true.py rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/pattern_is_not_anchored.py index 36b8e70cc98..63923788782 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_boolean_schemas_all_true.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/pattern_is_not_anchored.py @@ -66,8 +66,13 @@ from unit_test_api.schemas import ( # noqa: F401 ) -class OneofWithBooleanSchemasAllTrue( - ComposedSchema +class PatternIsNotAnchored( + _SchemaValidator( + regex=[{ + 'pattern': r'a+', # noqa: E501 + }], + ), + AnyTypeSchema ): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech @@ -75,34 +80,12 @@ class OneofWithBooleanSchemasAllTrue( Do not edit the class manually. """ - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 { - 'allOf': [ - ], - 'oneOf': [ - ], - 'anyOf': [ - ], - 'not': - None - } - def __new__( cls, *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Type[Schema], - ) -> 'OneofWithBooleanSchemasAllTrue': + ) -> 'PatternIsNotAnchored': return super().__new__( cls, *args, diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_boolean_schemas_one_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/pattern_validation.py similarity index 69% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_boolean_schemas_one_true.py rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/pattern_validation.py index 3f576a4e7b9..60d4530a637 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/oneof_with_boolean_schemas_one_true.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/pattern_validation.py @@ -66,8 +66,13 @@ from unit_test_api.schemas import ( # noqa: F401 ) -class OneofWithBooleanSchemasOneTrue( - ComposedSchema +class PatternValidation( + _SchemaValidator( + regex=[{ + 'pattern': r'^a*$', # noqa: E501 + }], + ), + AnyTypeSchema ): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech @@ -75,34 +80,12 @@ class OneofWithBooleanSchemasOneTrue( Do not edit the class manually. """ - @classmethod - @property - @functools.cache - def _composed_schemas(cls): - # 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 because 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 { - 'allOf': [ - ], - 'oneOf': [ - ], - 'anyOf': [ - ], - 'not': - None - } - def __new__( cls, *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Type[Schema], - ) -> 'OneofWithBooleanSchemasOneTrue': + ) -> 'PatternValidation': return super().__new__( cls, *args, diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py index d705b44b88b..3f0a236918d 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py @@ -11,13 +11,5 @@ # import sys # sys.setrecursionlimit(n) -from unit_test_api.model.nested_oneof_to_check_validation_semantics import NestedOneofToCheckValidationSemantics -from unit_test_api.model.oneof import Oneof -from unit_test_api.model.oneof_complex_types import OneofComplexTypes -from unit_test_api.model.oneof_with_base_schema import OneofWithBaseSchema -from unit_test_api.model.oneof_with_boolean_schemas_all_false import OneofWithBooleanSchemasAllFalse -from unit_test_api.model.oneof_with_boolean_schemas_all_true import OneofWithBooleanSchemasAllTrue -from unit_test_api.model.oneof_with_boolean_schemas_more_than_one_true import OneofWithBooleanSchemasMoreThanOneTrue -from unit_test_api.model.oneof_with_boolean_schemas_one_true import OneofWithBooleanSchemasOneTrue -from unit_test_api.model.oneof_with_empty_schema import OneofWithEmptySchema -from unit_test_api.model.oneof_with_required import OneofWithRequired +from unit_test_api.model.pattern_is_not_anchored import PatternIsNotAnchored +from unit_test_api.model.pattern_validation import PatternValidation -- GitLab From 9777d34e80edd5ccb7a05c91f6f64497725539c2 Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Mon, 27 Jun 2022 18:44:00 -0700 Subject: [PATCH 24/43] Adds patternProperties --- .../3_0/unit_test_spec/spec_writer.py | 5 +- .../resources/3_0/unit_test_spec/type.yaml | 46 +- .../docs/PatternIsNotAnchored.md | 9 - .../docs/PatternValidation.md | 9 - .../python-experimental/test/__init__.py | 0 .../test/test_pattern_is_not_anchored.py | 29 - .../test/test_pattern_validation.py | 72 - .../unit_test_api/__init__.py | 28 - .../unit_test_api/api/__init__.py | 0 .../unit_test_api/api_client.py | 1420 ----------- .../unit_test_api/apis/__init__.py | 0 .../unit_test_api/configuration.py | 440 ---- .../unit_test_api/exceptions.py | 136 - .../unit_test_api/model/__init__.py | 5 - .../model/pattern_is_not_anchored.py | 94 - .../unit_test_api/model/pattern_validation.py | 94 - .../unit_test_api/models/__init__.py | 15 - .../python-experimental/unit_test_api/rest.py | 253 -- .../unit_test_api/schemas.py | 2201 ----------------- 19 files changed, 6 insertions(+), 4850 deletions(-) delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PatternIsNotAnchored.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PatternValidation.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/__init__.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_is_not_anchored.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_validation.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/__init__.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/api/__init__.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/api_client.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/__init__.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/configuration.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/exceptions.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/__init__.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/pattern_is_not_anchored.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/pattern_validation.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/rest.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/schemas.py diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index cb56ee18d94..c3254571cde 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -88,6 +88,7 @@ class ExclusionReason: swagger_parser_validation_missing_bug = 'swagger-parser has a bug where validations are unset, https://github.com/swagger-api/swagger-parser/issues/1762' swagger_parser_items_type_bug = "swagger-parser has a bug where schema type is incorrectly set with items, https://github.com/swagger-api/swagger-parser/issues/1763" v303_does_not_support_id = 'v3.0.3 does not support the $id keyword' + v303_does_not_support_patternProperties = 'v3.0.3 does not support the patternProperties keyword' json_schema_test_draft = 'draft6' FILEPATH_TO_EXCLUDED_CASE_AND_REASON = { @@ -134,6 +135,7 @@ FILEPATH_TO_EXCLUDE_REASON = { (json_schema_test_draft, 'exclusiveMaximum.json'): ExclusionReason.swagger_parser_validation_missing_bug, (json_schema_test_draft, 'exclusiveMinimum.json'): ExclusionReason.swagger_parser_validation_missing_bug, (json_schema_test_draft, 'id.json'): ExclusionReason.v303_does_not_support_id, + (json_schema_test_draft, 'patternProperties.json'): ExclusionReason.v303_does_not_support_patternProperties, } openapi_additions = 'openapi_additions' @@ -168,7 +170,8 @@ JSON_SCHEMA_TEST_FILE_TO_FOLDERS = { # 'multipleOf.json': (json_schema_test_draft,), # 'not.json': (json_schema_test_draft,), # 'oneOf.json': (json_schema_test_draft,), # activate after fixing this - 'pattern.json': (json_schema_test_draft,), +# 'pattern.json': (json_schema_test_draft,), + 'patternProperties.json': (json_schema_test_draft,), } def get_json_schema_test_schemas(file_path: typing.Tuple[str]) -> typing.List[JsonSchemaTestSchema]: diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml index c6ac6794681..2a0b920f0b7 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml @@ -6,47 +6,5 @@ info: version: 0.0.1 paths: {} components: - schemas: - PatternValidation: - pattern: ^a*$ - PatternIsNotAnchored: - pattern: a+ - x-schema-test-examples: - PatternValidation: - AMatchingPatternIsValid: - description: a matching pattern is valid - data: aaa - valid: true - ANonMatchingPatternIsInvalid: - description: a non-matching pattern is invalid - data: abc - valid: false - IgnoresBooleans: - description: ignores booleans - data: true - valid: true - IgnoresIntegers: - description: ignores integers - data: 123 - valid: true - IgnoresFloats: - description: ignores floats - data: 1.0 - valid: true - IgnoresObjects: - description: ignores objects - data: {} - valid: true - IgnoresArrays: - description: ignores arrays - data: [] - valid: true - IgnoresNull: - description: ignores null - data: null - valid: true - PatternIsNotAnchored: - MatchesASubstring: - description: matches a substring - data: xxaayy - valid: true + schemas: {} + x-schema-test-examples: {} diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PatternIsNotAnchored.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PatternIsNotAnchored.md deleted file mode 100644 index bca3d004ba4..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PatternIsNotAnchored.md +++ /dev/null @@ -1,9 +0,0 @@ -# PatternIsNotAnchored - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PatternValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PatternValidation.md deleted file mode 100644 index ed358b81563..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PatternValidation.md +++ /dev/null @@ -1,9 +0,0 @@ -# PatternValidation - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_is_not_anchored.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_is_not_anchored.py deleted file mode 100644 index d78e6fcfab8..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_is_not_anchored.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.pattern_is_not_anchored import PatternIsNotAnchored - - -class TestPatternIsNotAnchored(unittest.TestCase): - """PatternIsNotAnchored unit test stubs""" - - def test_matches_a_substring_passes(self): - # matches a substring - PatternIsNotAnchored( - - "xxaayy" ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_validation.py deleted file mode 100644 index 3bc3bd740f7..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_validation.py +++ /dev/null @@ -1,72 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.pattern_validation import PatternValidation - - -class TestPatternValidation(unittest.TestCase): - """PatternValidation unit test stubs""" - - def test_ignores_arrays_passes(self): - # ignores arrays - PatternValidation( - [ - ] - ) - - def test_ignores_objects_passes(self): - # ignores objects - PatternValidation( - { - } - ) - - def test_ignores_null_passes(self): - # ignores null - PatternValidation( - - None ) - - def test_ignores_floats_passes(self): - # ignores floats - PatternValidation( - 1.0 ) - - def test_a_non_matching_pattern_is_invalid_fails(self): - # a non-matching pattern is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - PatternValidation( - - "abc" ) - - def test_ignores_booleans_passes(self): - # ignores booleans - PatternValidation( - - True ) - - def test_a_matching_pattern_is_valid_passes(self): - # a matching pattern is valid - PatternValidation( - - "aaa" ) - - def test_ignores_integers_passes(self): - # ignores integers - PatternValidation( - 123 ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/__init__.py deleted file mode 100644 index 5ca6e989be0..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/__init__.py +++ /dev/null @@ -1,28 +0,0 @@ -# coding: utf-8 - -# flake8: noqa - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -__version__ = "1.0.0" - -# import ApiClient -from unit_test_api.api_client import ApiClient - -# import Configuration -from unit_test_api.configuration import Configuration - -# import exceptions -from unit_test_api.exceptions import OpenApiException -from unit_test_api.exceptions import ApiAttributeError -from unit_test_api.exceptions import ApiTypeError -from unit_test_api.exceptions import ApiValueError -from unit_test_api.exceptions import ApiKeyError -from unit_test_api.exceptions import ApiException diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/api/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/api/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/api_client.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/api_client.py deleted file mode 100644 index 66e52cba296..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/api_client.py +++ /dev/null @@ -1,1420 +0,0 @@ -# coding: utf-8 -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -from dataclasses import dataclass -from decimal import Decimal -import enum -import email -import json -import os -import io -import atexit -from multiprocessing.pool import ThreadPool -import re -import tempfile -import typing -import urllib3 -from urllib3._collections import HTTPHeaderDict -from urllib.parse import quote -from urllib3.fields import RequestField as RequestFieldBase - - -from unit_test_api import rest -from unit_test_api.configuration import Configuration -from unit_test_api.exceptions import ApiTypeError, ApiValueError -from unit_test_api.schemas import ( - NoneClass, - BoolClass, - Schema, - FileIO, - BinarySchema, - date, - datetime, - none_type, - frozendict, - Unset, - unset, -) - - -class RequestField(RequestFieldBase): - def __eq__(self, other): - if not isinstance(other, RequestField): - return False - return self.__dict__ == other.__dict__ - - -class JSONEncoder(json.JSONEncoder): - def default(self, obj): - if isinstance(obj, str): - return str(obj) - elif isinstance(obj, float): - return float(obj) - elif isinstance(obj, int): - return int(obj) - elif isinstance(obj, Decimal): - if obj.as_tuple().exponent >= 0: - return int(obj) - return float(obj) - elif isinstance(obj, NoneClass): - return None - elif isinstance(obj, BoolClass): - return bool(obj) - elif isinstance(obj, (dict, frozendict)): - return {key: self.default(val) for key, val in obj.items()} - elif isinstance(obj, (list, tuple)): - return [self.default(item) for item in obj] - raise ApiValueError('Unable to prepare type {} for serialization'.format(obj.__class__.__name__)) - - -class ParameterInType(enum.Enum): - QUERY = 'query' - HEADER = 'header' - PATH = 'path' - COOKIE = 'cookie' - - -class ParameterStyle(enum.Enum): - MATRIX = 'matrix' - LABEL = 'label' - FORM = 'form' - SIMPLE = 'simple' - SPACE_DELIMITED = 'spaceDelimited' - PIPE_DELIMITED = 'pipeDelimited' - DEEP_OBJECT = 'deepObject' - - -class PrefixSeparatorIterator: - # A class to store prefixes and separators for rfc6570 expansions - - def __init__(self, prefix: str, separator: str): - self.prefix = prefix - self.separator = separator - self.first = True - if separator in {'.', '|', '%20'}: - item_separator = separator - else: - item_separator = ',' - self.item_separator = item_separator - - def __iter__(self): - return self - - def __next__(self): - if self.first: - self.first = False - return self.prefix - return self.separator - - -class ParameterSerializerBase: - @classmethod - def get_default_explode(cls, style: ParameterStyle) -> bool: - return False - - @staticmethod - def __ref6570_item_value(in_data: typing.Any, percent_encode: bool): - """ - Get representation if str/float/int/None/items in list/ values in dict - None is returned if an item is undefined, use cases are value= - - None - - [] - - {} - - [None, None None] - - {'a': None, 'b': None} - """ - if type(in_data) in {str, float, int}: - if percent_encode: - return quote(str(in_data)) - return str(in_data) - elif isinstance(in_data, none_type): - # ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1 - return None - elif isinstance(in_data, list) and not in_data: - # ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1 - return None - elif isinstance(in_data, dict) and not in_data: - # ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1 - return None - raise ApiValueError('Unable to generate a ref6570 item representation of {}'.format(in_data)) - - @staticmethod - def to_dict(name: str, value: str): - return {name: value} - - @classmethod - def ref6570_expansion( - cls, - variable_name: str, - in_data: typing.Any, - explode: bool, - percent_encode: bool, - prefix_separator_iterator: PrefixSeparatorIterator - ) -> str: - """ - Separator is for separate variables like dict with explode true, not for array item separation - """ - named_parameter_expansion = prefix_separator_iterator.separator in {'&', ';'} - var_name_piece = variable_name if named_parameter_expansion else '' - if type(in_data) in {str, float, int}: - item_value = cls.__ref6570_item_value(in_data, percent_encode) - if item_value is None: - return next(prefix_separator_iterator) + var_name_piece - elif item_value == '' and prefix_separator_iterator.separator == ';': - return next(prefix_separator_iterator) + var_name_piece - value_pair_equals = '=' if named_parameter_expansion else '' - return next(prefix_separator_iterator) + var_name_piece + value_pair_equals + item_value - elif isinstance(in_data, none_type): - # ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1 - return "" - elif isinstance(in_data, list): - item_values = [cls.__ref6570_item_value(v, percent_encode) for v in in_data] - item_values = [v for v in item_values if v is not None] - if not item_values: - # ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1 - return "" - value_pair_equals = '=' if named_parameter_expansion else '' - if not explode: - return ( - next(prefix_separator_iterator) + - var_name_piece + - value_pair_equals + - prefix_separator_iterator.item_separator.join(item_values) - ) - # exploded - return next(prefix_separator_iterator) + next(prefix_separator_iterator).join( - [var_name_piece + value_pair_equals + val for val in item_values] - ) - elif isinstance(in_data, dict): - in_data_transformed = {key: cls.__ref6570_item_value(val, percent_encode) for key, val in in_data.items()} - in_data_transformed = {key: val for key, val in in_data_transformed.items() if val is not None} - if not in_data_transformed: - # ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1 - return "" - value_pair_equals = '=' if named_parameter_expansion else '' - if not explode: - return ( - next(prefix_separator_iterator) + - var_name_piece + value_pair_equals + - prefix_separator_iterator.item_separator.join( - prefix_separator_iterator.item_separator.join( - item_pair - ) for item_pair in in_data_transformed.items() - ) - ) - # exploded - return next(prefix_separator_iterator) + next(prefix_separator_iterator).join( - [key + '=' + val for key, val in in_data_transformed.items()] - ) - # bool, bytes, etc - raise ApiValueError('Unable to generate a ref6570 representation of {}'.format(in_data)) - - -class StyleFormSerializer(ParameterSerializerBase): - @classmethod - def get_default_explode(cls, style: ParameterStyle) -> bool: - if style is ParameterStyle.FORM: - return True - return super().get_default_explode(style) - - def serialize_form( - self, - in_data: typing.Union[None, int, float, str, bool, dict, list], - name: str, - explode: bool, - percent_encode: bool, - prefix_separator_iterator: typing.Optional[PrefixSeparatorIterator] = None - ) -> str: - if prefix_separator_iterator is None: - prefix_separator_iterator = PrefixSeparatorIterator('?', '&') - return self.ref6570_expansion( - variable_name=name, - in_data=in_data, - explode=explode, - percent_encode=percent_encode, - prefix_separator_iterator=prefix_separator_iterator - ) - - -class StyleSimpleSerializer(ParameterSerializerBase): - - def serialize_simple( - self, - in_data: typing.Union[None, int, float, str, bool, dict, list], - name: str, - explode: bool, - percent_encode: bool - ) -> str: - prefix_separator_iterator = PrefixSeparatorIterator('', ',') - return self.ref6570_expansion( - variable_name=name, - in_data=in_data, - explode=explode, - percent_encode=percent_encode, - prefix_separator_iterator=prefix_separator_iterator - ) - - -@dataclass -class ParameterBase: - name: str - in_type: ParameterInType - required: bool - style: typing.Optional[ParameterStyle] - explode: typing.Optional[bool] - allow_reserved: typing.Optional[bool] - schema: typing.Optional[typing.Type[Schema]] - content: typing.Optional[typing.Dict[str, typing.Type[Schema]]] - - __style_to_in_type = { - ParameterStyle.MATRIX: {ParameterInType.PATH}, - ParameterStyle.LABEL: {ParameterInType.PATH}, - ParameterStyle.FORM: {ParameterInType.QUERY, ParameterInType.COOKIE}, - ParameterStyle.SIMPLE: {ParameterInType.PATH, ParameterInType.HEADER}, - ParameterStyle.SPACE_DELIMITED: {ParameterInType.QUERY}, - ParameterStyle.PIPE_DELIMITED: {ParameterInType.QUERY}, - ParameterStyle.DEEP_OBJECT: {ParameterInType.QUERY}, - } - __in_type_to_default_style = { - ParameterInType.QUERY: ParameterStyle.FORM, - ParameterInType.PATH: ParameterStyle.SIMPLE, - ParameterInType.HEADER: ParameterStyle.SIMPLE, - ParameterInType.COOKIE: ParameterStyle.FORM, - } - __disallowed_header_names = {'Accept', 'Content-Type', 'Authorization'} - _json_encoder = JSONEncoder() - _json_content_type = 'application/json' - - @classmethod - def __verify_style_to_in_type(cls, style: typing.Optional[ParameterStyle], in_type: ParameterInType): - if style is None: - return - in_type_set = cls.__style_to_in_type[style] - if in_type not in in_type_set: - raise ValueError( - 'Invalid style and in_type combination. For style={} only in_type={} are allowed'.format( - style, in_type_set - ) - ) - - def __init__( - self, - name: str, - in_type: ParameterInType, - required: bool = False, - style: typing.Optional[ParameterStyle] = None, - explode: bool = False, - allow_reserved: typing.Optional[bool] = None, - schema: typing.Optional[typing.Type[Schema]] = None, - content: typing.Optional[typing.Dict[str, typing.Type[Schema]]] = None - ): - if schema is None and content is None: - raise ValueError('Value missing; Pass in either schema or content') - if schema and content: - raise ValueError('Too many values provided. Both schema and content were provided. Only one may be input') - if name in self.__disallowed_header_names and in_type is ParameterInType.HEADER: - raise ValueError('Invalid name, name may not be one of {}'.format(self.__disallowed_header_names)) - self.__verify_style_to_in_type(style, in_type) - if content is None and style is None: - style = self.__in_type_to_default_style[in_type] - if content is not None and in_type in self.__in_type_to_default_style and len(content) != 1: - raise ValueError('Invalid content length, content length must equal 1') - self.in_type = in_type - self.name = name - self.required = required - self.style = style - self.explode = explode - self.allow_reserved = allow_reserved - self.schema = schema - self.content = content - - @staticmethod - def _remove_empty_and_cast( - in_data: typing.Tuple[typing.Tuple[str, str]], - ) -> typing.Dict[str, str]: - data = tuple(t for t in in_data if t) - if not data: - return dict() - return dict(data) - - def _serialize_json( - self, - in_data: typing.Union[None, int, float, str, bool, dict, list] - ) -> str: - return json.dumps(in_data) - - -class PathParameter(ParameterBase, StyleSimpleSerializer): - - def __init__( - self, - name: str, - required: bool = False, - style: typing.Optional[ParameterStyle] = None, - explode: bool = False, - allow_reserved: typing.Optional[bool] = None, - schema: typing.Optional[typing.Type[Schema]] = None, - content: typing.Optional[typing.Dict[str, typing.Type[Schema]]] = None - ): - super().__init__( - name, - in_type=ParameterInType.PATH, - required=required, - style=style, - explode=explode, - allow_reserved=allow_reserved, - schema=schema, - content=content - ) - - def _serialize_label( - self, - in_data: typing.Union[None, int, float, str, bool, dict, list] - ) -> typing.Dict[str, str]: - prefix_separator_iterator = PrefixSeparatorIterator('.', '.') - value = self.ref6570_expansion( - variable_name=self.name, - in_data=in_data, - explode=self.explode, - percent_encode=True, - prefix_separator_iterator=prefix_separator_iterator - ) - return self.to_dict(self.name, value) - - def _serialize_matrix( - self, - in_data: typing.Union[None, int, float, str, bool, dict, list] - ) -> typing.Dict[str, str]: - prefix_separator_iterator = PrefixSeparatorIterator(';', ';') - value = self.ref6570_expansion( - variable_name=self.name, - in_data=in_data, - explode=self.explode, - percent_encode=True, - prefix_separator_iterator=prefix_separator_iterator - ) - return self.to_dict(self.name, value) - - def _serialize_simple( - self, - in_data: typing.Union[None, int, float, str, bool, dict, list], - ) -> typing.Dict[str, str]: - value = self.serialize_simple( - in_data=in_data, - name=self.name, - explode=self.explode, - percent_encode=True - ) - return self.to_dict(self.name, value) - - def serialize( - self, - in_data: typing.Union[ - Schema, Decimal, int, float, str, date, datetime, None, bool, list, tuple, dict, frozendict] - ) -> typing.Dict[str, str]: - if self.schema: - cast_in_data = self.schema(in_data) - cast_in_data = self._json_encoder.default(cast_in_data) - """ - simple -> path - path: - returns path_params: dict - label -> path - returns path_params - matrix -> path - returns path_params - """ - if self.style: - if self.style is ParameterStyle.SIMPLE: - return self._serialize_simple(cast_in_data) - elif self.style is ParameterStyle.LABEL: - return self._serialize_label(cast_in_data) - elif self.style is ParameterStyle.MATRIX: - return self._serialize_matrix(cast_in_data) - # self.content will be length one - for content_type, schema in self.content.items(): - cast_in_data = schema(in_data) - cast_in_data = self._json_encoder.default(cast_in_data) - if content_type == self._json_content_type: - value = self._serialize_json(cast_in_data) - return self.to_dict(self.name, value) - raise NotImplementedError('Serialization of {} has not yet been implemented'.format(content_type)) - - -class QueryParameter(ParameterBase, StyleFormSerializer): - - def __init__( - self, - name: str, - required: bool = False, - style: typing.Optional[ParameterStyle] = None, - explode: typing.Optional[bool] = None, - allow_reserved: typing.Optional[bool] = None, - schema: typing.Optional[typing.Type[Schema]] = None, - content: typing.Optional[typing.Dict[str, typing.Type[Schema]]] = None - ): - used_style = ParameterStyle.FORM if style is None and content is None and schema else style - used_explode = self.get_default_explode(used_style) if explode is None else explode - - super().__init__( - name, - in_type=ParameterInType.QUERY, - required=required, - style=used_style, - explode=used_explode, - allow_reserved=allow_reserved, - schema=schema, - content=content - ) - - def __serialize_space_delimited( - self, - in_data: typing.Union[None, int, float, str, bool, dict, list], - prefix_separator_iterator: typing.Optional[PrefixSeparatorIterator] - ) -> typing.Dict[str, str]: - if prefix_separator_iterator is None: - prefix_separator_iterator = self.get_prefix_separator_iterator() - value = self.ref6570_expansion( - variable_name=self.name, - in_data=in_data, - explode=self.explode, - percent_encode=True, - prefix_separator_iterator=prefix_separator_iterator - ) - return self.to_dict(self.name, value) - - def __serialize_pipe_delimited( - self, - in_data: typing.Union[None, int, float, str, bool, dict, list], - prefix_separator_iterator: typing.Optional[PrefixSeparatorIterator] - ) -> typing.Dict[str, str]: - if prefix_separator_iterator is None: - prefix_separator_iterator = self.get_prefix_separator_iterator() - value = self.ref6570_expansion( - variable_name=self.name, - in_data=in_data, - explode=self.explode, - percent_encode=True, - prefix_separator_iterator=prefix_separator_iterator - ) - return self.to_dict(self.name, value) - - def __serialize_form( - self, - in_data: typing.Union[None, int, float, str, bool, dict, list], - prefix_separator_iterator: typing.Optional[PrefixSeparatorIterator] - ) -> typing.Dict[str, str]: - if prefix_separator_iterator is None: - prefix_separator_iterator = self.get_prefix_separator_iterator() - value = self.serialize_form( - in_data, - name=self.name, - explode=self.explode, - percent_encode=True, - prefix_separator_iterator=prefix_separator_iterator - ) - return self.to_dict(self.name, value) - - def get_prefix_separator_iterator(self) -> typing.Optional[PrefixSeparatorIterator]: - if not self.schema: - return None - if self.style is ParameterStyle.FORM: - return PrefixSeparatorIterator('?', '&') - elif self.style is ParameterStyle.SPACE_DELIMITED: - return PrefixSeparatorIterator('', '%20') - elif self.style is ParameterStyle.PIPE_DELIMITED: - return PrefixSeparatorIterator('', '|') - - def serialize( - self, - in_data: typing.Union[ - Schema, Decimal, int, float, str, date, datetime, None, bool, list, tuple, dict, frozendict], - prefix_separator_iterator: typing.Optional[PrefixSeparatorIterator] = None - ) -> typing.Dict[str, str]: - if self.schema: - cast_in_data = self.schema(in_data) - cast_in_data = self._json_encoder.default(cast_in_data) - """ - form -> query - query: - - GET/HEAD/DELETE: could use fields - - PUT/POST: must use urlencode to send parameters - returns fields: tuple - spaceDelimited -> query - returns fields - pipeDelimited -> query - returns fields - deepObject -> query, https://github.com/OAI/OpenAPI-Specification/issues/1706 - returns fields - """ - if self.style: - # TODO update query ones to omit setting values when [] {} or None is input - if self.style is ParameterStyle.FORM: - return self.__serialize_form(cast_in_data, prefix_separator_iterator) - elif self.style is ParameterStyle.SPACE_DELIMITED: - return self.__serialize_space_delimited(cast_in_data, prefix_separator_iterator) - elif self.style is ParameterStyle.PIPE_DELIMITED: - return self.__serialize_pipe_delimited(cast_in_data, prefix_separator_iterator) - # self.content will be length one - for content_type, schema in self.content.items(): - cast_in_data = schema(in_data) - cast_in_data = self._json_encoder.default(cast_in_data) - if content_type == self._json_content_type: - value = self._serialize_json(cast_in_data) - return self.to_dict(self.name, value) - raise NotImplementedError('Serialization of {} has not yet been implemented'.format(content_type)) - - -class CookieParameter(ParameterBase, StyleFormSerializer): - - def __init__( - self, - name: str, - required: bool = False, - style: typing.Optional[ParameterStyle] = None, - explode: typing.Optional[bool] = None, - allow_reserved: typing.Optional[bool] = None, - schema: typing.Optional[typing.Type[Schema]] = None, - content: typing.Optional[typing.Dict[str, typing.Type[Schema]]] = None - ): - used_style = ParameterStyle.FORM if style is None and content is None and schema else style - used_explode = self.get_default_explode(used_style) if explode is None else explode - - super().__init__( - name, - in_type=ParameterInType.COOKIE, - required=required, - style=used_style, - explode=used_explode, - allow_reserved=allow_reserved, - schema=schema, - content=content - ) - - def serialize( - self, - in_data: typing.Union[ - Schema, Decimal, int, float, str, date, datetime, None, bool, list, tuple, dict, frozendict] - ) -> typing.Dict[str, str]: - if self.schema: - cast_in_data = self.schema(in_data) - cast_in_data = self._json_encoder.default(cast_in_data) - """ - form -> cookie - returns fields: tuple - """ - if self.style: - """ - TODO add escaping of comma, space, equals - or turn encoding on - """ - value = self.serialize_form( - cast_in_data, - explode=self.explode, - name=self.name, - percent_encode=False, - prefix_separator_iterator=PrefixSeparatorIterator('', '&') - ) - return self.to_dict(self.name, value) - # self.content will be length one - for content_type, schema in self.content.items(): - cast_in_data = schema(in_data) - cast_in_data = self._json_encoder.default(cast_in_data) - if content_type == self._json_content_type: - value = self._serialize_json(cast_in_data) - return self.to_dict(self.name, value) - raise NotImplementedError('Serialization of {} has not yet been implemented'.format(content_type)) - - -class HeaderParameter(ParameterBase, StyleSimpleSerializer): - def __init__( - self, - name: str, - required: bool = False, - style: typing.Optional[ParameterStyle] = None, - explode: bool = False, - allow_reserved: typing.Optional[bool] = None, - schema: typing.Optional[typing.Type[Schema]] = None, - content: typing.Optional[typing.Dict[str, typing.Type[Schema]]] = None - ): - super().__init__( - name, - in_type=ParameterInType.HEADER, - required=required, - style=style, - explode=explode, - allow_reserved=allow_reserved, - schema=schema, - content=content - ) - - @staticmethod - def __to_headers(in_data: typing.Tuple[typing.Tuple[str, str], ...]) -> HTTPHeaderDict[str, str]: - data = tuple(t for t in in_data if t) - headers = HTTPHeaderDict() - if not data: - return headers - headers.extend(data) - return headers - - def _serialize_simple( - self, - in_data: typing.Union[None, int, float, str, bool, dict, list], - ) -> str: - return self.serialize_simple(in_data, self.name, self.explode, False) - - def serialize( - self, - in_data: typing.Union[ - Schema, Decimal, int, float, str, date, datetime, None, bool, list, tuple, dict, frozendict] - ) -> HTTPHeaderDict[str, str]: - if self.schema: - cast_in_data = self.schema(in_data) - cast_in_data = self._json_encoder.default(cast_in_data) - """ - simple -> header - headers: PoolManager needs a mapping, tuple is close - returns headers: dict - """ - if self.style: - value = self._serialize_simple(cast_in_data) - return self.__to_headers(((self.name, value),)) - # self.content will be length one - for content_type, schema in self.content.items(): - cast_in_data = schema(in_data) - cast_in_data = self._json_encoder.default(cast_in_data) - if content_type == self._json_content_type: - value = self._serialize_json(cast_in_data) - return self.__to_headers(((self.name, value),)) - raise NotImplementedError('Serialization of {} has not yet been implemented'.format(content_type)) - - -class Encoding: - def __init__( - self, - content_type: str, - headers: typing.Optional[typing.Dict[str, HeaderParameter]] = None, - style: typing.Optional[ParameterStyle] = None, - explode: bool = False, - allow_reserved: bool = False, - ): - self.content_type = content_type - self.headers = headers - self.style = style - self.explode = explode - self.allow_reserved = allow_reserved - - -@dataclass -class MediaType: - """ - Used to store request and response body schema information - encoding: - A map between a property name and its encoding information. - The key, being the property name, MUST exist in the schema as a property. - The encoding object SHALL only apply to requestBody objects when the media type is - multipart or application/x-www-form-urlencoded. - """ - schema: typing.Optional[typing.Type[Schema]] = None - encoding: typing.Optional[typing.Dict[str, Encoding]] = None - - -@dataclass -class ApiResponse: - response: urllib3.HTTPResponse - body: typing.Union[Unset, typing.Type[Schema]] - headers: typing.Union[Unset, typing.List[HeaderParameter]] - - def __init__( - self, - response: urllib3.HTTPResponse, - body: typing.Union[Unset, typing.Type[Schema]], - headers: typing.Union[Unset, typing.List[HeaderParameter]] - ): - """ - pycharm needs this to prevent 'Unexpected argument' warnings - """ - self.response = response - self.body = body - self.headers = headers - - -@dataclass -class ApiResponseWithoutDeserialization(ApiResponse): - response: urllib3.HTTPResponse - body: typing.Union[Unset, typing.Type[Schema]] = unset - headers: typing.Union[Unset, typing.List[HeaderParameter]] = unset - - -class JSONDetector: - @staticmethod - def content_type_is_json(content_type: str) -> bool: - """ - for when content_type strings also include charset info like: - application/json; charset=UTF-8 - """ - content_type_piece = content_type.split(';')[0] - if content_type_piece == 'application/json': - return True - return False - - -class OpenApiResponse(JSONDetector): - def __init__( - self, - response_cls: typing.Type[ApiResponse] = ApiResponse, - content: typing.Optional[typing.Dict[str, MediaType]] = None, - headers: typing.Optional[typing.List[HeaderParameter]] = None, - ): - self.headers = headers - if content is not None and len(content) == 0: - raise ValueError('Invalid value for content, the content dict must have >= 1 entry') - self.content = content - self.response_cls = response_cls - - @staticmethod - def __deserialize_json(response: urllib3.HTTPResponse) -> typing.Any: - # python must be >= 3.9 so we can pass in bytes into json.loads - return json.loads(response.data) - - @staticmethod - def __file_name_from_content_disposition(content_disposition: typing.Optional[str]) -> typing.Optional[str]: - if content_disposition is None: - return None - match = re.search('filename="(.+?)"', content_disposition) - if not match: - return None - return match.group(1) - - def __deserialize_application_octet_stream( - self, response: urllib3.HTTPResponse - ) -> typing.Union[bytes, io.BufferedReader]: - """ - urllib3 use cases: - 1. when preload_content=True (stream=False) then supports_chunked_reads is False and bytes are returned - 2. when preload_content=False (stream=True) then supports_chunked_reads is True and - a file will be written and returned - """ - if response.supports_chunked_reads(): - file_name = self.__file_name_from_content_disposition(response.headers.get('content-disposition')) - - if file_name is None: - _fd, path = tempfile.mkstemp() - else: - path = os.path.join(tempfile.gettempdir(), file_name) - # TODO get file_name from the filename at the end of the url if it exists - with open(path, 'wb') as new_file: - chunk_size = 1024 - while True: - data = response.read(chunk_size) - if not data: - break - new_file.write(data) - # release_conn is needed for streaming connections only - response.release_conn() - new_file = open(path, 'rb') - return new_file - else: - return response.data - - @staticmethod - def __deserialize_multipart_form_data( - response: urllib3.HTTPResponse - ) -> typing.Dict[str, typing.Any]: - msg = email.message_from_bytes(response.data) - return { - part.get_param("name", header="Content-Disposition"): part.get_payload( - decode=True - ).decode(part.get_content_charset()) - if part.get_content_charset() - else part.get_payload() - for part in msg.get_payload() - } - - def deserialize(self, response: urllib3.HTTPResponse, configuration: Configuration) -> ApiResponse: - content_type = response.getheader('content-type') - deserialized_body = unset - streamed = response.supports_chunked_reads() - - deserialized_headers = unset - if self.headers is not None: - # TODO add header deserialiation here - pass - - if self.content is not None: - if content_type not in self.content: - raise ApiValueError( - f'Invalid content_type={content_type} returned for response with ' - 'status_code={str(response.status)}' - ) - body_schema = self.content[content_type].schema - if body_schema is None: - # some specs do not define response content media type schemas - return self.response_cls( - response=response, - headers=deserialized_headers, - body=unset - ) - - if self.content_type_is_json(content_type): - body_data = self.__deserialize_json(response) - elif content_type == 'application/octet-stream': - body_data = self.__deserialize_application_octet_stream(response) - elif content_type.startswith('multipart/form-data'): - body_data = self.__deserialize_multipart_form_data(response) - content_type = 'multipart/form-data' - else: - raise NotImplementedError('Deserialization of {} has not yet been implemented'.format(content_type)) - deserialized_body = body_schema._from_openapi_data( - body_data, _configuration=configuration) - elif streamed: - response.release_conn() - - return self.response_cls( - response=response, - headers=deserialized_headers, - body=deserialized_body - ) - - -class ApiClient: - """Generic API client for OpenAPI client library builds. - - OpenAPI generic API client. This client handles the client- - server communication, and is invariant across implementations. Specifics of - the methods and models for each application are generated from the OpenAPI - templates. - - NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - Do not edit the class manually. - - :param configuration: .Configuration object for this client - :param header_name: a header to pass when making calls to the API. - :param header_value: a header value to pass when making calls to - the API. - :param cookie: a cookie to include in the header when making calls - to the API - :param pool_threads: The number of threads to use for async requests - to the API. More threads means more concurrent API requests. - """ - - _pool = None - __json_encoder = JSONEncoder() - - def __init__( - self, - configuration: typing.Optional[Configuration] = None, - header_name: typing.Optional[str] = None, - header_value: typing.Optional[str] = None, - cookie: typing.Optional[str] = None, - pool_threads: int = 1 - ): - if configuration is None: - configuration = Configuration() - self.configuration = configuration - self.pool_threads = pool_threads - - self.rest_client = rest.RESTClientObject(configuration) - self.default_headers = {} - if header_name is not None: - self.default_headers[header_name] = header_value - self.cookie = cookie - # Set default User-Agent. - self.user_agent = 'OpenAPI-Generator/1.0.0/python' - - def __enter__(self): - return self - - def __exit__(self, exc_type, exc_value, traceback): - self.close() - - def close(self): - if self._pool: - self._pool.close() - self._pool.join() - self._pool = None - if hasattr(atexit, 'unregister'): - atexit.unregister(self.close) - - @property - def pool(self): - """Create thread pool on first request - avoids instantiating unused threadpool for blocking clients. - """ - if self._pool is None: - atexit.register(self.close) - self._pool = ThreadPool(self.pool_threads) - return self._pool - - @property - def user_agent(self): - """User agent for this API client""" - return self.default_headers['User-Agent'] - - @user_agent.setter - def user_agent(self, value): - self.default_headers['User-Agent'] = value - - def set_default_header(self, header_name, header_value): - self.default_headers[header_name] = header_value - - def __call_api( - self, - resource_path: str, - method: str, - headers: typing.Optional[HTTPHeaderDict] = None, - body: typing.Optional[typing.Union[str, bytes]] = None, - fields: typing.Optional[typing.Tuple[typing.Tuple[str, str], ...]] = None, - auth_settings: typing.Optional[typing.List[str]] = None, - stream: bool = False, - timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - host: typing.Optional[str] = None, - ) -> urllib3.HTTPResponse: - - # header parameters - headers = headers or {} - headers.update(self.default_headers) - if self.cookie: - headers['Cookie'] = self.cookie - - # auth setting - self.update_params_for_auth(headers, - auth_settings, resource_path, method, body) - - # request url - if host is None: - url = self.configuration.host + resource_path - else: - # use server/host defined in path or operation instead - url = host + resource_path - - # perform request and return response - response = self.request( - method, - url, - headers=headers, - fields=fields, - body=body, - stream=stream, - timeout=timeout, - ) - return response - - def call_api( - self, - resource_path: str, - method: str, - headers: typing.Optional[HTTPHeaderDict] = None, - body: typing.Optional[typing.Union[str, bytes]] = None, - fields: typing.Optional[typing.Tuple[typing.Tuple[str, str], ...]] = None, - auth_settings: typing.Optional[typing.List[str]] = None, - async_req: typing.Optional[bool] = None, - stream: bool = False, - timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - host: typing.Optional[str] = None, - ) -> urllib3.HTTPResponse: - """Makes the HTTP request (synchronous) and returns deserialized data. - - To make an async_req request, set the async_req parameter. - - :param resource_path: Path to method endpoint. - :param method: Method to call. - :param headers: Header parameters to be - placed in the request header. - :param body: Request body. - :param fields: Request post form parameters, - for `application/x-www-form-urlencoded`, `multipart/form-data`. - :param auth_settings: Auth Settings names for the request. - :param async_req: execute request asynchronously - :type async_req: bool, optional TODO remove, unused - :param stream: if True, the urllib3.HTTPResponse object will - be returned without reading/decoding response - data. Also when True, if the openapi spec describes a file download, - the data will be written to a local filesystme file and the BinarySchema - instance will also inherit from FileSchema and FileIO - Default is False. - :type stream: bool, optional - :param timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :param host: api endpoint host - :return: - If async_req parameter is True, - the request will be called asynchronously. - The method will return the request thread. - If parameter async_req is False or missing, - then the method will return the response directly. - """ - - if not async_req: - return self.__call_api( - resource_path, - method, - headers, - body, - fields, - auth_settings, - stream, - timeout, - host, - ) - - return self.pool.apply_async( - self.__call_api, - ( - resource_path, - method, - headers, - body, - json, - fields, - auth_settings, - stream, - timeout, - host, - ) - ) - - def request( - self, - method: str, - url: str, - headers: typing.Optional[HTTPHeaderDict] = None, - fields: typing.Optional[typing.Tuple[typing.Tuple[str, str], ...]] = None, - body: typing.Optional[typing.Union[str, bytes]] = None, - stream: bool = False, - timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - ) -> urllib3.HTTPResponse: - """Makes the HTTP request using RESTClient.""" - if method == "GET": - return self.rest_client.GET(url, - stream=stream, - timeout=timeout, - headers=headers) - elif method == "HEAD": - return self.rest_client.HEAD(url, - stream=stream, - timeout=timeout, - headers=headers) - elif method == "OPTIONS": - return self.rest_client.OPTIONS(url, - headers=headers, - fields=fields, - stream=stream, - timeout=timeout, - body=body) - elif method == "POST": - return self.rest_client.POST(url, - headers=headers, - fields=fields, - stream=stream, - timeout=timeout, - body=body) - elif method == "PUT": - return self.rest_client.PUT(url, - headers=headers, - fields=fields, - stream=stream, - timeout=timeout, - body=body) - elif method == "PATCH": - return self.rest_client.PATCH(url, - headers=headers, - fields=fields, - stream=stream, - timeout=timeout, - body=body) - elif method == "DELETE": - return self.rest_client.DELETE(url, - headers=headers, - stream=stream, - timeout=timeout, - body=body) - else: - raise ApiValueError( - "http method must be `GET`, `HEAD`, `OPTIONS`," - " `POST`, `PATCH`, `PUT` or `DELETE`." - ) - - def update_params_for_auth(self, headers, auth_settings, - resource_path, method, body): - """Updates header and query params based on authentication setting. - - :param headers: Header parameters dict to be updated. - :param auth_settings: Authentication setting identifiers list. - :param resource_path: A string representation of the HTTP request resource path. - :param method: A string representation of the HTTP request method. - :param body: A object representing the body of the HTTP request. - The object type is the return value of _encoder.default(). - """ - if not auth_settings: - return - - for auth in auth_settings: - auth_setting = self.configuration.auth_settings().get(auth) - if auth_setting: - if auth_setting['in'] == 'cookie': - headers.add('Cookie', auth_setting['value']) - elif auth_setting['in'] == 'header': - if auth_setting['type'] != 'http-signature': - headers.add(auth_setting['key'], auth_setting['value']) - elif auth_setting['in'] == 'query': - """ TODO implement auth in query - need to pass in prefix_separator_iterator - and need to output resource_path with query params added - """ - raise ApiValueError("Auth in query not yet implemented") - else: - raise ApiValueError( - 'Authentication token must be in `query` or `header`' - ) - - -class Api: - """NOTE: This class is auto generated by OpenAPI Generator - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - def __init__(self, api_client: typing.Optional[ApiClient] = None): - if api_client is None: - api_client = ApiClient() - self.api_client = api_client - - @staticmethod - def _verify_typed_dict_inputs(cls: typing.Type[typing.TypedDict], data: typing.Dict[str, typing.Any]): - """ - Ensures that: - - required keys are present - - additional properties are not input - - value stored under required keys do not have the value unset - Note: detailed value checking is done in schema classes - """ - missing_required_keys = [] - required_keys_with_unset_values = [] - for required_key in cls.__required_keys__: - if required_key not in data: - missing_required_keys.append(required_key) - continue - value = data[required_key] - if value is unset: - required_keys_with_unset_values.append(required_key) - if missing_required_keys: - raise ApiTypeError( - '{} missing {} required arguments: {}'.format( - cls.__name__, len(missing_required_keys), missing_required_keys - ) - ) - if required_keys_with_unset_values: - raise ApiValueError( - '{} contains invalid unset values for {} required keys: {}'.format( - cls.__name__, len(required_keys_with_unset_values), required_keys_with_unset_values - ) - ) - - disallowed_additional_keys = [] - for key in data: - if key in cls.__required_keys__ or key in cls.__optional_keys__: - continue - disallowed_additional_keys.append(key) - if disallowed_additional_keys: - raise ApiTypeError( - '{} got {} unexpected keyword arguments: {}'.format( - cls.__name__, len(disallowed_additional_keys), disallowed_additional_keys - ) - ) - - def get_host( - self, - operation_id: str, - servers: typing.Tuple[typing.Dict[str, str], ...] = tuple(), - host_index: typing.Optional[int] = None - ) -> typing.Optional[str]: - configuration = self.api_client.configuration - try: - if host_index is None: - index = configuration.server_operation_index.get( - operation_id, configuration.server_index - ) - else: - index = host_index - server_variables = configuration.server_operation_variables.get( - operation_id, configuration.server_variables - ) - host = configuration.get_host_from_settings( - index, variables=server_variables, servers=servers - ) - except IndexError: - if servers: - raise ApiValueError( - "Invalid host index. Must be 0 <= index < %s" % - len(servers) - ) - host = None - return host - - -class SerializedRequestBody(typing.TypedDict, total=False): - body: typing.Union[str, bytes] - fields: typing.Tuple[typing.Union[RequestField, tuple[str, str]], ...] - - -class RequestBody(StyleFormSerializer, JSONDetector): - """ - A request body parameter - content: content_type to MediaType Schema info - """ - __json_encoder = JSONEncoder() - - def __init__( - self, - content: typing.Dict[str, MediaType], - required: bool = False, - ): - self.required = required - if len(content) == 0: - raise ValueError('Invalid value for content, the content dict must have >= 1 entry') - self.content = content - - def __serialize_json( - self, - in_data: typing.Any - ) -> typing.Dict[str, bytes]: - in_data = self.__json_encoder.default(in_data) - json_str = json.dumps(in_data, separators=(",", ":"), ensure_ascii=False).encode( - "utf-8" - ) - return dict(body=json_str) - - @staticmethod - def __serialize_text_plain(in_data: typing.Any) -> typing.Dict[str, str]: - if isinstance(in_data, frozendict): - raise ValueError('Unable to serialize type frozendict to text/plain') - elif isinstance(in_data, tuple): - raise ValueError('Unable to serialize type tuple to text/plain') - elif isinstance(in_data, NoneClass): - raise ValueError('Unable to serialize type NoneClass to text/plain') - elif isinstance(in_data, BoolClass): - raise ValueError('Unable to serialize type BoolClass to text/plain') - return dict(body=str(in_data)) - - def __multipart_json_item(self, key: str, value: Schema) -> RequestField: - json_value = self.__json_encoder.default(value) - return RequestField(name=key, data=json.dumps(json_value), headers={'Content-Type': 'application/json'}) - - def __multipart_form_item(self, key: str, value: Schema) -> RequestField: - if isinstance(value, str): - return RequestField(name=key, data=str(value), headers={'Content-Type': 'text/plain'}) - elif isinstance(value, bytes): - return RequestField(name=key, data=value, headers={'Content-Type': 'application/octet-stream'}) - elif isinstance(value, FileIO): - request_field = RequestField( - name=key, - data=value.read(), - filename=os.path.basename(value.name), - headers={'Content-Type': 'application/octet-stream'} - ) - value.close() - return request_field - else: - return self.__multipart_json_item(key=key, value=value) - - def __serialize_multipart_form_data( - self, in_data: Schema - ) -> typing.Dict[str, typing.Tuple[RequestField, ...]]: - if not isinstance(in_data, frozendict): - raise ValueError(f'Unable to serialize {in_data} to multipart/form-data because it is not a dict of data') - """ - In a multipart/form-data request body, each schema property, or each element of a schema array property, - takes a section in the payload with an internal header as defined by RFC7578. The serialization strategy - for each property of a multipart/form-data request body can be specified in an associated Encoding Object. - - When passing in multipart types, boundaries MAY be used to separate sections of the content being - transferred – thus, the following default Content-Types are defined for multipart: - - If the (object) property is a primitive, or an array of primitive values, the default Content-Type is text/plain - If the property is complex, or an array of complex values, the default Content-Type is application/json - Question: how is the array of primitives encoded? - If the property is a type: string with a contentEncoding, the default Content-Type is application/octet-stream - """ - fields = [] - for key, value in in_data.items(): - if isinstance(value, tuple): - if value: - # values use explode = True, so the code makes a RequestField for each item with name=key - for item in value: - request_field = self.__multipart_form_item(key=key, value=item) - fields.append(request_field) - else: - # send an empty array as json because exploding will not send it - request_field = self.__multipart_json_item(key=key, value=value) - fields.append(request_field) - else: - request_field = self.__multipart_form_item(key=key, value=value) - fields.append(request_field) - - return dict(fields=tuple(fields)) - - def __serialize_application_octet_stream(self, in_data: BinarySchema) -> typing.Dict[str, bytes]: - if isinstance(in_data, bytes): - return dict(body=in_data) - # FileIO type - result = dict(body=in_data.read()) - in_data.close() - return result - - def __serialize_application_x_www_form_data( - self, in_data: typing.Any - ) -> SerializedRequestBody: - """ - POST submission of form data in body - """ - if not isinstance(in_data, frozendict): - raise ValueError( - f'Unable to serialize {in_data} to application/x-www-form-urlencoded because it is not a dict of data') - cast_in_data = self.__json_encoder.default(in_data) - value = self.serialize_form(cast_in_data, name='', explode=True, percent_encode=False) - return dict(body=value) - - def serialize( - self, in_data: typing.Any, content_type: str - ) -> SerializedRequestBody: - """ - If a str is returned then the result will be assigned to data when making the request - If a tuple is returned then the result will be used as fields input in encode_multipart_formdata - Return a tuple of - - The key of the return dict is - - body for application/json - - encode_multipart and fields for multipart/form-data - """ - media_type = self.content[content_type] - if isinstance(in_data, media_type.schema): - cast_in_data = in_data - elif isinstance(in_data, (dict, frozendict)) and in_data: - cast_in_data = media_type.schema(**in_data) - else: - cast_in_data = media_type.schema(in_data) - # TODO check for and use encoding if it exists - # and content_type is multipart or application/x-www-form-urlencoded - if self.content_type_is_json(content_type): - return self.__serialize_json(cast_in_data) - elif content_type == 'text/plain': - return self.__serialize_text_plain(cast_in_data) - elif content_type == 'multipart/form-data': - return self.__serialize_multipart_form_data(cast_in_data) - elif content_type == 'application/x-www-form-urlencoded': - return self.__serialize_application_x_www_form_data(cast_in_data) - elif content_type == 'application/octet-stream': - return self.__serialize_application_octet_stream(cast_in_data) - raise NotImplementedError('Serialization has not yet been implemented for {}'.format(content_type)) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/configuration.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/configuration.py deleted file mode 100644 index 80407ef4b44..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/configuration.py +++ /dev/null @@ -1,440 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import copy -import logging -import multiprocessing -import sys -import urllib3 - -from http import client as http_client -from unit_test_api.exceptions import ApiValueError - - -JSON_SCHEMA_VALIDATION_KEYWORDS = { - 'multipleOf', 'maximum', 'exclusiveMaximum', - 'minimum', 'exclusiveMinimum', 'maxLength', - 'minLength', 'pattern', 'maxItems', 'minItems', - 'uniqueItems', 'maxProperties', 'minProperties', -} - -class Configuration(object): - """NOTE: This class is auto generated by OpenAPI Generator - - Ref: https://openapi-generator.tech - Do not edit the class manually. - - :param host: Base url - :param api_key: Dict to store API key(s). - Each entry in the dict specifies an API key. - The dict key is the name of the security scheme in the OAS specification. - The dict value is the API key secret. - :param api_key_prefix: Dict to store API prefix (e.g. Bearer) - The dict key is the name of the security scheme in the OAS specification. - The dict value is an API key prefix when generating the auth data. - :param username: Username for HTTP basic authentication - :param password: Password for HTTP basic authentication - :param discard_unknown_keys: Boolean value indicating whether to discard - unknown properties. A server may send a response that includes additional - properties that are not known by the client in the following scenarios: - 1. The OpenAPI document is incomplete, i.e. it does not match the server - implementation. - 2. The client was generated using an older version of the OpenAPI document - and the server has been upgraded since then. - If a schema in the OpenAPI document defines the additionalProperties attribute, - then all undeclared properties received by the server are injected into the - additional properties map. In that case, there are undeclared properties, and - nothing to discard. - :param disabled_client_side_validations (string): Comma-separated list of - JSON schema validation keywords to disable JSON schema structural validation - rules. The following keywords may be specified: multipleOf, maximum, - exclusiveMaximum, minimum, exclusiveMinimum, maxLength, minLength, pattern, - maxItems, minItems. - By default, the validation is performed for data generated locally by the client - and data received from the server, independent of any validation performed by - the server side. If the input data does not satisfy the JSON schema validation - rules specified in the OpenAPI document, an exception is raised. - If disabled_client_side_validations is set, structural validation is - disabled. This can be useful to troubleshoot data validation problem, such as - when the OpenAPI document validation rules do not match the actual API data - received by the server. - :param server_index: Index to servers configuration. - :param server_variables: Mapping with string values to replace variables in - templated server configuration. The validation of enums is performed for - variables with defined enum values before. - :param server_operation_index: Mapping from operation ID to an index to server - configuration. - :param server_operation_variables: Mapping from operation ID to a mapping with - string values to replace variables in templated server configuration. - The validation of enums is performed for variables with defined enum values before. - - """ - - _default = None - - def __init__(self, host=None, - api_key=None, api_key_prefix=None, - username=None, password=None, - discard_unknown_keys=False, - disabled_client_side_validations="", - server_index=None, server_variables=None, - server_operation_index=None, server_operation_variables=None, - ): - """Constructor - """ - self._base_path = "http://localhost" if host is None else host - """Default Base url - """ - self.server_index = 0 if server_index is None and host is None else server_index - self.server_operation_index = server_operation_index or {} - """Default server index - """ - self.server_variables = server_variables or {} - self.server_operation_variables = server_operation_variables or {} - """Default server variables - """ - self.temp_folder_path = None - """Temp file folder for downloading files - """ - # Authentication Settings - self.api_key = {} - if api_key: - self.api_key = api_key - """dict to store API key(s) - """ - self.api_key_prefix = {} - if api_key_prefix: - self.api_key_prefix = api_key_prefix - """dict to store API prefix (e.g. Bearer) - """ - self.refresh_api_key_hook = None - """function hook to refresh API key if expired - """ - self.username = username - """Username for HTTP basic authentication - """ - self.password = password - """Password for HTTP basic authentication - """ - self.discard_unknown_keys = discard_unknown_keys - self.disabled_client_side_validations = disabled_client_side_validations - self.logger = {} - """Logging Settings - """ - self.logger["package_logger"] = logging.getLogger("unit_test_api") - self.logger["urllib3_logger"] = logging.getLogger("urllib3") - self.logger_format = '%(asctime)s %(levelname)s %(message)s' - """Log format - """ - self.logger_stream_handler = None - """Log stream handler - """ - self.logger_file_handler = None - """Log file handler - """ - self.logger_file = None - """Debug file location - """ - self.debug = False - """Debug switch - """ - - self.verify_ssl = True - """SSL/TLS verification - Set this to false to skip verifying SSL certificate when calling API - from https server. - """ - self.ssl_ca_cert = None - """Set this to customize the certificate file to verify the peer. - """ - self.cert_file = None - """client certificate file - """ - self.key_file = None - """client key file - """ - self.assert_hostname = None - """Set this to True/False to enable/disable SSL hostname verification. - """ - - self.connection_pool_maxsize = multiprocessing.cpu_count() * 5 - """urllib3 connection pool's maximum number of connections saved - per pool. urllib3 uses 1 connection as default value, but this is - not the best value when you are making a lot of possibly parallel - requests to the same host, which is often the case here. - cpu_count * 5 is used as default value to increase performance. - """ - - self.proxy = None - """Proxy URL - """ - self.proxy_headers = None - """Proxy headers - """ - self.safe_chars_for_path_param = '' - """Safe chars for path_param - """ - self.retries = None - """Adding retries to override urllib3 default value 3 - """ - # Enable client side validation - self.client_side_validation = True - - # Options to pass down to the underlying urllib3 socket - self.socket_options = None - - def __deepcopy__(self, memo): - cls = self.__class__ - result = cls.__new__(cls) - memo[id(self)] = result - for k, v in self.__dict__.items(): - if k not in ('logger', 'logger_file_handler'): - setattr(result, k, copy.deepcopy(v, memo)) - # shallow copy of loggers - result.logger = copy.copy(self.logger) - # use setters to configure loggers - result.logger_file = self.logger_file - result.debug = self.debug - return result - - def __setattr__(self, name, value): - object.__setattr__(self, name, value) - if name == 'disabled_client_side_validations': - s = set(filter(None, value.split(','))) - for v in s: - if v not in JSON_SCHEMA_VALIDATION_KEYWORDS: - raise ApiValueError( - "Invalid keyword: '{0}''".format(v)) - self._disabled_client_side_validations = s - - @classmethod - def set_default(cls, default): - """Set default instance of configuration. - - It stores default configuration, which can be - returned by get_default_copy method. - - :param default: object of Configuration - """ - cls._default = copy.deepcopy(default) - - @classmethod - def get_default_copy(cls): - """Return new instance of configuration. - - This method returns newly created, based on default constructor, - object of Configuration class or returns a copy of default - configuration passed by the set_default method. - - :return: The configuration object. - """ - if cls._default is not None: - return copy.deepcopy(cls._default) - return Configuration() - - @property - def logger_file(self): - """The logger file. - - If the logger_file is None, then add stream handler and remove file - handler. Otherwise, add file handler and remove stream handler. - - :param value: The logger_file path. - :type: str - """ - return self.__logger_file - - @logger_file.setter - def logger_file(self, value): - """The logger file. - - If the logger_file is None, then add stream handler and remove file - handler. Otherwise, add file handler and remove stream handler. - - :param value: The logger_file path. - :type: str - """ - self.__logger_file = value - if self.__logger_file: - # If set logging file, - # then add file handler and remove stream handler. - self.logger_file_handler = logging.FileHandler(self.__logger_file) - self.logger_file_handler.setFormatter(self.logger_formatter) - for _, logger in self.logger.items(): - logger.addHandler(self.logger_file_handler) - - @property - def debug(self): - """Debug status - - :param value: The debug status, True or False. - :type: bool - """ - return self.__debug - - @debug.setter - def debug(self, value): - """Debug status - - :param value: The debug status, True or False. - :type: bool - """ - self.__debug = value - if self.__debug: - # if debug status is True, turn on debug logging - for _, logger in self.logger.items(): - logger.setLevel(logging.DEBUG) - # turn on http_client debug - http_client.HTTPConnection.debuglevel = 1 - else: - # if debug status is False, turn off debug logging, - # setting log level to default `logging.WARNING` - for _, logger in self.logger.items(): - logger.setLevel(logging.WARNING) - # turn off http_client debug - http_client.HTTPConnection.debuglevel = 0 - - @property - def logger_format(self): - """The logger format. - - The logger_formatter will be updated when sets logger_format. - - :param value: The format string. - :type: str - """ - return self.__logger_format - - @logger_format.setter - def logger_format(self, value): - """The logger format. - - The logger_formatter will be updated when sets logger_format. - - :param value: The format string. - :type: str - """ - self.__logger_format = value - self.logger_formatter = logging.Formatter(self.__logger_format) - - def get_api_key_with_prefix(self, identifier, alias=None): - """Gets API key (with prefix if set). - - :param identifier: The identifier of apiKey. - :param alias: The alternative identifier of apiKey. - :return: The token for api key authentication. - """ - if self.refresh_api_key_hook is not None: - self.refresh_api_key_hook(self) - key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None) - if key: - prefix = self.api_key_prefix.get(identifier) - if prefix: - return "%s %s" % (prefix, key) - else: - return key - - def get_basic_auth_token(self): - """Gets HTTP basic authentication header (string). - - :return: The token for basic HTTP authentication. - """ - username = "" - if self.username is not None: - username = self.username - password = "" - if self.password is not None: - password = self.password - return urllib3.util.make_headers( - basic_auth=username + ':' + password - ).get('authorization') - - def auth_settings(self): - """Gets Auth Settings dict for api client. - - :return: The Auth Settings information dict. - """ - auth = {} - return auth - - def to_debug_report(self): - """Gets the essential information for debugging. - - :return: The report for debugging. - """ - return "Python SDK Debug Report:\n"\ - "OS: {env}\n"\ - "Python Version: {pyversion}\n"\ - "Version of the API: 0.0.1\n"\ - "SDK Package Version: 1.0.0".\ - format(env=sys.platform, pyversion=sys.version) - - def get_host_settings(self): - """Gets an array of host settings - - :return: An array of host settings - """ - return [ - { - 'url': "", - 'description': "No description provided", - } - ] - - def get_host_from_settings(self, index, variables=None, servers=None): - """Gets host URL based on the index and variables - :param index: array index of the host settings - :param variables: hash of variable and the corresponding value - :param servers: an array of host settings or None - :return: URL based on host settings - """ - if index is None: - return self._base_path - - variables = {} if variables is None else variables - servers = self.get_host_settings() if servers is None else servers - - try: - server = servers[index] - except IndexError: - raise ValueError( - "Invalid index {0} when selecting the host settings. " - "Must be less than {1}".format(index, len(servers))) - - url = server['url'] - - # go through variables and replace placeholders - for variable_name, variable in server.get('variables', {}).items(): - used_value = variables.get( - variable_name, variable['default_value']) - - if 'enum_values' in variable \ - and used_value not in variable['enum_values']: - raise ValueError( - "The variable `{0}` in the host URL has invalid value " - "{1}. Must be {2}.".format( - variable_name, variables[variable_name], - variable['enum_values'])) - - url = url.replace("{" + variable_name + "}", used_value) - - return url - - @property - def host(self): - """Return generated host.""" - return self.get_host_from_settings(self.server_index, variables=self.server_variables) - - @host.setter - def host(self, value): - """Fix base path.""" - self._base_path = value - self.server_index = None diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/exceptions.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/exceptions.py deleted file mode 100644 index 54a51c36ab4..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/exceptions.py +++ /dev/null @@ -1,136 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - - -class OpenApiException(Exception): - """The base exception class for all OpenAPIExceptions""" - - -class ApiTypeError(OpenApiException, TypeError): - def __init__(self, msg, path_to_item=None, valid_classes=None, - key_type=None): - """ Raises an exception for TypeErrors - - Args: - msg (str): the exception message - - Keyword Args: - path_to_item (list): a list of keys an indices to get to the - current_item - None if unset - valid_classes (tuple): the primitive classes that current item - should be an instance of - None if unset - key_type (bool): False if our value is a value in a dict - True if it is a key in a dict - False if our item is an item in a list - None if unset - """ - self.path_to_item = path_to_item - self.valid_classes = valid_classes - self.key_type = key_type - full_msg = msg - if path_to_item: - full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) - super(ApiTypeError, self).__init__(full_msg) - - -class ApiValueError(OpenApiException, ValueError): - def __init__(self, msg, path_to_item=None): - """ - Args: - msg (str): the exception message - - Keyword Args: - path_to_item (list) the path to the exception in the - received_data dict. None if unset - """ - - self.path_to_item = path_to_item - full_msg = msg - if path_to_item: - full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) - super(ApiValueError, self).__init__(full_msg) - - -class ApiAttributeError(OpenApiException, AttributeError): - def __init__(self, msg, path_to_item=None): - """ - Raised when an attribute reference or assignment fails. - - Args: - msg (str): the exception message - - Keyword Args: - path_to_item (None/list) the path to the exception in the - received_data dict - """ - self.path_to_item = path_to_item - full_msg = msg - if path_to_item: - full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) - super(ApiAttributeError, self).__init__(full_msg) - - -class ApiKeyError(OpenApiException, KeyError): - def __init__(self, msg, path_to_item=None): - """ - Args: - msg (str): the exception message - - Keyword Args: - path_to_item (None/list) the path to the exception in the - received_data dict - """ - self.path_to_item = path_to_item - full_msg = msg - if path_to_item: - full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) - super(ApiKeyError, self).__init__(full_msg) - - -class ApiException(OpenApiException): - - def __init__(self, status=None, reason=None, api_response: 'unit_test_api.api_client.ApiResponse' = None): - if api_response: - self.status = api_response.response.status - self.reason = api_response.response.reason - self.body = api_response.response.data - self.headers = api_response.response.getheaders() - else: - self.status = status - self.reason = reason - self.body = None - self.headers = None - - def __str__(self): - """Custom error messages for exception""" - error_message = "({0})\n"\ - "Reason: {1}\n".format(self.status, self.reason) - if self.headers: - error_message += "HTTP response headers: {0}\n".format( - self.headers) - - if self.body: - error_message += "HTTP response body: {0}\n".format(self.body) - - return error_message - - -def render_path(path_to_item): - """Returns a string representation of a path""" - result = "" - for pth in path_to_item: - if isinstance(pth, int): - result += "[{0}]".format(pth) - else: - result += "['{0}']".format(pth) - return result diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/__init__.py deleted file mode 100644 index 0056d7a31eb..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -# we can not import model classes here because that would create a circular -# reference which would not work in python2 -# do not import all models into this module because that uses a lot of memory and stack frames -# if you need the ability to import all models from one package, import them with -# from unit_test_api.models import ModelA, ModelB diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/pattern_is_not_anchored.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/pattern_is_not_anchored.py deleted file mode 100644 index 63923788782..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/pattern_is_not_anchored.py +++ /dev/null @@ -1,94 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class PatternIsNotAnchored( - _SchemaValidator( - regex=[{ - 'pattern': r'a+', # noqa: E501 - }], - ), - AnyTypeSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'PatternIsNotAnchored': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/pattern_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/pattern_validation.py deleted file mode 100644 index 60d4530a637..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/pattern_validation.py +++ /dev/null @@ -1,94 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class PatternValidation( - _SchemaValidator( - regex=[{ - 'pattern': r'^a*$', # noqa: E501 - }], - ), - AnyTypeSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'PatternValidation': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py deleted file mode 100644 index 3f0a236918d..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# coding: utf-8 - -# flake8: noqa - -# import all models into this package -# if you have many models here with many references from one model to another this may -# raise a RecursionError -# to avoid this, import only the models that you directly need like: -# from from unit_test_api.model.pet import Pet -# or import this package, but before doing it, use: -# import sys -# sys.setrecursionlimit(n) - -from unit_test_api.model.pattern_is_not_anchored import PatternIsNotAnchored -from unit_test_api.model.pattern_validation import PatternValidation diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/rest.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/rest.py deleted file mode 100644 index 75a309eed90..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/rest.py +++ /dev/null @@ -1,253 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import logging -import ssl -from urllib.parse import urlencode -import typing - -import certifi -import urllib3 -from urllib3._collections import HTTPHeaderDict - -from unit_test_api.exceptions import ApiException, ApiValueError - - -logger = logging.getLogger(__name__) - - -class RESTClientObject(object): - - def __init__(self, configuration, pools_size=4, maxsize=None): - # urllib3.PoolManager will pass all kw parameters to connectionpool - # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501 - # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501 - # maxsize is the number of requests to host that are allowed in parallel # noqa: E501 - # Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501 - - # cert_reqs - if configuration.verify_ssl: - cert_reqs = ssl.CERT_REQUIRED - else: - cert_reqs = ssl.CERT_NONE - - # ca_certs - if configuration.ssl_ca_cert: - ca_certs = configuration.ssl_ca_cert - else: - # if not set certificate file, use Mozilla's root certificates. - ca_certs = certifi.where() - - addition_pool_args = {} - if configuration.assert_hostname is not None: - addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 - - if configuration.retries is not None: - addition_pool_args['retries'] = configuration.retries - - if configuration.socket_options is not None: - addition_pool_args['socket_options'] = configuration.socket_options - - if maxsize is None: - if configuration.connection_pool_maxsize is not None: - maxsize = configuration.connection_pool_maxsize - else: - maxsize = 4 - - # https pool manager - if configuration.proxy: - self.pool_manager = urllib3.ProxyManager( - num_pools=pools_size, - maxsize=maxsize, - cert_reqs=cert_reqs, - ca_certs=ca_certs, - cert_file=configuration.cert_file, - key_file=configuration.key_file, - proxy_url=configuration.proxy, - proxy_headers=configuration.proxy_headers, - **addition_pool_args - ) - else: - self.pool_manager = urllib3.PoolManager( - num_pools=pools_size, - maxsize=maxsize, - cert_reqs=cert_reqs, - ca_certs=ca_certs, - cert_file=configuration.cert_file, - key_file=configuration.key_file, - **addition_pool_args - ) - - def request( - self, - method: str, - url: str, - headers: typing.Optional[HTTPHeaderDict] = None, - fields: typing.Optional[typing.Tuple[typing.Tuple[str, typing.Any], ...]] = None, - body: typing.Optional[typing.Union[str, bytes]] = None, - stream: bool = False, - timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - ) -> urllib3.HTTPResponse: - """Perform requests. - - :param method: http request method - :param url: http request url - :param headers: http request headers - :param body: request body, for other types - :param fields: request parameters for - `application/x-www-form-urlencoded` - or `multipart/form-data` - :param stream: if True, the urllib3.HTTPResponse object will - be returned without reading/decoding response - data. Default is False. - :param timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - """ - method = method.upper() - assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', - 'PATCH', 'OPTIONS'] - - if fields and body: - raise ApiValueError( - "body parameter cannot be used with fields parameter." - ) - - fields = fields or {} - headers = headers or {} - - if timeout: - if isinstance(timeout, (int, float)): # noqa: E501,F821 - timeout = urllib3.Timeout(total=timeout) - elif (isinstance(timeout, tuple) and - len(timeout) == 2): - timeout = urllib3.Timeout(connect=timeout[0], read=timeout[1]) - - try: - # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` - if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: - if 'Content-Type' not in headers and body is None: - r = self.pool_manager.request( - method, - url, - preload_content=not stream, - timeout=timeout, - headers=headers - ) - elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 - r = self.pool_manager.request( - method, url, - fields=fields, - encode_multipart=False, - preload_content=not stream, - timeout=timeout, - headers=headers) - elif headers['Content-Type'] == 'multipart/form-data': - # must del headers['Content-Type'], or the correct - # Content-Type which generated by urllib3 will be - # overwritten. - del headers['Content-Type'] - r = self.pool_manager.request( - method, url, - fields=fields, - encode_multipart=True, - preload_content=not stream, - timeout=timeout, - headers=headers) - # Pass a `string` parameter directly in the body to support - # other content types than Json when `body` argument is - # provided in serialized form - elif isinstance(body, str) or isinstance(body, bytes): - request_body = body - r = self.pool_manager.request( - method, url, - body=request_body, - preload_content=not stream, - timeout=timeout, - headers=headers) - else: - # Cannot generate the request from given parameters - msg = """Cannot prepare a request message for provided - arguments. Please check that your arguments match - declared content type.""" - raise ApiException(status=0, reason=msg) - # For `GET`, `HEAD` - else: - r = self.pool_manager.request(method, url, - preload_content=not stream, - timeout=timeout, - headers=headers) - except urllib3.exceptions.SSLError as e: - msg = "{0}\n{1}".format(type(e).__name__, str(e)) - raise ApiException(status=0, reason=msg) - - if not stream: - # log response body - logger.debug("response body: %s", r.data) - - return r - - def GET(self, url, headers=None, stream=False, - timeout=None, fields=None) -> urllib3.HTTPResponse: - return self.request("GET", url, - headers=headers, - stream=stream, - timeout=timeout, - fields=fields) - - def HEAD(self, url, headers=None, stream=False, - timeout=None, fields=None) -> urllib3.HTTPResponse: - return self.request("HEAD", url, - headers=headers, - stream=stream, - timeout=timeout, - fields=fields) - - def OPTIONS(self, url, headers=None, - body=None, stream=False, timeout=None, fields=None) -> urllib3.HTTPResponse: - return self.request("OPTIONS", url, - headers=headers, - stream=stream, - timeout=timeout, - body=body, fields=fields) - - def DELETE(self, url, headers=None, body=None, - stream=False, timeout=None, fields=None) -> urllib3.HTTPResponse: - return self.request("DELETE", url, - headers=headers, - stream=stream, - timeout=timeout, - body=body, fields=fields) - - def POST(self, url, headers=None, - body=None, stream=False, timeout=None, fields=None) -> urllib3.HTTPResponse: - return self.request("POST", url, - headers=headers, - stream=stream, - timeout=timeout, - body=body, fields=fields) - - def PUT(self, url, headers=None, - body=None, stream=False, timeout=None, fields=None) -> urllib3.HTTPResponse: - return self.request("PUT", url, - headers=headers, - stream=stream, - timeout=timeout, - body=body, fields=fields) - - def PATCH(self, url, headers=None, - body=None, stream=False, timeout=None, fields=None) -> urllib3.HTTPResponse: - return self.request("PATCH", url, - headers=headers, - stream=stream, - timeout=timeout, - body=body, fields=fields) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/schemas.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/schemas.py deleted file mode 100644 index 0b78a94e7c4..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/schemas.py +++ /dev/null @@ -1,2201 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -from collections import defaultdict -from datetime import date, datetime, timedelta # noqa: F401 -import functools -import decimal -import io -import os -import re -import tempfile -import typing -import uuid - -from dateutil.parser.isoparser import isoparser, _takes_ascii -from frozendict import frozendict - -from unit_test_api.exceptions import ( - ApiTypeError, - ApiValueError, -) -from unit_test_api.configuration import ( - Configuration, -) - - -class Unset(object): - """ - An instance of this class is set as the default value for object type(dict) properties that are optional - When a property has an unset value, that property will not be assigned in the dict - """ - pass - -unset = Unset() - -none_type = type(None) -file_type = io.IOBase - - -class FileIO(io.FileIO): - """ - A class for storing files - Note: this class is not immutable - """ - - def __new__(cls, arg: typing.Union[io.FileIO, io.BufferedReader]): - if isinstance(arg, (io.FileIO, io.BufferedReader)): - arg.close() - inst = super(FileIO, cls).__new__(cls, arg.name) - super(FileIO, inst).__init__(arg.name) - return inst - raise ApiValueError('FileIO must be passed arg which contains the open file') - - -def update(d: dict, u: dict): - """ - Adds u to d - Where each dict is defaultdict(set) - """ - if not u: - return d - for k, v in u.items(): - if not v: - continue - if k not in d: - d[k] = v - else: - d[k] = d[k] | v - - -class ValidationMetadata(frozendict): - """ - A class storing metadata that is needed to validate OpenApi Schema payloads - """ - def __new__( - cls, - path_to_item: typing.Tuple[typing.Union[str, int], ...] = tuple(['args[0]']), - from_server: bool = False, - configuration: typing.Optional[Configuration] = None, - base_classes: typing.FrozenSet[typing.Type] = frozenset(), - ): - """ - Args: - path_to_item: the path to the current data being instantiated. - For {'a': [1]} if the code is handling, 1, then the path is ('args[0]', 'a', 0) - from_server: whether or not this data came form the server - True when receiving server data - False when instantiating model with client side data not form the server - configuration: the Configuration instance to use - This is needed because in Configuration: - - one can disable validation checking - base_classes: when deserializing data that matches multiple schemas, this is used to store - the schemas that have been traversed. This is used to stop processing when a cycle is seen. - """ - return super().__new__( - cls, - path_to_item=path_to_item, - from_server=from_server, - configuration=configuration, - base_classes=base_classes, - ) - - @property - def path_to_item(self) -> typing.Tuple[typing.Union[str, int], ...]: - return self.get('path_to_item') - - @property - def from_server(self) -> bool: - return self.get('from_server') - - @property - def configuration(self) -> typing.Optional[Configuration]: - return self.get('configuration') - - @property - def base_classes(self) -> typing.FrozenSet[typing.Type]: - return self.get('base_classes') - - -class ValidatorBase: - @staticmethod - def __is_json_validation_enabled(schema_keyword, configuration=None): - """Returns true if JSON schema validation is enabled for the specified - validation keyword. This can be used to skip JSON schema structural validation - as requested in the configuration. - - Args: - schema_keyword (string): the name of a JSON schema validation keyword. - configuration (Configuration): the configuration class. - """ - - return (configuration is None or - not hasattr(configuration, '_disabled_client_side_validations') or - schema_keyword not in configuration._disabled_client_side_validations) - - @staticmethod - def __raise_validation_error_message(value, constraint_msg, constraint_value, path_to_item, additional_txt=""): - raise ApiValueError( - "Invalid value `{value}`, {constraint_msg} `{constraint_value}`{additional_txt} at {path_to_item}".format( - value=value, - constraint_msg=constraint_msg, - constraint_value=constraint_value, - additional_txt=additional_txt, - path_to_item=path_to_item, - ) - ) - - @classmethod - def __check_str_validations(cls, - validations, input_values, - validation_metadata: ValidationMetadata): - - if (cls.__is_json_validation_enabled('maxLength', validation_metadata.configuration) and - 'max_length' in validations and - len(input_values) > validations['max_length']): - cls.__raise_validation_error_message( - value=input_values, - constraint_msg="length must be less than or equal to", - constraint_value=validations['max_length'], - path_to_item=validation_metadata.path_to_item - ) - - if (cls.__is_json_validation_enabled('minLength', validation_metadata.configuration) and - 'min_length' in validations and - len(input_values) < validations['min_length']): - cls.__raise_validation_error_message( - value=input_values, - constraint_msg="length must be greater than or equal to", - constraint_value=validations['min_length'], - path_to_item=validation_metadata.path_to_item - ) - - checked_value = input_values - if (cls.__is_json_validation_enabled('pattern', validation_metadata.configuration) and - 'regex' in validations): - for regex_dict in validations['regex']: - flags = regex_dict.get('flags', 0) - if not re.search(regex_dict['pattern'], checked_value, flags=flags): - if flags != 0: - # Don't print the regex flags if the flags are not - # specified in the OAS document. - cls.__raise_validation_error_message( - value=input_values, - constraint_msg="must match regular expression", - constraint_value=regex_dict['pattern'], - path_to_item=validation_metadata.path_to_item, - additional_txt=" with flags=`{}`".format(flags) - ) - cls.__raise_validation_error_message( - value=input_values, - constraint_msg="must match regular expression", - constraint_value=regex_dict['pattern'], - path_to_item=validation_metadata.path_to_item - ) - - @classmethod - def __check_tuple_validations( - cls, validations, input_values, - validation_metadata: ValidationMetadata): - - if (cls.__is_json_validation_enabled('maxItems', validation_metadata.configuration) and - 'max_items' in validations and - len(input_values) > validations['max_items']): - cls.__raise_validation_error_message( - value=input_values, - constraint_msg="number of items must be less than or equal to", - constraint_value=validations['max_items'], - path_to_item=validation_metadata.path_to_item - ) - - if (cls.__is_json_validation_enabled('minItems', validation_metadata.configuration) and - 'min_items' in validations and - len(input_values) < validations['min_items']): - cls.__raise_validation_error_message( - value=input_values, - constraint_msg="number of items must be greater than or equal to", - constraint_value=validations['min_items'], - path_to_item=validation_metadata.path_to_item - ) - - if (cls.__is_json_validation_enabled('uniqueItems', validation_metadata.configuration) and - 'unique_items' in validations and validations['unique_items'] and input_values): - unique_items = [] - for item in input_values: - if item not in unique_items: - unique_items.append(item) - if len(input_values) > len(unique_items): - cls.__raise_validation_error_message( - value=input_values, - constraint_msg="duplicate items were found, and the tuple must not contain duplicates because", - constraint_value='unique_items==True', - path_to_item=validation_metadata.path_to_item - ) - - @classmethod - def __check_dict_validations( - cls, validations, input_values, - validation_metadata: ValidationMetadata): - - if (cls.__is_json_validation_enabled('maxProperties', validation_metadata.configuration) and - 'max_properties' in validations and - len(input_values) > validations['max_properties']): - cls.__raise_validation_error_message( - value=input_values, - constraint_msg="number of properties must be less than or equal to", - constraint_value=validations['max_properties'], - path_to_item=validation_metadata.path_to_item - ) - - if (cls.__is_json_validation_enabled('minProperties', validation_metadata.configuration) and - 'min_properties' in validations and - len(input_values) < validations['min_properties']): - cls.__raise_validation_error_message( - value=input_values, - constraint_msg="number of properties must be greater than or equal to", - constraint_value=validations['min_properties'], - path_to_item=validation_metadata.path_to_item - ) - - @classmethod - def __check_numeric_validations( - cls, validations, input_values, - validation_metadata: ValidationMetadata): - - if cls.__is_json_validation_enabled('multipleOf', - validation_metadata.configuration) and 'multiple_of' in validations: - multiple_of_values = validations['multiple_of'] - for multiple_of_value in multiple_of_values: - if (isinstance(input_values, decimal.Decimal) and - not (float(input_values) / multiple_of_value).is_integer() - ): - # Note 'multipleOf' will be as good as the floating point arithmetic. - cls.__raise_validation_error_message( - value=input_values, - constraint_msg="value must be a multiple of", - constraint_value=multiple_of_value, - path_to_item=validation_metadata.path_to_item - ) - - checking_max_or_min_values = {'exclusive_maximum', 'inclusive_maximum', 'exclusive_minimum', - 'inclusive_minimum'}.isdisjoint(validations) is False - if not checking_max_or_min_values: - return - max_val = input_values - min_val = input_values - - if (cls.__is_json_validation_enabled('exclusiveMaximum', validation_metadata.configuration) and - 'exclusive_maximum' in validations and - max_val >= validations['exclusive_maximum']): - cls.__raise_validation_error_message( - value=input_values, - constraint_msg="must be a value less than", - constraint_value=validations['exclusive_maximum'], - path_to_item=validation_metadata.path_to_item - ) - - if (cls.__is_json_validation_enabled('maximum', validation_metadata.configuration) and - 'inclusive_maximum' in validations and - max_val > validations['inclusive_maximum']): - cls.__raise_validation_error_message( - value=input_values, - constraint_msg="must be a value less than or equal to", - constraint_value=validations['inclusive_maximum'], - path_to_item=validation_metadata.path_to_item - ) - - if (cls.__is_json_validation_enabled('exclusiveMinimum', validation_metadata.configuration) and - 'exclusive_minimum' in validations and - min_val <= validations['exclusive_minimum']): - cls.__raise_validation_error_message( - value=input_values, - constraint_msg="must be a value greater than", - constraint_value=validations['exclusive_maximum'], - path_to_item=validation_metadata.path_to_item - ) - - if (cls.__is_json_validation_enabled('minimum', validation_metadata.configuration) and - 'inclusive_minimum' in validations and - min_val < validations['inclusive_minimum']): - cls.__raise_validation_error_message( - value=input_values, - constraint_msg="must be a value greater than or equal to", - constraint_value=validations['inclusive_minimum'], - path_to_item=validation_metadata.path_to_item - ) - - @classmethod - def _check_validations_for_types( - cls, - validations, - input_values, - validation_metadata: ValidationMetadata - ): - if isinstance(input_values, str): - cls.__check_str_validations(validations, input_values, validation_metadata) - elif isinstance(input_values, tuple): - cls.__check_tuple_validations(validations, input_values, validation_metadata) - elif isinstance(input_values, frozendict): - cls.__check_dict_validations(validations, input_values, validation_metadata) - elif isinstance(input_values, decimal.Decimal): - cls.__check_numeric_validations(validations, input_values, validation_metadata) - try: - return super()._validate_validations_pass(input_values, validation_metadata) - except AttributeError: - return True - - -class Validator(typing.Protocol): - def _validate_validations_pass( - cls, - input_values, - validation_metadata: ValidationMetadata - ): - pass - - -def _SchemaValidator(**validations: typing.Union[str, bool, None, int, float, list[dict[str, typing.Union[str, int, float]]]]) -> Validator: - class SchemaValidator(ValidatorBase): - @classmethod - def _validate_validations_pass( - cls, - input_values, - validation_metadata: ValidationMetadata - ): - cls._check_validations_for_types(validations, input_values, validation_metadata) - try: - return super()._validate_validations_pass(input_values, validation_metadata) - except AttributeError: - return True - - return SchemaValidator - - -class TypeChecker(typing.Protocol): - @classmethod - def _validate_type( - cls, arg_simple_class: type - ) -> typing.Tuple[type]: - pass - - -def _SchemaTypeChecker(union_type_cls: typing.Union[typing.Any]) -> TypeChecker: - if typing.get_origin(union_type_cls) is typing.Union: - union_classes = typing.get_args(union_type_cls) - else: - # note: when a union of a single class is passed in, the union disappears - union_classes = tuple([union_type_cls]) - """ - I want the type hint... union_type_cls - and to use it as a base class but when I do, I get - TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases - """ - class SchemaTypeChecker: - @classmethod - def _validate_type(cls, arg_simple_class: type): - if arg_simple_class not in union_classes: - return union_classes - try: - return super()._validate_type(arg_simple_class) - except AttributeError: - return tuple() - - return SchemaTypeChecker - - -class EnumMakerBase: - @classmethod - @property - def _enum_by_value( - cls - ) -> type: - enum_classes = {} - if not hasattr(cls, "_enum_value_to_name"): - return enum_classes - for enum_value, enum_name in cls._enum_value_to_name.items(): - base_class = type(enum_value) - if base_class is none_type: - enum_classes[enum_value] = get_new_class( - "Dynamic" + cls.__name__, (cls, NoneClass)) - log_cache_usage(get_new_class) - elif base_class is bool: - enum_classes[enum_value] = get_new_class( - "Dynamic" + cls.__name__, (cls, BoolClass)) - log_cache_usage(get_new_class) - else: - enum_classes[enum_value] = get_new_class( - "Dynamic" + cls.__name__, (cls, Singleton, base_class)) - log_cache_usage(get_new_class) - return enum_classes - - -class EnumMakerInterface(typing.Protocol): - @classmethod - @property - def _enum_value_to_name( - cls - ) -> typing.Dict[typing.Union[str, decimal.Decimal, bool, none_type], str]: - pass - - @classmethod - @property - def _enum_by_value( - cls - ) -> type: - pass - - -def _SchemaEnumMaker(enum_value_to_name: typing.Dict[typing.Union[str, decimal.Decimal, bool, none_type], str]) -> EnumMakerInterface: - class SchemaEnumMaker(EnumMakerBase): - @classmethod - @property - def _enum_value_to_name( - cls - ) -> typing.Dict[typing.Union[str, decimal.Decimal, bool, none_type], str]: - pass - try: - super_enum_value_to_name = super()._enum_value_to_name - except AttributeError: - return enum_value_to_name - intersection = dict(enum_value_to_name.items() & super_enum_value_to_name.items()) - return intersection - - return SchemaEnumMaker - - -class Singleton: - """ - Enums and singletons are the same - The same instance is returned for a given key of (cls, arg) - """ - _instances = {} - - def __new__(cls, arg: typing.Any, **kwargs): - key = (cls, arg) - if key not in cls._instances: - if arg in {None, True, False}: - inst = super().__new__(cls) - # inst._value = arg - cls._instances[key] = inst - else: - cls._instances[key] = super().__new__(cls, arg) - return cls._instances[key] - - def __repr__(self): - if isinstance(self, NoneClass): - return f'<{self.__class__.__name__}: None>' - elif isinstance(self, BoolClass): - if (self.__class__, True) in self._instances: - return f'<{self.__class__.__name__}: True>' - return f'<{self.__class__.__name__}: False>' - return f'<{self.__class__.__name__}: {super().__repr__()}>' - - -class NoneClass(Singleton): - @classmethod - @property - def NONE(cls): - return cls(None) - - def __bool__(self) -> bool: - return False - - -class BoolClass(Singleton): - @classmethod - @property - def TRUE(cls): - return cls(True) - - @classmethod - @property - def FALSE(cls): - return cls(False) - - @functools.cache - def __bool__(self) -> bool: - for key, instance in self._instances.items(): - if self is instance: - return key[1] - raise ValueError('Unable to find the boolean value of this instance') - - -class BoolBase: - def is_true(self) -> bool: - """ - A replacement for x is True - True if the instance is a BoolClass True Singleton - """ - if not issubclass(self.__class__, BoolClass): - return False - return bool(self) - - def is_false(self) -> bool: - """ - A replacement for x is False - True if the instance is a BoolClass False Singleton - """ - if not issubclass(self.__class__, BoolClass): - return False - return bool(self) is False - - -class NoneBase: - def is_none(self) -> bool: - """ - A replacement for x is None - True if the instance is a NoneClass None Singleton - """ - if issubclass(self.__class__, NoneClass): - return True - return False - - -class StrBase: - @property - def as_str(self) -> str: - return self - - @property - def as_date(self) -> date: - raise Exception('not implemented') - - @property - def as_datetime(self) -> datetime: - raise Exception('not implemented') - - @property - def as_decimal(self) -> decimal.Decimal: - raise Exception('not implemented') - - @property - def as_uuid(self) -> uuid.UUID: - raise Exception('not implemented') - - -class UUIDBase(StrBase): - @property - @functools.cache - def as_uuid(self) -> uuid.UUID: - return uuid.UUID(self) - - @classmethod - def _validate_format(cls, arg: typing.Optional[str], validation_metadata: ValidationMetadata): - if isinstance(arg, str): - try: - uuid.UUID(arg) - return True - except ValueError: - raise ApiValueError( - "Invalid value '{}' for type UUID at {}".format(arg, validation_metadata.path_to_item) - ) - - @classmethod - def _validate( - cls, - arg, - validation_metadata: typing.Optional[ValidationMetadata] = None, - ): - """ - UUIDBase _validate - """ - cls._validate_format(arg, validation_metadata=validation_metadata) - return super()._validate(arg, validation_metadata=validation_metadata) - - -class CustomIsoparser(isoparser): - - @_takes_ascii - def parse_isodatetime(self, dt_str): - components, pos = self._parse_isodate(dt_str) - if len(dt_str) > pos: - if self._sep is None or dt_str[pos:pos + 1] == self._sep: - components += self._parse_isotime(dt_str[pos + 1:]) - else: - raise ValueError('String contains unknown ISO components') - - if len(components) > 3 and components[3] == 24: - components[3] = 0 - return datetime(*components) + timedelta(days=1) - - if len(components) <= 3: - raise ValueError('Value is not a datetime') - - return datetime(*components) - - @_takes_ascii - def parse_isodate(self, datestr): - components, pos = self._parse_isodate(datestr) - - if len(datestr) > pos: - raise ValueError('String contains invalid time components') - - if len(components) > 3: - raise ValueError('String contains invalid time components') - - return date(*components) - - -DEFAULT_ISOPARSER = CustomIsoparser() - - -class DateBase(StrBase): - @property - @functools.cache - def as_date(self) -> date: - return DEFAULT_ISOPARSER.parse_isodate(self) - - @classmethod - def _validate_format(cls, arg: typing.Optional[str], validation_metadata: ValidationMetadata): - if isinstance(arg, str): - try: - DEFAULT_ISOPARSER.parse_isodate(arg) - return True - except ValueError: - raise ApiValueError( - "Value does not conform to the required ISO-8601 date format. " - "Invalid value '{}' for type date at {}".format(arg, validation_metadata.path_to_item) - ) - - @classmethod - def _validate( - cls, - arg, - validation_metadata: typing.Optional[ValidationMetadata] = None, - ): - """ - DateBase _validate - """ - cls._validate_format(arg, validation_metadata=validation_metadata) - return super()._validate(arg, validation_metadata=validation_metadata) - - -class DateTimeBase: - @property - @functools.cache - def as_datetime(self) -> datetime: - return DEFAULT_ISOPARSER.parse_isodatetime(self) - - @classmethod - def _validate_format(cls, arg: typing.Optional[str], validation_metadata: ValidationMetadata): - if isinstance(arg, str): - try: - DEFAULT_ISOPARSER.parse_isodatetime(arg) - return True - except ValueError: - raise ApiValueError( - "Value does not conform to the required ISO-8601 datetime format. " - "Invalid value '{}' for type datetime at {}".format(arg, validation_metadata.path_to_item) - ) - - @classmethod - def _validate( - cls, - arg, - validation_metadata: ValidationMetadata, - ): - """ - DateTimeBase _validate - """ - cls._validate_format(arg, validation_metadata=validation_metadata) - return super()._validate(arg, validation_metadata=validation_metadata) - - -class DecimalBase(StrBase): - """ - A class for storing decimals that are sent over the wire as strings - These schemas must remain based on StrBase rather than NumberBase - because picking base classes must be deterministic - """ - - @property - @functools.cache - def as_decimal(self) -> decimal.Decimal: - return decimal.Decimal(self) - - @classmethod - def _validate_format(cls, arg: typing.Optional[str], validation_metadata: ValidationMetadata): - if isinstance(arg, str): - try: - decimal.Decimal(arg) - return True - except decimal.InvalidOperation: - raise ApiValueError( - "Value cannot be converted to a decimal. " - "Invalid value '{}' for type decimal at {}".format(arg, validation_metadata.path_to_item) - ) - - @classmethod - def _validate( - cls, - arg, - validation_metadata: ValidationMetadata, - ): - """ - DecimalBase _validate - """ - cls._validate_format(arg, validation_metadata=validation_metadata) - return super()._validate(arg, validation_metadata=validation_metadata) - - -class NumberBase: - @property - def as_int(self) -> int: - try: - return self._as_int - except AttributeError: - """ - Note: for some numbers like 9.0 they could be represented as an - integer but our code chooses to store them as - >>> Decimal('9.0').as_tuple() - DecimalTuple(sign=0, digits=(9, 0), exponent=-1) - so we can tell that the value came from a float and convert it back to a float - during later serialization - """ - if self.as_tuple().exponent < 0: - # this could be represented as an integer but should be represented as a float - # because that's what it was serialized from - raise ApiValueError(f'{self} is not an integer') - self._as_int = int(self) - return self._as_int - - @property - def as_float(self) -> float: - try: - return self._as_float - except AttributeError: - if self.as_tuple().exponent >= 0: - raise ApiValueError(f'{self} is not an float') - self._as_float = float(self) - return self._as_float - - -class ListBase: - @classmethod - def _validate_items(cls, list_items, validation_metadata: ValidationMetadata): - """ - Ensures that: - - values passed in for items are valid - Exceptions will be raised if: - - invalid arguments were passed in - - Args: - list_items: the input list of items - - Raises: - ApiTypeError - for missing required arguments, or for invalid properties - """ - - # if we have definitions for an items schema, use it - # otherwise accept anything - item_cls = getattr(cls, '_items', AnyTypeSchema) - path_to_schemas = {} - for i, value in enumerate(list_items): - if isinstance(value, item_cls): - continue - item_validation_metadata = ValidationMetadata( - from_server=validation_metadata.from_server, - configuration=validation_metadata.configuration, - path_to_item=validation_metadata.path_to_item+(i,) - ) - other_path_to_schemas = item_cls._validate( - value, validation_metadata=item_validation_metadata) - update(path_to_schemas, other_path_to_schemas) - return path_to_schemas - - @classmethod - def _validate( - cls, - arg, - validation_metadata: ValidationMetadata, - ): - """ - ListBase _validate - We return dynamic classes of different bases depending upon the inputs - This makes it so: - - the returned instance is always a subclass of our defining schema - - this allows us to check type based on whether an instance is a subclass of a schema - - the returned instance is a serializable type (except for None, True, and False) which are enums - - Returns: - new_cls (type): the new class - - Raises: - ApiValueError: when a string can't be converted into a date or datetime and it must be one of those classes - ApiTypeError: when the input type is not in the list of allowed spec types - """ - _path_to_schemas = super()._validate(arg, validation_metadata=validation_metadata) - if not isinstance(arg, tuple): - return _path_to_schemas - if cls in validation_metadata.base_classes: - # we have already moved through this class so stop here - return _path_to_schemas - updated_vm = ValidationMetadata( - configuration=validation_metadata.configuration, - from_server=validation_metadata.from_server, - path_to_item=validation_metadata.path_to_item, - base_classes=validation_metadata.base_classes | frozenset({cls}) - ) - other_path_to_schemas = cls._validate_items(arg, validation_metadata=updated_vm) - update(_path_to_schemas, other_path_to_schemas) - return _path_to_schemas - - @classmethod - def _get_items( - cls: 'Schema', - arg: typing.List[typing.Any], - path_to_item: typing.Tuple[typing.Union[str, int], ...], - path_to_schemas: typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Type['Schema']] - ): - ''' - ListBase _get_items - ''' - list_items = arg - cast_items = [] - # if we have definitions for an items schema, use it - # otherwise accept anything - - cls_item_cls = getattr(cls, '_items', AnyTypeSchema) - for i, value in enumerate(list_items): - item_path_to_item = path_to_item + (i,) - item_cls = path_to_schemas.get(item_path_to_item) - if item_cls is None: - item_cls = cls_item_cls - - if isinstance(value, item_cls): - cast_items.append(value) - continue - - new_value = item_cls._get_new_instance_without_conversion( - value, - item_path_to_item, - path_to_schemas - ) - cast_items.append(new_value) - - return cast_items - - -class Discriminable: - @classmethod - def _ensure_discriminator_value_present(cls, disc_property_name: str, validation_metadata: ValidationMetadata, *args): - if not args or args and disc_property_name not in args[0]: - # The input data does not contain the discriminator property - raise ApiValueError( - "Cannot deserialize input data due to missing discriminator. " - "The discriminator property '{}' is missing at path: {}".format(disc_property_name, validation_metadata.path_to_item) - ) - - @classmethod - def _get_discriminated_class(cls, disc_property_name: str, disc_payload_value: str): - """ - Used in schemas with discriminators - """ - if not hasattr(cls, '_discriminator'): - return None - disc = cls._discriminator - if disc_property_name not in disc: - return None - discriminated_cls = disc[disc_property_name].get(disc_payload_value) - if discriminated_cls is not None: - return discriminated_cls - elif not hasattr(cls, '_composed_schemas'): - return None - # TODO stop traveling if a cycle is hit - for allof_cls in cls._composed_schemas['allOf']: - discriminated_cls = allof_cls._get_discriminated_class( - disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) - if discriminated_cls is not None: - return discriminated_cls - for oneof_cls in cls._composed_schemas['oneOf']: - discriminated_cls = oneof_cls._get_discriminated_class( - disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) - if discriminated_cls is not None: - return discriminated_cls - for anyof_cls in cls._composed_schemas['anyOf']: - discriminated_cls = anyof_cls._get_discriminated_class( - disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) - if discriminated_cls is not None: - return discriminated_cls - return None - - -class DictBase(Discriminable): - # subclass properties - _required_property_names = set() - - @classmethod - def _validate_arg_presence(cls, arg): - """ - Ensures that: - - all required arguments are passed in - - the input variable names are valid - - present in properties or - - accepted because additionalProperties exists - Exceptions will be raised if: - - invalid arguments were passed in - - a var_name is invalid if additionProperties == None and var_name not in _properties - - required properties were not passed in - - Args: - arg: the input dict - - Raises: - ApiTypeError - for missing required arguments, or for invalid properties - """ - seen_required_properties = set() - invalid_arguments = [] - for property_name in arg: - if property_name in cls._required_property_names: - seen_required_properties.add(property_name) - elif property_name in cls._property_names: - continue - elif cls._additional_properties: - continue - else: - invalid_arguments.append(property_name) - missing_required_arguments = list(cls._required_property_names - seen_required_properties) - if missing_required_arguments: - missing_required_arguments.sort() - raise ApiTypeError( - "{} is missing {} required argument{}: {}".format( - cls.__name__, - len(missing_required_arguments), - "s" if len(missing_required_arguments) > 1 else "", - missing_required_arguments - ) - ) - if invalid_arguments: - invalid_arguments.sort() - raise ApiTypeError( - "{} was passed {} invalid argument{}: {}".format( - cls.__name__, - len(invalid_arguments), - "s" if len(invalid_arguments) > 1 else "", - invalid_arguments - ) - ) - - @classmethod - def _validate_args(cls, arg, validation_metadata: ValidationMetadata): - """ - Ensures that: - - values passed in for properties are valid - Exceptions will be raised if: - - invalid arguments were passed in - - Args: - arg: the input dict - - Raises: - ApiTypeError - for missing required arguments, or for invalid properties - """ - path_to_schemas = {} - for property_name, value in arg.items(): - if property_name in cls._required_property_names or property_name in cls._property_names: - schema = getattr(cls, property_name) - elif cls._additional_properties: - schema = cls._additional_properties - else: - raise ApiTypeError('Unable to find schema for value={} in class={} at path_to_item={}'.format( - value, cls, validation_metadata.path_to_item+(property_name,) - )) - if isinstance(value, schema): - continue - arg_validation_metadata = ValidationMetadata( - from_server=validation_metadata.from_server, - configuration=validation_metadata.configuration, - path_to_item=validation_metadata.path_to_item+(property_name,) - ) - other_path_to_schemas = schema._validate(value, validation_metadata=arg_validation_metadata) - update(path_to_schemas, other_path_to_schemas) - return path_to_schemas - - @classmethod - def _validate( - cls, - arg, - validation_metadata: ValidationMetadata, - ): - """ - DictBase _validate - We return dynamic classes of different bases depending upon the inputs - This makes it so: - - the returned instance is always a subclass of our defining schema - - this allows us to check type based on whether an instance is a subclass of a schema - - the returned instance is a serializable type (except for None, True, and False) which are enums - - Returns: - new_cls (type): the new class - - Raises: - ApiValueError: when a string can't be converted into a date or datetime and it must be one of those classes - ApiTypeError: when the input type is not in the list of allowed spec types - """ - if isinstance(arg, cls): - # an instance of the correct type was passed in - return {} - _path_to_schemas = super()._validate(arg, validation_metadata=validation_metadata) - if not isinstance(arg, frozendict): - return _path_to_schemas - cls._validate_arg_presence(arg) - other_path_to_schemas = cls._validate_args(arg, validation_metadata=validation_metadata) - update(_path_to_schemas, other_path_to_schemas) - try: - _discriminator = cls._discriminator - except AttributeError: - return _path_to_schemas - # discriminator exists - disc_prop_name = list(_discriminator.keys())[0] - cls._ensure_discriminator_value_present(disc_prop_name, validation_metadata, arg) - discriminated_cls = cls._get_discriminated_class( - disc_property_name=disc_prop_name, disc_payload_value=arg[disc_prop_name]) - if discriminated_cls is None: - raise ApiValueError( - "Invalid discriminator value was passed in to {}.{} Only the values {} are allowed at {}".format( - cls.__name__, - disc_prop_name, - list(_discriminator[disc_prop_name].keys()), - validation_metadata.path_to_item + (disc_prop_name,) - ) - ) - if discriminated_cls in validation_metadata.base_classes: - # we have already moved through this class so stop here - return _path_to_schemas - updated_vm = ValidationMetadata( - configuration=validation_metadata.configuration, - from_server=validation_metadata.from_server, - path_to_item=validation_metadata.path_to_item, - base_classes=validation_metadata.base_classes | frozenset({cls}) - ) - other_path_to_schemas = discriminated_cls._validate(arg, validation_metadata=updated_vm) - update(_path_to_schemas, other_path_to_schemas) - return _path_to_schemas - - @classmethod - @property - def _additional_properties(cls): - return AnyTypeSchema - - @classmethod - @property - @functools.cache - def _property_names(cls): - property_names = set() - for var_name, var_value in cls.__dict__.items(): - # referenced models are classmethods - is_classmethod = type(var_value) is classmethod - if is_classmethod: - property_names.add(var_name) - continue - is_class = type(var_value) is type - if not is_class: - continue - if not issubclass(var_value, Schema): - continue - if var_name == '_additional_properties': - continue - property_names.add(var_name) - property_names = list(property_names) - property_names.sort() - return tuple(property_names) - - @classmethod - def _get_properties( - cls, - arg: typing.Dict[str, typing.Any], - path_to_item: typing.Tuple[typing.Union[str, int], ...], - path_to_schemas: typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Type['Schema']] - ): - """ - DictBase _get_properties, this is how properties are set - These values already passed validation - """ - dict_items = {} - # if we have definitions for property schemas convert values using it - # otherwise accept anything - - for property_name_js, value in arg.items(): - property_cls = getattr(cls, property_name_js, cls._additional_properties) - property_path_to_item = path_to_item + (property_name_js,) - stored_property_cls = path_to_schemas.get(property_path_to_item) - if stored_property_cls: - property_cls = stored_property_cls - - if isinstance(value, property_cls): - dict_items[property_name_js] = value - continue - - new_value = property_cls._get_new_instance_without_conversion( - value, - property_path_to_item, - path_to_schemas - ) - dict_items[property_name_js] = new_value - return dict_items - - def __setattr__(self, name, value): - if not isinstance(self, FileIO): - raise AttributeError('property setting not supported on immutable instances') - - def __getattr__(self, name): - if isinstance(self, frozendict): - # if an attribute does not exist - try: - return self[name] - except KeyError as ex: - raise AttributeError(str(ex)) - return super().__getattr__(self, name) - - def __getattribute__(self, name): - # if an attribute does exist (for example as a class property but not as an instance method) - try: - return self[name] - except (KeyError, TypeError): - return super().__getattribute__(name) - - -inheritable_primitive_types_set = {decimal.Decimal, str, tuple, frozendict, FileIO, bytes} - - -class Schema: - """ - the base class of all swagger/openapi schemas/models - - ensures that: - - payload passes required validations - - payload is of allowed types - - payload value is an allowed enum value - """ - - @staticmethod - def __get_simple_class(input_value): - """Returns an input_value's simple class that we will use for type checking - - Args: - input_value (class/class_instance): the item for which we will return - the simple class - """ - if isinstance(input_value, tuple): - return tuple - elif isinstance(input_value, frozendict): - return frozendict - elif isinstance(input_value, none_type): - return none_type - elif isinstance(input_value, bytes): - return bytes - elif isinstance(input_value, (io.FileIO, io.BufferedReader)): - return FileIO - elif isinstance(input_value, bool): - # this must be higher than the int check because - # isinstance(True, int) == True - return bool - elif isinstance(input_value, int): - return int - elif isinstance(input_value, float): - return float - elif isinstance(input_value, datetime): - # this must be higher than the date check because - # isinstance(datetime_instance, date) == True - return datetime - elif isinstance(input_value, date): - return date - elif isinstance(input_value, str): - return str - return type(input_value) - - @staticmethod - def __get_valid_classes_phrase(input_classes): - """Returns a string phrase describing what types are allowed""" - all_classes = list(input_classes) - all_classes = sorted(all_classes, key=lambda cls: cls.__name__) - all_class_names = [cls.__name__ for cls in all_classes] - if len(all_class_names) == 1: - return "is {0}".format(all_class_names[0]) - return "is one of [{0}]".format(", ".join(all_class_names)) - - @classmethod - def __type_error_message( - cls, var_value=None, var_name=None, valid_classes=None, key_type=None - ): - """ - Keyword Args: - var_value (any): the variable which has the type_error - var_name (str): the name of the variable which has the typ error - valid_classes (tuple): the accepted classes for current_item's - value - key_type (bool): False if our value is a value in a dict - True if it is a key in a dict - False if our item is an item in a tuple - """ - key_or_value = "value" - if key_type: - key_or_value = "key" - valid_classes_phrase = cls.__get_valid_classes_phrase(valid_classes) - msg = "Invalid type. Required {1} type {2} and " "passed type was {3}".format( - var_name, - key_or_value, - valid_classes_phrase, - type(var_value).__name__, - ) - return msg - - @classmethod - def __get_type_error(cls, var_value, path_to_item, valid_classes, key_type=False): - error_msg = cls.__type_error_message( - var_name=path_to_item[-1], - var_value=var_value, - valid_classes=valid_classes, - key_type=key_type, - ) - return ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=valid_classes, - key_type=key_type, - ) - - @classmethod - def _class_by_base_class(cls, base_cls: type) -> type: - cls_name = "Dynamic"+cls.__name__ - if base_cls is bool: - new_cls = get_new_class(cls_name, (cls, BoolBase, BoolClass)) - elif base_cls is str: - new_cls = get_new_class(cls_name, (cls, StrBase, str)) - elif base_cls is decimal.Decimal: - new_cls = get_new_class(cls_name, (cls, NumberBase, decimal.Decimal)) - elif base_cls is tuple: - new_cls = get_new_class(cls_name, (cls, ListBase, tuple)) - elif base_cls is frozendict: - new_cls = get_new_class(cls_name, (cls, DictBase, frozendict)) - elif base_cls is none_type: - new_cls = get_new_class(cls_name, (cls, NoneBase, NoneClass)) - log_cache_usage(get_new_class) - return new_cls - - @classmethod - def _validate( - cls, - arg, - validation_metadata: ValidationMetadata, - ): - """ - Schema _validate - Runs all schema validation logic and - returns a dynamic class of different bases depending upon the input - This makes it so: - - the returned instance is always a subclass of our defining schema - - this allows us to check type based on whether an instance is a subclass of a schema - - the returned instance is a serializable type (except for None, True, and False) which are enums - - Use cases: - 1. inheritable type: string/decimal.Decimal/frozendict/tuple - 2. enum value cases: 'hi', 1 -> no base_class set because the enum includes the base class - 3. uninheritable type: True/False/None -> no base_class because the base class is not inheritable - _enum_by_value will handle this use case - - Required Steps: - 1. verify type of input is valid vs the allowed _types - 2. check validations that are applicable for this type of input - 3. if enums exist, check that the value exists in the enum - - Returns: - path_to_schemas: a map of path to schemas - - Raises: - ApiValueError: when a string can't be converted into a date or datetime and it must be one of those classes - ApiTypeError: when the input type is not in the list of allowed spec types - """ - base_class = cls.__get_simple_class(arg) - failed_type_check_classes = cls._validate_type(base_class) - if failed_type_check_classes: - raise cls.__get_type_error( - arg, - validation_metadata.path_to_item, - failed_type_check_classes, - key_type=False, - ) - if hasattr(cls, '_validate_validations_pass'): - cls._validate_validations_pass(arg, validation_metadata) - path_to_schemas = {} - if validation_metadata.path_to_item not in path_to_schemas: - path_to_schemas[validation_metadata.path_to_item] = set() - path_to_schemas[validation_metadata.path_to_item].add(cls) - - if hasattr(cls, "_enum_by_value"): - cls._validate_enum_value(arg) - return path_to_schemas - - if base_class is none_type or base_class is bool: - return path_to_schemas - - path_to_schemas[validation_metadata.path_to_item].add(base_class) - return path_to_schemas - - @classmethod - def _validate_enum_value(cls, arg): - try: - cls._enum_by_value[arg] - except KeyError: - raise ApiValueError("Invalid value {} passed in to {}, {}".format(arg, cls, cls._enum_value_to_name)) - - @classmethod - def __get_new_cls( - cls, - arg, - validation_metadata: ValidationMetadata - ) -> typing.Dict[typing.Tuple[typing.Union[str, int], ...], 'Schema']: - """ - Make a new dynamic class and return an instance of that class - We are making an instance of cls, but instead of making cls - make a new class, new_cls - which includes dynamic bases including cls - return an instance of that new class - - Dict property + List Item Assignment Use cases: - 1. value is NOT an instance of the required schema class - the value is validated by _validate - _validate returns a key value pair - where the key is the path to the item, and the value will be the required manufactured class - made out of the matching schemas - 2. value is an instance of the the correct schema type - the value is NOT validated by _validate, _validate only checks that the instance is of the correct schema type - for this value, _validate does NOT return an entry for it in _path_to_schemas - and in list/dict _get_items,_get_properties the value will be directly assigned - because value is of the correct type, and validation was run earlier when the instance was created - """ - _path_to_schemas = cls._validate(arg, validation_metadata=validation_metadata) - # loop through it make a new class for each entry - # do not modify the returned result because it is cached and we would be modifying the cached value - path_to_schemas = {} - for path, schema_classes in _path_to_schemas.items(): - enum_schema = any( - hasattr(this_cls, '_enum_by_value') for this_cls in schema_classes) - inheritable_primitive_type = schema_classes.intersection(inheritable_primitive_types_set) - chosen_schema_classes = schema_classes - suffix = tuple() - if inheritable_primitive_type: - chosen_schema_classes = schema_classes - inheritable_primitive_types_set - if not enum_schema: - # include the inheritable_primitive_type - suffix = tuple(inheritable_primitive_type) - - if len(chosen_schema_classes) == 1 and not suffix: - mfg_cls = tuple(chosen_schema_classes)[0] - else: - x_schema = schema_descendents & chosen_schema_classes - if x_schema: - x_schema = x_schema.pop() - if any(c is not x_schema and issubclass(c, x_schema) for c in chosen_schema_classes): - # needed to not have a mro error in get_new_class - chosen_schema_classes.remove(x_schema) - used_classes = tuple(sorted(chosen_schema_classes, key=lambda a_cls: a_cls.__name__)) + suffix - mfg_cls = get_new_class(class_name='DynamicSchema', bases=used_classes) - - if inheritable_primitive_type and not enum_schema: - path_to_schemas[path] = mfg_cls - continue - - # Use case: value is None, True, False, or an enum value - value = arg - for key in path[1:]: - # if path is bigger than one, get the value that mfg_cls validated - value = value[key] - if hasattr(mfg_cls, '_enum_by_value'): - mfg_cls = mfg_cls._enum_by_value[value] - elif value in {True, False}: - mfg_cls = mfg_cls._class_by_base_class(bool) - elif value is None: - mfg_cls = mfg_cls._class_by_base_class(none_type) - else: - raise ApiValueError('Unhandled case value={} bases={}'.format(value, mfg_cls.__bases__)) - path_to_schemas[path] = mfg_cls - - return path_to_schemas - - @classmethod - def _get_new_instance_without_conversion( - cls: 'Schema', - arg: typing.Any, - path_to_item: typing.Tuple[typing.Union[str, int], ...], - path_to_schemas: typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Type['Schema']] - ): - # We have a Dynamic class and we are making an instance of it - if issubclass(cls, frozendict): - properties = cls._get_properties(arg, path_to_item, path_to_schemas) - return super(Schema, cls).__new__(cls, properties) - elif issubclass(cls, tuple): - items = cls._get_items(arg, path_to_item, path_to_schemas) - return super(Schema, cls).__new__(cls, items) - """ - str = openapi str, date, and datetime - decimal.Decimal = openapi int and float - FileIO = openapi binary type and the user inputs a file - bytes = openapi binary type and the user inputs bytes - """ - return super(Schema, cls).__new__(cls, arg) - - @classmethod - def _from_openapi_data( - cls, - arg: typing.Union[ - str, - date, - datetime, - int, - float, - decimal.Decimal, - bool, - None, - 'Schema', - dict, - frozendict, - tuple, - list, - io.FileIO, - io.BufferedReader, - bytes - ], - _configuration: typing.Optional[Configuration] - ): - """ - Schema _from_openapi_data - """ - arg = cast_to_allowed_types(arg, from_server=True) - validation_metadata = ValidationMetadata(from_server=True, configuration=_configuration) - path_to_schemas = cls.__get_new_cls(arg, validation_metadata) - new_cls = path_to_schemas[validation_metadata.path_to_item] - new_inst = new_cls._get_new_instance_without_conversion( - arg, - validation_metadata.path_to_item, - path_to_schemas - ) - return new_inst - - @staticmethod - def __get_input_dict(*args, **kwargs) -> frozendict: - input_dict = {} - if args and isinstance(args[0], (dict, frozendict)): - input_dict.update(args[0]) - if kwargs: - input_dict.update(kwargs) - return frozendict(input_dict) - - @staticmethod - def __remove_unsets(kwargs): - return {key: val for key, val in kwargs.items() if val is not unset} - - def __new__(cls, *args: typing.Union[dict, frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema'], _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Union[dict, frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema', Unset]): - """ - Schema __new__ - - Args: - args (int/float/decimal.Decimal/str/list/tuple/dict/frozendict/bool/None): the value - kwargs (str, int/float/decimal.Decimal/str/list/tuple/dict/frozendict/bool/None): dict values - _configuration: contains the Configuration that enables json schema validation keywords - like minItems, minLength etc - """ - kwargs = cls.__remove_unsets(kwargs) - if not args and not kwargs: - raise TypeError( - 'No input given. args or kwargs must be given.' - ) - if not kwargs and args and not isinstance(args[0], dict): - arg = args[0] - else: - arg = cls.__get_input_dict(*args, **kwargs) - validation_metadata = ValidationMetadata(configuration=_configuration, from_server=False) - arg = cast_to_allowed_types(arg, from_server=validation_metadata.from_server) - path_to_schemas = cls.__get_new_cls(arg, validation_metadata) - new_cls = path_to_schemas[validation_metadata.path_to_item] - return new_cls._get_new_instance_without_conversion( - arg, - validation_metadata.path_to_item, - path_to_schemas - ) - - def __init__( - self, - *args: typing.Union[ - dict, frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema'], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Union[ - dict, frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema', Unset - ] - ): - """ - this is needed to fix 'Unexpected argument' warning in pycharm - this code does nothing because all Schema instances are immutable - this means that all input data is passed into and used in new, and after the new instance is made - no new attributes are assigned and init is not used - """ - pass - - -def cast_to_allowed_types(arg: typing.Union[str, date, datetime, decimal.Decimal, int, float, None, dict, frozendict, list, tuple, bytes, Schema], from_server=False) -> typing.Union[str, bytes, decimal.Decimal, None, frozendict, tuple, Schema]: - """ - from_server=False date, datetime -> str - int, float -> Decimal - StrSchema will convert that to bytes and remember the encoding when we pass in str input - """ - if isinstance(arg, str): - return arg - elif type(arg) is dict or type(arg) is frozendict: - return frozendict({key: cast_to_allowed_types(val) for key, val in arg.items()}) - elif isinstance(arg, bool): - """ - this check must come before isinstance(arg, (int, float)) - because isinstance(True, int) is True - """ - return arg - elif isinstance(arg, int): - return decimal.Decimal(arg) - elif isinstance(arg, float): - decimal_from_float = decimal.Decimal(arg) - if decimal_from_float.as_integer_ratio()[1] == 1: - # 9.0 -> Decimal('9.0') - # 3.4028234663852886e+38 -> Decimal('340282346638528859811704183484516925440.0') - return decimal.Decimal(str(decimal_from_float)+'.0') - return decimal_from_float - elif type(arg) is list or type(arg) is tuple: - return tuple([cast_to_allowed_types(item) for item in arg]) - elif arg is None: - return arg - elif isinstance(arg, (date, datetime)): - if not from_server: - return arg.isoformat() - # ApiTypeError will be thrown later by _validate_type - return arg - elif isinstance(arg, uuid.UUID): - if not from_server: - return str(arg) - # ApiTypeError will be thrown later by _validate_type - return arg - elif isinstance(arg, decimal.Decimal): - return arg - elif isinstance(arg, bytes): - return arg - elif isinstance(arg, decimal.Decimal): - return arg - elif isinstance(arg, (io.FileIO, io.BufferedReader)): - if arg.closed: - raise ApiValueError('Invalid file state; file is closed and must be open') - return arg - elif isinstance(arg, Schema): - return arg - raise ValueError('Invalid type passed in got input={} type={}'.format(arg, type(arg))) - - -class ComposedBase(Discriminable): - - @classmethod - def __get_allof_classes(cls, arg, validation_metadata: ValidationMetadata): - path_to_schemas = defaultdict(set) - for allof_cls in cls._composed_schemas['allOf']: - if allof_cls in validation_metadata.base_classes: - continue - other_path_to_schemas = allof_cls._validate(arg, validation_metadata=validation_metadata) - update(path_to_schemas, other_path_to_schemas) - return path_to_schemas - - @classmethod - def __get_oneof_class( - cls, - arg, - discriminated_cls, - validation_metadata: ValidationMetadata, - path_to_schemas: typing.Dict[typing.Tuple, typing.Set[typing.Type[Schema]]] - ): - oneof_classes = [] - chosen_oneof_cls = None - original_base_classes = validation_metadata.base_classes - new_base_classes = validation_metadata.base_classes - path_to_schemas = defaultdict(set) - for oneof_cls in cls._composed_schemas['oneOf']: - if oneof_cls in path_to_schemas[validation_metadata.path_to_item]: - oneof_classes.append(oneof_cls) - continue - if isinstance(arg, oneof_cls): - # passed in instance is the correct type - chosen_oneof_cls = oneof_cls - oneof_classes.append(oneof_cls) - continue - try: - path_to_schemas = oneof_cls._validate(arg, validation_metadata=validation_metadata) - new_base_classes = validation_metadata.base_classes - except (ApiValueError, ApiTypeError) as ex: - if discriminated_cls is not None and oneof_cls is discriminated_cls: - raise ex - continue - chosen_oneof_cls = oneof_cls - oneof_classes.append(oneof_cls) - if not oneof_classes: - raise ApiValueError( - "Invalid inputs given to generate an instance of {}. None " - "of the oneOf schemas matched the input data.".format(cls) - ) - elif len(oneof_classes) > 1: - raise ApiValueError( - "Invalid inputs given to generate an instance of {}. Multiple " - "oneOf schemas {} matched the inputs, but a max of one is allowed.".format(cls, oneof_classes) - ) - return path_to_schemas - - @classmethod - def __get_anyof_classes( - cls, - arg, - discriminated_cls, - validation_metadata: ValidationMetadata - ): - anyof_classes = [] - chosen_anyof_cls = None - original_base_classes = validation_metadata.base_classes - path_to_schemas = defaultdict(set) - for anyof_cls in cls._composed_schemas['anyOf']: - if anyof_cls in validation_metadata.base_classes: - continue - if isinstance(arg, anyof_cls): - # passed in instance is the correct type - chosen_anyof_cls = anyof_cls - anyof_classes.append(anyof_cls) - continue - - try: - other_path_to_schemas = anyof_cls._validate(arg, validation_metadata=validation_metadata) - except (ApiValueError, ApiTypeError) as ex: - if discriminated_cls is not None and anyof_cls is discriminated_cls: - raise ex - continue - original_base_classes = validation_metadata.base_classes - chosen_anyof_cls = anyof_cls - anyof_classes.append(anyof_cls) - update(path_to_schemas, other_path_to_schemas) - if not anyof_classes: - raise ApiValueError( - "Invalid inputs given to generate an instance of {}. None " - "of the anyOf schemas matched the input data.".format(cls) - ) - return path_to_schemas - - @classmethod - def _validate( - cls, - arg, - validation_metadata: ValidationMetadata, - ): - """ - ComposedBase _validate - We return dynamic classes of different bases depending upon the inputs - This makes it so: - - the returned instance is always a subclass of our defining schema - - this allows us to check type based on whether an instance is a subclass of a schema - - the returned instance is a serializable type (except for None, True, and False) which are enums - - Returns: - new_cls (type): the new class - - Raises: - ApiValueError: when a string can't be converted into a date or datetime and it must be one of those classes - ApiTypeError: when the input type is not in the list of allowed spec types - """ - if isinstance(arg, Schema) and validation_metadata.from_server is False: - if isinstance(arg, cls): - # an instance of the correct type was passed in - return {} - raise ApiTypeError( - 'Incorrect type passed in, required type was {} and passed type was {} at {}'.format( - cls, - type(arg), - validation_metadata.path_to_item - ) - ) - - # validation checking on types, validations, and enums - path_to_schemas = super()._validate(arg, validation_metadata=validation_metadata) - - updated_vm = ValidationMetadata( - configuration=validation_metadata.configuration, - from_server=validation_metadata.from_server, - path_to_item=validation_metadata.path_to_item, - base_classes=validation_metadata.base_classes | frozenset({cls}) - ) - - # process composed schema - _discriminator = getattr(cls, '_discriminator', None) - discriminated_cls = None - if _discriminator and arg and isinstance(arg, frozendict): - disc_property_name = list(_discriminator.keys())[0] - cls._ensure_discriminator_value_present(disc_property_name, updated_vm, arg) - # get discriminated_cls by looking at the dict in the current class - discriminated_cls = cls._get_discriminated_class( - disc_property_name=disc_property_name, disc_payload_value=arg[disc_property_name]) - if discriminated_cls is None: - raise ApiValueError( - "Invalid discriminator value '{}' was passed in to {}.{} Only the values {} are allowed at {}".format( - arg[disc_property_name], - cls.__name__, - disc_property_name, - list(_discriminator[disc_property_name].keys()), - updated_vm.path_to_item + (disc_property_name,) - ) - ) - - if cls._composed_schemas['allOf']: - other_path_to_schemas = cls.__get_allof_classes(arg, validation_metadata=updated_vm) - update(path_to_schemas, other_path_to_schemas) - if cls._composed_schemas['oneOf']: - other_path_to_schemas = cls.__get_oneof_class( - arg, - discriminated_cls=discriminated_cls, - validation_metadata=updated_vm, - path_to_schemas=path_to_schemas - ) - update(path_to_schemas, other_path_to_schemas) - if cls._composed_schemas['anyOf']: - other_path_to_schemas = cls.__get_anyof_classes( - arg, - discriminated_cls=discriminated_cls, - validation_metadata=updated_vm - ) - update(path_to_schemas, other_path_to_schemas) - not_cls = cls._composed_schemas['not'] - if not_cls: - other_path_to_schemas = None - try: - other_path_to_schemas = not_cls._validate(arg, validation_metadata=updated_vm) - except (ApiValueError, ApiTypeError): - pass - if other_path_to_schemas: - raise ApiValueError( - "Invalid value '{}' was passed in to {}. Value is invalid because it is disallowed by {}".format( - arg, - cls.__name__, - not_cls.__name__, - ) - ) - - if discriminated_cls is not None: - # TODO use an exception from this package here - assert discriminated_cls in path_to_schemas[updated_vm.path_to_item] - return path_to_schemas - - -# DictBase, ListBase, NumberBase, StrBase, BoolBase, NoneBase -class ComposedSchema( - _SchemaTypeChecker(typing.Union[none_type, str, decimal.Decimal, bool, tuple, frozendict]), - ComposedBase, - DictBase, - ListBase, - NumberBase, - StrBase, - BoolBase, - NoneBase, - Schema -): - - # subclass properties - _composed_schemas = {} - - @classmethod - def _from_openapi_data(cls, *args: typing.Any, _configuration: typing.Optional[Configuration] = None, **kwargs): - if not args: - if not kwargs: - raise ApiTypeError('{} is missing required input data in args or kwargs'.format(cls.__name__)) - args = (kwargs, ) - return super()._from_openapi_data(args[0], _configuration=_configuration) - - -class ListSchema( - _SchemaTypeChecker(typing.Union[tuple]), - ListBase, - Schema -): - - @classmethod - def _from_openapi_data(cls, arg: typing.List[typing.Any], _configuration: typing.Optional[Configuration] = None): - return super()._from_openapi_data(arg, _configuration=_configuration) - - def __new__(cls, arg: typing.Union[list, tuple], **kwargs: ValidationMetadata): - return super().__new__(cls, arg, **kwargs) - - -class NoneSchema( - _SchemaTypeChecker(typing.Union[none_type]), - NoneBase, - Schema -): - - @classmethod - def _from_openapi_data(cls, arg: None, _configuration: typing.Optional[Configuration] = None): - return super()._from_openapi_data(arg, _configuration=_configuration) - - def __new__(cls, arg: None, **kwargs: typing.Union[ValidationMetadata]): - return super().__new__(cls, arg, **kwargs) - - -class NumberSchema( - _SchemaTypeChecker(typing.Union[decimal.Decimal]), - NumberBase, - Schema -): - """ - This is used for type: number with no format - Both integers AND floats are accepted - """ - - @classmethod - def _from_openapi_data(cls, arg: typing.Union[int, float, decimal.Decimal], _configuration: typing.Optional[Configuration] = None): - return super()._from_openapi_data(arg, _configuration=_configuration) - - def __new__(cls, arg: typing.Union[decimal.Decimal, int, float], **kwargs: typing.Union[ValidationMetadata]): - return super().__new__(cls, arg, **kwargs) - - -class IntBase(NumberBase): - @property - def as_int(self) -> int: - try: - return self._as_int - except AttributeError: - self._as_int = int(self) - return self._as_int - - @classmethod - def _validate_format(cls, arg: typing.Optional[decimal.Decimal], validation_metadata: ValidationMetadata): - if isinstance(arg, decimal.Decimal): - - denominator = arg.as_integer_ratio()[-1] - if denominator != 1: - raise ApiValueError( - "Invalid value '{}' for type integer at {}".format(arg, validation_metadata.path_to_item) - ) - - @classmethod - def _validate( - cls, - arg, - validation_metadata: ValidationMetadata, - ): - """ - IntBase _validate - TODO what about types = (int, number) -> IntBase, NumberBase? We could drop int and keep number only - """ - cls._validate_format(arg, validation_metadata=validation_metadata) - return super()._validate(arg, validation_metadata=validation_metadata) - - -class IntSchema(IntBase, NumberSchema): - - @classmethod - def _from_openapi_data(cls, arg: int, _configuration: typing.Optional[Configuration] = None): - return super()._from_openapi_data(arg, _configuration=_configuration) - - def __new__(cls, arg: typing.Union[decimal.Decimal, int], **kwargs: typing.Union[ValidationMetadata]): - return super().__new__(cls, arg, **kwargs) - - -class Int32Base( - _SchemaValidator( - inclusive_minimum=decimal.Decimal(-2147483648), - inclusive_maximum=decimal.Decimal(2147483647) - ), -): - pass - - -class Int32Schema( - Int32Base, - IntSchema -): - pass - - -class Int64Base( - _SchemaValidator( - inclusive_minimum=decimal.Decimal(-9223372036854775808), - inclusive_maximum=decimal.Decimal(9223372036854775807) - ), -): - pass - - -class Int64Schema( - Int64Base, - IntSchema -): - pass - - -class Float32Base( - _SchemaValidator( - inclusive_minimum=decimal.Decimal(-3.4028234663852886e+38), - inclusive_maximum=decimal.Decimal(3.4028234663852886e+38) - ), -): - pass - - -class Float32Schema( - Float32Base, - NumberSchema -): - - @classmethod - def _from_openapi_data(cls, arg: typing.Union[float, decimal.Decimal], _configuration: typing.Optional[Configuration] = None): - # todo check format - return super()._from_openapi_data(arg, _configuration=_configuration) - - -class Float64Base( - _SchemaValidator( - inclusive_minimum=decimal.Decimal(-1.7976931348623157E+308), - inclusive_maximum=decimal.Decimal(1.7976931348623157E+308) - ), -): - pass - - -class Float64Schema( - Float64Base, - NumberSchema -): - - @classmethod - def _from_openapi_data(cls, arg: typing.Union[float, decimal.Decimal], _configuration: typing.Optional[Configuration] = None): - # todo check format - return super()._from_openapi_data(arg, _configuration=_configuration) - - -class StrSchema( - _SchemaTypeChecker(typing.Union[str]), - StrBase, - Schema -): - """ - date + datetime string types must inherit from this class - That is because one can validate a str payload as both: - - type: string (format unset) - - type: string, format: date - """ - - @classmethod - def _from_openapi_data(cls, arg: typing.Union[str], _configuration: typing.Optional[Configuration] = None) -> 'StrSchema': - return super()._from_openapi_data(arg, _configuration=_configuration) - - def __new__(cls, arg: typing.Union[str, date, datetime, uuid.UUID], **kwargs: typing.Union[ValidationMetadata]): - return super().__new__(cls, arg, **kwargs) - - -class UUIDSchema(UUIDBase, StrSchema): - - def __new__(cls, arg: typing.Union[str, uuid.UUID], **kwargs: typing.Union[ValidationMetadata]): - return super().__new__(cls, arg, **kwargs) - - -class DateSchema(DateBase, StrSchema): - - def __new__(cls, arg: typing.Union[str, datetime], **kwargs: typing.Union[ValidationMetadata]): - return super().__new__(cls, arg, **kwargs) - - -class DateTimeSchema(DateTimeBase, StrSchema): - - def __new__(cls, arg: typing.Union[str, datetime], **kwargs: typing.Union[ValidationMetadata]): - return super().__new__(cls, arg, **kwargs) - - -class DecimalSchema(DecimalBase, StrSchema): - - def __new__(cls, arg: typing.Union[str], **kwargs: typing.Union[ValidationMetadata]): - """ - Note: Decimals may not be passed in because cast_to_allowed_types is only invoked once for payloads - which can be simple (str) or complex (dicts or lists with nested values) - Because casting is only done once and recursively casts all values prior to validation then for a potential - client side Decimal input if Decimal was accepted as an input in DecimalSchema then one would not know - if one was using it for a StrSchema (where it should be cast to str) or one is using it for NumberSchema - where it should stay as Decimal. - """ - return super().__new__(cls, arg, **kwargs) - - -class BytesSchema( - _SchemaTypeChecker(typing.Union[bytes]), - Schema, -): - """ - this class will subclass bytes and is immutable - """ - def __new__(cls, arg: typing.Union[bytes], **kwargs: typing.Union[ValidationMetadata]): - return super(Schema, cls).__new__(cls, arg) - - -class FileSchema( - _SchemaTypeChecker(typing.Union[FileIO]), - Schema, -): - """ - This class is NOT immutable - Dynamic classes are built using it for example when AnyType allows in binary data - Al other schema classes ARE immutable - If one wanted to make this immutable one could make this a DictSchema with required properties: - - data = BytesSchema (which would be an immutable bytes based schema) - - file_name = StrSchema - and cast_to_allowed_types would convert bytes and file instances into dicts containing data + file_name - The downside would be that data would be stored in memory which one may not want to do for very large files - - The developer is responsible for closing this file and deleting it - - This class was kept as mutable: - - to allow file reading and writing to disk - - to be able to preserve file name info - """ - - def __new__(cls, arg: typing.Union[io.FileIO, io.BufferedReader], **kwargs: typing.Union[ValidationMetadata]): - return super(Schema, cls).__new__(cls, arg) - - -class BinaryBase: - pass - - -class BinarySchema( - _SchemaTypeChecker(typing.Union[bytes, FileIO]), - ComposedBase, - BinaryBase, - Schema, -): - - @classmethod - @property - def _composed_schemas(cls): - # 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 because 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 { - 'allOf': [], - 'oneOf': [ - BytesSchema, - FileSchema, - ], - 'anyOf': [ - ], - 'not': None - } - - def __new__(cls, arg: typing.Union[io.FileIO, io.BufferedReader, bytes], **kwargs: typing.Union[ValidationMetadata]): - return super().__new__(cls, arg) - - -class BoolSchema( - _SchemaTypeChecker(typing.Union[bool]), - BoolBase, - Schema -): - - @classmethod - def _from_openapi_data(cls, arg: bool, _configuration: typing.Optional[Configuration] = None): - return super()._from_openapi_data(arg, _configuration=_configuration) - - def __new__(cls, arg: bool, **kwargs: typing.Union[ValidationMetadata]): - return super().__new__(cls, arg, **kwargs) - - -class AnyTypeSchema( - _SchemaTypeChecker( - typing.Union[frozendict, tuple, decimal.Decimal, str, bool, none_type, bytes, FileIO] - ), - DictBase, - ListBase, - NumberBase, - StrBase, - BoolBase, - NoneBase, - Schema -): - pass - - -class DictSchema( - _SchemaTypeChecker(typing.Union[frozendict]), - DictBase, - Schema -): - - @classmethod - def _from_openapi_data(cls, arg: typing.Dict[str, typing.Any], _configuration: typing.Optional[Configuration] = None): - return super()._from_openapi_data(arg, _configuration=_configuration) - - def __new__(cls, *args: typing.Union[dict, frozendict], **kwargs: typing.Union[dict, frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, bytes, Schema, Unset, ValidationMetadata]): - return super().__new__(cls, *args, **kwargs) - - -schema_descendents = set([NoneSchema, DictSchema, ListSchema, NumberSchema, StrSchema, BoolSchema]) - - -def deserialize_file(response_data, configuration, content_disposition=None): - """Deserializes body to file - - Saves response body into a file in a temporary folder, - using the filename from the `Content-Disposition` header if provided. - - Args: - param response_data (str): the file data to write - configuration (Configuration): the instance to use to convert files - - Keyword Args: - content_disposition (str): the value of the Content-Disposition - header - - Returns: - (file_type): the deserialized file which is open - The user is responsible for closing and reading the file - """ - fd, path = tempfile.mkstemp(dir=configuration.temp_folder_path) - os.close(fd) - os.remove(path) - - if content_disposition: - filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', - content_disposition).group(1) - path = os.path.join(os.path.dirname(path), filename) - - with open(path, "wb") as f: - if isinstance(response_data, str): - # change str to bytes so we can write it - response_data = response_data.encode('utf-8') - f.write(response_data) - - f = open(path, "rb") - return f - - -@functools.cache -def get_new_class( - class_name: str, - bases: typing.Tuple[typing.Type[typing.Union[Schema, typing.Any]], ...] -) -> typing.Type[Schema]: - """ - Returns a new class that is made with the subclass bases - """ - return type(class_name, bases, {}) - - -LOG_CACHE_USAGE = False - - -def log_cache_usage(cache_fn): - if LOG_CACHE_USAGE: - print(cache_fn.__name__, cache_fn.cache_info()) -- GitLab From bdf915db42ff8bb95f5e8fa9b0924bb7cffcfc37 Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Mon, 27 Jun 2022 23:08:36 -0700 Subject: [PATCH 25/43] Working on properties examples, partial fix for escaped characters --- .../codegen/ObjectWithTypeBooleans.java | 4 +- .../PythonExperimentalClientCodegen.java | 16 +- .../payload_renderer.handlebars | 4 +- .../model_templates/schema.handlebars | 2 +- .../3_0/unit_test_spec/spec_writer.py | 7 +- .../resources/3_0/unit_test_spec/type.yaml | 85 +- .../.openapi-generator/FILES | 12 +- .../python-experimental/README.md | 4 +- .../docs/ObjectPropertiesValidation.md | 11 + .../docs/PropertiesWithEscapedCharacters.md | 16 + .../python-experimental/test/__init__.py | 0 .../test/test_object_properties_validation.py | 95 + ...test_properties_with_escaped_characters.py | 82 + .../unit_test_api/__init__.py | 28 + .../unit_test_api/api/__init__.py | 0 .../unit_test_api/api_client.py | 1420 +++++++++++ .../unit_test_api/apis/__init__.py | 0 .../unit_test_api/configuration.py | 440 ++++ .../unit_test_api/exceptions.py | 136 + .../unit_test_api/model/__init__.py | 5 + .../model/object_properties_validation.py | 95 + .../properties_with_escaped_characters.py | 108 + .../unit_test_api/models/__init__.py | 15 + .../python-experimental/unit_test_api/rest.py | 253 ++ .../unit_test_api/schemas.py | 2201 +++++++++++++++++ 25 files changed, 5020 insertions(+), 19 deletions(-) create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ObjectPropertiesValidation.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PropertiesWithEscapedCharacters.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/__init__.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_object_properties_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/__init__.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/api/__init__.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/api_client.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/__init__.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/configuration.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/exceptions.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/__init__.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/object_properties_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/properties_with_escaped_characters.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/rest.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/schemas.py diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/ObjectWithTypeBooleans.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/ObjectWithTypeBooleans.java index 3b6312b44e0..9b2f8ed3c6b 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/ObjectWithTypeBooleans.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/ObjectWithTypeBooleans.java @@ -31,9 +31,9 @@ public class ObjectWithTypeBooleans { } } else if (value instanceof LinkedHashMap) { LinkedHashMap<String, Object> castValue = (LinkedHashMap<String, Object>) value; - LinkedHashMap<String, ObjectWithTypeBooleans> castMap = new LinkedHashMap<>(); + LinkedHashMap<ObjectWithTypeBooleans, ObjectWithTypeBooleans> castMap = new LinkedHashMap<>(); for (Map.Entry entry: castValue.entrySet()) { - String entryKey = (String) entry.getKey(); + ObjectWithTypeBooleans entryKey = new ObjectWithTypeBooleans(entry.getKey()); ObjectWithTypeBooleans entryValue = new ObjectWithTypeBooleans(entry.getValue()); castMap.put(entryKey, entryValue); } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java index 44ae9750c2d..19aee3f6613 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java @@ -1158,21 +1158,29 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen { } protected Object processTestExampleData(Object value) { + String nullChar = "\0"; if (value instanceof Integer){ return value; } else if (value instanceof Double || value instanceof Float || value instanceof Boolean){ return value; } else if (value instanceof String) { - String nullChar = "\0"; String stringValue = (String) value; if (stringValue.contains(nullChar)) { stringValue = stringValue.replace(nullChar, "\\x00"); } + String backSlash = "\\"; + if (stringValue.contains(backSlash)) { + stringValue = stringValue.replace(backSlash, "\\\\"); + } + String doubleQuoteChar = "\""; + if (stringValue.contains(doubleQuoteChar)) { + stringValue = stringValue.replace(doubleQuoteChar, "\\\""); + } return stringValue; } else if (value instanceof LinkedHashMap) { - LinkedHashMap<String, Object> fixedValues = (LinkedHashMap<String, Object>) value; - for (Map.Entry entry: fixedValues.entrySet()) { - String entryKey = (String) entry.getKey(); + LinkedHashMap<String, Object> fixedValues = new LinkedHashMap(); + for (Map.Entry entry: ((LinkedHashMap<String, Object>) value).entrySet()) { + String entryKey = (String) processTestExampleData(entry.getKey()); Object entryValue = processTestExampleData(entry.getValue()); fixedValues.put(entryKey, entryValue); } diff --git a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars index b6b1a63cea3..29114dafa35 100644 --- a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars +++ b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars @@ -8,7 +8,9 @@ {{#if isMap}} {{#not value.isEmpty}}**{{/not}}{ {{#each value}} - "{{@key}}": + {{#with @key}} + {{> model_templates/payload_renderer }}: + {{/with}} {{#with this}} {{> model_templates/payload_renderer }}, {{/with}} diff --git a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/schema.handlebars b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/schema.handlebars index 7523d39f0ea..fb6453f7918 100644 --- a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/schema.handlebars +++ b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/schema.handlebars @@ -39,7 +39,7 @@ {{/or}} {{/or}} {{#if nameInSnakeCase}} -locals()['{{baseName}}'] = {{name}} +locals()['{{{baseName}}}'] = {{name}} del locals()['{{name}}'] {{/if}} {{/if}} diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index c3254571cde..db3bae19789 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -124,6 +124,10 @@ FILEPATH_TO_EXCLUDED_CASE_AND_REASON = { (json_schema_test_draft, 'oneOf.json'): { 'oneOf with missing optional property': ExclusionReason.v303_does_not_support_boolean_schemas_in_location, }, + (json_schema_test_draft, 'properties.json'): { + 'properties, patternProperties, additionalProperties interaction': ExclusionReason.v303_does_not_support_patternProperties, + 'properties with boolean schema': ExclusionReason.v303_does_not_support_boolean_schemas_in_location, + } } FILEPATH_TO_EXCLUDE_REASON = { (json_schema_test_draft, 'additionalItems.json'): ExclusionReason.v303_does_not_support_additionalItems, @@ -171,7 +175,8 @@ JSON_SCHEMA_TEST_FILE_TO_FOLDERS = { # 'not.json': (json_schema_test_draft,), # 'oneOf.json': (json_schema_test_draft,), # activate after fixing this # 'pattern.json': (json_schema_test_draft,), - 'patternProperties.json': (json_schema_test_draft,), +# 'patternProperties.json': (json_schema_test_draft,), + 'properties.json': (json_schema_test_draft,), } def get_json_schema_test_schemas(file_path: typing.Tuple[str]) -> typing.List[JsonSchemaTestSchema]: diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml index 2a0b920f0b7..5095cd42dc6 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml @@ -6,5 +6,86 @@ info: version: 0.0.1 paths: {} components: - schemas: {} - x-schema-test-examples: {} + schemas: + ObjectPropertiesValidation: + properties: + foo: + type: integer + bar: + type: string + PropertiesWithEscapedCharacters: + properties: + ? 'foo + + bar' + : type: number + foo"bar: + type: number + foo\bar: + type: number + "foo\rbar": + type: number + "foo\tbar": + type: number + "foo\fbar": + type: number + x-schema-test-examples: + ObjectPropertiesValidation: + BothPropertiesPresentAndValidIsValid: + description: both properties present and valid is valid + data: + foo: 1 + bar: baz + valid: true + OnePropertyInvalidIsInvalid: + description: one property invalid is invalid + data: + foo: 1 + bar: {} + valid: false + BothPropertiesInvalidIsInvalid: + description: both properties invalid is invalid + data: + foo: [] + bar: {} + valid: false + DoesnTInvalidateOtherProperties: + description: doesn't invalidate other properties + data: + quux: [] + valid: true + IgnoresArrays: + description: ignores arrays + data: [] + valid: true + IgnoresOtherNonObjects: + description: ignores other non-objects + data: 12 + valid: true + PropertiesWithEscapedCharacters: + ObjectWithAllNumbersIsValid: + description: object with all numbers is valid + data: + ? 'foo + + bar' + : 1 + foo"bar: 1 + foo\bar: 1 + "foo\rbar": 1 + "foo\tbar": 1 + "foo\fbar": 1 + valid: true + ObjectWithStringsIsInvalid: + description: object with strings is invalid + data: + ? 'foo + + bar' + : '1' + foo"bar: '1' + foo\bar: '1' + "foo\rbar": '1' + "foo\tbar": '1' + "foo\fbar": '1' + valid: false diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index 64a999b8b6e..f7612595387 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -2,16 +2,16 @@ .gitlab-ci.yml .travis.yml README.md -docs/PatternIsNotAnchored.md -docs/PatternValidation.md +docs/ObjectPropertiesValidation.md +docs/PropertiesWithEscapedCharacters.md git_push.sh requirements.txt setup.cfg setup.py test-requirements.txt test/__init__.py -test/test_pattern_is_not_anchored.py -test/test_pattern_validation.py +test/test_object_properties_validation.py +test/test_properties_with_escaped_characters.py tox.ini unit_test_api/__init__.py unit_test_api/api/__init__.py @@ -20,8 +20,8 @@ unit_test_api/apis/__init__.py unit_test_api/configuration.py unit_test_api/exceptions.py unit_test_api/model/__init__.py -unit_test_api/model/pattern_is_not_anchored.py -unit_test_api/model/pattern_validation.py +unit_test_api/model/object_properties_validation.py +unit_test_api/model/properties_with_escaped_characters.py unit_test_api/models/__init__.py unit_test_api/rest.py unit_test_api/schemas.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md index 341ac90f843..1362e29d020 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md @@ -62,8 +62,8 @@ Class | Method | HTTP request | Description ## Documentation For Models - - [PatternIsNotAnchored](docs/PatternIsNotAnchored.md) - - [PatternValidation](docs/PatternValidation.md) + - [ObjectPropertiesValidation](docs/ObjectPropertiesValidation.md) + - [PropertiesWithEscapedCharacters](docs/PropertiesWithEscapedCharacters.md) ## Documentation For Authorization diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ObjectPropertiesValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ObjectPropertiesValidation.md new file mode 100644 index 00000000000..9307469f5bb --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ObjectPropertiesValidation.md @@ -0,0 +1,11 @@ +# ObjectPropertiesValidation + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**foo** | **int** | | [optional] +**bar** | **str** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PropertiesWithEscapedCharacters.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PropertiesWithEscapedCharacters.md new file mode 100644 index 00000000000..03b7ad904cf --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PropertiesWithEscapedCharacters.md @@ -0,0 +1,16 @@ +# PropertiesWithEscapedCharacters + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**foo +bar** | **int, float** | | [optional] +**foo"bar** | **int, float** | | [optional] +**foo\bar** | **int, float** | | [optional] +**foo bar** | **int, float** | | [optional] +**foo bar** | **int, float** | | [optional] +**foobar** | **int, float** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_object_properties_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_object_properties_validation.py new file mode 100644 index 00000000000..6aaf84593ca --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_object_properties_validation.py @@ -0,0 +1,95 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.object_properties_validation import ObjectPropertiesValidation + + +class TestObjectPropertiesValidation(unittest.TestCase): + """ObjectPropertiesValidation unit test stubs""" + + def test_ignores_arrays_passes(self): + # ignores arrays + ObjectPropertiesValidation( + [ + ] + ) + + def test_ignores_other_non_objects_passes(self): + # ignores other non-objects + ObjectPropertiesValidation( + 12 ) + + def test_one_property_invalid_is_invalid_fails(self): + # one property invalid is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + ObjectPropertiesValidation( + **{ + + "foo": + 1, + + "bar": + { + } +, + } + ) + + def test_both_properties_present_and_valid_is_valid_passes(self): + # both properties present and valid is valid + ObjectPropertiesValidation( + **{ + + "foo": + 1, + + "bar": + + "baz", + } + ) + + def test_doesn_t_invalidate_other_properties_passes(self): + # doesn't invalidate other properties + ObjectPropertiesValidation( + **{ + + "quux": + [ + ] +, + } + ) + + def test_both_properties_invalid_is_invalid_fails(self): + # both properties invalid is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + ObjectPropertiesValidation( + **{ + + "foo": + [ + ] +, + + "bar": + { + } +, + } + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py new file mode 100644 index 00000000000..65c155d6ab9 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py @@ -0,0 +1,82 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.properties_with_escaped_characters import PropertiesWithEscapedCharacters + + +class TestPropertiesWithEscapedCharacters(unittest.TestCase): + """PropertiesWithEscapedCharacters unit test stubs""" + + def test_object_with_all_numbers_is_valid_passes(self): + # object with all numbers is valid + PropertiesWithEscapedCharacters( + **{ + + """foo +bar""": + 1, + + "foo\"bar": + 1, + + "foo\\bar": + 1, + + """foo bar""": + 1, + + "foo bar": + 1, + + "foobar": + 1, + } + ) + + def test_object_with_strings_is_invalid_fails(self): + # object with strings is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + PropertiesWithEscapedCharacters( + **{ + + """foo +bar""": + + "1", + + "foo\"bar": + + "1", + + "foo\\bar": + + "1", + + """foo bar""": + + "1", + + "foo bar": + + "1", + + "foobar": + + "1", + } + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/__init__.py new file mode 100644 index 00000000000..5ca6e989be0 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/__init__.py @@ -0,0 +1,28 @@ +# coding: utf-8 + +# flake8: noqa + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +__version__ = "1.0.0" + +# import ApiClient +from unit_test_api.api_client import ApiClient + +# import Configuration +from unit_test_api.configuration import Configuration + +# import exceptions +from unit_test_api.exceptions import OpenApiException +from unit_test_api.exceptions import ApiAttributeError +from unit_test_api.exceptions import ApiTypeError +from unit_test_api.exceptions import ApiValueError +from unit_test_api.exceptions import ApiKeyError +from unit_test_api.exceptions import ApiException diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/api/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/api/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/api_client.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/api_client.py new file mode 100644 index 00000000000..66e52cba296 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/api_client.py @@ -0,0 +1,1420 @@ +# coding: utf-8 +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +from dataclasses import dataclass +from decimal import Decimal +import enum +import email +import json +import os +import io +import atexit +from multiprocessing.pool import ThreadPool +import re +import tempfile +import typing +import urllib3 +from urllib3._collections import HTTPHeaderDict +from urllib.parse import quote +from urllib3.fields import RequestField as RequestFieldBase + + +from unit_test_api import rest +from unit_test_api.configuration import Configuration +from unit_test_api.exceptions import ApiTypeError, ApiValueError +from unit_test_api.schemas import ( + NoneClass, + BoolClass, + Schema, + FileIO, + BinarySchema, + date, + datetime, + none_type, + frozendict, + Unset, + unset, +) + + +class RequestField(RequestFieldBase): + def __eq__(self, other): + if not isinstance(other, RequestField): + return False + return self.__dict__ == other.__dict__ + + +class JSONEncoder(json.JSONEncoder): + def default(self, obj): + if isinstance(obj, str): + return str(obj) + elif isinstance(obj, float): + return float(obj) + elif isinstance(obj, int): + return int(obj) + elif isinstance(obj, Decimal): + if obj.as_tuple().exponent >= 0: + return int(obj) + return float(obj) + elif isinstance(obj, NoneClass): + return None + elif isinstance(obj, BoolClass): + return bool(obj) + elif isinstance(obj, (dict, frozendict)): + return {key: self.default(val) for key, val in obj.items()} + elif isinstance(obj, (list, tuple)): + return [self.default(item) for item in obj] + raise ApiValueError('Unable to prepare type {} for serialization'.format(obj.__class__.__name__)) + + +class ParameterInType(enum.Enum): + QUERY = 'query' + HEADER = 'header' + PATH = 'path' + COOKIE = 'cookie' + + +class ParameterStyle(enum.Enum): + MATRIX = 'matrix' + LABEL = 'label' + FORM = 'form' + SIMPLE = 'simple' + SPACE_DELIMITED = 'spaceDelimited' + PIPE_DELIMITED = 'pipeDelimited' + DEEP_OBJECT = 'deepObject' + + +class PrefixSeparatorIterator: + # A class to store prefixes and separators for rfc6570 expansions + + def __init__(self, prefix: str, separator: str): + self.prefix = prefix + self.separator = separator + self.first = True + if separator in {'.', '|', '%20'}: + item_separator = separator + else: + item_separator = ',' + self.item_separator = item_separator + + def __iter__(self): + return self + + def __next__(self): + if self.first: + self.first = False + return self.prefix + return self.separator + + +class ParameterSerializerBase: + @classmethod + def get_default_explode(cls, style: ParameterStyle) -> bool: + return False + + @staticmethod + def __ref6570_item_value(in_data: typing.Any, percent_encode: bool): + """ + Get representation if str/float/int/None/items in list/ values in dict + None is returned if an item is undefined, use cases are value= + - None + - [] + - {} + - [None, None None] + - {'a': None, 'b': None} + """ + if type(in_data) in {str, float, int}: + if percent_encode: + return quote(str(in_data)) + return str(in_data) + elif isinstance(in_data, none_type): + # ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1 + return None + elif isinstance(in_data, list) and not in_data: + # ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1 + return None + elif isinstance(in_data, dict) and not in_data: + # ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1 + return None + raise ApiValueError('Unable to generate a ref6570 item representation of {}'.format(in_data)) + + @staticmethod + def to_dict(name: str, value: str): + return {name: value} + + @classmethod + def ref6570_expansion( + cls, + variable_name: str, + in_data: typing.Any, + explode: bool, + percent_encode: bool, + prefix_separator_iterator: PrefixSeparatorIterator + ) -> str: + """ + Separator is for separate variables like dict with explode true, not for array item separation + """ + named_parameter_expansion = prefix_separator_iterator.separator in {'&', ';'} + var_name_piece = variable_name if named_parameter_expansion else '' + if type(in_data) in {str, float, int}: + item_value = cls.__ref6570_item_value(in_data, percent_encode) + if item_value is None: + return next(prefix_separator_iterator) + var_name_piece + elif item_value == '' and prefix_separator_iterator.separator == ';': + return next(prefix_separator_iterator) + var_name_piece + value_pair_equals = '=' if named_parameter_expansion else '' + return next(prefix_separator_iterator) + var_name_piece + value_pair_equals + item_value + elif isinstance(in_data, none_type): + # ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1 + return "" + elif isinstance(in_data, list): + item_values = [cls.__ref6570_item_value(v, percent_encode) for v in in_data] + item_values = [v for v in item_values if v is not None] + if not item_values: + # ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1 + return "" + value_pair_equals = '=' if named_parameter_expansion else '' + if not explode: + return ( + next(prefix_separator_iterator) + + var_name_piece + + value_pair_equals + + prefix_separator_iterator.item_separator.join(item_values) + ) + # exploded + return next(prefix_separator_iterator) + next(prefix_separator_iterator).join( + [var_name_piece + value_pair_equals + val for val in item_values] + ) + elif isinstance(in_data, dict): + in_data_transformed = {key: cls.__ref6570_item_value(val, percent_encode) for key, val in in_data.items()} + in_data_transformed = {key: val for key, val in in_data_transformed.items() if val is not None} + if not in_data_transformed: + # ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1 + return "" + value_pair_equals = '=' if named_parameter_expansion else '' + if not explode: + return ( + next(prefix_separator_iterator) + + var_name_piece + value_pair_equals + + prefix_separator_iterator.item_separator.join( + prefix_separator_iterator.item_separator.join( + item_pair + ) for item_pair in in_data_transformed.items() + ) + ) + # exploded + return next(prefix_separator_iterator) + next(prefix_separator_iterator).join( + [key + '=' + val for key, val in in_data_transformed.items()] + ) + # bool, bytes, etc + raise ApiValueError('Unable to generate a ref6570 representation of {}'.format(in_data)) + + +class StyleFormSerializer(ParameterSerializerBase): + @classmethod + def get_default_explode(cls, style: ParameterStyle) -> bool: + if style is ParameterStyle.FORM: + return True + return super().get_default_explode(style) + + def serialize_form( + self, + in_data: typing.Union[None, int, float, str, bool, dict, list], + name: str, + explode: bool, + percent_encode: bool, + prefix_separator_iterator: typing.Optional[PrefixSeparatorIterator] = None + ) -> str: + if prefix_separator_iterator is None: + prefix_separator_iterator = PrefixSeparatorIterator('?', '&') + return self.ref6570_expansion( + variable_name=name, + in_data=in_data, + explode=explode, + percent_encode=percent_encode, + prefix_separator_iterator=prefix_separator_iterator + ) + + +class StyleSimpleSerializer(ParameterSerializerBase): + + def serialize_simple( + self, + in_data: typing.Union[None, int, float, str, bool, dict, list], + name: str, + explode: bool, + percent_encode: bool + ) -> str: + prefix_separator_iterator = PrefixSeparatorIterator('', ',') + return self.ref6570_expansion( + variable_name=name, + in_data=in_data, + explode=explode, + percent_encode=percent_encode, + prefix_separator_iterator=prefix_separator_iterator + ) + + +@dataclass +class ParameterBase: + name: str + in_type: ParameterInType + required: bool + style: typing.Optional[ParameterStyle] + explode: typing.Optional[bool] + allow_reserved: typing.Optional[bool] + schema: typing.Optional[typing.Type[Schema]] + content: typing.Optional[typing.Dict[str, typing.Type[Schema]]] + + __style_to_in_type = { + ParameterStyle.MATRIX: {ParameterInType.PATH}, + ParameterStyle.LABEL: {ParameterInType.PATH}, + ParameterStyle.FORM: {ParameterInType.QUERY, ParameterInType.COOKIE}, + ParameterStyle.SIMPLE: {ParameterInType.PATH, ParameterInType.HEADER}, + ParameterStyle.SPACE_DELIMITED: {ParameterInType.QUERY}, + ParameterStyle.PIPE_DELIMITED: {ParameterInType.QUERY}, + ParameterStyle.DEEP_OBJECT: {ParameterInType.QUERY}, + } + __in_type_to_default_style = { + ParameterInType.QUERY: ParameterStyle.FORM, + ParameterInType.PATH: ParameterStyle.SIMPLE, + ParameterInType.HEADER: ParameterStyle.SIMPLE, + ParameterInType.COOKIE: ParameterStyle.FORM, + } + __disallowed_header_names = {'Accept', 'Content-Type', 'Authorization'} + _json_encoder = JSONEncoder() + _json_content_type = 'application/json' + + @classmethod + def __verify_style_to_in_type(cls, style: typing.Optional[ParameterStyle], in_type: ParameterInType): + if style is None: + return + in_type_set = cls.__style_to_in_type[style] + if in_type not in in_type_set: + raise ValueError( + 'Invalid style and in_type combination. For style={} only in_type={} are allowed'.format( + style, in_type_set + ) + ) + + def __init__( + self, + name: str, + in_type: ParameterInType, + required: bool = False, + style: typing.Optional[ParameterStyle] = None, + explode: bool = False, + allow_reserved: typing.Optional[bool] = None, + schema: typing.Optional[typing.Type[Schema]] = None, + content: typing.Optional[typing.Dict[str, typing.Type[Schema]]] = None + ): + if schema is None and content is None: + raise ValueError('Value missing; Pass in either schema or content') + if schema and content: + raise ValueError('Too many values provided. Both schema and content were provided. Only one may be input') + if name in self.__disallowed_header_names and in_type is ParameterInType.HEADER: + raise ValueError('Invalid name, name may not be one of {}'.format(self.__disallowed_header_names)) + self.__verify_style_to_in_type(style, in_type) + if content is None and style is None: + style = self.__in_type_to_default_style[in_type] + if content is not None and in_type in self.__in_type_to_default_style and len(content) != 1: + raise ValueError('Invalid content length, content length must equal 1') + self.in_type = in_type + self.name = name + self.required = required + self.style = style + self.explode = explode + self.allow_reserved = allow_reserved + self.schema = schema + self.content = content + + @staticmethod + def _remove_empty_and_cast( + in_data: typing.Tuple[typing.Tuple[str, str]], + ) -> typing.Dict[str, str]: + data = tuple(t for t in in_data if t) + if not data: + return dict() + return dict(data) + + def _serialize_json( + self, + in_data: typing.Union[None, int, float, str, bool, dict, list] + ) -> str: + return json.dumps(in_data) + + +class PathParameter(ParameterBase, StyleSimpleSerializer): + + def __init__( + self, + name: str, + required: bool = False, + style: typing.Optional[ParameterStyle] = None, + explode: bool = False, + allow_reserved: typing.Optional[bool] = None, + schema: typing.Optional[typing.Type[Schema]] = None, + content: typing.Optional[typing.Dict[str, typing.Type[Schema]]] = None + ): + super().__init__( + name, + in_type=ParameterInType.PATH, + required=required, + style=style, + explode=explode, + allow_reserved=allow_reserved, + schema=schema, + content=content + ) + + def _serialize_label( + self, + in_data: typing.Union[None, int, float, str, bool, dict, list] + ) -> typing.Dict[str, str]: + prefix_separator_iterator = PrefixSeparatorIterator('.', '.') + value = self.ref6570_expansion( + variable_name=self.name, + in_data=in_data, + explode=self.explode, + percent_encode=True, + prefix_separator_iterator=prefix_separator_iterator + ) + return self.to_dict(self.name, value) + + def _serialize_matrix( + self, + in_data: typing.Union[None, int, float, str, bool, dict, list] + ) -> typing.Dict[str, str]: + prefix_separator_iterator = PrefixSeparatorIterator(';', ';') + value = self.ref6570_expansion( + variable_name=self.name, + in_data=in_data, + explode=self.explode, + percent_encode=True, + prefix_separator_iterator=prefix_separator_iterator + ) + return self.to_dict(self.name, value) + + def _serialize_simple( + self, + in_data: typing.Union[None, int, float, str, bool, dict, list], + ) -> typing.Dict[str, str]: + value = self.serialize_simple( + in_data=in_data, + name=self.name, + explode=self.explode, + percent_encode=True + ) + return self.to_dict(self.name, value) + + def serialize( + self, + in_data: typing.Union[ + Schema, Decimal, int, float, str, date, datetime, None, bool, list, tuple, dict, frozendict] + ) -> typing.Dict[str, str]: + if self.schema: + cast_in_data = self.schema(in_data) + cast_in_data = self._json_encoder.default(cast_in_data) + """ + simple -> path + path: + returns path_params: dict + label -> path + returns path_params + matrix -> path + returns path_params + """ + if self.style: + if self.style is ParameterStyle.SIMPLE: + return self._serialize_simple(cast_in_data) + elif self.style is ParameterStyle.LABEL: + return self._serialize_label(cast_in_data) + elif self.style is ParameterStyle.MATRIX: + return self._serialize_matrix(cast_in_data) + # self.content will be length one + for content_type, schema in self.content.items(): + cast_in_data = schema(in_data) + cast_in_data = self._json_encoder.default(cast_in_data) + if content_type == self._json_content_type: + value = self._serialize_json(cast_in_data) + return self.to_dict(self.name, value) + raise NotImplementedError('Serialization of {} has not yet been implemented'.format(content_type)) + + +class QueryParameter(ParameterBase, StyleFormSerializer): + + def __init__( + self, + name: str, + required: bool = False, + style: typing.Optional[ParameterStyle] = None, + explode: typing.Optional[bool] = None, + allow_reserved: typing.Optional[bool] = None, + schema: typing.Optional[typing.Type[Schema]] = None, + content: typing.Optional[typing.Dict[str, typing.Type[Schema]]] = None + ): + used_style = ParameterStyle.FORM if style is None and content is None and schema else style + used_explode = self.get_default_explode(used_style) if explode is None else explode + + super().__init__( + name, + in_type=ParameterInType.QUERY, + required=required, + style=used_style, + explode=used_explode, + allow_reserved=allow_reserved, + schema=schema, + content=content + ) + + def __serialize_space_delimited( + self, + in_data: typing.Union[None, int, float, str, bool, dict, list], + prefix_separator_iterator: typing.Optional[PrefixSeparatorIterator] + ) -> typing.Dict[str, str]: + if prefix_separator_iterator is None: + prefix_separator_iterator = self.get_prefix_separator_iterator() + value = self.ref6570_expansion( + variable_name=self.name, + in_data=in_data, + explode=self.explode, + percent_encode=True, + prefix_separator_iterator=prefix_separator_iterator + ) + return self.to_dict(self.name, value) + + def __serialize_pipe_delimited( + self, + in_data: typing.Union[None, int, float, str, bool, dict, list], + prefix_separator_iterator: typing.Optional[PrefixSeparatorIterator] + ) -> typing.Dict[str, str]: + if prefix_separator_iterator is None: + prefix_separator_iterator = self.get_prefix_separator_iterator() + value = self.ref6570_expansion( + variable_name=self.name, + in_data=in_data, + explode=self.explode, + percent_encode=True, + prefix_separator_iterator=prefix_separator_iterator + ) + return self.to_dict(self.name, value) + + def __serialize_form( + self, + in_data: typing.Union[None, int, float, str, bool, dict, list], + prefix_separator_iterator: typing.Optional[PrefixSeparatorIterator] + ) -> typing.Dict[str, str]: + if prefix_separator_iterator is None: + prefix_separator_iterator = self.get_prefix_separator_iterator() + value = self.serialize_form( + in_data, + name=self.name, + explode=self.explode, + percent_encode=True, + prefix_separator_iterator=prefix_separator_iterator + ) + return self.to_dict(self.name, value) + + def get_prefix_separator_iterator(self) -> typing.Optional[PrefixSeparatorIterator]: + if not self.schema: + return None + if self.style is ParameterStyle.FORM: + return PrefixSeparatorIterator('?', '&') + elif self.style is ParameterStyle.SPACE_DELIMITED: + return PrefixSeparatorIterator('', '%20') + elif self.style is ParameterStyle.PIPE_DELIMITED: + return PrefixSeparatorIterator('', '|') + + def serialize( + self, + in_data: typing.Union[ + Schema, Decimal, int, float, str, date, datetime, None, bool, list, tuple, dict, frozendict], + prefix_separator_iterator: typing.Optional[PrefixSeparatorIterator] = None + ) -> typing.Dict[str, str]: + if self.schema: + cast_in_data = self.schema(in_data) + cast_in_data = self._json_encoder.default(cast_in_data) + """ + form -> query + query: + - GET/HEAD/DELETE: could use fields + - PUT/POST: must use urlencode to send parameters + returns fields: tuple + spaceDelimited -> query + returns fields + pipeDelimited -> query + returns fields + deepObject -> query, https://github.com/OAI/OpenAPI-Specification/issues/1706 + returns fields + """ + if self.style: + # TODO update query ones to omit setting values when [] {} or None is input + if self.style is ParameterStyle.FORM: + return self.__serialize_form(cast_in_data, prefix_separator_iterator) + elif self.style is ParameterStyle.SPACE_DELIMITED: + return self.__serialize_space_delimited(cast_in_data, prefix_separator_iterator) + elif self.style is ParameterStyle.PIPE_DELIMITED: + return self.__serialize_pipe_delimited(cast_in_data, prefix_separator_iterator) + # self.content will be length one + for content_type, schema in self.content.items(): + cast_in_data = schema(in_data) + cast_in_data = self._json_encoder.default(cast_in_data) + if content_type == self._json_content_type: + value = self._serialize_json(cast_in_data) + return self.to_dict(self.name, value) + raise NotImplementedError('Serialization of {} has not yet been implemented'.format(content_type)) + + +class CookieParameter(ParameterBase, StyleFormSerializer): + + def __init__( + self, + name: str, + required: bool = False, + style: typing.Optional[ParameterStyle] = None, + explode: typing.Optional[bool] = None, + allow_reserved: typing.Optional[bool] = None, + schema: typing.Optional[typing.Type[Schema]] = None, + content: typing.Optional[typing.Dict[str, typing.Type[Schema]]] = None + ): + used_style = ParameterStyle.FORM if style is None and content is None and schema else style + used_explode = self.get_default_explode(used_style) if explode is None else explode + + super().__init__( + name, + in_type=ParameterInType.COOKIE, + required=required, + style=used_style, + explode=used_explode, + allow_reserved=allow_reserved, + schema=schema, + content=content + ) + + def serialize( + self, + in_data: typing.Union[ + Schema, Decimal, int, float, str, date, datetime, None, bool, list, tuple, dict, frozendict] + ) -> typing.Dict[str, str]: + if self.schema: + cast_in_data = self.schema(in_data) + cast_in_data = self._json_encoder.default(cast_in_data) + """ + form -> cookie + returns fields: tuple + """ + if self.style: + """ + TODO add escaping of comma, space, equals + or turn encoding on + """ + value = self.serialize_form( + cast_in_data, + explode=self.explode, + name=self.name, + percent_encode=False, + prefix_separator_iterator=PrefixSeparatorIterator('', '&') + ) + return self.to_dict(self.name, value) + # self.content will be length one + for content_type, schema in self.content.items(): + cast_in_data = schema(in_data) + cast_in_data = self._json_encoder.default(cast_in_data) + if content_type == self._json_content_type: + value = self._serialize_json(cast_in_data) + return self.to_dict(self.name, value) + raise NotImplementedError('Serialization of {} has not yet been implemented'.format(content_type)) + + +class HeaderParameter(ParameterBase, StyleSimpleSerializer): + def __init__( + self, + name: str, + required: bool = False, + style: typing.Optional[ParameterStyle] = None, + explode: bool = False, + allow_reserved: typing.Optional[bool] = None, + schema: typing.Optional[typing.Type[Schema]] = None, + content: typing.Optional[typing.Dict[str, typing.Type[Schema]]] = None + ): + super().__init__( + name, + in_type=ParameterInType.HEADER, + required=required, + style=style, + explode=explode, + allow_reserved=allow_reserved, + schema=schema, + content=content + ) + + @staticmethod + def __to_headers(in_data: typing.Tuple[typing.Tuple[str, str], ...]) -> HTTPHeaderDict[str, str]: + data = tuple(t for t in in_data if t) + headers = HTTPHeaderDict() + if not data: + return headers + headers.extend(data) + return headers + + def _serialize_simple( + self, + in_data: typing.Union[None, int, float, str, bool, dict, list], + ) -> str: + return self.serialize_simple(in_data, self.name, self.explode, False) + + def serialize( + self, + in_data: typing.Union[ + Schema, Decimal, int, float, str, date, datetime, None, bool, list, tuple, dict, frozendict] + ) -> HTTPHeaderDict[str, str]: + if self.schema: + cast_in_data = self.schema(in_data) + cast_in_data = self._json_encoder.default(cast_in_data) + """ + simple -> header + headers: PoolManager needs a mapping, tuple is close + returns headers: dict + """ + if self.style: + value = self._serialize_simple(cast_in_data) + return self.__to_headers(((self.name, value),)) + # self.content will be length one + for content_type, schema in self.content.items(): + cast_in_data = schema(in_data) + cast_in_data = self._json_encoder.default(cast_in_data) + if content_type == self._json_content_type: + value = self._serialize_json(cast_in_data) + return self.__to_headers(((self.name, value),)) + raise NotImplementedError('Serialization of {} has not yet been implemented'.format(content_type)) + + +class Encoding: + def __init__( + self, + content_type: str, + headers: typing.Optional[typing.Dict[str, HeaderParameter]] = None, + style: typing.Optional[ParameterStyle] = None, + explode: bool = False, + allow_reserved: bool = False, + ): + self.content_type = content_type + self.headers = headers + self.style = style + self.explode = explode + self.allow_reserved = allow_reserved + + +@dataclass +class MediaType: + """ + Used to store request and response body schema information + encoding: + A map between a property name and its encoding information. + The key, being the property name, MUST exist in the schema as a property. + The encoding object SHALL only apply to requestBody objects when the media type is + multipart or application/x-www-form-urlencoded. + """ + schema: typing.Optional[typing.Type[Schema]] = None + encoding: typing.Optional[typing.Dict[str, Encoding]] = None + + +@dataclass +class ApiResponse: + response: urllib3.HTTPResponse + body: typing.Union[Unset, typing.Type[Schema]] + headers: typing.Union[Unset, typing.List[HeaderParameter]] + + def __init__( + self, + response: urllib3.HTTPResponse, + body: typing.Union[Unset, typing.Type[Schema]], + headers: typing.Union[Unset, typing.List[HeaderParameter]] + ): + """ + pycharm needs this to prevent 'Unexpected argument' warnings + """ + self.response = response + self.body = body + self.headers = headers + + +@dataclass +class ApiResponseWithoutDeserialization(ApiResponse): + response: urllib3.HTTPResponse + body: typing.Union[Unset, typing.Type[Schema]] = unset + headers: typing.Union[Unset, typing.List[HeaderParameter]] = unset + + +class JSONDetector: + @staticmethod + def content_type_is_json(content_type: str) -> bool: + """ + for when content_type strings also include charset info like: + application/json; charset=UTF-8 + """ + content_type_piece = content_type.split(';')[0] + if content_type_piece == 'application/json': + return True + return False + + +class OpenApiResponse(JSONDetector): + def __init__( + self, + response_cls: typing.Type[ApiResponse] = ApiResponse, + content: typing.Optional[typing.Dict[str, MediaType]] = None, + headers: typing.Optional[typing.List[HeaderParameter]] = None, + ): + self.headers = headers + if content is not None and len(content) == 0: + raise ValueError('Invalid value for content, the content dict must have >= 1 entry') + self.content = content + self.response_cls = response_cls + + @staticmethod + def __deserialize_json(response: urllib3.HTTPResponse) -> typing.Any: + # python must be >= 3.9 so we can pass in bytes into json.loads + return json.loads(response.data) + + @staticmethod + def __file_name_from_content_disposition(content_disposition: typing.Optional[str]) -> typing.Optional[str]: + if content_disposition is None: + return None + match = re.search('filename="(.+?)"', content_disposition) + if not match: + return None + return match.group(1) + + def __deserialize_application_octet_stream( + self, response: urllib3.HTTPResponse + ) -> typing.Union[bytes, io.BufferedReader]: + """ + urllib3 use cases: + 1. when preload_content=True (stream=False) then supports_chunked_reads is False and bytes are returned + 2. when preload_content=False (stream=True) then supports_chunked_reads is True and + a file will be written and returned + """ + if response.supports_chunked_reads(): + file_name = self.__file_name_from_content_disposition(response.headers.get('content-disposition')) + + if file_name is None: + _fd, path = tempfile.mkstemp() + else: + path = os.path.join(tempfile.gettempdir(), file_name) + # TODO get file_name from the filename at the end of the url if it exists + with open(path, 'wb') as new_file: + chunk_size = 1024 + while True: + data = response.read(chunk_size) + if not data: + break + new_file.write(data) + # release_conn is needed for streaming connections only + response.release_conn() + new_file = open(path, 'rb') + return new_file + else: + return response.data + + @staticmethod + def __deserialize_multipart_form_data( + response: urllib3.HTTPResponse + ) -> typing.Dict[str, typing.Any]: + msg = email.message_from_bytes(response.data) + return { + part.get_param("name", header="Content-Disposition"): part.get_payload( + decode=True + ).decode(part.get_content_charset()) + if part.get_content_charset() + else part.get_payload() + for part in msg.get_payload() + } + + def deserialize(self, response: urllib3.HTTPResponse, configuration: Configuration) -> ApiResponse: + content_type = response.getheader('content-type') + deserialized_body = unset + streamed = response.supports_chunked_reads() + + deserialized_headers = unset + if self.headers is not None: + # TODO add header deserialiation here + pass + + if self.content is not None: + if content_type not in self.content: + raise ApiValueError( + f'Invalid content_type={content_type} returned for response with ' + 'status_code={str(response.status)}' + ) + body_schema = self.content[content_type].schema + if body_schema is None: + # some specs do not define response content media type schemas + return self.response_cls( + response=response, + headers=deserialized_headers, + body=unset + ) + + if self.content_type_is_json(content_type): + body_data = self.__deserialize_json(response) + elif content_type == 'application/octet-stream': + body_data = self.__deserialize_application_octet_stream(response) + elif content_type.startswith('multipart/form-data'): + body_data = self.__deserialize_multipart_form_data(response) + content_type = 'multipart/form-data' + else: + raise NotImplementedError('Deserialization of {} has not yet been implemented'.format(content_type)) + deserialized_body = body_schema._from_openapi_data( + body_data, _configuration=configuration) + elif streamed: + response.release_conn() + + return self.response_cls( + response=response, + headers=deserialized_headers, + body=deserialized_body + ) + + +class ApiClient: + """Generic API client for OpenAPI client library builds. + + OpenAPI generic API client. This client handles the client- + server communication, and is invariant across implementations. Specifics of + the methods and models for each application are generated from the OpenAPI + templates. + + NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + Do not edit the class manually. + + :param configuration: .Configuration object for this client + :param header_name: a header to pass when making calls to the API. + :param header_value: a header value to pass when making calls to + the API. + :param cookie: a cookie to include in the header when making calls + to the API + :param pool_threads: The number of threads to use for async requests + to the API. More threads means more concurrent API requests. + """ + + _pool = None + __json_encoder = JSONEncoder() + + def __init__( + self, + configuration: typing.Optional[Configuration] = None, + header_name: typing.Optional[str] = None, + header_value: typing.Optional[str] = None, + cookie: typing.Optional[str] = None, + pool_threads: int = 1 + ): + if configuration is None: + configuration = Configuration() + self.configuration = configuration + self.pool_threads = pool_threads + + self.rest_client = rest.RESTClientObject(configuration) + self.default_headers = {} + if header_name is not None: + self.default_headers[header_name] = header_value + self.cookie = cookie + # Set default User-Agent. + self.user_agent = 'OpenAPI-Generator/1.0.0/python' + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + self.close() + + def close(self): + if self._pool: + self._pool.close() + self._pool.join() + self._pool = None + if hasattr(atexit, 'unregister'): + atexit.unregister(self.close) + + @property + def pool(self): + """Create thread pool on first request + avoids instantiating unused threadpool for blocking clients. + """ + if self._pool is None: + atexit.register(self.close) + self._pool = ThreadPool(self.pool_threads) + return self._pool + + @property + def user_agent(self): + """User agent for this API client""" + return self.default_headers['User-Agent'] + + @user_agent.setter + def user_agent(self, value): + self.default_headers['User-Agent'] = value + + def set_default_header(self, header_name, header_value): + self.default_headers[header_name] = header_value + + def __call_api( + self, + resource_path: str, + method: str, + headers: typing.Optional[HTTPHeaderDict] = None, + body: typing.Optional[typing.Union[str, bytes]] = None, + fields: typing.Optional[typing.Tuple[typing.Tuple[str, str], ...]] = None, + auth_settings: typing.Optional[typing.List[str]] = None, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + host: typing.Optional[str] = None, + ) -> urllib3.HTTPResponse: + + # header parameters + headers = headers or {} + headers.update(self.default_headers) + if self.cookie: + headers['Cookie'] = self.cookie + + # auth setting + self.update_params_for_auth(headers, + auth_settings, resource_path, method, body) + + # request url + if host is None: + url = self.configuration.host + resource_path + else: + # use server/host defined in path or operation instead + url = host + resource_path + + # perform request and return response + response = self.request( + method, + url, + headers=headers, + fields=fields, + body=body, + stream=stream, + timeout=timeout, + ) + return response + + def call_api( + self, + resource_path: str, + method: str, + headers: typing.Optional[HTTPHeaderDict] = None, + body: typing.Optional[typing.Union[str, bytes]] = None, + fields: typing.Optional[typing.Tuple[typing.Tuple[str, str], ...]] = None, + auth_settings: typing.Optional[typing.List[str]] = None, + async_req: typing.Optional[bool] = None, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + host: typing.Optional[str] = None, + ) -> urllib3.HTTPResponse: + """Makes the HTTP request (synchronous) and returns deserialized data. + + To make an async_req request, set the async_req parameter. + + :param resource_path: Path to method endpoint. + :param method: Method to call. + :param headers: Header parameters to be + placed in the request header. + :param body: Request body. + :param fields: Request post form parameters, + for `application/x-www-form-urlencoded`, `multipart/form-data`. + :param auth_settings: Auth Settings names for the request. + :param async_req: execute request asynchronously + :type async_req: bool, optional TODO remove, unused + :param stream: if True, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Also when True, if the openapi spec describes a file download, + the data will be written to a local filesystme file and the BinarySchema + instance will also inherit from FileSchema and FileIO + Default is False. + :type stream: bool, optional + :param timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param host: api endpoint host + :return: + If async_req parameter is True, + the request will be called asynchronously. + The method will return the request thread. + If parameter async_req is False or missing, + then the method will return the response directly. + """ + + if not async_req: + return self.__call_api( + resource_path, + method, + headers, + body, + fields, + auth_settings, + stream, + timeout, + host, + ) + + return self.pool.apply_async( + self.__call_api, + ( + resource_path, + method, + headers, + body, + json, + fields, + auth_settings, + stream, + timeout, + host, + ) + ) + + def request( + self, + method: str, + url: str, + headers: typing.Optional[HTTPHeaderDict] = None, + fields: typing.Optional[typing.Tuple[typing.Tuple[str, str], ...]] = None, + body: typing.Optional[typing.Union[str, bytes]] = None, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> urllib3.HTTPResponse: + """Makes the HTTP request using RESTClient.""" + if method == "GET": + return self.rest_client.GET(url, + stream=stream, + timeout=timeout, + headers=headers) + elif method == "HEAD": + return self.rest_client.HEAD(url, + stream=stream, + timeout=timeout, + headers=headers) + elif method == "OPTIONS": + return self.rest_client.OPTIONS(url, + headers=headers, + fields=fields, + stream=stream, + timeout=timeout, + body=body) + elif method == "POST": + return self.rest_client.POST(url, + headers=headers, + fields=fields, + stream=stream, + timeout=timeout, + body=body) + elif method == "PUT": + return self.rest_client.PUT(url, + headers=headers, + fields=fields, + stream=stream, + timeout=timeout, + body=body) + elif method == "PATCH": + return self.rest_client.PATCH(url, + headers=headers, + fields=fields, + stream=stream, + timeout=timeout, + body=body) + elif method == "DELETE": + return self.rest_client.DELETE(url, + headers=headers, + stream=stream, + timeout=timeout, + body=body) + else: + raise ApiValueError( + "http method must be `GET`, `HEAD`, `OPTIONS`," + " `POST`, `PATCH`, `PUT` or `DELETE`." + ) + + def update_params_for_auth(self, headers, auth_settings, + resource_path, method, body): + """Updates header and query params based on authentication setting. + + :param headers: Header parameters dict to be updated. + :param auth_settings: Authentication setting identifiers list. + :param resource_path: A string representation of the HTTP request resource path. + :param method: A string representation of the HTTP request method. + :param body: A object representing the body of the HTTP request. + The object type is the return value of _encoder.default(). + """ + if not auth_settings: + return + + for auth in auth_settings: + auth_setting = self.configuration.auth_settings().get(auth) + if auth_setting: + if auth_setting['in'] == 'cookie': + headers.add('Cookie', auth_setting['value']) + elif auth_setting['in'] == 'header': + if auth_setting['type'] != 'http-signature': + headers.add(auth_setting['key'], auth_setting['value']) + elif auth_setting['in'] == 'query': + """ TODO implement auth in query + need to pass in prefix_separator_iterator + and need to output resource_path with query params added + """ + raise ApiValueError("Auth in query not yet implemented") + else: + raise ApiValueError( + 'Authentication token must be in `query` or `header`' + ) + + +class Api: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client: typing.Optional[ApiClient] = None): + if api_client is None: + api_client = ApiClient() + self.api_client = api_client + + @staticmethod + def _verify_typed_dict_inputs(cls: typing.Type[typing.TypedDict], data: typing.Dict[str, typing.Any]): + """ + Ensures that: + - required keys are present + - additional properties are not input + - value stored under required keys do not have the value unset + Note: detailed value checking is done in schema classes + """ + missing_required_keys = [] + required_keys_with_unset_values = [] + for required_key in cls.__required_keys__: + if required_key not in data: + missing_required_keys.append(required_key) + continue + value = data[required_key] + if value is unset: + required_keys_with_unset_values.append(required_key) + if missing_required_keys: + raise ApiTypeError( + '{} missing {} required arguments: {}'.format( + cls.__name__, len(missing_required_keys), missing_required_keys + ) + ) + if required_keys_with_unset_values: + raise ApiValueError( + '{} contains invalid unset values for {} required keys: {}'.format( + cls.__name__, len(required_keys_with_unset_values), required_keys_with_unset_values + ) + ) + + disallowed_additional_keys = [] + for key in data: + if key in cls.__required_keys__ or key in cls.__optional_keys__: + continue + disallowed_additional_keys.append(key) + if disallowed_additional_keys: + raise ApiTypeError( + '{} got {} unexpected keyword arguments: {}'.format( + cls.__name__, len(disallowed_additional_keys), disallowed_additional_keys + ) + ) + + def get_host( + self, + operation_id: str, + servers: typing.Tuple[typing.Dict[str, str], ...] = tuple(), + host_index: typing.Optional[int] = None + ) -> typing.Optional[str]: + configuration = self.api_client.configuration + try: + if host_index is None: + index = configuration.server_operation_index.get( + operation_id, configuration.server_index + ) + else: + index = host_index + server_variables = configuration.server_operation_variables.get( + operation_id, configuration.server_variables + ) + host = configuration.get_host_from_settings( + index, variables=server_variables, servers=servers + ) + except IndexError: + if servers: + raise ApiValueError( + "Invalid host index. Must be 0 <= index < %s" % + len(servers) + ) + host = None + return host + + +class SerializedRequestBody(typing.TypedDict, total=False): + body: typing.Union[str, bytes] + fields: typing.Tuple[typing.Union[RequestField, tuple[str, str]], ...] + + +class RequestBody(StyleFormSerializer, JSONDetector): + """ + A request body parameter + content: content_type to MediaType Schema info + """ + __json_encoder = JSONEncoder() + + def __init__( + self, + content: typing.Dict[str, MediaType], + required: bool = False, + ): + self.required = required + if len(content) == 0: + raise ValueError('Invalid value for content, the content dict must have >= 1 entry') + self.content = content + + def __serialize_json( + self, + in_data: typing.Any + ) -> typing.Dict[str, bytes]: + in_data = self.__json_encoder.default(in_data) + json_str = json.dumps(in_data, separators=(",", ":"), ensure_ascii=False).encode( + "utf-8" + ) + return dict(body=json_str) + + @staticmethod + def __serialize_text_plain(in_data: typing.Any) -> typing.Dict[str, str]: + if isinstance(in_data, frozendict): + raise ValueError('Unable to serialize type frozendict to text/plain') + elif isinstance(in_data, tuple): + raise ValueError('Unable to serialize type tuple to text/plain') + elif isinstance(in_data, NoneClass): + raise ValueError('Unable to serialize type NoneClass to text/plain') + elif isinstance(in_data, BoolClass): + raise ValueError('Unable to serialize type BoolClass to text/plain') + return dict(body=str(in_data)) + + def __multipart_json_item(self, key: str, value: Schema) -> RequestField: + json_value = self.__json_encoder.default(value) + return RequestField(name=key, data=json.dumps(json_value), headers={'Content-Type': 'application/json'}) + + def __multipart_form_item(self, key: str, value: Schema) -> RequestField: + if isinstance(value, str): + return RequestField(name=key, data=str(value), headers={'Content-Type': 'text/plain'}) + elif isinstance(value, bytes): + return RequestField(name=key, data=value, headers={'Content-Type': 'application/octet-stream'}) + elif isinstance(value, FileIO): + request_field = RequestField( + name=key, + data=value.read(), + filename=os.path.basename(value.name), + headers={'Content-Type': 'application/octet-stream'} + ) + value.close() + return request_field + else: + return self.__multipart_json_item(key=key, value=value) + + def __serialize_multipart_form_data( + self, in_data: Schema + ) -> typing.Dict[str, typing.Tuple[RequestField, ...]]: + if not isinstance(in_data, frozendict): + raise ValueError(f'Unable to serialize {in_data} to multipart/form-data because it is not a dict of data') + """ + In a multipart/form-data request body, each schema property, or each element of a schema array property, + takes a section in the payload with an internal header as defined by RFC7578. The serialization strategy + for each property of a multipart/form-data request body can be specified in an associated Encoding Object. + + When passing in multipart types, boundaries MAY be used to separate sections of the content being + transferred – thus, the following default Content-Types are defined for multipart: + + If the (object) property is a primitive, or an array of primitive values, the default Content-Type is text/plain + If the property is complex, or an array of complex values, the default Content-Type is application/json + Question: how is the array of primitives encoded? + If the property is a type: string with a contentEncoding, the default Content-Type is application/octet-stream + """ + fields = [] + for key, value in in_data.items(): + if isinstance(value, tuple): + if value: + # values use explode = True, so the code makes a RequestField for each item with name=key + for item in value: + request_field = self.__multipart_form_item(key=key, value=item) + fields.append(request_field) + else: + # send an empty array as json because exploding will not send it + request_field = self.__multipart_json_item(key=key, value=value) + fields.append(request_field) + else: + request_field = self.__multipart_form_item(key=key, value=value) + fields.append(request_field) + + return dict(fields=tuple(fields)) + + def __serialize_application_octet_stream(self, in_data: BinarySchema) -> typing.Dict[str, bytes]: + if isinstance(in_data, bytes): + return dict(body=in_data) + # FileIO type + result = dict(body=in_data.read()) + in_data.close() + return result + + def __serialize_application_x_www_form_data( + self, in_data: typing.Any + ) -> SerializedRequestBody: + """ + POST submission of form data in body + """ + if not isinstance(in_data, frozendict): + raise ValueError( + f'Unable to serialize {in_data} to application/x-www-form-urlencoded because it is not a dict of data') + cast_in_data = self.__json_encoder.default(in_data) + value = self.serialize_form(cast_in_data, name='', explode=True, percent_encode=False) + return dict(body=value) + + def serialize( + self, in_data: typing.Any, content_type: str + ) -> SerializedRequestBody: + """ + If a str is returned then the result will be assigned to data when making the request + If a tuple is returned then the result will be used as fields input in encode_multipart_formdata + Return a tuple of + + The key of the return dict is + - body for application/json + - encode_multipart and fields for multipart/form-data + """ + media_type = self.content[content_type] + if isinstance(in_data, media_type.schema): + cast_in_data = in_data + elif isinstance(in_data, (dict, frozendict)) and in_data: + cast_in_data = media_type.schema(**in_data) + else: + cast_in_data = media_type.schema(in_data) + # TODO check for and use encoding if it exists + # and content_type is multipart or application/x-www-form-urlencoded + if self.content_type_is_json(content_type): + return self.__serialize_json(cast_in_data) + elif content_type == 'text/plain': + return self.__serialize_text_plain(cast_in_data) + elif content_type == 'multipart/form-data': + return self.__serialize_multipart_form_data(cast_in_data) + elif content_type == 'application/x-www-form-urlencoded': + return self.__serialize_application_x_www_form_data(cast_in_data) + elif content_type == 'application/octet-stream': + return self.__serialize_application_octet_stream(cast_in_data) + raise NotImplementedError('Serialization has not yet been implemented for {}'.format(content_type)) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/configuration.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/configuration.py new file mode 100644 index 00000000000..80407ef4b44 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/configuration.py @@ -0,0 +1,440 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import copy +import logging +import multiprocessing +import sys +import urllib3 + +from http import client as http_client +from unit_test_api.exceptions import ApiValueError + + +JSON_SCHEMA_VALIDATION_KEYWORDS = { + 'multipleOf', 'maximum', 'exclusiveMaximum', + 'minimum', 'exclusiveMinimum', 'maxLength', + 'minLength', 'pattern', 'maxItems', 'minItems', + 'uniqueItems', 'maxProperties', 'minProperties', +} + +class Configuration(object): + """NOTE: This class is auto generated by OpenAPI Generator + + Ref: https://openapi-generator.tech + Do not edit the class manually. + + :param host: Base url + :param api_key: Dict to store API key(s). + Each entry in the dict specifies an API key. + The dict key is the name of the security scheme in the OAS specification. + The dict value is the API key secret. + :param api_key_prefix: Dict to store API prefix (e.g. Bearer) + The dict key is the name of the security scheme in the OAS specification. + The dict value is an API key prefix when generating the auth data. + :param username: Username for HTTP basic authentication + :param password: Password for HTTP basic authentication + :param discard_unknown_keys: Boolean value indicating whether to discard + unknown properties. A server may send a response that includes additional + properties that are not known by the client in the following scenarios: + 1. The OpenAPI document is incomplete, i.e. it does not match the server + implementation. + 2. The client was generated using an older version of the OpenAPI document + and the server has been upgraded since then. + If a schema in the OpenAPI document defines the additionalProperties attribute, + then all undeclared properties received by the server are injected into the + additional properties map. In that case, there are undeclared properties, and + nothing to discard. + :param disabled_client_side_validations (string): Comma-separated list of + JSON schema validation keywords to disable JSON schema structural validation + rules. The following keywords may be specified: multipleOf, maximum, + exclusiveMaximum, minimum, exclusiveMinimum, maxLength, minLength, pattern, + maxItems, minItems. + By default, the validation is performed for data generated locally by the client + and data received from the server, independent of any validation performed by + the server side. If the input data does not satisfy the JSON schema validation + rules specified in the OpenAPI document, an exception is raised. + If disabled_client_side_validations is set, structural validation is + disabled. This can be useful to troubleshoot data validation problem, such as + when the OpenAPI document validation rules do not match the actual API data + received by the server. + :param server_index: Index to servers configuration. + :param server_variables: Mapping with string values to replace variables in + templated server configuration. The validation of enums is performed for + variables with defined enum values before. + :param server_operation_index: Mapping from operation ID to an index to server + configuration. + :param server_operation_variables: Mapping from operation ID to a mapping with + string values to replace variables in templated server configuration. + The validation of enums is performed for variables with defined enum values before. + + """ + + _default = None + + def __init__(self, host=None, + api_key=None, api_key_prefix=None, + username=None, password=None, + discard_unknown_keys=False, + disabled_client_side_validations="", + server_index=None, server_variables=None, + server_operation_index=None, server_operation_variables=None, + ): + """Constructor + """ + self._base_path = "http://localhost" if host is None else host + """Default Base url + """ + self.server_index = 0 if server_index is None and host is None else server_index + self.server_operation_index = server_operation_index or {} + """Default server index + """ + self.server_variables = server_variables or {} + self.server_operation_variables = server_operation_variables or {} + """Default server variables + """ + self.temp_folder_path = None + """Temp file folder for downloading files + """ + # Authentication Settings + self.api_key = {} + if api_key: + self.api_key = api_key + """dict to store API key(s) + """ + self.api_key_prefix = {} + if api_key_prefix: + self.api_key_prefix = api_key_prefix + """dict to store API prefix (e.g. Bearer) + """ + self.refresh_api_key_hook = None + """function hook to refresh API key if expired + """ + self.username = username + """Username for HTTP basic authentication + """ + self.password = password + """Password for HTTP basic authentication + """ + self.discard_unknown_keys = discard_unknown_keys + self.disabled_client_side_validations = disabled_client_side_validations + self.logger = {} + """Logging Settings + """ + self.logger["package_logger"] = logging.getLogger("unit_test_api") + self.logger["urllib3_logger"] = logging.getLogger("urllib3") + self.logger_format = '%(asctime)s %(levelname)s %(message)s' + """Log format + """ + self.logger_stream_handler = None + """Log stream handler + """ + self.logger_file_handler = None + """Log file handler + """ + self.logger_file = None + """Debug file location + """ + self.debug = False + """Debug switch + """ + + self.verify_ssl = True + """SSL/TLS verification + Set this to false to skip verifying SSL certificate when calling API + from https server. + """ + self.ssl_ca_cert = None + """Set this to customize the certificate file to verify the peer. + """ + self.cert_file = None + """client certificate file + """ + self.key_file = None + """client key file + """ + self.assert_hostname = None + """Set this to True/False to enable/disable SSL hostname verification. + """ + + self.connection_pool_maxsize = multiprocessing.cpu_count() * 5 + """urllib3 connection pool's maximum number of connections saved + per pool. urllib3 uses 1 connection as default value, but this is + not the best value when you are making a lot of possibly parallel + requests to the same host, which is often the case here. + cpu_count * 5 is used as default value to increase performance. + """ + + self.proxy = None + """Proxy URL + """ + self.proxy_headers = None + """Proxy headers + """ + self.safe_chars_for_path_param = '' + """Safe chars for path_param + """ + self.retries = None + """Adding retries to override urllib3 default value 3 + """ + # Enable client side validation + self.client_side_validation = True + + # Options to pass down to the underlying urllib3 socket + self.socket_options = None + + def __deepcopy__(self, memo): + cls = self.__class__ + result = cls.__new__(cls) + memo[id(self)] = result + for k, v in self.__dict__.items(): + if k not in ('logger', 'logger_file_handler'): + setattr(result, k, copy.deepcopy(v, memo)) + # shallow copy of loggers + result.logger = copy.copy(self.logger) + # use setters to configure loggers + result.logger_file = self.logger_file + result.debug = self.debug + return result + + def __setattr__(self, name, value): + object.__setattr__(self, name, value) + if name == 'disabled_client_side_validations': + s = set(filter(None, value.split(','))) + for v in s: + if v not in JSON_SCHEMA_VALIDATION_KEYWORDS: + raise ApiValueError( + "Invalid keyword: '{0}''".format(v)) + self._disabled_client_side_validations = s + + @classmethod + def set_default(cls, default): + """Set default instance of configuration. + + It stores default configuration, which can be + returned by get_default_copy method. + + :param default: object of Configuration + """ + cls._default = copy.deepcopy(default) + + @classmethod + def get_default_copy(cls): + """Return new instance of configuration. + + This method returns newly created, based on default constructor, + object of Configuration class or returns a copy of default + configuration passed by the set_default method. + + :return: The configuration object. + """ + if cls._default is not None: + return copy.deepcopy(cls._default) + return Configuration() + + @property + def logger_file(self): + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + return self.__logger_file + + @logger_file.setter + def logger_file(self, value): + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + self.__logger_file = value + if self.__logger_file: + # If set logging file, + # then add file handler and remove stream handler. + self.logger_file_handler = logging.FileHandler(self.__logger_file) + self.logger_file_handler.setFormatter(self.logger_formatter) + for _, logger in self.logger.items(): + logger.addHandler(self.logger_file_handler) + + @property + def debug(self): + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + return self.__debug + + @debug.setter + def debug(self, value): + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + self.__debug = value + if self.__debug: + # if debug status is True, turn on debug logging + for _, logger in self.logger.items(): + logger.setLevel(logging.DEBUG) + # turn on http_client debug + http_client.HTTPConnection.debuglevel = 1 + else: + # if debug status is False, turn off debug logging, + # setting log level to default `logging.WARNING` + for _, logger in self.logger.items(): + logger.setLevel(logging.WARNING) + # turn off http_client debug + http_client.HTTPConnection.debuglevel = 0 + + @property + def logger_format(self): + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + return self.__logger_format + + @logger_format.setter + def logger_format(self, value): + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + self.__logger_format = value + self.logger_formatter = logging.Formatter(self.__logger_format) + + def get_api_key_with_prefix(self, identifier, alias=None): + """Gets API key (with prefix if set). + + :param identifier: The identifier of apiKey. + :param alias: The alternative identifier of apiKey. + :return: The token for api key authentication. + """ + if self.refresh_api_key_hook is not None: + self.refresh_api_key_hook(self) + key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None) + if key: + prefix = self.api_key_prefix.get(identifier) + if prefix: + return "%s %s" % (prefix, key) + else: + return key + + def get_basic_auth_token(self): + """Gets HTTP basic authentication header (string). + + :return: The token for basic HTTP authentication. + """ + username = "" + if self.username is not None: + username = self.username + password = "" + if self.password is not None: + password = self.password + return urllib3.util.make_headers( + basic_auth=username + ':' + password + ).get('authorization') + + def auth_settings(self): + """Gets Auth Settings dict for api client. + + :return: The Auth Settings information dict. + """ + auth = {} + return auth + + def to_debug_report(self): + """Gets the essential information for debugging. + + :return: The report for debugging. + """ + return "Python SDK Debug Report:\n"\ + "OS: {env}\n"\ + "Python Version: {pyversion}\n"\ + "Version of the API: 0.0.1\n"\ + "SDK Package Version: 1.0.0".\ + format(env=sys.platform, pyversion=sys.version) + + def get_host_settings(self): + """Gets an array of host settings + + :return: An array of host settings + """ + return [ + { + 'url': "", + 'description': "No description provided", + } + ] + + def get_host_from_settings(self, index, variables=None, servers=None): + """Gets host URL based on the index and variables + :param index: array index of the host settings + :param variables: hash of variable and the corresponding value + :param servers: an array of host settings or None + :return: URL based on host settings + """ + if index is None: + return self._base_path + + variables = {} if variables is None else variables + servers = self.get_host_settings() if servers is None else servers + + try: + server = servers[index] + except IndexError: + raise ValueError( + "Invalid index {0} when selecting the host settings. " + "Must be less than {1}".format(index, len(servers))) + + url = server['url'] + + # go through variables and replace placeholders + for variable_name, variable in server.get('variables', {}).items(): + used_value = variables.get( + variable_name, variable['default_value']) + + if 'enum_values' in variable \ + and used_value not in variable['enum_values']: + raise ValueError( + "The variable `{0}` in the host URL has invalid value " + "{1}. Must be {2}.".format( + variable_name, variables[variable_name], + variable['enum_values'])) + + url = url.replace("{" + variable_name + "}", used_value) + + return url + + @property + def host(self): + """Return generated host.""" + return self.get_host_from_settings(self.server_index, variables=self.server_variables) + + @host.setter + def host(self, value): + """Fix base path.""" + self._base_path = value + self.server_index = None diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/exceptions.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/exceptions.py new file mode 100644 index 00000000000..54a51c36ab4 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/exceptions.py @@ -0,0 +1,136 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + + +class OpenApiException(Exception): + """The base exception class for all OpenAPIExceptions""" + + +class ApiTypeError(OpenApiException, TypeError): + def __init__(self, msg, path_to_item=None, valid_classes=None, + key_type=None): + """ Raises an exception for TypeErrors + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list): a list of keys an indices to get to the + current_item + None if unset + valid_classes (tuple): the primitive classes that current item + should be an instance of + None if unset + key_type (bool): False if our value is a value in a dict + True if it is a key in a dict + False if our item is an item in a list + None if unset + """ + self.path_to_item = path_to_item + self.valid_classes = valid_classes + self.key_type = key_type + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiTypeError, self).__init__(full_msg) + + +class ApiValueError(OpenApiException, ValueError): + def __init__(self, msg, path_to_item=None): + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list) the path to the exception in the + received_data dict. None if unset + """ + + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiValueError, self).__init__(full_msg) + + +class ApiAttributeError(OpenApiException, AttributeError): + def __init__(self, msg, path_to_item=None): + """ + Raised when an attribute reference or assignment fails. + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + """ + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiAttributeError, self).__init__(full_msg) + + +class ApiKeyError(OpenApiException, KeyError): + def __init__(self, msg, path_to_item=None): + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + """ + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiKeyError, self).__init__(full_msg) + + +class ApiException(OpenApiException): + + def __init__(self, status=None, reason=None, api_response: 'unit_test_api.api_client.ApiResponse' = None): + if api_response: + self.status = api_response.response.status + self.reason = api_response.response.reason + self.body = api_response.response.data + self.headers = api_response.response.getheaders() + else: + self.status = status + self.reason = reason + self.body = None + self.headers = None + + def __str__(self): + """Custom error messages for exception""" + error_message = "({0})\n"\ + "Reason: {1}\n".format(self.status, self.reason) + if self.headers: + error_message += "HTTP response headers: {0}\n".format( + self.headers) + + if self.body: + error_message += "HTTP response body: {0}\n".format(self.body) + + return error_message + + +def render_path(path_to_item): + """Returns a string representation of a path""" + result = "" + for pth in path_to_item: + if isinstance(pth, int): + result += "[{0}]".format(pth) + else: + result += "['{0}']".format(pth) + return result diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/__init__.py new file mode 100644 index 00000000000..0056d7a31eb --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/__init__.py @@ -0,0 +1,5 @@ +# we can not import model classes here because that would create a circular +# reference which would not work in python2 +# do not import all models into this module because that uses a lot of memory and stack frames +# if you need the ability to import all models from one package, import them with +# from unit_test_api.models import ModelA, ModelB diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/object_properties_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/object_properties_validation.py new file mode 100644 index 00000000000..a5ac3ccf95d --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/object_properties_validation.py @@ -0,0 +1,95 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class ObjectPropertiesValidation( + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + foo = IntSchema + bar = StrSchema + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + foo: typing.Union[foo, Unset] = unset, + bar: typing.Union[bar, Unset] = unset, + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'ObjectPropertiesValidation': + return super().__new__( + cls, + *args, + foo=foo, + bar=bar, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/properties_with_escaped_characters.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/properties_with_escaped_characters.py new file mode 100644 index 00000000000..b022465743f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/properties_with_escaped_characters.py @@ -0,0 +1,108 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class PropertiesWithEscapedCharacters( + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + foobar = NumberSchema + locals()['foo +bar'] = foobar + del locals()['foobar'] + foobar = NumberSchema + locals()['foo"bar'] = foobar + del locals()['foobar'] + foo_bar = NumberSchema + locals()['foo\bar'] = foo_bar + del locals()['foo_bar'] + foobar = NumberSchema + locals()['foo bar'] = foobar + del locals()['foobar'] + foobar = NumberSchema + locals()['foo bar'] = foobar + del locals()['foobar'] + foobar = NumberSchema + locals()['foobar'] = foobar + del locals()['foobar'] + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'PropertiesWithEscapedCharacters': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py new file mode 100644 index 00000000000..c4d96c15d2f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py @@ -0,0 +1,15 @@ +# coding: utf-8 + +# flake8: noqa + +# import all models into this package +# if you have many models here with many references from one model to another this may +# raise a RecursionError +# to avoid this, import only the models that you directly need like: +# from from unit_test_api.model.pet import Pet +# or import this package, but before doing it, use: +# import sys +# sys.setrecursionlimit(n) + +from unit_test_api.model.object_properties_validation import ObjectPropertiesValidation +from unit_test_api.model.properties_with_escaped_characters import PropertiesWithEscapedCharacters diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/rest.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/rest.py new file mode 100644 index 00000000000..75a309eed90 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/rest.py @@ -0,0 +1,253 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import logging +import ssl +from urllib.parse import urlencode +import typing + +import certifi +import urllib3 +from urllib3._collections import HTTPHeaderDict + +from unit_test_api.exceptions import ApiException, ApiValueError + + +logger = logging.getLogger(__name__) + + +class RESTClientObject(object): + + def __init__(self, configuration, pools_size=4, maxsize=None): + # urllib3.PoolManager will pass all kw parameters to connectionpool + # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501 + # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501 + # maxsize is the number of requests to host that are allowed in parallel # noqa: E501 + # Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501 + + # cert_reqs + if configuration.verify_ssl: + cert_reqs = ssl.CERT_REQUIRED + else: + cert_reqs = ssl.CERT_NONE + + # ca_certs + if configuration.ssl_ca_cert: + ca_certs = configuration.ssl_ca_cert + else: + # if not set certificate file, use Mozilla's root certificates. + ca_certs = certifi.where() + + addition_pool_args = {} + if configuration.assert_hostname is not None: + addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 + + if configuration.retries is not None: + addition_pool_args['retries'] = configuration.retries + + if configuration.socket_options is not None: + addition_pool_args['socket_options'] = configuration.socket_options + + if maxsize is None: + if configuration.connection_pool_maxsize is not None: + maxsize = configuration.connection_pool_maxsize + else: + maxsize = 4 + + # https pool manager + if configuration.proxy: + self.pool_manager = urllib3.ProxyManager( + num_pools=pools_size, + maxsize=maxsize, + cert_reqs=cert_reqs, + ca_certs=ca_certs, + cert_file=configuration.cert_file, + key_file=configuration.key_file, + proxy_url=configuration.proxy, + proxy_headers=configuration.proxy_headers, + **addition_pool_args + ) + else: + self.pool_manager = urllib3.PoolManager( + num_pools=pools_size, + maxsize=maxsize, + cert_reqs=cert_reqs, + ca_certs=ca_certs, + cert_file=configuration.cert_file, + key_file=configuration.key_file, + **addition_pool_args + ) + + def request( + self, + method: str, + url: str, + headers: typing.Optional[HTTPHeaderDict] = None, + fields: typing.Optional[typing.Tuple[typing.Tuple[str, typing.Any], ...]] = None, + body: typing.Optional[typing.Union[str, bytes]] = None, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> urllib3.HTTPResponse: + """Perform requests. + + :param method: http request method + :param url: http request url + :param headers: http request headers + :param body: request body, for other types + :param fields: request parameters for + `application/x-www-form-urlencoded` + or `multipart/form-data` + :param stream: if True, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is False. + :param timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + """ + method = method.upper() + assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', + 'PATCH', 'OPTIONS'] + + if fields and body: + raise ApiValueError( + "body parameter cannot be used with fields parameter." + ) + + fields = fields or {} + headers = headers or {} + + if timeout: + if isinstance(timeout, (int, float)): # noqa: E501,F821 + timeout = urllib3.Timeout(total=timeout) + elif (isinstance(timeout, tuple) and + len(timeout) == 2): + timeout = urllib3.Timeout(connect=timeout[0], read=timeout[1]) + + try: + # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` + if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: + if 'Content-Type' not in headers and body is None: + r = self.pool_manager.request( + method, + url, + preload_content=not stream, + timeout=timeout, + headers=headers + ) + elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 + r = self.pool_manager.request( + method, url, + fields=fields, + encode_multipart=False, + preload_content=not stream, + timeout=timeout, + headers=headers) + elif headers['Content-Type'] == 'multipart/form-data': + # must del headers['Content-Type'], or the correct + # Content-Type which generated by urllib3 will be + # overwritten. + del headers['Content-Type'] + r = self.pool_manager.request( + method, url, + fields=fields, + encode_multipart=True, + preload_content=not stream, + timeout=timeout, + headers=headers) + # Pass a `string` parameter directly in the body to support + # other content types than Json when `body` argument is + # provided in serialized form + elif isinstance(body, str) or isinstance(body, bytes): + request_body = body + r = self.pool_manager.request( + method, url, + body=request_body, + preload_content=not stream, + timeout=timeout, + headers=headers) + else: + # Cannot generate the request from given parameters + msg = """Cannot prepare a request message for provided + arguments. Please check that your arguments match + declared content type.""" + raise ApiException(status=0, reason=msg) + # For `GET`, `HEAD` + else: + r = self.pool_manager.request(method, url, + preload_content=not stream, + timeout=timeout, + headers=headers) + except urllib3.exceptions.SSLError as e: + msg = "{0}\n{1}".format(type(e).__name__, str(e)) + raise ApiException(status=0, reason=msg) + + if not stream: + # log response body + logger.debug("response body: %s", r.data) + + return r + + def GET(self, url, headers=None, stream=False, + timeout=None, fields=None) -> urllib3.HTTPResponse: + return self.request("GET", url, + headers=headers, + stream=stream, + timeout=timeout, + fields=fields) + + def HEAD(self, url, headers=None, stream=False, + timeout=None, fields=None) -> urllib3.HTTPResponse: + return self.request("HEAD", url, + headers=headers, + stream=stream, + timeout=timeout, + fields=fields) + + def OPTIONS(self, url, headers=None, + body=None, stream=False, timeout=None, fields=None) -> urllib3.HTTPResponse: + return self.request("OPTIONS", url, + headers=headers, + stream=stream, + timeout=timeout, + body=body, fields=fields) + + def DELETE(self, url, headers=None, body=None, + stream=False, timeout=None, fields=None) -> urllib3.HTTPResponse: + return self.request("DELETE", url, + headers=headers, + stream=stream, + timeout=timeout, + body=body, fields=fields) + + def POST(self, url, headers=None, + body=None, stream=False, timeout=None, fields=None) -> urllib3.HTTPResponse: + return self.request("POST", url, + headers=headers, + stream=stream, + timeout=timeout, + body=body, fields=fields) + + def PUT(self, url, headers=None, + body=None, stream=False, timeout=None, fields=None) -> urllib3.HTTPResponse: + return self.request("PUT", url, + headers=headers, + stream=stream, + timeout=timeout, + body=body, fields=fields) + + def PATCH(self, url, headers=None, + body=None, stream=False, timeout=None, fields=None) -> urllib3.HTTPResponse: + return self.request("PATCH", url, + headers=headers, + stream=stream, + timeout=timeout, + body=body, fields=fields) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/schemas.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/schemas.py new file mode 100644 index 00000000000..0b78a94e7c4 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/schemas.py @@ -0,0 +1,2201 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +from collections import defaultdict +from datetime import date, datetime, timedelta # noqa: F401 +import functools +import decimal +import io +import os +import re +import tempfile +import typing +import uuid + +from dateutil.parser.isoparser import isoparser, _takes_ascii +from frozendict import frozendict + +from unit_test_api.exceptions import ( + ApiTypeError, + ApiValueError, +) +from unit_test_api.configuration import ( + Configuration, +) + + +class Unset(object): + """ + An instance of this class is set as the default value for object type(dict) properties that are optional + When a property has an unset value, that property will not be assigned in the dict + """ + pass + +unset = Unset() + +none_type = type(None) +file_type = io.IOBase + + +class FileIO(io.FileIO): + """ + A class for storing files + Note: this class is not immutable + """ + + def __new__(cls, arg: typing.Union[io.FileIO, io.BufferedReader]): + if isinstance(arg, (io.FileIO, io.BufferedReader)): + arg.close() + inst = super(FileIO, cls).__new__(cls, arg.name) + super(FileIO, inst).__init__(arg.name) + return inst + raise ApiValueError('FileIO must be passed arg which contains the open file') + + +def update(d: dict, u: dict): + """ + Adds u to d + Where each dict is defaultdict(set) + """ + if not u: + return d + for k, v in u.items(): + if not v: + continue + if k not in d: + d[k] = v + else: + d[k] = d[k] | v + + +class ValidationMetadata(frozendict): + """ + A class storing metadata that is needed to validate OpenApi Schema payloads + """ + def __new__( + cls, + path_to_item: typing.Tuple[typing.Union[str, int], ...] = tuple(['args[0]']), + from_server: bool = False, + configuration: typing.Optional[Configuration] = None, + base_classes: typing.FrozenSet[typing.Type] = frozenset(), + ): + """ + Args: + path_to_item: the path to the current data being instantiated. + For {'a': [1]} if the code is handling, 1, then the path is ('args[0]', 'a', 0) + from_server: whether or not this data came form the server + True when receiving server data + False when instantiating model with client side data not form the server + configuration: the Configuration instance to use + This is needed because in Configuration: + - one can disable validation checking + base_classes: when deserializing data that matches multiple schemas, this is used to store + the schemas that have been traversed. This is used to stop processing when a cycle is seen. + """ + return super().__new__( + cls, + path_to_item=path_to_item, + from_server=from_server, + configuration=configuration, + base_classes=base_classes, + ) + + @property + def path_to_item(self) -> typing.Tuple[typing.Union[str, int], ...]: + return self.get('path_to_item') + + @property + def from_server(self) -> bool: + return self.get('from_server') + + @property + def configuration(self) -> typing.Optional[Configuration]: + return self.get('configuration') + + @property + def base_classes(self) -> typing.FrozenSet[typing.Type]: + return self.get('base_classes') + + +class ValidatorBase: + @staticmethod + def __is_json_validation_enabled(schema_keyword, configuration=None): + """Returns true if JSON schema validation is enabled for the specified + validation keyword. This can be used to skip JSON schema structural validation + as requested in the configuration. + + Args: + schema_keyword (string): the name of a JSON schema validation keyword. + configuration (Configuration): the configuration class. + """ + + return (configuration is None or + not hasattr(configuration, '_disabled_client_side_validations') or + schema_keyword not in configuration._disabled_client_side_validations) + + @staticmethod + def __raise_validation_error_message(value, constraint_msg, constraint_value, path_to_item, additional_txt=""): + raise ApiValueError( + "Invalid value `{value}`, {constraint_msg} `{constraint_value}`{additional_txt} at {path_to_item}".format( + value=value, + constraint_msg=constraint_msg, + constraint_value=constraint_value, + additional_txt=additional_txt, + path_to_item=path_to_item, + ) + ) + + @classmethod + def __check_str_validations(cls, + validations, input_values, + validation_metadata: ValidationMetadata): + + if (cls.__is_json_validation_enabled('maxLength', validation_metadata.configuration) and + 'max_length' in validations and + len(input_values) > validations['max_length']): + cls.__raise_validation_error_message( + value=input_values, + constraint_msg="length must be less than or equal to", + constraint_value=validations['max_length'], + path_to_item=validation_metadata.path_to_item + ) + + if (cls.__is_json_validation_enabled('minLength', validation_metadata.configuration) and + 'min_length' in validations and + len(input_values) < validations['min_length']): + cls.__raise_validation_error_message( + value=input_values, + constraint_msg="length must be greater than or equal to", + constraint_value=validations['min_length'], + path_to_item=validation_metadata.path_to_item + ) + + checked_value = input_values + if (cls.__is_json_validation_enabled('pattern', validation_metadata.configuration) and + 'regex' in validations): + for regex_dict in validations['regex']: + flags = regex_dict.get('flags', 0) + if not re.search(regex_dict['pattern'], checked_value, flags=flags): + if flags != 0: + # Don't print the regex flags if the flags are not + # specified in the OAS document. + cls.__raise_validation_error_message( + value=input_values, + constraint_msg="must match regular expression", + constraint_value=regex_dict['pattern'], + path_to_item=validation_metadata.path_to_item, + additional_txt=" with flags=`{}`".format(flags) + ) + cls.__raise_validation_error_message( + value=input_values, + constraint_msg="must match regular expression", + constraint_value=regex_dict['pattern'], + path_to_item=validation_metadata.path_to_item + ) + + @classmethod + def __check_tuple_validations( + cls, validations, input_values, + validation_metadata: ValidationMetadata): + + if (cls.__is_json_validation_enabled('maxItems', validation_metadata.configuration) and + 'max_items' in validations and + len(input_values) > validations['max_items']): + cls.__raise_validation_error_message( + value=input_values, + constraint_msg="number of items must be less than or equal to", + constraint_value=validations['max_items'], + path_to_item=validation_metadata.path_to_item + ) + + if (cls.__is_json_validation_enabled('minItems', validation_metadata.configuration) and + 'min_items' in validations and + len(input_values) < validations['min_items']): + cls.__raise_validation_error_message( + value=input_values, + constraint_msg="number of items must be greater than or equal to", + constraint_value=validations['min_items'], + path_to_item=validation_metadata.path_to_item + ) + + if (cls.__is_json_validation_enabled('uniqueItems', validation_metadata.configuration) and + 'unique_items' in validations and validations['unique_items'] and input_values): + unique_items = [] + for item in input_values: + if item not in unique_items: + unique_items.append(item) + if len(input_values) > len(unique_items): + cls.__raise_validation_error_message( + value=input_values, + constraint_msg="duplicate items were found, and the tuple must not contain duplicates because", + constraint_value='unique_items==True', + path_to_item=validation_metadata.path_to_item + ) + + @classmethod + def __check_dict_validations( + cls, validations, input_values, + validation_metadata: ValidationMetadata): + + if (cls.__is_json_validation_enabled('maxProperties', validation_metadata.configuration) and + 'max_properties' in validations and + len(input_values) > validations['max_properties']): + cls.__raise_validation_error_message( + value=input_values, + constraint_msg="number of properties must be less than or equal to", + constraint_value=validations['max_properties'], + path_to_item=validation_metadata.path_to_item + ) + + if (cls.__is_json_validation_enabled('minProperties', validation_metadata.configuration) and + 'min_properties' in validations and + len(input_values) < validations['min_properties']): + cls.__raise_validation_error_message( + value=input_values, + constraint_msg="number of properties must be greater than or equal to", + constraint_value=validations['min_properties'], + path_to_item=validation_metadata.path_to_item + ) + + @classmethod + def __check_numeric_validations( + cls, validations, input_values, + validation_metadata: ValidationMetadata): + + if cls.__is_json_validation_enabled('multipleOf', + validation_metadata.configuration) and 'multiple_of' in validations: + multiple_of_values = validations['multiple_of'] + for multiple_of_value in multiple_of_values: + if (isinstance(input_values, decimal.Decimal) and + not (float(input_values) / multiple_of_value).is_integer() + ): + # Note 'multipleOf' will be as good as the floating point arithmetic. + cls.__raise_validation_error_message( + value=input_values, + constraint_msg="value must be a multiple of", + constraint_value=multiple_of_value, + path_to_item=validation_metadata.path_to_item + ) + + checking_max_or_min_values = {'exclusive_maximum', 'inclusive_maximum', 'exclusive_minimum', + 'inclusive_minimum'}.isdisjoint(validations) is False + if not checking_max_or_min_values: + return + max_val = input_values + min_val = input_values + + if (cls.__is_json_validation_enabled('exclusiveMaximum', validation_metadata.configuration) and + 'exclusive_maximum' in validations and + max_val >= validations['exclusive_maximum']): + cls.__raise_validation_error_message( + value=input_values, + constraint_msg="must be a value less than", + constraint_value=validations['exclusive_maximum'], + path_to_item=validation_metadata.path_to_item + ) + + if (cls.__is_json_validation_enabled('maximum', validation_metadata.configuration) and + 'inclusive_maximum' in validations and + max_val > validations['inclusive_maximum']): + cls.__raise_validation_error_message( + value=input_values, + constraint_msg="must be a value less than or equal to", + constraint_value=validations['inclusive_maximum'], + path_to_item=validation_metadata.path_to_item + ) + + if (cls.__is_json_validation_enabled('exclusiveMinimum', validation_metadata.configuration) and + 'exclusive_minimum' in validations and + min_val <= validations['exclusive_minimum']): + cls.__raise_validation_error_message( + value=input_values, + constraint_msg="must be a value greater than", + constraint_value=validations['exclusive_maximum'], + path_to_item=validation_metadata.path_to_item + ) + + if (cls.__is_json_validation_enabled('minimum', validation_metadata.configuration) and + 'inclusive_minimum' in validations and + min_val < validations['inclusive_minimum']): + cls.__raise_validation_error_message( + value=input_values, + constraint_msg="must be a value greater than or equal to", + constraint_value=validations['inclusive_minimum'], + path_to_item=validation_metadata.path_to_item + ) + + @classmethod + def _check_validations_for_types( + cls, + validations, + input_values, + validation_metadata: ValidationMetadata + ): + if isinstance(input_values, str): + cls.__check_str_validations(validations, input_values, validation_metadata) + elif isinstance(input_values, tuple): + cls.__check_tuple_validations(validations, input_values, validation_metadata) + elif isinstance(input_values, frozendict): + cls.__check_dict_validations(validations, input_values, validation_metadata) + elif isinstance(input_values, decimal.Decimal): + cls.__check_numeric_validations(validations, input_values, validation_metadata) + try: + return super()._validate_validations_pass(input_values, validation_metadata) + except AttributeError: + return True + + +class Validator(typing.Protocol): + def _validate_validations_pass( + cls, + input_values, + validation_metadata: ValidationMetadata + ): + pass + + +def _SchemaValidator(**validations: typing.Union[str, bool, None, int, float, list[dict[str, typing.Union[str, int, float]]]]) -> Validator: + class SchemaValidator(ValidatorBase): + @classmethod + def _validate_validations_pass( + cls, + input_values, + validation_metadata: ValidationMetadata + ): + cls._check_validations_for_types(validations, input_values, validation_metadata) + try: + return super()._validate_validations_pass(input_values, validation_metadata) + except AttributeError: + return True + + return SchemaValidator + + +class TypeChecker(typing.Protocol): + @classmethod + def _validate_type( + cls, arg_simple_class: type + ) -> typing.Tuple[type]: + pass + + +def _SchemaTypeChecker(union_type_cls: typing.Union[typing.Any]) -> TypeChecker: + if typing.get_origin(union_type_cls) is typing.Union: + union_classes = typing.get_args(union_type_cls) + else: + # note: when a union of a single class is passed in, the union disappears + union_classes = tuple([union_type_cls]) + """ + I want the type hint... union_type_cls + and to use it as a base class but when I do, I get + TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases + """ + class SchemaTypeChecker: + @classmethod + def _validate_type(cls, arg_simple_class: type): + if arg_simple_class not in union_classes: + return union_classes + try: + return super()._validate_type(arg_simple_class) + except AttributeError: + return tuple() + + return SchemaTypeChecker + + +class EnumMakerBase: + @classmethod + @property + def _enum_by_value( + cls + ) -> type: + enum_classes = {} + if not hasattr(cls, "_enum_value_to_name"): + return enum_classes + for enum_value, enum_name in cls._enum_value_to_name.items(): + base_class = type(enum_value) + if base_class is none_type: + enum_classes[enum_value] = get_new_class( + "Dynamic" + cls.__name__, (cls, NoneClass)) + log_cache_usage(get_new_class) + elif base_class is bool: + enum_classes[enum_value] = get_new_class( + "Dynamic" + cls.__name__, (cls, BoolClass)) + log_cache_usage(get_new_class) + else: + enum_classes[enum_value] = get_new_class( + "Dynamic" + cls.__name__, (cls, Singleton, base_class)) + log_cache_usage(get_new_class) + return enum_classes + + +class EnumMakerInterface(typing.Protocol): + @classmethod + @property + def _enum_value_to_name( + cls + ) -> typing.Dict[typing.Union[str, decimal.Decimal, bool, none_type], str]: + pass + + @classmethod + @property + def _enum_by_value( + cls + ) -> type: + pass + + +def _SchemaEnumMaker(enum_value_to_name: typing.Dict[typing.Union[str, decimal.Decimal, bool, none_type], str]) -> EnumMakerInterface: + class SchemaEnumMaker(EnumMakerBase): + @classmethod + @property + def _enum_value_to_name( + cls + ) -> typing.Dict[typing.Union[str, decimal.Decimal, bool, none_type], str]: + pass + try: + super_enum_value_to_name = super()._enum_value_to_name + except AttributeError: + return enum_value_to_name + intersection = dict(enum_value_to_name.items() & super_enum_value_to_name.items()) + return intersection + + return SchemaEnumMaker + + +class Singleton: + """ + Enums and singletons are the same + The same instance is returned for a given key of (cls, arg) + """ + _instances = {} + + def __new__(cls, arg: typing.Any, **kwargs): + key = (cls, arg) + if key not in cls._instances: + if arg in {None, True, False}: + inst = super().__new__(cls) + # inst._value = arg + cls._instances[key] = inst + else: + cls._instances[key] = super().__new__(cls, arg) + return cls._instances[key] + + def __repr__(self): + if isinstance(self, NoneClass): + return f'<{self.__class__.__name__}: None>' + elif isinstance(self, BoolClass): + if (self.__class__, True) in self._instances: + return f'<{self.__class__.__name__}: True>' + return f'<{self.__class__.__name__}: False>' + return f'<{self.__class__.__name__}: {super().__repr__()}>' + + +class NoneClass(Singleton): + @classmethod + @property + def NONE(cls): + return cls(None) + + def __bool__(self) -> bool: + return False + + +class BoolClass(Singleton): + @classmethod + @property + def TRUE(cls): + return cls(True) + + @classmethod + @property + def FALSE(cls): + return cls(False) + + @functools.cache + def __bool__(self) -> bool: + for key, instance in self._instances.items(): + if self is instance: + return key[1] + raise ValueError('Unable to find the boolean value of this instance') + + +class BoolBase: + def is_true(self) -> bool: + """ + A replacement for x is True + True if the instance is a BoolClass True Singleton + """ + if not issubclass(self.__class__, BoolClass): + return False + return bool(self) + + def is_false(self) -> bool: + """ + A replacement for x is False + True if the instance is a BoolClass False Singleton + """ + if not issubclass(self.__class__, BoolClass): + return False + return bool(self) is False + + +class NoneBase: + def is_none(self) -> bool: + """ + A replacement for x is None + True if the instance is a NoneClass None Singleton + """ + if issubclass(self.__class__, NoneClass): + return True + return False + + +class StrBase: + @property + def as_str(self) -> str: + return self + + @property + def as_date(self) -> date: + raise Exception('not implemented') + + @property + def as_datetime(self) -> datetime: + raise Exception('not implemented') + + @property + def as_decimal(self) -> decimal.Decimal: + raise Exception('not implemented') + + @property + def as_uuid(self) -> uuid.UUID: + raise Exception('not implemented') + + +class UUIDBase(StrBase): + @property + @functools.cache + def as_uuid(self) -> uuid.UUID: + return uuid.UUID(self) + + @classmethod + def _validate_format(cls, arg: typing.Optional[str], validation_metadata: ValidationMetadata): + if isinstance(arg, str): + try: + uuid.UUID(arg) + return True + except ValueError: + raise ApiValueError( + "Invalid value '{}' for type UUID at {}".format(arg, validation_metadata.path_to_item) + ) + + @classmethod + def _validate( + cls, + arg, + validation_metadata: typing.Optional[ValidationMetadata] = None, + ): + """ + UUIDBase _validate + """ + cls._validate_format(arg, validation_metadata=validation_metadata) + return super()._validate(arg, validation_metadata=validation_metadata) + + +class CustomIsoparser(isoparser): + + @_takes_ascii + def parse_isodatetime(self, dt_str): + components, pos = self._parse_isodate(dt_str) + if len(dt_str) > pos: + if self._sep is None or dt_str[pos:pos + 1] == self._sep: + components += self._parse_isotime(dt_str[pos + 1:]) + else: + raise ValueError('String contains unknown ISO components') + + if len(components) > 3 and components[3] == 24: + components[3] = 0 + return datetime(*components) + timedelta(days=1) + + if len(components) <= 3: + raise ValueError('Value is not a datetime') + + return datetime(*components) + + @_takes_ascii + def parse_isodate(self, datestr): + components, pos = self._parse_isodate(datestr) + + if len(datestr) > pos: + raise ValueError('String contains invalid time components') + + if len(components) > 3: + raise ValueError('String contains invalid time components') + + return date(*components) + + +DEFAULT_ISOPARSER = CustomIsoparser() + + +class DateBase(StrBase): + @property + @functools.cache + def as_date(self) -> date: + return DEFAULT_ISOPARSER.parse_isodate(self) + + @classmethod + def _validate_format(cls, arg: typing.Optional[str], validation_metadata: ValidationMetadata): + if isinstance(arg, str): + try: + DEFAULT_ISOPARSER.parse_isodate(arg) + return True + except ValueError: + raise ApiValueError( + "Value does not conform to the required ISO-8601 date format. " + "Invalid value '{}' for type date at {}".format(arg, validation_metadata.path_to_item) + ) + + @classmethod + def _validate( + cls, + arg, + validation_metadata: typing.Optional[ValidationMetadata] = None, + ): + """ + DateBase _validate + """ + cls._validate_format(arg, validation_metadata=validation_metadata) + return super()._validate(arg, validation_metadata=validation_metadata) + + +class DateTimeBase: + @property + @functools.cache + def as_datetime(self) -> datetime: + return DEFAULT_ISOPARSER.parse_isodatetime(self) + + @classmethod + def _validate_format(cls, arg: typing.Optional[str], validation_metadata: ValidationMetadata): + if isinstance(arg, str): + try: + DEFAULT_ISOPARSER.parse_isodatetime(arg) + return True + except ValueError: + raise ApiValueError( + "Value does not conform to the required ISO-8601 datetime format. " + "Invalid value '{}' for type datetime at {}".format(arg, validation_metadata.path_to_item) + ) + + @classmethod + def _validate( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + """ + DateTimeBase _validate + """ + cls._validate_format(arg, validation_metadata=validation_metadata) + return super()._validate(arg, validation_metadata=validation_metadata) + + +class DecimalBase(StrBase): + """ + A class for storing decimals that are sent over the wire as strings + These schemas must remain based on StrBase rather than NumberBase + because picking base classes must be deterministic + """ + + @property + @functools.cache + def as_decimal(self) -> decimal.Decimal: + return decimal.Decimal(self) + + @classmethod + def _validate_format(cls, arg: typing.Optional[str], validation_metadata: ValidationMetadata): + if isinstance(arg, str): + try: + decimal.Decimal(arg) + return True + except decimal.InvalidOperation: + raise ApiValueError( + "Value cannot be converted to a decimal. " + "Invalid value '{}' for type decimal at {}".format(arg, validation_metadata.path_to_item) + ) + + @classmethod + def _validate( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + """ + DecimalBase _validate + """ + cls._validate_format(arg, validation_metadata=validation_metadata) + return super()._validate(arg, validation_metadata=validation_metadata) + + +class NumberBase: + @property + def as_int(self) -> int: + try: + return self._as_int + except AttributeError: + """ + Note: for some numbers like 9.0 they could be represented as an + integer but our code chooses to store them as + >>> Decimal('9.0').as_tuple() + DecimalTuple(sign=0, digits=(9, 0), exponent=-1) + so we can tell that the value came from a float and convert it back to a float + during later serialization + """ + if self.as_tuple().exponent < 0: + # this could be represented as an integer but should be represented as a float + # because that's what it was serialized from + raise ApiValueError(f'{self} is not an integer') + self._as_int = int(self) + return self._as_int + + @property + def as_float(self) -> float: + try: + return self._as_float + except AttributeError: + if self.as_tuple().exponent >= 0: + raise ApiValueError(f'{self} is not an float') + self._as_float = float(self) + return self._as_float + + +class ListBase: + @classmethod + def _validate_items(cls, list_items, validation_metadata: ValidationMetadata): + """ + Ensures that: + - values passed in for items are valid + Exceptions will be raised if: + - invalid arguments were passed in + + Args: + list_items: the input list of items + + Raises: + ApiTypeError - for missing required arguments, or for invalid properties + """ + + # if we have definitions for an items schema, use it + # otherwise accept anything + item_cls = getattr(cls, '_items', AnyTypeSchema) + path_to_schemas = {} + for i, value in enumerate(list_items): + if isinstance(value, item_cls): + continue + item_validation_metadata = ValidationMetadata( + from_server=validation_metadata.from_server, + configuration=validation_metadata.configuration, + path_to_item=validation_metadata.path_to_item+(i,) + ) + other_path_to_schemas = item_cls._validate( + value, validation_metadata=item_validation_metadata) + update(path_to_schemas, other_path_to_schemas) + return path_to_schemas + + @classmethod + def _validate( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + """ + ListBase _validate + We return dynamic classes of different bases depending upon the inputs + This makes it so: + - the returned instance is always a subclass of our defining schema + - this allows us to check type based on whether an instance is a subclass of a schema + - the returned instance is a serializable type (except for None, True, and False) which are enums + + Returns: + new_cls (type): the new class + + Raises: + ApiValueError: when a string can't be converted into a date or datetime and it must be one of those classes + ApiTypeError: when the input type is not in the list of allowed spec types + """ + _path_to_schemas = super()._validate(arg, validation_metadata=validation_metadata) + if not isinstance(arg, tuple): + return _path_to_schemas + if cls in validation_metadata.base_classes: + # we have already moved through this class so stop here + return _path_to_schemas + updated_vm = ValidationMetadata( + configuration=validation_metadata.configuration, + from_server=validation_metadata.from_server, + path_to_item=validation_metadata.path_to_item, + base_classes=validation_metadata.base_classes | frozenset({cls}) + ) + other_path_to_schemas = cls._validate_items(arg, validation_metadata=updated_vm) + update(_path_to_schemas, other_path_to_schemas) + return _path_to_schemas + + @classmethod + def _get_items( + cls: 'Schema', + arg: typing.List[typing.Any], + path_to_item: typing.Tuple[typing.Union[str, int], ...], + path_to_schemas: typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Type['Schema']] + ): + ''' + ListBase _get_items + ''' + list_items = arg + cast_items = [] + # if we have definitions for an items schema, use it + # otherwise accept anything + + cls_item_cls = getattr(cls, '_items', AnyTypeSchema) + for i, value in enumerate(list_items): + item_path_to_item = path_to_item + (i,) + item_cls = path_to_schemas.get(item_path_to_item) + if item_cls is None: + item_cls = cls_item_cls + + if isinstance(value, item_cls): + cast_items.append(value) + continue + + new_value = item_cls._get_new_instance_without_conversion( + value, + item_path_to_item, + path_to_schemas + ) + cast_items.append(new_value) + + return cast_items + + +class Discriminable: + @classmethod + def _ensure_discriminator_value_present(cls, disc_property_name: str, validation_metadata: ValidationMetadata, *args): + if not args or args and disc_property_name not in args[0]: + # The input data does not contain the discriminator property + raise ApiValueError( + "Cannot deserialize input data due to missing discriminator. " + "The discriminator property '{}' is missing at path: {}".format(disc_property_name, validation_metadata.path_to_item) + ) + + @classmethod + def _get_discriminated_class(cls, disc_property_name: str, disc_payload_value: str): + """ + Used in schemas with discriminators + """ + if not hasattr(cls, '_discriminator'): + return None + disc = cls._discriminator + if disc_property_name not in disc: + return None + discriminated_cls = disc[disc_property_name].get(disc_payload_value) + if discriminated_cls is not None: + return discriminated_cls + elif not hasattr(cls, '_composed_schemas'): + return None + # TODO stop traveling if a cycle is hit + for allof_cls in cls._composed_schemas['allOf']: + discriminated_cls = allof_cls._get_discriminated_class( + disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) + if discriminated_cls is not None: + return discriminated_cls + for oneof_cls in cls._composed_schemas['oneOf']: + discriminated_cls = oneof_cls._get_discriminated_class( + disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) + if discriminated_cls is not None: + return discriminated_cls + for anyof_cls in cls._composed_schemas['anyOf']: + discriminated_cls = anyof_cls._get_discriminated_class( + disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) + if discriminated_cls is not None: + return discriminated_cls + return None + + +class DictBase(Discriminable): + # subclass properties + _required_property_names = set() + + @classmethod + def _validate_arg_presence(cls, arg): + """ + Ensures that: + - all required arguments are passed in + - the input variable names are valid + - present in properties or + - accepted because additionalProperties exists + Exceptions will be raised if: + - invalid arguments were passed in + - a var_name is invalid if additionProperties == None and var_name not in _properties + - required properties were not passed in + + Args: + arg: the input dict + + Raises: + ApiTypeError - for missing required arguments, or for invalid properties + """ + seen_required_properties = set() + invalid_arguments = [] + for property_name in arg: + if property_name in cls._required_property_names: + seen_required_properties.add(property_name) + elif property_name in cls._property_names: + continue + elif cls._additional_properties: + continue + else: + invalid_arguments.append(property_name) + missing_required_arguments = list(cls._required_property_names - seen_required_properties) + if missing_required_arguments: + missing_required_arguments.sort() + raise ApiTypeError( + "{} is missing {} required argument{}: {}".format( + cls.__name__, + len(missing_required_arguments), + "s" if len(missing_required_arguments) > 1 else "", + missing_required_arguments + ) + ) + if invalid_arguments: + invalid_arguments.sort() + raise ApiTypeError( + "{} was passed {} invalid argument{}: {}".format( + cls.__name__, + len(invalid_arguments), + "s" if len(invalid_arguments) > 1 else "", + invalid_arguments + ) + ) + + @classmethod + def _validate_args(cls, arg, validation_metadata: ValidationMetadata): + """ + Ensures that: + - values passed in for properties are valid + Exceptions will be raised if: + - invalid arguments were passed in + + Args: + arg: the input dict + + Raises: + ApiTypeError - for missing required arguments, or for invalid properties + """ + path_to_schemas = {} + for property_name, value in arg.items(): + if property_name in cls._required_property_names or property_name in cls._property_names: + schema = getattr(cls, property_name) + elif cls._additional_properties: + schema = cls._additional_properties + else: + raise ApiTypeError('Unable to find schema for value={} in class={} at path_to_item={}'.format( + value, cls, validation_metadata.path_to_item+(property_name,) + )) + if isinstance(value, schema): + continue + arg_validation_metadata = ValidationMetadata( + from_server=validation_metadata.from_server, + configuration=validation_metadata.configuration, + path_to_item=validation_metadata.path_to_item+(property_name,) + ) + other_path_to_schemas = schema._validate(value, validation_metadata=arg_validation_metadata) + update(path_to_schemas, other_path_to_schemas) + return path_to_schemas + + @classmethod + def _validate( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + """ + DictBase _validate + We return dynamic classes of different bases depending upon the inputs + This makes it so: + - the returned instance is always a subclass of our defining schema + - this allows us to check type based on whether an instance is a subclass of a schema + - the returned instance is a serializable type (except for None, True, and False) which are enums + + Returns: + new_cls (type): the new class + + Raises: + ApiValueError: when a string can't be converted into a date or datetime and it must be one of those classes + ApiTypeError: when the input type is not in the list of allowed spec types + """ + if isinstance(arg, cls): + # an instance of the correct type was passed in + return {} + _path_to_schemas = super()._validate(arg, validation_metadata=validation_metadata) + if not isinstance(arg, frozendict): + return _path_to_schemas + cls._validate_arg_presence(arg) + other_path_to_schemas = cls._validate_args(arg, validation_metadata=validation_metadata) + update(_path_to_schemas, other_path_to_schemas) + try: + _discriminator = cls._discriminator + except AttributeError: + return _path_to_schemas + # discriminator exists + disc_prop_name = list(_discriminator.keys())[0] + cls._ensure_discriminator_value_present(disc_prop_name, validation_metadata, arg) + discriminated_cls = cls._get_discriminated_class( + disc_property_name=disc_prop_name, disc_payload_value=arg[disc_prop_name]) + if discriminated_cls is None: + raise ApiValueError( + "Invalid discriminator value was passed in to {}.{} Only the values {} are allowed at {}".format( + cls.__name__, + disc_prop_name, + list(_discriminator[disc_prop_name].keys()), + validation_metadata.path_to_item + (disc_prop_name,) + ) + ) + if discriminated_cls in validation_metadata.base_classes: + # we have already moved through this class so stop here + return _path_to_schemas + updated_vm = ValidationMetadata( + configuration=validation_metadata.configuration, + from_server=validation_metadata.from_server, + path_to_item=validation_metadata.path_to_item, + base_classes=validation_metadata.base_classes | frozenset({cls}) + ) + other_path_to_schemas = discriminated_cls._validate(arg, validation_metadata=updated_vm) + update(_path_to_schemas, other_path_to_schemas) + return _path_to_schemas + + @classmethod + @property + def _additional_properties(cls): + return AnyTypeSchema + + @classmethod + @property + @functools.cache + def _property_names(cls): + property_names = set() + for var_name, var_value in cls.__dict__.items(): + # referenced models are classmethods + is_classmethod = type(var_value) is classmethod + if is_classmethod: + property_names.add(var_name) + continue + is_class = type(var_value) is type + if not is_class: + continue + if not issubclass(var_value, Schema): + continue + if var_name == '_additional_properties': + continue + property_names.add(var_name) + property_names = list(property_names) + property_names.sort() + return tuple(property_names) + + @classmethod + def _get_properties( + cls, + arg: typing.Dict[str, typing.Any], + path_to_item: typing.Tuple[typing.Union[str, int], ...], + path_to_schemas: typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Type['Schema']] + ): + """ + DictBase _get_properties, this is how properties are set + These values already passed validation + """ + dict_items = {} + # if we have definitions for property schemas convert values using it + # otherwise accept anything + + for property_name_js, value in arg.items(): + property_cls = getattr(cls, property_name_js, cls._additional_properties) + property_path_to_item = path_to_item + (property_name_js,) + stored_property_cls = path_to_schemas.get(property_path_to_item) + if stored_property_cls: + property_cls = stored_property_cls + + if isinstance(value, property_cls): + dict_items[property_name_js] = value + continue + + new_value = property_cls._get_new_instance_without_conversion( + value, + property_path_to_item, + path_to_schemas + ) + dict_items[property_name_js] = new_value + return dict_items + + def __setattr__(self, name, value): + if not isinstance(self, FileIO): + raise AttributeError('property setting not supported on immutable instances') + + def __getattr__(self, name): + if isinstance(self, frozendict): + # if an attribute does not exist + try: + return self[name] + except KeyError as ex: + raise AttributeError(str(ex)) + return super().__getattr__(self, name) + + def __getattribute__(self, name): + # if an attribute does exist (for example as a class property but not as an instance method) + try: + return self[name] + except (KeyError, TypeError): + return super().__getattribute__(name) + + +inheritable_primitive_types_set = {decimal.Decimal, str, tuple, frozendict, FileIO, bytes} + + +class Schema: + """ + the base class of all swagger/openapi schemas/models + + ensures that: + - payload passes required validations + - payload is of allowed types + - payload value is an allowed enum value + """ + + @staticmethod + def __get_simple_class(input_value): + """Returns an input_value's simple class that we will use for type checking + + Args: + input_value (class/class_instance): the item for which we will return + the simple class + """ + if isinstance(input_value, tuple): + return tuple + elif isinstance(input_value, frozendict): + return frozendict + elif isinstance(input_value, none_type): + return none_type + elif isinstance(input_value, bytes): + return bytes + elif isinstance(input_value, (io.FileIO, io.BufferedReader)): + return FileIO + elif isinstance(input_value, bool): + # this must be higher than the int check because + # isinstance(True, int) == True + return bool + elif isinstance(input_value, int): + return int + elif isinstance(input_value, float): + return float + elif isinstance(input_value, datetime): + # this must be higher than the date check because + # isinstance(datetime_instance, date) == True + return datetime + elif isinstance(input_value, date): + return date + elif isinstance(input_value, str): + return str + return type(input_value) + + @staticmethod + def __get_valid_classes_phrase(input_classes): + """Returns a string phrase describing what types are allowed""" + all_classes = list(input_classes) + all_classes = sorted(all_classes, key=lambda cls: cls.__name__) + all_class_names = [cls.__name__ for cls in all_classes] + if len(all_class_names) == 1: + return "is {0}".format(all_class_names[0]) + return "is one of [{0}]".format(", ".join(all_class_names)) + + @classmethod + def __type_error_message( + cls, var_value=None, var_name=None, valid_classes=None, key_type=None + ): + """ + Keyword Args: + var_value (any): the variable which has the type_error + var_name (str): the name of the variable which has the typ error + valid_classes (tuple): the accepted classes for current_item's + value + key_type (bool): False if our value is a value in a dict + True if it is a key in a dict + False if our item is an item in a tuple + """ + key_or_value = "value" + if key_type: + key_or_value = "key" + valid_classes_phrase = cls.__get_valid_classes_phrase(valid_classes) + msg = "Invalid type. Required {1} type {2} and " "passed type was {3}".format( + var_name, + key_or_value, + valid_classes_phrase, + type(var_value).__name__, + ) + return msg + + @classmethod + def __get_type_error(cls, var_value, path_to_item, valid_classes, key_type=False): + error_msg = cls.__type_error_message( + var_name=path_to_item[-1], + var_value=var_value, + valid_classes=valid_classes, + key_type=key_type, + ) + return ApiTypeError( + error_msg, + path_to_item=path_to_item, + valid_classes=valid_classes, + key_type=key_type, + ) + + @classmethod + def _class_by_base_class(cls, base_cls: type) -> type: + cls_name = "Dynamic"+cls.__name__ + if base_cls is bool: + new_cls = get_new_class(cls_name, (cls, BoolBase, BoolClass)) + elif base_cls is str: + new_cls = get_new_class(cls_name, (cls, StrBase, str)) + elif base_cls is decimal.Decimal: + new_cls = get_new_class(cls_name, (cls, NumberBase, decimal.Decimal)) + elif base_cls is tuple: + new_cls = get_new_class(cls_name, (cls, ListBase, tuple)) + elif base_cls is frozendict: + new_cls = get_new_class(cls_name, (cls, DictBase, frozendict)) + elif base_cls is none_type: + new_cls = get_new_class(cls_name, (cls, NoneBase, NoneClass)) + log_cache_usage(get_new_class) + return new_cls + + @classmethod + def _validate( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + """ + Schema _validate + Runs all schema validation logic and + returns a dynamic class of different bases depending upon the input + This makes it so: + - the returned instance is always a subclass of our defining schema + - this allows us to check type based on whether an instance is a subclass of a schema + - the returned instance is a serializable type (except for None, True, and False) which are enums + + Use cases: + 1. inheritable type: string/decimal.Decimal/frozendict/tuple + 2. enum value cases: 'hi', 1 -> no base_class set because the enum includes the base class + 3. uninheritable type: True/False/None -> no base_class because the base class is not inheritable + _enum_by_value will handle this use case + + Required Steps: + 1. verify type of input is valid vs the allowed _types + 2. check validations that are applicable for this type of input + 3. if enums exist, check that the value exists in the enum + + Returns: + path_to_schemas: a map of path to schemas + + Raises: + ApiValueError: when a string can't be converted into a date or datetime and it must be one of those classes + ApiTypeError: when the input type is not in the list of allowed spec types + """ + base_class = cls.__get_simple_class(arg) + failed_type_check_classes = cls._validate_type(base_class) + if failed_type_check_classes: + raise cls.__get_type_error( + arg, + validation_metadata.path_to_item, + failed_type_check_classes, + key_type=False, + ) + if hasattr(cls, '_validate_validations_pass'): + cls._validate_validations_pass(arg, validation_metadata) + path_to_schemas = {} + if validation_metadata.path_to_item not in path_to_schemas: + path_to_schemas[validation_metadata.path_to_item] = set() + path_to_schemas[validation_metadata.path_to_item].add(cls) + + if hasattr(cls, "_enum_by_value"): + cls._validate_enum_value(arg) + return path_to_schemas + + if base_class is none_type or base_class is bool: + return path_to_schemas + + path_to_schemas[validation_metadata.path_to_item].add(base_class) + return path_to_schemas + + @classmethod + def _validate_enum_value(cls, arg): + try: + cls._enum_by_value[arg] + except KeyError: + raise ApiValueError("Invalid value {} passed in to {}, {}".format(arg, cls, cls._enum_value_to_name)) + + @classmethod + def __get_new_cls( + cls, + arg, + validation_metadata: ValidationMetadata + ) -> typing.Dict[typing.Tuple[typing.Union[str, int], ...], 'Schema']: + """ + Make a new dynamic class and return an instance of that class + We are making an instance of cls, but instead of making cls + make a new class, new_cls + which includes dynamic bases including cls + return an instance of that new class + + Dict property + List Item Assignment Use cases: + 1. value is NOT an instance of the required schema class + the value is validated by _validate + _validate returns a key value pair + where the key is the path to the item, and the value will be the required manufactured class + made out of the matching schemas + 2. value is an instance of the the correct schema type + the value is NOT validated by _validate, _validate only checks that the instance is of the correct schema type + for this value, _validate does NOT return an entry for it in _path_to_schemas + and in list/dict _get_items,_get_properties the value will be directly assigned + because value is of the correct type, and validation was run earlier when the instance was created + """ + _path_to_schemas = cls._validate(arg, validation_metadata=validation_metadata) + # loop through it make a new class for each entry + # do not modify the returned result because it is cached and we would be modifying the cached value + path_to_schemas = {} + for path, schema_classes in _path_to_schemas.items(): + enum_schema = any( + hasattr(this_cls, '_enum_by_value') for this_cls in schema_classes) + inheritable_primitive_type = schema_classes.intersection(inheritable_primitive_types_set) + chosen_schema_classes = schema_classes + suffix = tuple() + if inheritable_primitive_type: + chosen_schema_classes = schema_classes - inheritable_primitive_types_set + if not enum_schema: + # include the inheritable_primitive_type + suffix = tuple(inheritable_primitive_type) + + if len(chosen_schema_classes) == 1 and not suffix: + mfg_cls = tuple(chosen_schema_classes)[0] + else: + x_schema = schema_descendents & chosen_schema_classes + if x_schema: + x_schema = x_schema.pop() + if any(c is not x_schema and issubclass(c, x_schema) for c in chosen_schema_classes): + # needed to not have a mro error in get_new_class + chosen_schema_classes.remove(x_schema) + used_classes = tuple(sorted(chosen_schema_classes, key=lambda a_cls: a_cls.__name__)) + suffix + mfg_cls = get_new_class(class_name='DynamicSchema', bases=used_classes) + + if inheritable_primitive_type and not enum_schema: + path_to_schemas[path] = mfg_cls + continue + + # Use case: value is None, True, False, or an enum value + value = arg + for key in path[1:]: + # if path is bigger than one, get the value that mfg_cls validated + value = value[key] + if hasattr(mfg_cls, '_enum_by_value'): + mfg_cls = mfg_cls._enum_by_value[value] + elif value in {True, False}: + mfg_cls = mfg_cls._class_by_base_class(bool) + elif value is None: + mfg_cls = mfg_cls._class_by_base_class(none_type) + else: + raise ApiValueError('Unhandled case value={} bases={}'.format(value, mfg_cls.__bases__)) + path_to_schemas[path] = mfg_cls + + return path_to_schemas + + @classmethod + def _get_new_instance_without_conversion( + cls: 'Schema', + arg: typing.Any, + path_to_item: typing.Tuple[typing.Union[str, int], ...], + path_to_schemas: typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Type['Schema']] + ): + # We have a Dynamic class and we are making an instance of it + if issubclass(cls, frozendict): + properties = cls._get_properties(arg, path_to_item, path_to_schemas) + return super(Schema, cls).__new__(cls, properties) + elif issubclass(cls, tuple): + items = cls._get_items(arg, path_to_item, path_to_schemas) + return super(Schema, cls).__new__(cls, items) + """ + str = openapi str, date, and datetime + decimal.Decimal = openapi int and float + FileIO = openapi binary type and the user inputs a file + bytes = openapi binary type and the user inputs bytes + """ + return super(Schema, cls).__new__(cls, arg) + + @classmethod + def _from_openapi_data( + cls, + arg: typing.Union[ + str, + date, + datetime, + int, + float, + decimal.Decimal, + bool, + None, + 'Schema', + dict, + frozendict, + tuple, + list, + io.FileIO, + io.BufferedReader, + bytes + ], + _configuration: typing.Optional[Configuration] + ): + """ + Schema _from_openapi_data + """ + arg = cast_to_allowed_types(arg, from_server=True) + validation_metadata = ValidationMetadata(from_server=True, configuration=_configuration) + path_to_schemas = cls.__get_new_cls(arg, validation_metadata) + new_cls = path_to_schemas[validation_metadata.path_to_item] + new_inst = new_cls._get_new_instance_without_conversion( + arg, + validation_metadata.path_to_item, + path_to_schemas + ) + return new_inst + + @staticmethod + def __get_input_dict(*args, **kwargs) -> frozendict: + input_dict = {} + if args and isinstance(args[0], (dict, frozendict)): + input_dict.update(args[0]) + if kwargs: + input_dict.update(kwargs) + return frozendict(input_dict) + + @staticmethod + def __remove_unsets(kwargs): + return {key: val for key, val in kwargs.items() if val is not unset} + + def __new__(cls, *args: typing.Union[dict, frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema'], _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Union[dict, frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema', Unset]): + """ + Schema __new__ + + Args: + args (int/float/decimal.Decimal/str/list/tuple/dict/frozendict/bool/None): the value + kwargs (str, int/float/decimal.Decimal/str/list/tuple/dict/frozendict/bool/None): dict values + _configuration: contains the Configuration that enables json schema validation keywords + like minItems, minLength etc + """ + kwargs = cls.__remove_unsets(kwargs) + if not args and not kwargs: + raise TypeError( + 'No input given. args or kwargs must be given.' + ) + if not kwargs and args and not isinstance(args[0], dict): + arg = args[0] + else: + arg = cls.__get_input_dict(*args, **kwargs) + validation_metadata = ValidationMetadata(configuration=_configuration, from_server=False) + arg = cast_to_allowed_types(arg, from_server=validation_metadata.from_server) + path_to_schemas = cls.__get_new_cls(arg, validation_metadata) + new_cls = path_to_schemas[validation_metadata.path_to_item] + return new_cls._get_new_instance_without_conversion( + arg, + validation_metadata.path_to_item, + path_to_schemas + ) + + def __init__( + self, + *args: typing.Union[ + dict, frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema'], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Union[ + dict, frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema', Unset + ] + ): + """ + this is needed to fix 'Unexpected argument' warning in pycharm + this code does nothing because all Schema instances are immutable + this means that all input data is passed into and used in new, and after the new instance is made + no new attributes are assigned and init is not used + """ + pass + + +def cast_to_allowed_types(arg: typing.Union[str, date, datetime, decimal.Decimal, int, float, None, dict, frozendict, list, tuple, bytes, Schema], from_server=False) -> typing.Union[str, bytes, decimal.Decimal, None, frozendict, tuple, Schema]: + """ + from_server=False date, datetime -> str + int, float -> Decimal + StrSchema will convert that to bytes and remember the encoding when we pass in str input + """ + if isinstance(arg, str): + return arg + elif type(arg) is dict or type(arg) is frozendict: + return frozendict({key: cast_to_allowed_types(val) for key, val in arg.items()}) + elif isinstance(arg, bool): + """ + this check must come before isinstance(arg, (int, float)) + because isinstance(True, int) is True + """ + return arg + elif isinstance(arg, int): + return decimal.Decimal(arg) + elif isinstance(arg, float): + decimal_from_float = decimal.Decimal(arg) + if decimal_from_float.as_integer_ratio()[1] == 1: + # 9.0 -> Decimal('9.0') + # 3.4028234663852886e+38 -> Decimal('340282346638528859811704183484516925440.0') + return decimal.Decimal(str(decimal_from_float)+'.0') + return decimal_from_float + elif type(arg) is list or type(arg) is tuple: + return tuple([cast_to_allowed_types(item) for item in arg]) + elif arg is None: + return arg + elif isinstance(arg, (date, datetime)): + if not from_server: + return arg.isoformat() + # ApiTypeError will be thrown later by _validate_type + return arg + elif isinstance(arg, uuid.UUID): + if not from_server: + return str(arg) + # ApiTypeError will be thrown later by _validate_type + return arg + elif isinstance(arg, decimal.Decimal): + return arg + elif isinstance(arg, bytes): + return arg + elif isinstance(arg, decimal.Decimal): + return arg + elif isinstance(arg, (io.FileIO, io.BufferedReader)): + if arg.closed: + raise ApiValueError('Invalid file state; file is closed and must be open') + return arg + elif isinstance(arg, Schema): + return arg + raise ValueError('Invalid type passed in got input={} type={}'.format(arg, type(arg))) + + +class ComposedBase(Discriminable): + + @classmethod + def __get_allof_classes(cls, arg, validation_metadata: ValidationMetadata): + path_to_schemas = defaultdict(set) + for allof_cls in cls._composed_schemas['allOf']: + if allof_cls in validation_metadata.base_classes: + continue + other_path_to_schemas = allof_cls._validate(arg, validation_metadata=validation_metadata) + update(path_to_schemas, other_path_to_schemas) + return path_to_schemas + + @classmethod + def __get_oneof_class( + cls, + arg, + discriminated_cls, + validation_metadata: ValidationMetadata, + path_to_schemas: typing.Dict[typing.Tuple, typing.Set[typing.Type[Schema]]] + ): + oneof_classes = [] + chosen_oneof_cls = None + original_base_classes = validation_metadata.base_classes + new_base_classes = validation_metadata.base_classes + path_to_schemas = defaultdict(set) + for oneof_cls in cls._composed_schemas['oneOf']: + if oneof_cls in path_to_schemas[validation_metadata.path_to_item]: + oneof_classes.append(oneof_cls) + continue + if isinstance(arg, oneof_cls): + # passed in instance is the correct type + chosen_oneof_cls = oneof_cls + oneof_classes.append(oneof_cls) + continue + try: + path_to_schemas = oneof_cls._validate(arg, validation_metadata=validation_metadata) + new_base_classes = validation_metadata.base_classes + except (ApiValueError, ApiTypeError) as ex: + if discriminated_cls is not None and oneof_cls is discriminated_cls: + raise ex + continue + chosen_oneof_cls = oneof_cls + oneof_classes.append(oneof_cls) + if not oneof_classes: + raise ApiValueError( + "Invalid inputs given to generate an instance of {}. None " + "of the oneOf schemas matched the input data.".format(cls) + ) + elif len(oneof_classes) > 1: + raise ApiValueError( + "Invalid inputs given to generate an instance of {}. Multiple " + "oneOf schemas {} matched the inputs, but a max of one is allowed.".format(cls, oneof_classes) + ) + return path_to_schemas + + @classmethod + def __get_anyof_classes( + cls, + arg, + discriminated_cls, + validation_metadata: ValidationMetadata + ): + anyof_classes = [] + chosen_anyof_cls = None + original_base_classes = validation_metadata.base_classes + path_to_schemas = defaultdict(set) + for anyof_cls in cls._composed_schemas['anyOf']: + if anyof_cls in validation_metadata.base_classes: + continue + if isinstance(arg, anyof_cls): + # passed in instance is the correct type + chosen_anyof_cls = anyof_cls + anyof_classes.append(anyof_cls) + continue + + try: + other_path_to_schemas = anyof_cls._validate(arg, validation_metadata=validation_metadata) + except (ApiValueError, ApiTypeError) as ex: + if discriminated_cls is not None and anyof_cls is discriminated_cls: + raise ex + continue + original_base_classes = validation_metadata.base_classes + chosen_anyof_cls = anyof_cls + anyof_classes.append(anyof_cls) + update(path_to_schemas, other_path_to_schemas) + if not anyof_classes: + raise ApiValueError( + "Invalid inputs given to generate an instance of {}. None " + "of the anyOf schemas matched the input data.".format(cls) + ) + return path_to_schemas + + @classmethod + def _validate( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + """ + ComposedBase _validate + We return dynamic classes of different bases depending upon the inputs + This makes it so: + - the returned instance is always a subclass of our defining schema + - this allows us to check type based on whether an instance is a subclass of a schema + - the returned instance is a serializable type (except for None, True, and False) which are enums + + Returns: + new_cls (type): the new class + + Raises: + ApiValueError: when a string can't be converted into a date or datetime and it must be one of those classes + ApiTypeError: when the input type is not in the list of allowed spec types + """ + if isinstance(arg, Schema) and validation_metadata.from_server is False: + if isinstance(arg, cls): + # an instance of the correct type was passed in + return {} + raise ApiTypeError( + 'Incorrect type passed in, required type was {} and passed type was {} at {}'.format( + cls, + type(arg), + validation_metadata.path_to_item + ) + ) + + # validation checking on types, validations, and enums + path_to_schemas = super()._validate(arg, validation_metadata=validation_metadata) + + updated_vm = ValidationMetadata( + configuration=validation_metadata.configuration, + from_server=validation_metadata.from_server, + path_to_item=validation_metadata.path_to_item, + base_classes=validation_metadata.base_classes | frozenset({cls}) + ) + + # process composed schema + _discriminator = getattr(cls, '_discriminator', None) + discriminated_cls = None + if _discriminator and arg and isinstance(arg, frozendict): + disc_property_name = list(_discriminator.keys())[0] + cls._ensure_discriminator_value_present(disc_property_name, updated_vm, arg) + # get discriminated_cls by looking at the dict in the current class + discriminated_cls = cls._get_discriminated_class( + disc_property_name=disc_property_name, disc_payload_value=arg[disc_property_name]) + if discriminated_cls is None: + raise ApiValueError( + "Invalid discriminator value '{}' was passed in to {}.{} Only the values {} are allowed at {}".format( + arg[disc_property_name], + cls.__name__, + disc_property_name, + list(_discriminator[disc_property_name].keys()), + updated_vm.path_to_item + (disc_property_name,) + ) + ) + + if cls._composed_schemas['allOf']: + other_path_to_schemas = cls.__get_allof_classes(arg, validation_metadata=updated_vm) + update(path_to_schemas, other_path_to_schemas) + if cls._composed_schemas['oneOf']: + other_path_to_schemas = cls.__get_oneof_class( + arg, + discriminated_cls=discriminated_cls, + validation_metadata=updated_vm, + path_to_schemas=path_to_schemas + ) + update(path_to_schemas, other_path_to_schemas) + if cls._composed_schemas['anyOf']: + other_path_to_schemas = cls.__get_anyof_classes( + arg, + discriminated_cls=discriminated_cls, + validation_metadata=updated_vm + ) + update(path_to_schemas, other_path_to_schemas) + not_cls = cls._composed_schemas['not'] + if not_cls: + other_path_to_schemas = None + try: + other_path_to_schemas = not_cls._validate(arg, validation_metadata=updated_vm) + except (ApiValueError, ApiTypeError): + pass + if other_path_to_schemas: + raise ApiValueError( + "Invalid value '{}' was passed in to {}. Value is invalid because it is disallowed by {}".format( + arg, + cls.__name__, + not_cls.__name__, + ) + ) + + if discriminated_cls is not None: + # TODO use an exception from this package here + assert discriminated_cls in path_to_schemas[updated_vm.path_to_item] + return path_to_schemas + + +# DictBase, ListBase, NumberBase, StrBase, BoolBase, NoneBase +class ComposedSchema( + _SchemaTypeChecker(typing.Union[none_type, str, decimal.Decimal, bool, tuple, frozendict]), + ComposedBase, + DictBase, + ListBase, + NumberBase, + StrBase, + BoolBase, + NoneBase, + Schema +): + + # subclass properties + _composed_schemas = {} + + @classmethod + def _from_openapi_data(cls, *args: typing.Any, _configuration: typing.Optional[Configuration] = None, **kwargs): + if not args: + if not kwargs: + raise ApiTypeError('{} is missing required input data in args or kwargs'.format(cls.__name__)) + args = (kwargs, ) + return super()._from_openapi_data(args[0], _configuration=_configuration) + + +class ListSchema( + _SchemaTypeChecker(typing.Union[tuple]), + ListBase, + Schema +): + + @classmethod + def _from_openapi_data(cls, arg: typing.List[typing.Any], _configuration: typing.Optional[Configuration] = None): + return super()._from_openapi_data(arg, _configuration=_configuration) + + def __new__(cls, arg: typing.Union[list, tuple], **kwargs: ValidationMetadata): + return super().__new__(cls, arg, **kwargs) + + +class NoneSchema( + _SchemaTypeChecker(typing.Union[none_type]), + NoneBase, + Schema +): + + @classmethod + def _from_openapi_data(cls, arg: None, _configuration: typing.Optional[Configuration] = None): + return super()._from_openapi_data(arg, _configuration=_configuration) + + def __new__(cls, arg: None, **kwargs: typing.Union[ValidationMetadata]): + return super().__new__(cls, arg, **kwargs) + + +class NumberSchema( + _SchemaTypeChecker(typing.Union[decimal.Decimal]), + NumberBase, + Schema +): + """ + This is used for type: number with no format + Both integers AND floats are accepted + """ + + @classmethod + def _from_openapi_data(cls, arg: typing.Union[int, float, decimal.Decimal], _configuration: typing.Optional[Configuration] = None): + return super()._from_openapi_data(arg, _configuration=_configuration) + + def __new__(cls, arg: typing.Union[decimal.Decimal, int, float], **kwargs: typing.Union[ValidationMetadata]): + return super().__new__(cls, arg, **kwargs) + + +class IntBase(NumberBase): + @property + def as_int(self) -> int: + try: + return self._as_int + except AttributeError: + self._as_int = int(self) + return self._as_int + + @classmethod + def _validate_format(cls, arg: typing.Optional[decimal.Decimal], validation_metadata: ValidationMetadata): + if isinstance(arg, decimal.Decimal): + + denominator = arg.as_integer_ratio()[-1] + if denominator != 1: + raise ApiValueError( + "Invalid value '{}' for type integer at {}".format(arg, validation_metadata.path_to_item) + ) + + @classmethod + def _validate( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + """ + IntBase _validate + TODO what about types = (int, number) -> IntBase, NumberBase? We could drop int and keep number only + """ + cls._validate_format(arg, validation_metadata=validation_metadata) + return super()._validate(arg, validation_metadata=validation_metadata) + + +class IntSchema(IntBase, NumberSchema): + + @classmethod + def _from_openapi_data(cls, arg: int, _configuration: typing.Optional[Configuration] = None): + return super()._from_openapi_data(arg, _configuration=_configuration) + + def __new__(cls, arg: typing.Union[decimal.Decimal, int], **kwargs: typing.Union[ValidationMetadata]): + return super().__new__(cls, arg, **kwargs) + + +class Int32Base( + _SchemaValidator( + inclusive_minimum=decimal.Decimal(-2147483648), + inclusive_maximum=decimal.Decimal(2147483647) + ), +): + pass + + +class Int32Schema( + Int32Base, + IntSchema +): + pass + + +class Int64Base( + _SchemaValidator( + inclusive_minimum=decimal.Decimal(-9223372036854775808), + inclusive_maximum=decimal.Decimal(9223372036854775807) + ), +): + pass + + +class Int64Schema( + Int64Base, + IntSchema +): + pass + + +class Float32Base( + _SchemaValidator( + inclusive_minimum=decimal.Decimal(-3.4028234663852886e+38), + inclusive_maximum=decimal.Decimal(3.4028234663852886e+38) + ), +): + pass + + +class Float32Schema( + Float32Base, + NumberSchema +): + + @classmethod + def _from_openapi_data(cls, arg: typing.Union[float, decimal.Decimal], _configuration: typing.Optional[Configuration] = None): + # todo check format + return super()._from_openapi_data(arg, _configuration=_configuration) + + +class Float64Base( + _SchemaValidator( + inclusive_minimum=decimal.Decimal(-1.7976931348623157E+308), + inclusive_maximum=decimal.Decimal(1.7976931348623157E+308) + ), +): + pass + + +class Float64Schema( + Float64Base, + NumberSchema +): + + @classmethod + def _from_openapi_data(cls, arg: typing.Union[float, decimal.Decimal], _configuration: typing.Optional[Configuration] = None): + # todo check format + return super()._from_openapi_data(arg, _configuration=_configuration) + + +class StrSchema( + _SchemaTypeChecker(typing.Union[str]), + StrBase, + Schema +): + """ + date + datetime string types must inherit from this class + That is because one can validate a str payload as both: + - type: string (format unset) + - type: string, format: date + """ + + @classmethod + def _from_openapi_data(cls, arg: typing.Union[str], _configuration: typing.Optional[Configuration] = None) -> 'StrSchema': + return super()._from_openapi_data(arg, _configuration=_configuration) + + def __new__(cls, arg: typing.Union[str, date, datetime, uuid.UUID], **kwargs: typing.Union[ValidationMetadata]): + return super().__new__(cls, arg, **kwargs) + + +class UUIDSchema(UUIDBase, StrSchema): + + def __new__(cls, arg: typing.Union[str, uuid.UUID], **kwargs: typing.Union[ValidationMetadata]): + return super().__new__(cls, arg, **kwargs) + + +class DateSchema(DateBase, StrSchema): + + def __new__(cls, arg: typing.Union[str, datetime], **kwargs: typing.Union[ValidationMetadata]): + return super().__new__(cls, arg, **kwargs) + + +class DateTimeSchema(DateTimeBase, StrSchema): + + def __new__(cls, arg: typing.Union[str, datetime], **kwargs: typing.Union[ValidationMetadata]): + return super().__new__(cls, arg, **kwargs) + + +class DecimalSchema(DecimalBase, StrSchema): + + def __new__(cls, arg: typing.Union[str], **kwargs: typing.Union[ValidationMetadata]): + """ + Note: Decimals may not be passed in because cast_to_allowed_types is only invoked once for payloads + which can be simple (str) or complex (dicts or lists with nested values) + Because casting is only done once and recursively casts all values prior to validation then for a potential + client side Decimal input if Decimal was accepted as an input in DecimalSchema then one would not know + if one was using it for a StrSchema (where it should be cast to str) or one is using it for NumberSchema + where it should stay as Decimal. + """ + return super().__new__(cls, arg, **kwargs) + + +class BytesSchema( + _SchemaTypeChecker(typing.Union[bytes]), + Schema, +): + """ + this class will subclass bytes and is immutable + """ + def __new__(cls, arg: typing.Union[bytes], **kwargs: typing.Union[ValidationMetadata]): + return super(Schema, cls).__new__(cls, arg) + + +class FileSchema( + _SchemaTypeChecker(typing.Union[FileIO]), + Schema, +): + """ + This class is NOT immutable + Dynamic classes are built using it for example when AnyType allows in binary data + Al other schema classes ARE immutable + If one wanted to make this immutable one could make this a DictSchema with required properties: + - data = BytesSchema (which would be an immutable bytes based schema) + - file_name = StrSchema + and cast_to_allowed_types would convert bytes and file instances into dicts containing data + file_name + The downside would be that data would be stored in memory which one may not want to do for very large files + + The developer is responsible for closing this file and deleting it + + This class was kept as mutable: + - to allow file reading and writing to disk + - to be able to preserve file name info + """ + + def __new__(cls, arg: typing.Union[io.FileIO, io.BufferedReader], **kwargs: typing.Union[ValidationMetadata]): + return super(Schema, cls).__new__(cls, arg) + + +class BinaryBase: + pass + + +class BinarySchema( + _SchemaTypeChecker(typing.Union[bytes, FileIO]), + ComposedBase, + BinaryBase, + Schema, +): + + @classmethod + @property + def _composed_schemas(cls): + # 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 because 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 { + 'allOf': [], + 'oneOf': [ + BytesSchema, + FileSchema, + ], + 'anyOf': [ + ], + 'not': None + } + + def __new__(cls, arg: typing.Union[io.FileIO, io.BufferedReader, bytes], **kwargs: typing.Union[ValidationMetadata]): + return super().__new__(cls, arg) + + +class BoolSchema( + _SchemaTypeChecker(typing.Union[bool]), + BoolBase, + Schema +): + + @classmethod + def _from_openapi_data(cls, arg: bool, _configuration: typing.Optional[Configuration] = None): + return super()._from_openapi_data(arg, _configuration=_configuration) + + def __new__(cls, arg: bool, **kwargs: typing.Union[ValidationMetadata]): + return super().__new__(cls, arg, **kwargs) + + +class AnyTypeSchema( + _SchemaTypeChecker( + typing.Union[frozendict, tuple, decimal.Decimal, str, bool, none_type, bytes, FileIO] + ), + DictBase, + ListBase, + NumberBase, + StrBase, + BoolBase, + NoneBase, + Schema +): + pass + + +class DictSchema( + _SchemaTypeChecker(typing.Union[frozendict]), + DictBase, + Schema +): + + @classmethod + def _from_openapi_data(cls, arg: typing.Dict[str, typing.Any], _configuration: typing.Optional[Configuration] = None): + return super()._from_openapi_data(arg, _configuration=_configuration) + + def __new__(cls, *args: typing.Union[dict, frozendict], **kwargs: typing.Union[dict, frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, bytes, Schema, Unset, ValidationMetadata]): + return super().__new__(cls, *args, **kwargs) + + +schema_descendents = set([NoneSchema, DictSchema, ListSchema, NumberSchema, StrSchema, BoolSchema]) + + +def deserialize_file(response_data, configuration, content_disposition=None): + """Deserializes body to file + + Saves response body into a file in a temporary folder, + using the filename from the `Content-Disposition` header if provided. + + Args: + param response_data (str): the file data to write + configuration (Configuration): the instance to use to convert files + + Keyword Args: + content_disposition (str): the value of the Content-Disposition + header + + Returns: + (file_type): the deserialized file which is open + The user is responsible for closing and reading the file + """ + fd, path = tempfile.mkstemp(dir=configuration.temp_folder_path) + os.close(fd) + os.remove(path) + + if content_disposition: + filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', + content_disposition).group(1) + path = os.path.join(os.path.dirname(path), filename) + + with open(path, "wb") as f: + if isinstance(response_data, str): + # change str to bytes so we can write it + response_data = response_data.encode('utf-8') + f.write(response_data) + + f = open(path, "rb") + return f + + +@functools.cache +def get_new_class( + class_name: str, + bases: typing.Tuple[typing.Type[typing.Union[Schema, typing.Any]], ...] +) -> typing.Type[Schema]: + """ + Returns a new class that is made with the subclass bases + """ + return type(class_name, bases, {}) + + +LOG_CACHE_USAGE = False + + +def log_cache_usage(cache_fn): + if LOG_CACHE_USAGE: + print(cache_fn.__name__, cache_fn.cache_info()) -- GitLab From 83c18f960a3a9e9ca3abf87f46eb804224b1f8b3 Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Mon, 27 Jun 2022 23:26:33 -0700 Subject: [PATCH 26/43] Further improves example string escaping --- .../PythonExperimentalClientCodegen.java | 20 +++++++++++++---- .../.openapi-generator/FILES | 1 - ...test_properties_with_escaped_characters.py | 22 +++++++++---------- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java index 19aee3f6613..2078a85fd51 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java @@ -1168,14 +1168,26 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen { if (stringValue.contains(nullChar)) { stringValue = stringValue.replace(nullChar, "\\x00"); } - String backSlash = "\\"; - if (stringValue.contains(backSlash)) { - stringValue = stringValue.replace(backSlash, "\\\\"); - } String doubleQuoteChar = "\""; if (stringValue.contains(doubleQuoteChar)) { stringValue = stringValue.replace(doubleQuoteChar, "\\\""); } + String lineSep = System.lineSeparator(); + if (stringValue.contains(lineSep)) { + stringValue = stringValue.replace(lineSep, "\\n"); + } + String carriageReturn = "\r"; + if (stringValue.contains(carriageReturn)) { + stringValue = stringValue.replace(carriageReturn, "\\r"); + } + String tab = "\t"; + if (stringValue.contains(tab)) { + stringValue = stringValue.replace(tab, "\\t"); + } + String formFeed = "\f"; + if (stringValue.contains(formFeed)) { + stringValue = stringValue.replace(formFeed, "\\f"); + } return stringValue; } else if (value instanceof LinkedHashMap) { LinkedHashMap<String, Object> fixedValues = new LinkedHashMap(); diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index f7612595387..52193c82e6b 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -10,7 +10,6 @@ setup.cfg setup.py test-requirements.txt test/__init__.py -test/test_object_properties_validation.py test/test_properties_with_escaped_characters.py tox.ini unit_test_api/__init__.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py index 65c155d6ab9..6a83bc4cfc9 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py @@ -23,23 +23,22 @@ class TestPropertiesWithEscapedCharacters(unittest.TestCase): PropertiesWithEscapedCharacters( **{ - """foo -bar""": + "foo\nbar": 1, "foo\"bar": 1, - "foo\\bar": + "foo\bar": 1, - """foo bar""": + "foo\rbar": 1, - "foo bar": + "foo\tbar": 1, - "foobar": + "foo\fbar": 1, } ) @@ -50,8 +49,7 @@ bar""": PropertiesWithEscapedCharacters( **{ - """foo -bar""": + "foo\nbar": "1", @@ -59,19 +57,19 @@ bar""": "1", - "foo\\bar": + "foo\bar": "1", - """foo bar""": + "foo\rbar": "1", - "foo bar": + "foo\tbar": "1", - "foobar": + "foo\fbar": "1", } -- GitLab From 5f3152e20f22820ef5676a66be86fb9541345327 Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Mon, 27 Jun 2022 23:38:37 -0700 Subject: [PATCH 27/43] Fixes properties test cases --- .../languages/PythonExperimentalClientCodegen.java | 5 +++++ .../model_templates/schema.handlebars | 2 +- .../python-experimental/.openapi-generator/FILES | 1 + .../docs/PropertiesWithEscapedCharacters.md | 13 ++++++------- .../test/test_properties_with_escaped_characters.py | 4 ++-- .../model/properties_with_escaped_characters.py | 13 ++++++------- 6 files changed, 21 insertions(+), 17 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java index 2078a85fd51..2988ca07677 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java @@ -849,6 +849,7 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen { // templates use its presence to handle these badly named variables / keys if ((isReservedWord(name) || !isValidPythonVarOrClassName(name)) && !name.equals(cp.name)) { cp.nameInSnakeCase = cp.name; + cp.baseName = (String) processTestExampleData(name); } else { cp.nameInSnakeCase = null; } @@ -1168,6 +1169,10 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen { if (stringValue.contains(nullChar)) { stringValue = stringValue.replace(nullChar, "\\x00"); } + String backslash = "\\"; + if (stringValue.contains(backslash)) { + stringValue = stringValue.replace(backslash, "\\\\"); + } String doubleQuoteChar = "\""; if (stringValue.contains(doubleQuoteChar)) { stringValue = stringValue.replace(doubleQuoteChar, "\\\""); diff --git a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/schema.handlebars b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/schema.handlebars index fb6453f7918..8b577418410 100644 --- a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/schema.handlebars +++ b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/schema.handlebars @@ -39,7 +39,7 @@ {{/or}} {{/or}} {{#if nameInSnakeCase}} -locals()['{{{baseName}}}'] = {{name}} +locals()["{{{baseName}}}"] = {{name}} del locals()['{{name}}'] {{/if}} {{/if}} diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index 52193c82e6b..f7612595387 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -10,6 +10,7 @@ setup.cfg setup.py test-requirements.txt test/__init__.py +test/test_object_properties_validation.py test/test_properties_with_escaped_characters.py tox.ini unit_test_api/__init__.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PropertiesWithEscapedCharacters.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PropertiesWithEscapedCharacters.md index 03b7ad904cf..e585f0e8e14 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PropertiesWithEscapedCharacters.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PropertiesWithEscapedCharacters.md @@ -3,13 +3,12 @@ #### Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**foo -bar** | **int, float** | | [optional] -**foo"bar** | **int, float** | | [optional] -**foo\bar** | **int, float** | | [optional] -**foo bar** | **int, float** | | [optional] -**foo bar** | **int, float** | | [optional] -**foobar** | **int, float** | | [optional] +**foo\nbar** | **int, float** | | [optional] +**foo\"bar** | **int, float** | | [optional] +**foo\\bar** | **int, float** | | [optional] +**foo\rbar** | **int, float** | | [optional] +**foo\tbar** | **int, float** | | [optional] +**foo\fbar** | **int, float** | | [optional] **any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py index 6a83bc4cfc9..8c326af86b7 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py @@ -29,7 +29,7 @@ class TestPropertiesWithEscapedCharacters(unittest.TestCase): "foo\"bar": 1, - "foo\bar": + "foo\\bar": 1, "foo\rbar": @@ -57,7 +57,7 @@ class TestPropertiesWithEscapedCharacters(unittest.TestCase): "1", - "foo\bar": + "foo\\bar": "1", diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/properties_with_escaped_characters.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/properties_with_escaped_characters.py index b022465743f..5b1aceb23a4 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/properties_with_escaped_characters.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/properties_with_escaped_characters.py @@ -75,23 +75,22 @@ class PropertiesWithEscapedCharacters( Do not edit the class manually. """ foobar = NumberSchema - locals()['foo -bar'] = foobar + locals()["foo\nbar"] = foobar del locals()['foobar'] foobar = NumberSchema - locals()['foo"bar'] = foobar + locals()["foo\"bar"] = foobar del locals()['foobar'] foo_bar = NumberSchema - locals()['foo\bar'] = foo_bar + locals()["foo\\bar"] = foo_bar del locals()['foo_bar'] foobar = NumberSchema - locals()['foo bar'] = foobar + locals()["foo\rbar"] = foobar del locals()['foobar'] foobar = NumberSchema - locals()['foo bar'] = foobar + locals()["foo\tbar"] = foobar del locals()['foobar'] foobar = NumberSchema - locals()['foobar'] = foobar + locals()["foo\fbar"] = foobar del locals()['foobar'] def __new__( -- GitLab From 9c9c7b4967fb90df277e65f7276d168711a3b68d Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Tue, 28 Jun 2022 00:17:38 -0700 Subject: [PATCH 28/43] Adds draft6 test samples license --- .../3_0/unit_test_spec/draft6/LICENSE | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/LICENSE diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/LICENSE b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/LICENSE new file mode 100644 index 00000000000..050eb041f96 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/draft6/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2012 Julian Berman + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file -- GitLab From 1bcb7fbdefede54fcc93e4384efd7b7ccd5d5e7f Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Tue, 28 Jun 2022 10:16:12 -0700 Subject: [PATCH 29/43] Adds ref --- .../python-experimental_3_0_3_unit_test.yaml | 2 +- .../unit_test_spec/3_0_3_unit_test_spec.yaml | 70 ++++++++++++++ .../3_0/unit_test_spec/spec_writer.py | 92 +++++++++++------- .../resources/3_0/unit_test_spec/type.yaml | 91 ------------------ .../.openapi-generator/FILES | 15 +-- .../python-experimental/README.md | 5 +- ...=> PropertyNamedRefThatIsNotAReference.md} | 9 +- ...ation.md => RelativePointerRefToObject.md} | 4 +- .../docs/RootPointerRef.md | 9 ++ .../test/test_object_properties_validation.py | 95 ------------------- ...test_properties_with_escaped_characters.py | 80 ---------------- ...perty_named_ref_that_is_not_a_reference.py | 45 +++++++++ .../test_relative_pointer_ref_to_object.py | 45 +++++++++ .../test/test_root_pointer_ref.py | 79 +++++++++++++++ ...erty_named_ref_that_is_not_a_reference.py} | 13 +-- ...s.py => relative_pointer_ref_to_object.py} | 34 +++---- .../unit_test_api/model/root_pointer_ref.py | 92 ++++++++++++++++++ .../unit_test_api/models/__init__.py | 5 +- 18 files changed, 439 insertions(+), 346 deletions(-) create mode 100644 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml delete mode 100644 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml rename samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/{PropertiesWithEscapedCharacters.md => PropertyNamedRefThatIsNotAReference.md} (58%) rename samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/{ObjectPropertiesValidation.md => RelativePointerRefToObject.md} (83%) create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RootPointerRef.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_object_properties_validation.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_property_named_ref_that_is_not_a_reference.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_relative_pointer_ref_to_object.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_root_pointer_ref.py rename samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/{object_properties_validation.py => property_named_ref_that_is_not_a_reference.py} (88%) rename samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/{properties_with_escaped_characters.py => relative_pointer_ref_to_object.py} (75%) create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/root_pointer_ref.py diff --git a/bin/configs/python-experimental_3_0_3_unit_test.yaml b/bin/configs/python-experimental_3_0_3_unit_test.yaml index 3169f0804e1..a6428fb1ad7 100644 --- a/bin/configs/python-experimental_3_0_3_unit_test.yaml +++ b/bin/configs/python-experimental_3_0_3_unit_test.yaml @@ -1,6 +1,6 @@ generatorName: python-experimental outputDir: samples/openapi3/client/3_0_3_unit_test/python-experimental -inputSpec: modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml +inputSpec: modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml templateDir: modules/openapi-generator/src/main/resources/python-experimental additionalProperties: packageName: unit_test_api diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml new file mode 100644 index 00000000000..3e2c773f429 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml @@ -0,0 +1,70 @@ +openapi: 3.0.3 +info: + title: openapi 3.0.3 sample spec + description: sample spec for testing openapi functionality, built from json schema + tests for draft6 + version: 0.0.1 +paths: {} +components: + schemas: + RootPointerRef: + properties: + foo: + $ref: '#' + additionalProperties: false + RelativePointerRefToObject: + properties: + foo: + type: integer + bar: + $ref: '#/properties/foo' + PropertyNamedRefThatIsNotAReference: + properties: + $ref: + type: string + x-schema-test-examples: + RootPointerRef: + Match: + description: match + data: + foo: false + valid: true + RecursiveMatch: + description: recursive match + data: + foo: + foo: false + valid: true + Mismatch: + description: mismatch + data: + bar: false + valid: false + RecursiveMismatch: + description: recursive mismatch + data: + foo: + bar: false + valid: false + RelativePointerRefToObject: + Match: + description: match + data: + bar: 3 + valid: true + Mismatch: + description: mismatch + data: + bar: true + valid: false + PropertyNamedRefThatIsNotAReference: + PropertyNamedRefValid: + description: property named $ref valid + data: + $ref: a + valid: true + PropertyNamedRefInvalid: + description: property named $ref invalid + data: + $ref: 2 + valid: false diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index db3bae19789..4aea69c4866 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -7,25 +7,13 @@ import typing import yaml """ -Swagger-parser can create one spec from multiple files BUT: -- it must use refs to values in another file -- those refs will be turned into component schemas $refs -- so it will not dereference and inline schemas +This file ingests json schemas from +https://github.com/json-schema-org/JSON-Schema-Test-Suite/tree/main/tests +and writes those test schemas and test cases into a sample openapi spec document +That spec document can then be used to write clients or server stubs which +can contain autogenerated tests that use the json schema test cases -Note: -- 3.0.3: schema supports only a single example -- That example could $ref a component example but we have not ability to test negative examples -- Higher spec versions do have examples BUT: examples does not store pass fail info - - that info could be added as an x-flag - -components.examples Re-use solution: -- including an x-valid tag in each example to note if it should pass or fail -- v3.0.3: add x-examples to schema for passing and failing examples -- ref the needed examples -- using examples for passing examples - -BUT: -- the parser already supports refing examples to a separate yaml file any way +The python-experimental client is the first user of this test spec. TODO: - [DONE] load json file and write it into components/schemas @@ -46,31 +34,45 @@ class JsonSchemaTestCase: data: typing.Union[str, int, float, bool, None, list, dict] valid: bool -JsonSchema = typing.TypedDict( +JsonSchemaDict = typing.TypedDict( 'JsonSchema', { - 'type': str, - 'properties': typing.Dict[str, 'JsonSchema'], - 'patternProperties': typing.Dict[str, 'JsonSchema'], - 'additionalProperties': typing.Union[bool, 'JsonSchema'], + 'additionalProperties': 'JsonSchema', 'allOf': typing.List['JsonSchema'], 'anyOf': typing.List['JsonSchema'], - 'oneOf': typing.List['JsonSchema'], - 'not': 'JsonSchema', - 'maxLength': int, - 'minLength': int, - 'required': typing.List[str], + 'default': typing.Any, + 'enum': typing.List[typing.Any], + 'exclusiveMaximum': typing.Union[int, float], + 'exclusiveMinimum': typing.Union[int, float], + 'format': str, + 'items': 'JsonSchema', 'maximum': typing.Union[int, float], + 'maxItems': int, + 'maxLength': int, + 'maxProperties': int, 'minimum': typing.Union[int, float], + 'minItems': int, + 'minLength': int, + 'minProperties': int, 'multipleOf': typing.Union[int, float], + 'not': 'JsonSchema', + 'oneOf': typing.List['JsonSchema'], + 'pattern': str, + 'properties': typing.Dict[str, 'JsonSchema'], + '$ref': str, + 'required': typing.List[str], + 'type': str, + 'uniqueItems': bool, }, total=False ) +JsonSchema = typing.Union['JsonSchemaDict', bool] + @dataclasses.dataclass class JsonSchemaTestSchema: description: str - schema: typing.Union[bool, JsonSchema] + schema: JsonSchema tests: typing.List[JsonSchemaTestCase] @@ -89,6 +91,9 @@ class ExclusionReason: swagger_parser_items_type_bug = "swagger-parser has a bug where schema type is incorrectly set with items, https://github.com/swagger-api/swagger-parser/issues/1763" v303_does_not_support_id = 'v3.0.3 does not support the $id keyword' v303_does_not_support_patternProperties = 'v3.0.3 does not support the patternProperties keyword' + v303_does_not_support_propertyNames = 'v3.0.3 does not support the propertyNames keyword' + v303_does_not_support_items_schema_array = 'v3.0.3 does not support an array of schemas for items' + swagger_parser_exception = 'swagger-parser threw and exception for this test case' json_schema_test_draft = 'draft6' FILEPATH_TO_EXCLUDED_CASE_AND_REASON = { @@ -127,6 +132,26 @@ FILEPATH_TO_EXCLUDED_CASE_AND_REASON = { (json_schema_test_draft, 'properties.json'): { 'properties, patternProperties, additionalProperties interaction': ExclusionReason.v303_does_not_support_patternProperties, 'properties with boolean schema': ExclusionReason.v303_does_not_support_boolean_schemas_in_location, + }, + (json_schema_test_draft, 'ref.json'): { + 'relative refs with absolute uris and defs': ExclusionReason.v303_does_not_support_id, + '$ref prevents a sibling $id from changing the base uri': ExclusionReason.v303_does_not_support_id, + 'property named $ref, containing an actual $ref': ExclusionReason.v303_does_not_support_definitions, + 'naive replacement of $ref with its destination is not correct': ExclusionReason.v303_does_not_support_definitions, + 'relative pointer ref to array': ExclusionReason.v303_does_not_support_items_schema_array, + 'ref overrides any sibling keywords': ExclusionReason.v303_does_not_support_definitions, + 'Location-independent identifier with base URI change in subschema': ExclusionReason.v303_does_not_support_definitions, + 'escaped pointer ref': ExclusionReason.v303_does_not_support_definitions, + 'Location-independent identifier': ExclusionReason.v303_does_not_support_definitions, + 'refs with relative uris and defs': ExclusionReason.v303_does_not_support_id, + 'Recursive references between schemas': ExclusionReason.v303_does_not_support_definitions, + 'refs with quote': ExclusionReason.v303_does_not_support_definitions, + 'refs with quote': ExclusionReason.v303_does_not_support_definitions, + '$ref to boolean schema true': ExclusionReason.v303_does_not_support_definitions, + 'Recursive references between schemas': ExclusionReason.v303_does_not_support_id, + 'nested refs': ExclusionReason.v303_does_not_support_definitions, + '$ref to boolean schema false': ExclusionReason.v303_does_not_support_definitions, + 'remote ref, containing refs itself': ExclusionReason.swagger_parser_exception, } } FILEPATH_TO_EXCLUDE_REASON = { @@ -140,12 +165,12 @@ FILEPATH_TO_EXCLUDE_REASON = { (json_schema_test_draft, 'exclusiveMinimum.json'): ExclusionReason.swagger_parser_validation_missing_bug, (json_schema_test_draft, 'id.json'): ExclusionReason.v303_does_not_support_id, (json_schema_test_draft, 'patternProperties.json'): ExclusionReason.v303_does_not_support_patternProperties, + (json_schema_test_draft, 'propertyNames.json'): ExclusionReason.v303_does_not_support_propertyNames, } openapi_additions = 'openapi_additions' JSON_SCHEMA_TEST_FILE_TO_FOLDERS = { -# 'type.json': (json_schema_test_draft, openapi_additions), # 'additionalItems.json': (json_schema_test_draft,), # 'additionalProperties.json': (json_schema_test_draft,), # 'allOf.json': (json_schema_test_draft,), # activate later after fixing composition processing @@ -176,7 +201,10 @@ JSON_SCHEMA_TEST_FILE_TO_FOLDERS = { # 'oneOf.json': (json_schema_test_draft,), # activate after fixing this # 'pattern.json': (json_schema_test_draft,), # 'patternProperties.json': (json_schema_test_draft,), - 'properties.json': (json_schema_test_draft,), +# 'properties.json': (json_schema_test_draft,), + 'propertyNames.json': (json_schema_test_draft,), + 'ref.json': (json_schema_test_draft,), +# 'type.json': (json_schema_test_draft, openapi_additions), } def get_json_schema_test_schemas(file_path: typing.Tuple[str]) -> typing.List[JsonSchemaTestSchema]: @@ -307,7 +335,7 @@ def write_openapi_spec(): sort_keys=False ) ) - spec_out = 'type.yaml' + spec_out = '3_0_3_unit_test_spec.yaml' with open(spec_out, 'w') as yaml_out: yaml_out.write( yaml.dump( diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml deleted file mode 100644 index 5095cd42dc6..00000000000 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/type.yaml +++ /dev/null @@ -1,91 +0,0 @@ -openapi: 3.0.3 -info: - title: openapi 3.0.3 sample spec - description: sample spec for testing openapi functionality, built from json schema - tests for draft6 - version: 0.0.1 -paths: {} -components: - schemas: - ObjectPropertiesValidation: - properties: - foo: - type: integer - bar: - type: string - PropertiesWithEscapedCharacters: - properties: - ? 'foo - - bar' - : type: number - foo"bar: - type: number - foo\bar: - type: number - "foo\rbar": - type: number - "foo\tbar": - type: number - "foo\fbar": - type: number - x-schema-test-examples: - ObjectPropertiesValidation: - BothPropertiesPresentAndValidIsValid: - description: both properties present and valid is valid - data: - foo: 1 - bar: baz - valid: true - OnePropertyInvalidIsInvalid: - description: one property invalid is invalid - data: - foo: 1 - bar: {} - valid: false - BothPropertiesInvalidIsInvalid: - description: both properties invalid is invalid - data: - foo: [] - bar: {} - valid: false - DoesnTInvalidateOtherProperties: - description: doesn't invalidate other properties - data: - quux: [] - valid: true - IgnoresArrays: - description: ignores arrays - data: [] - valid: true - IgnoresOtherNonObjects: - description: ignores other non-objects - data: 12 - valid: true - PropertiesWithEscapedCharacters: - ObjectWithAllNumbersIsValid: - description: object with all numbers is valid - data: - ? 'foo - - bar' - : 1 - foo"bar: 1 - foo\bar: 1 - "foo\rbar": 1 - "foo\tbar": 1 - "foo\fbar": 1 - valid: true - ObjectWithStringsIsInvalid: - description: object with strings is invalid - data: - ? 'foo - - bar' - : '1' - foo"bar: '1' - foo\bar: '1' - "foo\rbar": '1' - "foo\tbar": '1' - "foo\fbar": '1' - valid: false diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index f7612595387..636a6565c94 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -2,16 +2,18 @@ .gitlab-ci.yml .travis.yml README.md -docs/ObjectPropertiesValidation.md -docs/PropertiesWithEscapedCharacters.md +docs/PropertyNamedRefThatIsNotAReference.md +docs/RelativePointerRefToObject.md +docs/RootPointerRef.md git_push.sh requirements.txt setup.cfg setup.py test-requirements.txt test/__init__.py -test/test_object_properties_validation.py -test/test_properties_with_escaped_characters.py +test/test_property_named_ref_that_is_not_a_reference.py +test/test_relative_pointer_ref_to_object.py +test/test_root_pointer_ref.py tox.ini unit_test_api/__init__.py unit_test_api/api/__init__.py @@ -20,8 +22,9 @@ unit_test_api/apis/__init__.py unit_test_api/configuration.py unit_test_api/exceptions.py unit_test_api/model/__init__.py -unit_test_api/model/object_properties_validation.py -unit_test_api/model/properties_with_escaped_characters.py +unit_test_api/model/property_named_ref_that_is_not_a_reference.py +unit_test_api/model/relative_pointer_ref_to_object.py +unit_test_api/model/root_pointer_ref.py unit_test_api/models/__init__.py unit_test_api/rest.py unit_test_api/schemas.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md index 1362e29d020..855772529a8 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md @@ -62,8 +62,9 @@ Class | Method | HTTP request | Description ## Documentation For Models - - [ObjectPropertiesValidation](docs/ObjectPropertiesValidation.md) - - [PropertiesWithEscapedCharacters](docs/PropertiesWithEscapedCharacters.md) + - [PropertyNamedRefThatIsNotAReference](docs/PropertyNamedRefThatIsNotAReference.md) + - [RelativePointerRefToObject](docs/RelativePointerRefToObject.md) + - [RootPointerRef](docs/RootPointerRef.md) ## Documentation For Authorization diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PropertiesWithEscapedCharacters.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PropertyNamedRefThatIsNotAReference.md similarity index 58% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PropertiesWithEscapedCharacters.md rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PropertyNamedRefThatIsNotAReference.md index e585f0e8e14..7f51dc33bb9 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PropertiesWithEscapedCharacters.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PropertyNamedRefThatIsNotAReference.md @@ -1,14 +1,9 @@ -# PropertiesWithEscapedCharacters +# PropertyNamedRefThatIsNotAReference #### Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**foo\nbar** | **int, float** | | [optional] -**foo\"bar** | **int, float** | | [optional] -**foo\\bar** | **int, float** | | [optional] -**foo\rbar** | **int, float** | | [optional] -**foo\tbar** | **int, float** | | [optional] -**foo\fbar** | **int, float** | | [optional] +**$ref** | **str** | | [optional] **any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ObjectPropertiesValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RelativePointerRefToObject.md similarity index 83% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ObjectPropertiesValidation.md rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RelativePointerRefToObject.md index 9307469f5bb..ee3c8b29ca1 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ObjectPropertiesValidation.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RelativePointerRefToObject.md @@ -1,10 +1,10 @@ -# ObjectPropertiesValidation +# RelativePointerRefToObject #### Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **foo** | **int** | | [optional] -**bar** | **str** | | [optional] +**bar** | [**ERRORUNKNOWN**](ERRORUNKNOWN.md) | | [optional] **any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RootPointerRef.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RootPointerRef.md new file mode 100644 index 00000000000..35ea0a016cb --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RootPointerRef.md @@ -0,0 +1,9 @@ +# RootPointerRef + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**foo** | **** | | [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/3_0_3_unit_test/python-experimental/test/test_object_properties_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_object_properties_validation.py deleted file mode 100644 index 6aaf84593ca..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_object_properties_validation.py +++ /dev/null @@ -1,95 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.object_properties_validation import ObjectPropertiesValidation - - -class TestObjectPropertiesValidation(unittest.TestCase): - """ObjectPropertiesValidation unit test stubs""" - - def test_ignores_arrays_passes(self): - # ignores arrays - ObjectPropertiesValidation( - [ - ] - ) - - def test_ignores_other_non_objects_passes(self): - # ignores other non-objects - ObjectPropertiesValidation( - 12 ) - - def test_one_property_invalid_is_invalid_fails(self): - # one property invalid is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - ObjectPropertiesValidation( - **{ - - "foo": - 1, - - "bar": - { - } -, - } - ) - - def test_both_properties_present_and_valid_is_valid_passes(self): - # both properties present and valid is valid - ObjectPropertiesValidation( - **{ - - "foo": - 1, - - "bar": - - "baz", - } - ) - - def test_doesn_t_invalidate_other_properties_passes(self): - # doesn't invalidate other properties - ObjectPropertiesValidation( - **{ - - "quux": - [ - ] -, - } - ) - - def test_both_properties_invalid_is_invalid_fails(self): - # both properties invalid is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - ObjectPropertiesValidation( - **{ - - "foo": - [ - ] -, - - "bar": - { - } -, - } - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py deleted file mode 100644 index 8c326af86b7..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py +++ /dev/null @@ -1,80 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.properties_with_escaped_characters import PropertiesWithEscapedCharacters - - -class TestPropertiesWithEscapedCharacters(unittest.TestCase): - """PropertiesWithEscapedCharacters unit test stubs""" - - def test_object_with_all_numbers_is_valid_passes(self): - # object with all numbers is valid - PropertiesWithEscapedCharacters( - **{ - - "foo\nbar": - 1, - - "foo\"bar": - 1, - - "foo\\bar": - 1, - - "foo\rbar": - 1, - - "foo\tbar": - 1, - - "foo\fbar": - 1, - } - ) - - def test_object_with_strings_is_invalid_fails(self): - # object with strings is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - PropertiesWithEscapedCharacters( - **{ - - "foo\nbar": - - "1", - - "foo\"bar": - - "1", - - "foo\\bar": - - "1", - - "foo\rbar": - - "1", - - "foo\tbar": - - "1", - - "foo\fbar": - - "1", - } - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_property_named_ref_that_is_not_a_reference.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_property_named_ref_that_is_not_a_reference.py new file mode 100644 index 00000000000..da3dc97e5a2 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_property_named_ref_that_is_not_a_reference.py @@ -0,0 +1,45 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.property_named_ref_that_is_not_a_reference import PropertyNamedRefThatIsNotAReference + + +class TestPropertyNamedRefThatIsNotAReference(unittest.TestCase): + """PropertyNamedRefThatIsNotAReference unit test stubs""" + + def test_property_named_ref_valid_passes(self): + # property named $ref valid + PropertyNamedRefThatIsNotAReference( + **{ + + "$ref": + + "a", + } + ) + + def test_property_named_ref_invalid_fails(self): + # property named $ref invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + PropertyNamedRefThatIsNotAReference( + **{ + + "$ref": + 2, + } + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_relative_pointer_ref_to_object.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_relative_pointer_ref_to_object.py new file mode 100644 index 00000000000..6f496dc5acc --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_relative_pointer_ref_to_object.py @@ -0,0 +1,45 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.relative_pointer_ref_to_object import RelativePointerRefToObject + + +class TestRelativePointerRefToObject(unittest.TestCase): + """RelativePointerRefToObject unit test stubs""" + + def test_mismatch_fails(self): + # mismatch + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + RelativePointerRefToObject( + **{ + + "bar": + + True, + } + ) + + def test_match_passes(self): + # match + RelativePointerRefToObject( + **{ + + "bar": + 3, + } + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_root_pointer_ref.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_root_pointer_ref.py new file mode 100644 index 00000000000..00fafc77cf5 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_root_pointer_ref.py @@ -0,0 +1,79 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.root_pointer_ref import RootPointerRef + + +class TestRootPointerRef(unittest.TestCase): + """RootPointerRef unit test stubs""" + + def test_recursive_mismatch_fails(self): + # recursive mismatch + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + RootPointerRef( + **{ + + "foo": + **{ + + "bar": + + False, + } +, + } + ) + + def test_mismatch_fails(self): + # mismatch + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + RootPointerRef( + **{ + + "bar": + + False, + } + ) + + def test_match_passes(self): + # match + RootPointerRef( + **{ + + "foo": + + False, + } + ) + + def test_recursive_match_passes(self): + # recursive match + RootPointerRef( + **{ + + "foo": + **{ + + "foo": + + False, + } +, + } + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/object_properties_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/property_named_ref_that_is_not_a_reference.py similarity index 88% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/object_properties_validation.py rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/property_named_ref_that_is_not_a_reference.py index a5ac3ccf95d..0f3628abc04 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/object_properties_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/property_named_ref_that_is_not_a_reference.py @@ -66,7 +66,7 @@ from unit_test_api.schemas import ( # noqa: F401 ) -class ObjectPropertiesValidation( +class PropertyNamedRefThatIsNotAReference( AnyTypeSchema ): """NOTE: This class is auto generated by OpenAPI Generator. @@ -74,22 +74,19 @@ class ObjectPropertiesValidation( Do not edit the class manually. """ - foo = IntSchema - bar = StrSchema + ref = StrSchema + locals()["$ref"] = ref + del locals()['ref'] def __new__( cls, *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - foo: typing.Union[foo, Unset] = unset, - bar: typing.Union[bar, Unset] = unset, _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Type[Schema], - ) -> 'ObjectPropertiesValidation': + ) -> 'PropertyNamedRefThatIsNotAReference': return super().__new__( cls, *args, - foo=foo, - bar=bar, _configuration=_configuration, **kwargs, ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/properties_with_escaped_characters.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/relative_pointer_ref_to_object.py similarity index 75% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/properties_with_escaped_characters.py rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/relative_pointer_ref_to_object.py index 5b1aceb23a4..c9bb9329fdd 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/properties_with_escaped_characters.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/relative_pointer_ref_to_object.py @@ -66,7 +66,7 @@ from unit_test_api.schemas import ( # noqa: F401 ) -class PropertiesWithEscapedCharacters( +class RelativePointerRefToObject( AnyTypeSchema ): """NOTE: This class is auto generated by OpenAPI Generator. @@ -74,34 +74,28 @@ class PropertiesWithEscapedCharacters( Do not edit the class manually. """ - foobar = NumberSchema - locals()["foo\nbar"] = foobar - del locals()['foobar'] - foobar = NumberSchema - locals()["foo\"bar"] = foobar - del locals()['foobar'] - foo_bar = NumberSchema - locals()["foo\\bar"] = foo_bar - del locals()['foo_bar'] - foobar = NumberSchema - locals()["foo\rbar"] = foobar - del locals()['foobar'] - foobar = NumberSchema - locals()["foo\tbar"] = foobar - del locals()['foobar'] - foobar = NumberSchema - locals()["foo\fbar"] = foobar - del locals()['foobar'] + foo = IntSchema + + @classmethod + @property + def bar(cls) -> typing.Type['ERRORUNKNOWN']: + return ERRORUNKNOWN def __new__( cls, *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + foo: typing.Union[foo, Unset] = unset, + bar: typing.Union['ERRORUNKNOWN', Unset] = unset, _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Type[Schema], - ) -> 'PropertiesWithEscapedCharacters': + ) -> 'RelativePointerRefToObject': return super().__new__( cls, *args, + foo=foo, + bar=bar, _configuration=_configuration, **kwargs, ) + +from unit_test_api.model.errorunknown import ERRORUNKNOWN diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/root_pointer_ref.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/root_pointer_ref.py new file mode 100644 index 00000000000..d3bc2c4fe65 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/root_pointer_ref.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class RootPointerRef( + DictSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + foo = Schema + _additional_properties = None + + + def __new__( + cls, + *args: typing.Union[dict, frozendict, ], + foo: typing.Union[foo, Unset] = unset, + _configuration: typing.Optional[Configuration] = None, + ) -> 'RootPointerRef': + return super().__new__( + cls, + *args, + foo=foo, + _configuration=_configuration, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py index c4d96c15d2f..88743c7d8e7 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py @@ -11,5 +11,6 @@ # import sys # sys.setrecursionlimit(n) -from unit_test_api.model.object_properties_validation import ObjectPropertiesValidation -from unit_test_api.model.properties_with_escaped_characters import PropertiesWithEscapedCharacters +from unit_test_api.model.property_named_ref_that_is_not_a_reference import PropertyNamedRefThatIsNotAReference +from unit_test_api.model.relative_pointer_ref_to_object import RelativePointerRefToObject +from unit_test_api.model.root_pointer_ref import RootPointerRef -- GitLab From c31d9598a9b8c9d7c94289166c06645ea0fe648f Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Tue, 28 Jun 2022 15:18:55 -0700 Subject: [PATCH 30/43] Finishes ref --- .../payload_renderer.handlebars | 2 +- .../python-experimental/model_test.handlebars | 12 ++- .../unit_test_spec/3_0_3_unit_test_spec.yaml | 45 -------- .../unit_test_spec/openapi_additions/ref.json | 72 +++++++++++++ .../3_0/unit_test_spec/spec_writer.py | 17 ++- .../.openapi-generator/FILES | 6 -- .../python-experimental/README.md | 2 - .../docs/RelativePointerRefToObject.md | 11 -- .../docs/RootPointerRef.md | 9 -- ...perty_named_ref_that_is_not_a_reference.py | 14 ++- .../test_relative_pointer_ref_to_object.py | 45 -------- .../test/test_root_pointer_ref.py | 79 -------------- .../model/relative_pointer_ref_to_object.py | 101 ------------------ .../unit_test_api/model/root_pointer_ref.py | 92 ---------------- .../unit_test_api/models/__init__.py | 2 - 15 files changed, 105 insertions(+), 404 deletions(-) create mode 100755 modules/openapi-generator/src/test/resources/3_0/unit_test_spec/openapi_additions/ref.json delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RelativePointerRefToObject.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RootPointerRef.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_relative_pointer_ref_to_object.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_root_pointer_ref.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/relative_pointer_ref_to_object.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/root_pointer_ref.py diff --git a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars index 29114dafa35..29507a82fb0 100644 --- a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars +++ b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars @@ -6,7 +6,7 @@ ] {{else}} {{#if isMap}} -{{#not value.isEmpty}}**{{/not}}{ +{ {{#each value}} {{#with @key}} {{> model_templates/payload_renderer }}: diff --git a/modules/openapi-generator/src/main/resources/python-experimental/model_test.handlebars b/modules/openapi-generator/src/main/resources/python-experimental/model_test.handlebars index 8313533a8b5..031185e090c 100644 --- a/modules/openapi-generator/src/main/resources/python-experimental/model_test.handlebars +++ b/modules/openapi-generator/src/main/resources/python-experimental/model_test.handlebars @@ -8,25 +8,29 @@ import {{packageName}} {{#each models}} {{#with model}} from {{packageName}}.{{modelPackage}}.{{classFilename}} import {{classname}} +from {{packageName}} import configuration class Test{{classname}}(unittest.TestCase): """{{classname}} unit test stubs""" + _configuration = configuration.Configuration() {{#each testCases}} {{#with this }} def test_{{@key}}_{{#if valid}}passes{{else}}fails{{/if}}(self): # {{description}} {{#if valid}} - {{classname}}( + {{classname}}._from_openapi_data( {{#with data}} - {{>model_templates/payload_renderer}}{{/with}} + {{>model_templates/payload_renderer}}{{/with}}, + _configuration=self._configuration ) {{else}} with self.assertRaises(({{packageName}}.ApiValueError, {{packageName}}.ApiTypeError, TypeError)): - {{classname}}( + {{classname}}._from_openapi_data( {{#with data}} - {{>model_templates/payload_renderer}}{{/with}} + {{>model_templates/payload_renderer}}{{/with}}, + _configuration=self._configuration ) {{/if}} {{/with}} diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml index 3e2c773f429..7d129db3d67 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml @@ -7,56 +7,11 @@ info: paths: {} components: schemas: - RootPointerRef: - properties: - foo: - $ref: '#' - additionalProperties: false - RelativePointerRefToObject: - properties: - foo: - type: integer - bar: - $ref: '#/properties/foo' PropertyNamedRefThatIsNotAReference: properties: $ref: type: string x-schema-test-examples: - RootPointerRef: - Match: - description: match - data: - foo: false - valid: true - RecursiveMatch: - description: recursive match - data: - foo: - foo: false - valid: true - Mismatch: - description: mismatch - data: - bar: false - valid: false - RecursiveMismatch: - description: recursive mismatch - data: - foo: - bar: false - valid: false - RelativePointerRefToObject: - Match: - description: match - data: - bar: 3 - valid: true - Mismatch: - description: mismatch - data: - bar: true - valid: false PropertyNamedRefThatIsNotAReference: PropertyNamedRefValid: description: property named $ref valid diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/openapi_additions/ref.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/openapi_additions/ref.json new file mode 100755 index 00000000000..ec4aad9d92b --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/openapi_additions/ref.json @@ -0,0 +1,72 @@ +[ + { + "description": "property refs containing component schema", + "schema": { + "properties": { + "foo": {"$ref": "#/components/schemas/PropertyRefsContainingComponentSchema"} + }, + "additionalProperties": false + }, + "tests": [ + { + "description": "match", + "data": {"foo": false}, + "valid": true + }, + { + "description": "recursive match", + "data": {"foo": {"foo": false}}, + "valid": true + }, + { + "description": "mismatch", + "data": {"bar": false}, + "valid": false + }, + { + "description": "recursive mismatch", + "data": {"foo": {"bar": false}}, + "valid": false + } + ] + }, + { + "description": "property refs adjacent property", + "schema": { + "properties": { + "foo": {"type": "integer"}, + "bar": {"$ref": "#/components/schemas/PropertyRefsAdjacentProperty/properties/foo"} + } + }, + "tests": [ + { + "description": "match", + "data": {"bar": 3}, + "valid": true + }, + { + "description": "mismatch", + "data": {"bar": true}, + "valid": false + } + ] + }, + { + "description": "component refs another component", + "schema": { + "$ref": "#/components/schemas/PropertyNamedRefThatIsNotAReference" + }, + "tests": [ + { + "description": "property named $ref valid", + "data": {"$ref": "a"}, + "valid": true + }, + { + "description": "property named $ref invalid", + "data": {"$ref": 2}, + "valid": false + } + ] + } +] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index 4aea69c4866..d9f407f0808 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -94,8 +94,14 @@ class ExclusionReason: v303_does_not_support_propertyNames = 'v3.0.3 does not support the propertyNames keyword' v303_does_not_support_items_schema_array = 'v3.0.3 does not support an array of schemas for items' swagger_parser_exception = 'swagger-parser threw and exception for this test case' + ref_location_not_the_same_for_json_and_openapi = 'the location referenced is not the same going from json schema to openapi' + ref_to_adjacent_property_bug = 'Refing an adjacent property does not work, issue at https://github.com/OpenAPITools/openapi-generator/issues/12729' + swagger_parser_anytype_bug = 'Swagger parser sets type incorrectly for this anyType schema https://github.com/swagger-api/swagger-parser/issues/1603' + component_ref_component_bug = 'A component refing another component does not work, issue at https://github.com/OpenAPITools/openapi-generator/issues/12730' json_schema_test_draft = 'draft6' +openapi_additions = 'openapi_additions' + FILEPATH_TO_EXCLUDED_CASE_AND_REASON = { (json_schema_test_draft, 'type.json'): { 'multiple types can be specified in an array': ExclusionReason.v303_does_not_support_array_of_types, @@ -152,6 +158,13 @@ FILEPATH_TO_EXCLUDED_CASE_AND_REASON = { 'nested refs': ExclusionReason.v303_does_not_support_definitions, '$ref to boolean schema false': ExclusionReason.v303_does_not_support_definitions, 'remote ref, containing refs itself': ExclusionReason.swagger_parser_exception, + 'relative pointer ref to object': ExclusionReason.ref_location_not_the_same_for_json_and_openapi, + 'root pointer ref': ExclusionReason.ref_location_not_the_same_for_json_and_openapi, + }, + (openapi_additions, 'ref.json'): { + 'property refs adjacent property': ExclusionReason.ref_to_adjacent_property_bug, + 'property refs containing component schema': ExclusionReason.swagger_parser_anytype_bug, + 'component refs another component': ExclusionReason.component_ref_component_bug, } } FILEPATH_TO_EXCLUDE_REASON = { @@ -168,8 +181,6 @@ FILEPATH_TO_EXCLUDE_REASON = { (json_schema_test_draft, 'propertyNames.json'): ExclusionReason.v303_does_not_support_propertyNames, } -openapi_additions = 'openapi_additions' - JSON_SCHEMA_TEST_FILE_TO_FOLDERS = { # 'additionalItems.json': (json_schema_test_draft,), # 'additionalProperties.json': (json_schema_test_draft,), @@ -203,7 +214,7 @@ JSON_SCHEMA_TEST_FILE_TO_FOLDERS = { # 'patternProperties.json': (json_schema_test_draft,), # 'properties.json': (json_schema_test_draft,), 'propertyNames.json': (json_schema_test_draft,), - 'ref.json': (json_schema_test_draft,), + 'ref.json': (json_schema_test_draft, openapi_additions), # 'type.json': (json_schema_test_draft, openapi_additions), } diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index 636a6565c94..7f7c3d84b8c 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -3,8 +3,6 @@ .travis.yml README.md docs/PropertyNamedRefThatIsNotAReference.md -docs/RelativePointerRefToObject.md -docs/RootPointerRef.md git_push.sh requirements.txt setup.cfg @@ -12,8 +10,6 @@ setup.py test-requirements.txt test/__init__.py test/test_property_named_ref_that_is_not_a_reference.py -test/test_relative_pointer_ref_to_object.py -test/test_root_pointer_ref.py tox.ini unit_test_api/__init__.py unit_test_api/api/__init__.py @@ -23,8 +19,6 @@ unit_test_api/configuration.py unit_test_api/exceptions.py unit_test_api/model/__init__.py unit_test_api/model/property_named_ref_that_is_not_a_reference.py -unit_test_api/model/relative_pointer_ref_to_object.py -unit_test_api/model/root_pointer_ref.py unit_test_api/models/__init__.py unit_test_api/rest.py unit_test_api/schemas.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md index 855772529a8..fce90814790 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md @@ -63,8 +63,6 @@ Class | Method | HTTP request | Description ## Documentation For Models - [PropertyNamedRefThatIsNotAReference](docs/PropertyNamedRefThatIsNotAReference.md) - - [RelativePointerRefToObject](docs/RelativePointerRefToObject.md) - - [RootPointerRef](docs/RootPointerRef.md) ## Documentation For Authorization diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RelativePointerRefToObject.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RelativePointerRefToObject.md deleted file mode 100644 index ee3c8b29ca1..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RelativePointerRefToObject.md +++ /dev/null @@ -1,11 +0,0 @@ -# RelativePointerRefToObject - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**foo** | **int** | | [optional] -**bar** | [**ERRORUNKNOWN**](ERRORUNKNOWN.md) | | [optional] -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RootPointerRef.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RootPointerRef.md deleted file mode 100644 index 35ea0a016cb..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RootPointerRef.md +++ /dev/null @@ -1,9 +0,0 @@ -# RootPointerRef - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**foo** | **** | | [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/3_0_3_unit_test/python-experimental/test/test_property_named_ref_that_is_not_a_reference.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_property_named_ref_that_is_not_a_reference.py index da3dc97e5a2..0b099e71700 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_property_named_ref_that_is_not_a_reference.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_property_named_ref_that_is_not_a_reference.py @@ -13,31 +13,37 @@ import unittest import unit_test_api from unit_test_api.model.property_named_ref_that_is_not_a_reference import PropertyNamedRefThatIsNotAReference +from unit_test_api import configuration class TestPropertyNamedRefThatIsNotAReference(unittest.TestCase): """PropertyNamedRefThatIsNotAReference unit test stubs""" + _configuration = configuration.Configuration() def test_property_named_ref_valid_passes(self): # property named $ref valid - PropertyNamedRefThatIsNotAReference( - **{ + PropertyNamedRefThatIsNotAReference._from_openapi_data( + { "$ref": "a", } +, + _configuration=self._configuration ) def test_property_named_ref_invalid_fails(self): # property named $ref invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - PropertyNamedRefThatIsNotAReference( - **{ + PropertyNamedRefThatIsNotAReference._from_openapi_data( + { "$ref": 2, } +, + _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_relative_pointer_ref_to_object.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_relative_pointer_ref_to_object.py deleted file mode 100644 index 6f496dc5acc..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_relative_pointer_ref_to_object.py +++ /dev/null @@ -1,45 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.relative_pointer_ref_to_object import RelativePointerRefToObject - - -class TestRelativePointerRefToObject(unittest.TestCase): - """RelativePointerRefToObject unit test stubs""" - - def test_mismatch_fails(self): - # mismatch - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - RelativePointerRefToObject( - **{ - - "bar": - - True, - } - ) - - def test_match_passes(self): - # match - RelativePointerRefToObject( - **{ - - "bar": - 3, - } - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_root_pointer_ref.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_root_pointer_ref.py deleted file mode 100644 index 00fafc77cf5..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_root_pointer_ref.py +++ /dev/null @@ -1,79 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.root_pointer_ref import RootPointerRef - - -class TestRootPointerRef(unittest.TestCase): - """RootPointerRef unit test stubs""" - - def test_recursive_mismatch_fails(self): - # recursive mismatch - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - RootPointerRef( - **{ - - "foo": - **{ - - "bar": - - False, - } -, - } - ) - - def test_mismatch_fails(self): - # mismatch - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - RootPointerRef( - **{ - - "bar": - - False, - } - ) - - def test_match_passes(self): - # match - RootPointerRef( - **{ - - "foo": - - False, - } - ) - - def test_recursive_match_passes(self): - # recursive match - RootPointerRef( - **{ - - "foo": - **{ - - "foo": - - False, - } -, - } - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/relative_pointer_ref_to_object.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/relative_pointer_ref_to_object.py deleted file mode 100644 index c9bb9329fdd..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/relative_pointer_ref_to_object.py +++ /dev/null @@ -1,101 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class RelativePointerRefToObject( - AnyTypeSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - foo = IntSchema - - @classmethod - @property - def bar(cls) -> typing.Type['ERRORUNKNOWN']: - return ERRORUNKNOWN - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - foo: typing.Union[foo, Unset] = unset, - bar: typing.Union['ERRORUNKNOWN', Unset] = unset, - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'RelativePointerRefToObject': - return super().__new__( - cls, - *args, - foo=foo, - bar=bar, - _configuration=_configuration, - **kwargs, - ) - -from unit_test_api.model.errorunknown import ERRORUNKNOWN diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/root_pointer_ref.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/root_pointer_ref.py deleted file mode 100644 index d3bc2c4fe65..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/root_pointer_ref.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class RootPointerRef( - DictSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - foo = Schema - _additional_properties = None - - - def __new__( - cls, - *args: typing.Union[dict, frozendict, ], - foo: typing.Union[foo, Unset] = unset, - _configuration: typing.Optional[Configuration] = None, - ) -> 'RootPointerRef': - return super().__new__( - cls, - *args, - foo=foo, - _configuration=_configuration, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py index 88743c7d8e7..3c5e6308558 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py @@ -12,5 +12,3 @@ # sys.setrecursionlimit(n) from unit_test_api.model.property_named_ref_that_is_not_a_reference import PropertyNamedRefThatIsNotAReference -from unit_test_api.model.relative_pointer_ref_to_object import RelativePointerRefToObject -from unit_test_api.model.root_pointer_ref import RootPointerRef -- GitLab From d8aac4ecd5fcb7a517b89522b9bac714a8fb02e8 Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Tue, 28 Jun 2022 20:37:56 -0700 Subject: [PATCH 31/43] Adds remoteRef --- .../unit_test_spec/3_0_3_unit_test_spec.yaml | 19 +--- .../3_0/unit_test_spec/spec_writer.py | 18 +++- .../.openapi-generator/FILES | 3 - .../python-experimental/README.md | 1 - .../PropertyNamedRefThatIsNotAReference.md | 10 -- ...perty_named_ref_that_is_not_a_reference.py | 51 ---------- ...perty_named_ref_that_is_not_a_reference.py | 92 ------------------- .../unit_test_api/models/__init__.py | 1 - 8 files changed, 17 insertions(+), 178 deletions(-) delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PropertyNamedRefThatIsNotAReference.md delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_property_named_ref_that_is_not_a_reference.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/property_named_ref_that_is_not_a_reference.py diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml index 7d129db3d67..2a0b920f0b7 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml @@ -6,20 +6,5 @@ info: version: 0.0.1 paths: {} components: - schemas: - PropertyNamedRefThatIsNotAReference: - properties: - $ref: - type: string - x-schema-test-examples: - PropertyNamedRefThatIsNotAReference: - PropertyNamedRefValid: - description: property named $ref valid - data: - $ref: a - valid: true - PropertyNamedRefInvalid: - description: property named $ref invalid - data: - $ref: 2 - valid: false + schemas: {} + x-schema-test-examples: {} diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index d9f407f0808..38bbdeafcba 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -98,6 +98,7 @@ class ExclusionReason: ref_to_adjacent_property_bug = 'Refing an adjacent property does not work, issue at https://github.com/OpenAPITools/openapi-generator/issues/12729' swagger_parser_anytype_bug = 'Swagger parser sets type incorrectly for this anyType schema https://github.com/swagger-api/swagger-parser/issues/1603' component_ref_component_bug = 'A component refing another component does not work, issue at https://github.com/OpenAPITools/openapi-generator/issues/12730' + not_running_the_localhost_server = 'the openapo-generator is not running the localhost server needed to serve remoteRef files' json_schema_test_draft = 'draft6' openapi_additions = 'openapi_additions' @@ -165,7 +166,17 @@ FILEPATH_TO_EXCLUDED_CASE_AND_REASON = { 'property refs adjacent property': ExclusionReason.ref_to_adjacent_property_bug, 'property refs containing component schema': ExclusionReason.swagger_parser_anytype_bug, 'component refs another component': ExclusionReason.component_ref_component_bug, - } + }, + (json_schema_test_draft, 'refRemote.json'): { + 'base URI change - change folder': ExclusionReason.v303_does_not_support_id, + 'base URI change - change folder in subschema': ExclusionReason.v303_does_not_support_definitions, + 'remote ref with ref to definitions': ExclusionReason.v303_does_not_support_id, + 'root ref in remote ref': ExclusionReason.v303_does_not_support_id, + 'base URI change': ExclusionReason.v303_does_not_support_id, + 'remote ref': ExclusionReason.not_running_the_localhost_server, + 'fragment within remote ref': ExclusionReason.not_running_the_localhost_server, + 'ref within remote ref': ExclusionReason.not_running_the_localhost_server, + }, } FILEPATH_TO_EXCLUDE_REASON = { (json_schema_test_draft, 'additionalItems.json'): ExclusionReason.v303_does_not_support_additionalItems, @@ -213,8 +224,9 @@ JSON_SCHEMA_TEST_FILE_TO_FOLDERS = { # 'pattern.json': (json_schema_test_draft,), # 'patternProperties.json': (json_schema_test_draft,), # 'properties.json': (json_schema_test_draft,), - 'propertyNames.json': (json_schema_test_draft,), - 'ref.json': (json_schema_test_draft, openapi_additions), +# 'propertyNames.json': (json_schema_test_draft,), +# 'ref.json': (json_schema_test_draft, openapi_additions), + 'refRemote.json': (json_schema_test_draft,), # 'type.json': (json_schema_test_draft, openapi_additions), } diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index 7f7c3d84b8c..a5c70c8904f 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -2,14 +2,12 @@ .gitlab-ci.yml .travis.yml README.md -docs/PropertyNamedRefThatIsNotAReference.md git_push.sh requirements.txt setup.cfg setup.py test-requirements.txt test/__init__.py -test/test_property_named_ref_that_is_not_a_reference.py tox.ini unit_test_api/__init__.py unit_test_api/api/__init__.py @@ -18,7 +16,6 @@ unit_test_api/apis/__init__.py unit_test_api/configuration.py unit_test_api/exceptions.py unit_test_api/model/__init__.py -unit_test_api/model/property_named_ref_that_is_not_a_reference.py unit_test_api/models/__init__.py unit_test_api/rest.py unit_test_api/schemas.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md index fce90814790..162b9a6acb5 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md @@ -62,7 +62,6 @@ Class | Method | HTTP request | Description ## Documentation For Models - - [PropertyNamedRefThatIsNotAReference](docs/PropertyNamedRefThatIsNotAReference.md) ## Documentation For Authorization diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PropertyNamedRefThatIsNotAReference.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PropertyNamedRefThatIsNotAReference.md deleted file mode 100644 index 7f51dc33bb9..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PropertyNamedRefThatIsNotAReference.md +++ /dev/null @@ -1,10 +0,0 @@ -# PropertyNamedRefThatIsNotAReference - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**$ref** | **str** | | [optional] -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_property_named_ref_that_is_not_a_reference.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_property_named_ref_that_is_not_a_reference.py deleted file mode 100644 index 0b099e71700..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_property_named_ref_that_is_not_a_reference.py +++ /dev/null @@ -1,51 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.property_named_ref_that_is_not_a_reference import PropertyNamedRefThatIsNotAReference -from unit_test_api import configuration - - -class TestPropertyNamedRefThatIsNotAReference(unittest.TestCase): - """PropertyNamedRefThatIsNotAReference unit test stubs""" - _configuration = configuration.Configuration() - - def test_property_named_ref_valid_passes(self): - # property named $ref valid - PropertyNamedRefThatIsNotAReference._from_openapi_data( - { - - "$ref": - - "a", - } -, - _configuration=self._configuration - ) - - def test_property_named_ref_invalid_fails(self): - # property named $ref invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - PropertyNamedRefThatIsNotAReference._from_openapi_data( - { - - "$ref": - 2, - } -, - _configuration=self._configuration - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/property_named_ref_that_is_not_a_reference.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/property_named_ref_that_is_not_a_reference.py deleted file mode 100644 index 0f3628abc04..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/property_named_ref_that_is_not_a_reference.py +++ /dev/null @@ -1,92 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class PropertyNamedRefThatIsNotAReference( - AnyTypeSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - ref = StrSchema - locals()["$ref"] = ref - del locals()['ref'] - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'PropertyNamedRefThatIsNotAReference': - return super().__new__( - cls, - *args, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py index 3c5e6308558..f986d1632e4 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py @@ -11,4 +11,3 @@ # import sys # sys.setrecursionlimit(n) -from unit_test_api.model.property_named_ref_that_is_not_a_reference import PropertyNamedRefThatIsNotAReference -- GitLab From 3f5f7fa100f9ecbf01696adacbbd415e37821032 Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Tue, 28 Jun 2022 21:26:40 -0700 Subject: [PATCH 32/43] Adds required --- .../unit_test_spec/3_0_3_unit_test_spec.yaml | 50 +++++++++- .../3_0/unit_test_spec/spec_writer.py | 7 +- .../.openapi-generator/FILES | 9 ++ .../python-experimental/README.md | 3 + .../docs/RequiredDefaultValidation.md | 10 ++ .../docs/RequiredValidation.md | 11 +++ .../docs/RequiredWithEmptyArray.md | 10 ++ .../test/test_required_default_validation.py | 34 +++++++ .../test/test_required_validation.py | 74 ++++++++++++++ .../test/test_required_with_empty_array.py | 34 +++++++ .../model/required_default_validation.py | 92 +++++++++++++++++ .../model/required_validation.py | 98 +++++++++++++++++++ .../model/required_with_empty_array.py | 92 +++++++++++++++++ .../unit_test_api/models/__init__.py | 3 + 14 files changed, 524 insertions(+), 3 deletions(-) create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredDefaultValidation.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredValidation.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredWithEmptyArray.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_default_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_with_empty_array.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_default_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_with_empty_array.py diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml index 2a0b920f0b7..6651590c041 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml @@ -6,5 +6,51 @@ info: version: 0.0.1 paths: {} components: - schemas: {} - x-schema-test-examples: {} + schemas: + RequiredValidation: + properties: + foo: {} + bar: {} + required: + - foo + RequiredDefaultValidation: + properties: + foo: {} + RequiredWithEmptyArray: + properties: + foo: {} + required: [] + x-schema-test-examples: + RequiredValidation: + PresentRequiredPropertyIsValid: + description: present required property is valid + data: + foo: 1 + valid: true + NonPresentRequiredPropertyIsInvalid: + description: non-present required property is invalid + data: + bar: 1 + valid: false + IgnoresArrays: + description: ignores arrays + data: [] + valid: true + IgnoresStrings: + description: ignores strings + data: '' + valid: true + IgnoresOtherNonObjects: + description: ignores other non-objects + data: 12 + valid: true + RequiredDefaultValidation: + NotRequiredByDefault: + description: not required by default + data: {} + valid: true + RequiredWithEmptyArray: + PropertyNotRequired: + description: property not required + data: {} + valid: true diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index 38bbdeafcba..9532a211cc3 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -99,6 +99,7 @@ class ExclusionReason: swagger_parser_anytype_bug = 'Swagger parser sets type incorrectly for this anyType schema https://github.com/swagger-api/swagger-parser/issues/1603' component_ref_component_bug = 'A component refing another component does not work, issue at https://github.com/OpenAPITools/openapi-generator/issues/12730' not_running_the_localhost_server = 'the openapo-generator is not running the localhost server needed to serve remoteRef files' + required_vars_missing_for_anytype_schema_bug = 'fails because of a bug where required vars are forgotten, see issue https://github.com/OpenAPITools/openapi-generator/issues/8906' json_schema_test_draft = 'draft6' openapi_additions = 'openapi_additions' @@ -177,6 +178,9 @@ FILEPATH_TO_EXCLUDED_CASE_AND_REASON = { 'fragment within remote ref': ExclusionReason.not_running_the_localhost_server, 'ref within remote ref': ExclusionReason.not_running_the_localhost_server, }, + (json_schema_test_draft, 'required.json'): { + 'required with escaped characters': ExclusionReason.required_vars_missing_for_anytype_schema_bug, + }, } FILEPATH_TO_EXCLUDE_REASON = { (json_schema_test_draft, 'additionalItems.json'): ExclusionReason.v303_does_not_support_additionalItems, @@ -226,7 +230,8 @@ JSON_SCHEMA_TEST_FILE_TO_FOLDERS = { # 'properties.json': (json_schema_test_draft,), # 'propertyNames.json': (json_schema_test_draft,), # 'ref.json': (json_schema_test_draft, openapi_additions), - 'refRemote.json': (json_schema_test_draft,), +# 'refRemote.json': (json_schema_test_draft,), + 'required.json': (json_schema_test_draft,), # 'type.json': (json_schema_test_draft, openapi_additions), } diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index a5c70c8904f..e2ce438bb9d 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -2,12 +2,18 @@ .gitlab-ci.yml .travis.yml README.md +docs/RequiredDefaultValidation.md +docs/RequiredValidation.md +docs/RequiredWithEmptyArray.md git_push.sh requirements.txt setup.cfg setup.py test-requirements.txt test/__init__.py +test/test_required_default_validation.py +test/test_required_validation.py +test/test_required_with_empty_array.py tox.ini unit_test_api/__init__.py unit_test_api/api/__init__.py @@ -16,6 +22,9 @@ unit_test_api/apis/__init__.py unit_test_api/configuration.py unit_test_api/exceptions.py unit_test_api/model/__init__.py +unit_test_api/model/required_default_validation.py +unit_test_api/model/required_validation.py +unit_test_api/model/required_with_empty_array.py unit_test_api/models/__init__.py unit_test_api/rest.py unit_test_api/schemas.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md index 162b9a6acb5..96665484ef6 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md @@ -62,6 +62,9 @@ Class | Method | HTTP request | Description ## Documentation For Models + - [RequiredDefaultValidation](docs/RequiredDefaultValidation.md) + - [RequiredValidation](docs/RequiredValidation.md) + - [RequiredWithEmptyArray](docs/RequiredWithEmptyArray.md) ## Documentation For Authorization diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredDefaultValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredDefaultValidation.md new file mode 100644 index 00000000000..46c719866d7 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredDefaultValidation.md @@ -0,0 +1,10 @@ +# RequiredDefaultValidation + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**foo** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredValidation.md new file mode 100644 index 00000000000..31ab7e70c48 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredValidation.md @@ -0,0 +1,11 @@ +# RequiredValidation + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**foo** | **bool, date, datetime, dict, float, int, list, str, none_type** | | +**bar** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredWithEmptyArray.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredWithEmptyArray.md new file mode 100644 index 00000000000..c243bc4b3d2 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredWithEmptyArray.md @@ -0,0 +1,10 @@ +# RequiredWithEmptyArray + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**foo** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_default_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_default_validation.py new file mode 100644 index 00000000000..6321d617382 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_default_validation.py @@ -0,0 +1,34 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.required_default_validation import RequiredDefaultValidation +from unit_test_api import configuration + + +class TestRequiredDefaultValidation(unittest.TestCase): + """RequiredDefaultValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_not_required_by_default_passes(self): + # not required by default + RequiredDefaultValidation._from_openapi_data( + { + } +, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_validation.py new file mode 100644 index 00000000000..b358c6bd044 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_validation.py @@ -0,0 +1,74 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.required_validation import RequiredValidation +from unit_test_api import configuration + + +class TestRequiredValidation(unittest.TestCase): + """RequiredValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_ignores_arrays_passes(self): + # ignores arrays + RequiredValidation._from_openapi_data( + [ + ] +, + _configuration=self._configuration + ) + + def test_present_required_property_is_valid_passes(self): + # present required property is valid + RequiredValidation._from_openapi_data( + { + + "foo": + 1, + } +, + _configuration=self._configuration + ) + + def test_ignores_other_non_objects_passes(self): + # ignores other non-objects + RequiredValidation._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_ignores_strings_passes(self): + # ignores strings + RequiredValidation._from_openapi_data( + + "", + _configuration=self._configuration + ) + + def test_non_present_required_property_is_invalid_fails(self): + # non-present required property is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + RequiredValidation._from_openapi_data( + { + + "bar": + 1, + } +, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_with_empty_array.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_with_empty_array.py new file mode 100644 index 00000000000..ef045be9fe1 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_with_empty_array.py @@ -0,0 +1,34 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.required_with_empty_array import RequiredWithEmptyArray +from unit_test_api import configuration + + +class TestRequiredWithEmptyArray(unittest.TestCase): + """RequiredWithEmptyArray unit test stubs""" + _configuration = configuration.Configuration() + + def test_property_not_required_passes(self): + # property not required + RequiredWithEmptyArray._from_openapi_data( + { + } +, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_default_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_default_validation.py new file mode 100644 index 00000000000..94993796890 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_default_validation.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class RequiredDefaultValidation( + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + foo = AnyTypeSchema + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + foo: typing.Union[foo, Unset] = unset, + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'RequiredDefaultValidation': + return super().__new__( + cls, + *args, + foo=foo, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_validation.py new file mode 100644 index 00000000000..a0d4c00017a --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_validation.py @@ -0,0 +1,98 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class RequiredValidation( + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + _required_property_names = set(( + 'foo', + )) + foo = AnyTypeSchema + bar = AnyTypeSchema + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + foo: foo, + bar: typing.Union[bar, Unset] = unset, + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'RequiredValidation': + return super().__new__( + cls, + *args, + foo=foo, + bar=bar, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_with_empty_array.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_with_empty_array.py new file mode 100644 index 00000000000..4a7a203a126 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_with_empty_array.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class RequiredWithEmptyArray( + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + foo = AnyTypeSchema + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + foo: typing.Union[foo, Unset] = unset, + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'RequiredWithEmptyArray': + return super().__new__( + cls, + *args, + foo=foo, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py index f986d1632e4..8ab6a510e3c 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py @@ -11,3 +11,6 @@ # import sys # sys.setrecursionlimit(n) +from unit_test_api.model.required_default_validation import RequiredDefaultValidation +from unit_test_api.model.required_validation import RequiredValidation +from unit_test_api.model.required_with_empty_array import RequiredWithEmptyArray -- GitLab From b1a80a8a69737219623285dab46c305a714d4b0a Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Wed, 29 Jun 2022 13:58:28 -0700 Subject: [PATCH 33/43] Improves required testing --- .../python-experimental/schemas.handlebars | 7 +- .../unit_test_spec/3_0_3_unit_test_spec.yaml | 319 ++++++++-- .../3_0/unit_test_spec/spec_writer.py | 9 +- .../.openapi-generator/FILES | 15 +- .../python-experimental/README.md | 5 +- .../docs/RequiredValidation.md | 11 - ...Array.md => UniqueitemsFalseValidation.md} | 3 +- ...Validation.md => UniqueitemsValidation.md} | 3 +- .../test/test_required_default_validation.py | 34 -- .../test/test_required_validation.py | 74 --- .../test/test_required_with_empty_array.py | 34 -- .../test/test_uniqueitems_false_validation.py | 322 ++++++++++ .../test/test_uniqueitems_validation.py | 566 ++++++++++++++++++ .../model/required_validation.py | 98 --- ...ray.py => uniqueitems_false_validation.py} | 9 +- ...alidation.py => uniqueitems_validation.py} | 10 +- .../unit_test_api/models/__init__.py | 5 +- .../unit_test_api/schemas.py | 7 +- 18 files changed, 1207 insertions(+), 324 deletions(-) delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredValidation.md rename samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/{RequiredWithEmptyArray.md => UniqueitemsFalseValidation.md} (79%) rename samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/{RequiredDefaultValidation.md => UniqueitemsValidation.md} (78%) delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_default_validation.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_validation.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_with_empty_array.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uniqueitems_false_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uniqueitems_validation.py delete mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_validation.py rename samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/{required_with_empty_array.py => uniqueitems_false_validation.py} (92%) rename samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/{required_default_validation.py => uniqueitems_validation.py} (91%) diff --git a/modules/openapi-generator/src/main/resources/python-experimental/schemas.handlebars b/modules/openapi-generator/src/main/resources/python-experimental/schemas.handlebars index d7eb0accba2..e0e72256a84 100644 --- a/modules/openapi-generator/src/main/resources/python-experimental/schemas.handlebars +++ b/modules/openapi-generator/src/main/resources/python-experimental/schemas.handlebars @@ -221,10 +221,11 @@ class ValidatorBase: if (cls.__is_json_validation_enabled('uniqueItems', validation_metadata.configuration) and 'unique_items' in validations and validations['unique_items'] and input_values): - unique_items = [] + unique_items = set() for item in input_values: - if item not in unique_items: - unique_items.append(item) + pair = (item, item.__class__) + if pair not in unique_items: + unique_items.add(pair) if len(input_values) > len(unique_items): cls.__raise_validation_error_message( value=input_values, diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml index 6651590c041..fa19c2ebd6c 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml @@ -7,50 +7,295 @@ info: paths: {} components: schemas: - RequiredValidation: - properties: - foo: {} - bar: {} - required: - - foo - RequiredDefaultValidation: - properties: - foo: {} - RequiredWithEmptyArray: - properties: - foo: {} - required: [] + UniqueitemsValidation: + uniqueItems: true + UniqueitemsFalseValidation: + uniqueItems: false x-schema-test-examples: - RequiredValidation: - PresentRequiredPropertyIsValid: - description: present required property is valid + UniqueitemsValidation: + UniqueArrayOfIntegersIsValid: + description: unique array of integers is valid data: - foo: 1 + - 1 + - 2 valid: true - NonPresentRequiredPropertyIsInvalid: - description: non-present required property is invalid + NonUniqueArrayOfIntegersIsInvalid: + description: non-unique array of integers is invalid data: - bar: 1 + - 1 + - 1 valid: false - IgnoresArrays: - description: ignores arrays - data: [] + NonUniqueArrayOfMoreThanTwoIntegersIsInvalid: + description: non-unique array of more than two integers is invalid + data: + - 1 + - 2 + - 1 + valid: false + NumbersAreUniqueIfMathematicallyUnequal: + description: numbers are unique if mathematically unequal + data: + - 1.0 + - 1.0 + - 1 + valid: false + FalseIsNotEqualToZero: + description: false is not equal to zero + data: + - 0 + - false + valid: true + TrueIsNotEqualToOne: + description: true is not equal to one + data: + - 1 + - true + valid: true + UniqueArrayOfStringsIsValid: + description: unique array of strings is valid + data: + - foo + - bar + - baz + valid: true + NonUniqueArrayOfStringsIsInvalid: + description: non-unique array of strings is invalid + data: + - foo + - bar + - foo + valid: false + UniqueArrayOfObjectsIsValid: + description: unique array of objects is valid + data: + - foo: bar + - foo: baz + valid: true + NonUniqueArrayOfObjectsIsInvalid: + description: non-unique array of objects is invalid + data: + - foo: bar + - foo: bar + valid: false + UniqueArrayOfNestedObjectsIsValid: + description: unique array of nested objects is valid + data: + - foo: + bar: + baz: true + - foo: + bar: + baz: false + valid: true + NonUniqueArrayOfNestedObjectsIsInvalid: + description: non-unique array of nested objects is invalid + data: + - foo: + bar: + baz: true + - foo: + bar: + baz: true + valid: false + UniqueArrayOfArraysIsValid: + description: unique array of arrays is valid + data: + - - foo + - - bar + valid: true + NonUniqueArrayOfArraysIsInvalid: + description: non-unique array of arrays is invalid + data: + - - foo + - - foo + valid: false + NonUniqueArrayOfMoreThanTwoArraysIsInvalid: + description: non-unique array of more than two arrays is invalid + data: + - - foo + - - bar + - - foo + valid: false + 1AndTrueAreUnique: + description: '[1] and [true] are unique' + data: + - - 1 + - - true valid: true - IgnoresStrings: - description: ignores strings - data: '' + 0AndFalseAreUnique: + description: '[0] and [false] are unique' + data: + - - 0 + - - false valid: true - IgnoresOtherNonObjects: - description: ignores other non-objects - data: 12 + Nested1AndTrueAreUnique: + description: nested [1] and [true] are unique + data: + - - - 1 + - foo + - - - true + - foo valid: true - RequiredDefaultValidation: - NotRequiredByDefault: - description: not required by default - data: {} + Nested0AndFalseAreUnique: + description: nested [0] and [false] are unique + data: + - - - 0 + - foo + - - - false + - foo + valid: true + UniqueHeterogeneousTypesAreValid: + description: unique heterogeneous types are valid + data: + - {} + - - 1 + - true + - null + - 1 + - '{}' + valid: true + NonUniqueHeterogeneousTypesAreInvalid: + description: non-unique heterogeneous types are invalid + data: + - {} + - - 1 + - true + - null + - {} + - 1 + valid: false + DifferentObjectsAreUnique: + description: different objects are unique + data: + - a: 1 + b: 2 + - a: 2 + b: 1 valid: true - RequiredWithEmptyArray: - PropertyNotRequired: - description: property not required - data: {} + ObjectsAreNonUniqueDespiteKeyOrder: + description: objects are non-unique despite key order + data: + - a: 1 + b: 2 + - b: 2 + a: 1 + valid: false + AFalseAndA0AreUnique: + description: '{"a": false} and {"a": 0} are unique' + data: + - a: false + - a: 0 + valid: true + ATrueAndA1AreUnique: + description: '{"a": true} and {"a": 1} are unique' + data: + - a: true + - a: 1 + valid: true + UniqueitemsFalseValidation: + UniqueArrayOfIntegersIsValid: + description: unique array of integers is valid + data: + - 1 + - 2 + valid: true + NonUniqueArrayOfIntegersIsValid: + description: non-unique array of integers is valid + data: + - 1 + - 1 + valid: true + NumbersAreUniqueIfMathematicallyUnequal: + description: numbers are unique if mathematically unequal + data: + - 1.0 + - 1.0 + - 1 + valid: true + FalseIsNotEqualToZero: + description: false is not equal to zero + data: + - 0 + - false + valid: true + TrueIsNotEqualToOne: + description: true is not equal to one + data: + - 1 + - true + valid: true + UniqueArrayOfObjectsIsValid: + description: unique array of objects is valid + data: + - foo: bar + - foo: baz + valid: true + NonUniqueArrayOfObjectsIsValid: + description: non-unique array of objects is valid + data: + - foo: bar + - foo: bar + valid: true + UniqueArrayOfNestedObjectsIsValid: + description: unique array of nested objects is valid + data: + - foo: + bar: + baz: true + - foo: + bar: + baz: false + valid: true + NonUniqueArrayOfNestedObjectsIsValid: + description: non-unique array of nested objects is valid + data: + - foo: + bar: + baz: true + - foo: + bar: + baz: true + valid: true + UniqueArrayOfArraysIsValid: + description: unique array of arrays is valid + data: + - - foo + - - bar + valid: true + NonUniqueArrayOfArraysIsValid: + description: non-unique array of arrays is valid + data: + - - foo + - - foo + valid: true + 1AndTrueAreUnique: + description: 1 and true are unique + data: + - 1 + - true + valid: true + 0AndFalseAreUnique: + description: 0 and false are unique + data: + - 0 + - false + valid: true + UniqueHeterogeneousTypesAreValid: + description: unique heterogeneous types are valid + data: + - {} + - - 1 + - true + - null + - 1 + valid: true + NonUniqueHeterogeneousTypesAreValid: + description: non-unique heterogeneous types are valid + data: + - {} + - - 1 + - true + - null + - {} + - 1 valid: true diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index 9532a211cc3..92fc510c7ac 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -181,6 +181,12 @@ FILEPATH_TO_EXCLUDED_CASE_AND_REASON = { (json_schema_test_draft, 'required.json'): { 'required with escaped characters': ExclusionReason.required_vars_missing_for_anytype_schema_bug, }, + (json_schema_test_draft, 'uniqueItems.json'): { + 'uniqueItems with an array of items': ExclusionReason.v303_does_not_support_items_schema_array, + 'uniqueItems=false with an array of items': ExclusionReason.v303_does_not_support_items_schema_array, + 'uniqueItems with an array of items and additionalItems=false': ExclusionReason.v303_does_not_support_items_schema_array, + 'uniqueItems=false with an array of items and additionalItems=false': ExclusionReason.v303_does_not_support_items_schema_array, + }, } FILEPATH_TO_EXCLUDE_REASON = { (json_schema_test_draft, 'additionalItems.json'): ExclusionReason.v303_does_not_support_additionalItems, @@ -231,8 +237,9 @@ JSON_SCHEMA_TEST_FILE_TO_FOLDERS = { # 'propertyNames.json': (json_schema_test_draft,), # 'ref.json': (json_schema_test_draft, openapi_additions), # 'refRemote.json': (json_schema_test_draft,), - 'required.json': (json_schema_test_draft,), +# 'required.json': (json_schema_test_draft,), # 'type.json': (json_schema_test_draft, openapi_additions), + 'uniqueItems.json': (json_schema_test_draft,), } def get_json_schema_test_schemas(file_path: typing.Tuple[str]) -> typing.List[JsonSchemaTestSchema]: diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index e2ce438bb9d..1d8b38d3a2d 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -2,18 +2,16 @@ .gitlab-ci.yml .travis.yml README.md -docs/RequiredDefaultValidation.md -docs/RequiredValidation.md -docs/RequiredWithEmptyArray.md +docs/UniqueitemsFalseValidation.md +docs/UniqueitemsValidation.md git_push.sh requirements.txt setup.cfg setup.py test-requirements.txt test/__init__.py -test/test_required_default_validation.py -test/test_required_validation.py -test/test_required_with_empty_array.py +test/test_uniqueitems_false_validation.py +test/test_uniqueitems_validation.py tox.ini unit_test_api/__init__.py unit_test_api/api/__init__.py @@ -22,9 +20,8 @@ unit_test_api/apis/__init__.py unit_test_api/configuration.py unit_test_api/exceptions.py unit_test_api/model/__init__.py -unit_test_api/model/required_default_validation.py -unit_test_api/model/required_validation.py -unit_test_api/model/required_with_empty_array.py +unit_test_api/model/uniqueitems_false_validation.py +unit_test_api/model/uniqueitems_validation.py unit_test_api/models/__init__.py unit_test_api/rest.py unit_test_api/schemas.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md index 96665484ef6..f9c665e5b7b 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md @@ -62,9 +62,8 @@ Class | Method | HTTP request | Description ## Documentation For Models - - [RequiredDefaultValidation](docs/RequiredDefaultValidation.md) - - [RequiredValidation](docs/RequiredValidation.md) - - [RequiredWithEmptyArray](docs/RequiredWithEmptyArray.md) + - [UniqueitemsFalseValidation](docs/UniqueitemsFalseValidation.md) + - [UniqueitemsValidation](docs/UniqueitemsValidation.md) ## Documentation For Authorization diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredValidation.md deleted file mode 100644 index 31ab7e70c48..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredValidation.md +++ /dev/null @@ -1,11 +0,0 @@ -# RequiredValidation - -#### Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**foo** | **bool, date, datetime, dict, float, int, list, str, none_type** | | -**bar** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] -**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredWithEmptyArray.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/UniqueitemsFalseValidation.md similarity index 79% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredWithEmptyArray.md rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/UniqueitemsFalseValidation.md index c243bc4b3d2..99e0a5ba1c8 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredWithEmptyArray.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/UniqueitemsFalseValidation.md @@ -1,9 +1,8 @@ -# RequiredWithEmptyArray +# UniqueitemsFalseValidation #### Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**foo** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] **any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredDefaultValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/UniqueitemsValidation.md similarity index 78% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredDefaultValidation.md rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/UniqueitemsValidation.md index 46c719866d7..8cd8bbdc612 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredDefaultValidation.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/UniqueitemsValidation.md @@ -1,9 +1,8 @@ -# RequiredDefaultValidation +# UniqueitemsValidation #### Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**foo** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] **any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_default_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_default_validation.py deleted file mode 100644 index 6321d617382..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_default_validation.py +++ /dev/null @@ -1,34 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.required_default_validation import RequiredDefaultValidation -from unit_test_api import configuration - - -class TestRequiredDefaultValidation(unittest.TestCase): - """RequiredDefaultValidation unit test stubs""" - _configuration = configuration.Configuration() - - def test_not_required_by_default_passes(self): - # not required by default - RequiredDefaultValidation._from_openapi_data( - { - } -, - _configuration=self._configuration - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_validation.py deleted file mode 100644 index b358c6bd044..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_validation.py +++ /dev/null @@ -1,74 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.required_validation import RequiredValidation -from unit_test_api import configuration - - -class TestRequiredValidation(unittest.TestCase): - """RequiredValidation unit test stubs""" - _configuration = configuration.Configuration() - - def test_ignores_arrays_passes(self): - # ignores arrays - RequiredValidation._from_openapi_data( - [ - ] -, - _configuration=self._configuration - ) - - def test_present_required_property_is_valid_passes(self): - # present required property is valid - RequiredValidation._from_openapi_data( - { - - "foo": - 1, - } -, - _configuration=self._configuration - ) - - def test_ignores_other_non_objects_passes(self): - # ignores other non-objects - RequiredValidation._from_openapi_data( - 12, - _configuration=self._configuration - ) - - def test_ignores_strings_passes(self): - # ignores strings - RequiredValidation._from_openapi_data( - - "", - _configuration=self._configuration - ) - - def test_non_present_required_property_is_invalid_fails(self): - # non-present required property is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): - RequiredValidation._from_openapi_data( - { - - "bar": - 1, - } -, - _configuration=self._configuration - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_with_empty_array.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_with_empty_array.py deleted file mode 100644 index ef045be9fe1..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_with_empty_array.py +++ /dev/null @@ -1,34 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import unittest - -import unit_test_api -from unit_test_api.model.required_with_empty_array import RequiredWithEmptyArray -from unit_test_api import configuration - - -class TestRequiredWithEmptyArray(unittest.TestCase): - """RequiredWithEmptyArray unit test stubs""" - _configuration = configuration.Configuration() - - def test_property_not_required_passes(self): - # property not required - RequiredWithEmptyArray._from_openapi_data( - { - } -, - _configuration=self._configuration - ) - - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uniqueitems_false_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uniqueitems_false_validation.py new file mode 100644 index 00000000000..f18fcfa0705 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uniqueitems_false_validation.py @@ -0,0 +1,322 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.uniqueitems_false_validation import UniqueitemsFalseValidation +from unit_test_api import configuration + + +class TestUniqueitemsFalseValidation(unittest.TestCase): + """UniqueitemsFalseValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_non_unique_array_of_integers_is_valid_passes(self): + # non-unique array of integers is valid + UniqueitemsFalseValidation._from_openapi_data( + [ + 1, + 1, + ] +, + _configuration=self._configuration + ) + + def test_unique_array_of_objects_is_valid_passes(self): + # unique array of objects is valid + UniqueitemsFalseValidation._from_openapi_data( + [ + { + + "foo": + + "bar", + } +, + { + + "foo": + + "baz", + } +, + ] +, + _configuration=self._configuration + ) + + def test_non_unique_array_of_nested_objects_is_valid_passes(self): + # non-unique array of nested objects is valid + UniqueitemsFalseValidation._from_openapi_data( + [ + { + + "foo": + { + + "bar": + { + + "baz": + + True, + } +, + } +, + } +, + { + + "foo": + { + + "bar": + { + + "baz": + + True, + } +, + } +, + } +, + ] +, + _configuration=self._configuration + ) + + def test_non_unique_array_of_objects_is_valid_passes(self): + # non-unique array of objects is valid + UniqueitemsFalseValidation._from_openapi_data( + [ + { + + "foo": + + "bar", + } +, + { + + "foo": + + "bar", + } +, + ] +, + _configuration=self._configuration + ) + + def test_1_and_true_are_unique_passes(self): + # 1 and true are unique + UniqueitemsFalseValidation._from_openapi_data( + [ + 1, + + True, + ] +, + _configuration=self._configuration + ) + + def test_unique_array_of_integers_is_valid_passes(self): + # unique array of integers is valid + UniqueitemsFalseValidation._from_openapi_data( + [ + 1, + 2, + ] +, + _configuration=self._configuration + ) + + def test_non_unique_array_of_arrays_is_valid_passes(self): + # non-unique array of arrays is valid + UniqueitemsFalseValidation._from_openapi_data( + [ + [ + + "foo", + ] +, + [ + + "foo", + ] +, + ] +, + _configuration=self._configuration + ) + + def test_numbers_are_unique_if_mathematically_unequal_passes(self): + # numbers are unique if mathematically unequal + UniqueitemsFalseValidation._from_openapi_data( + [ + 1.0, + 1.0, + 1, + ] +, + _configuration=self._configuration + ) + + def test_false_is_not_equal_to_zero_passes(self): + # false is not equal to zero + UniqueitemsFalseValidation._from_openapi_data( + [ + 0, + + False, + ] +, + _configuration=self._configuration + ) + + def test_unique_array_of_nested_objects_is_valid_passes(self): + # unique array of nested objects is valid + UniqueitemsFalseValidation._from_openapi_data( + [ + { + + "foo": + { + + "bar": + { + + "baz": + + True, + } +, + } +, + } +, + { + + "foo": + { + + "bar": + { + + "baz": + + False, + } +, + } +, + } +, + ] +, + _configuration=self._configuration + ) + + def test_0_and_false_are_unique_passes(self): + # 0 and false are unique + UniqueitemsFalseValidation._from_openapi_data( + [ + 0, + + False, + ] +, + _configuration=self._configuration + ) + + def test_unique_array_of_arrays_is_valid_passes(self): + # unique array of arrays is valid + UniqueitemsFalseValidation._from_openapi_data( + [ + [ + + "foo", + ] +, + [ + + "bar", + ] +, + ] +, + _configuration=self._configuration + ) + + def test_true_is_not_equal_to_one_passes(self): + # true is not equal to one + UniqueitemsFalseValidation._from_openapi_data( + [ + 1, + + True, + ] +, + _configuration=self._configuration + ) + + def test_non_unique_heterogeneous_types_are_valid_passes(self): + # non-unique heterogeneous types are valid + UniqueitemsFalseValidation._from_openapi_data( + [ + { + } +, + [ + 1, + ] +, + + True, + + None, + { + } +, + 1, + ] +, + _configuration=self._configuration + ) + + def test_unique_heterogeneous_types_are_valid_passes(self): + # unique heterogeneous types are valid + UniqueitemsFalseValidation._from_openapi_data( + [ + { + } +, + [ + 1, + ] +, + + True, + + None, + 1, + ] +, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uniqueitems_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uniqueitems_validation.py new file mode 100644 index 00000000000..1a87d4d91a6 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uniqueitems_validation.py @@ -0,0 +1,566 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.uniqueitems_validation import UniqueitemsValidation +from unit_test_api import configuration + + +class TestUniqueitemsValidation(unittest.TestCase): + """UniqueitemsValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_unique_array_of_objects_is_valid_passes(self): + # unique array of objects is valid + UniqueitemsValidation._from_openapi_data( + [ + { + + "foo": + + "bar", + } +, + { + + "foo": + + "baz", + } +, + ] +, + _configuration=self._configuration + ) + + def test_a_true_and_a1_are_unique_passes(self): + # {"a": true} and {"a": 1} are unique + UniqueitemsValidation._from_openapi_data( + [ + { + + "a": + + True, + } +, + { + + "a": + 1, + } +, + ] +, + _configuration=self._configuration + ) + + def test_non_unique_heterogeneous_types_are_invalid_fails(self): + # non-unique heterogeneous types are invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + UniqueitemsValidation._from_openapi_data( + [ + { + } +, + [ + 1, + ] +, + + True, + + None, + { + } +, + 1, + ] +, + _configuration=self._configuration + ) + + def test_nested0_and_false_are_unique_passes(self): + # nested [0] and [false] are unique + UniqueitemsValidation._from_openapi_data( + [ + [ + [ + 0, + ] +, + + "foo", + ] +, + [ + [ + + False, + ] +, + + "foo", + ] +, + ] +, + _configuration=self._configuration + ) + + def test_a_false_and_a0_are_unique_passes(self): + # {"a": false} and {"a": 0} are unique + UniqueitemsValidation._from_openapi_data( + [ + { + + "a": + + False, + } +, + { + + "a": + 0, + } +, + ] +, + _configuration=self._configuration + ) + + def test_numbers_are_unique_if_mathematically_unequal_fails(self): + # numbers are unique if mathematically unequal + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + UniqueitemsValidation._from_openapi_data( + [ + 1.0, + 1.0, + 1, + ] +, + _configuration=self._configuration + ) + + def test_false_is_not_equal_to_zero_passes(self): + # false is not equal to zero + UniqueitemsValidation._from_openapi_data( + [ + 0, + + False, + ] +, + _configuration=self._configuration + ) + + def test_0_and_false_are_unique_passes(self): + # [0] and [false] are unique + UniqueitemsValidation._from_openapi_data( + [ + [ + 0, + ] +, + [ + + False, + ] +, + ] +, + _configuration=self._configuration + ) + + def test_unique_array_of_arrays_is_valid_passes(self): + # unique array of arrays is valid + UniqueitemsValidation._from_openapi_data( + [ + [ + + "foo", + ] +, + [ + + "bar", + ] +, + ] +, + _configuration=self._configuration + ) + + def test_non_unique_array_of_nested_objects_is_invalid_fails(self): + # non-unique array of nested objects is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + UniqueitemsValidation._from_openapi_data( + [ + { + + "foo": + { + + "bar": + { + + "baz": + + True, + } +, + } +, + } +, + { + + "foo": + { + + "bar": + { + + "baz": + + True, + } +, + } +, + } +, + ] +, + _configuration=self._configuration + ) + + def test_non_unique_array_of_more_than_two_integers_is_invalid_fails(self): + # non-unique array of more than two integers is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + UniqueitemsValidation._from_openapi_data( + [ + 1, + 2, + 1, + ] +, + _configuration=self._configuration + ) + + def test_true_is_not_equal_to_one_passes(self): + # true is not equal to one + UniqueitemsValidation._from_openapi_data( + [ + 1, + + True, + ] +, + _configuration=self._configuration + ) + + def test_objects_are_non_unique_despite_key_order_fails(self): + # objects are non-unique despite key order + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + UniqueitemsValidation._from_openapi_data( + [ + { + + "a": + 1, + + "b": + 2, + } +, + { + + "b": + 2, + + "a": + 1, + } +, + ] +, + _configuration=self._configuration + ) + + def test_unique_array_of_strings_is_valid_passes(self): + # unique array of strings is valid + UniqueitemsValidation._from_openapi_data( + [ + + "foo", + + "bar", + + "baz", + ] +, + _configuration=self._configuration + ) + + def test_1_and_true_are_unique_passes(self): + # [1] and [true] are unique + UniqueitemsValidation._from_openapi_data( + [ + [ + 1, + ] +, + [ + + True, + ] +, + ] +, + _configuration=self._configuration + ) + + def test_different_objects_are_unique_passes(self): + # different objects are unique + UniqueitemsValidation._from_openapi_data( + [ + { + + "a": + 1, + + "b": + 2, + } +, + { + + "a": + 2, + + "b": + 1, + } +, + ] +, + _configuration=self._configuration + ) + + def test_unique_array_of_integers_is_valid_passes(self): + # unique array of integers is valid + UniqueitemsValidation._from_openapi_data( + [ + 1, + 2, + ] +, + _configuration=self._configuration + ) + + def test_non_unique_array_of_more_than_two_arrays_is_invalid_fails(self): + # non-unique array of more than two arrays is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + UniqueitemsValidation._from_openapi_data( + [ + [ + + "foo", + ] +, + [ + + "bar", + ] +, + [ + + "foo", + ] +, + ] +, + _configuration=self._configuration + ) + + def test_non_unique_array_of_objects_is_invalid_fails(self): + # non-unique array of objects is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + UniqueitemsValidation._from_openapi_data( + [ + { + + "foo": + + "bar", + } +, + { + + "foo": + + "bar", + } +, + ] +, + _configuration=self._configuration + ) + + def test_unique_array_of_nested_objects_is_valid_passes(self): + # unique array of nested objects is valid + UniqueitemsValidation._from_openapi_data( + [ + { + + "foo": + { + + "bar": + { + + "baz": + + True, + } +, + } +, + } +, + { + + "foo": + { + + "bar": + { + + "baz": + + False, + } +, + } +, + } +, + ] +, + _configuration=self._configuration + ) + + def test_non_unique_array_of_arrays_is_invalid_fails(self): + # non-unique array of arrays is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + UniqueitemsValidation._from_openapi_data( + [ + [ + + "foo", + ] +, + [ + + "foo", + ] +, + ] +, + _configuration=self._configuration + ) + + def test_non_unique_array_of_strings_is_invalid_fails(self): + # non-unique array of strings is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + UniqueitemsValidation._from_openapi_data( + [ + + "foo", + + "bar", + + "foo", + ] +, + _configuration=self._configuration + ) + + def test_nested1_and_true_are_unique_passes(self): + # nested [1] and [true] are unique + UniqueitemsValidation._from_openapi_data( + [ + [ + [ + 1, + ] +, + + "foo", + ] +, + [ + [ + + True, + ] +, + + "foo", + ] +, + ] +, + _configuration=self._configuration + ) + + def test_unique_heterogeneous_types_are_valid_passes(self): + # unique heterogeneous types are valid + UniqueitemsValidation._from_openapi_data( + [ + { + } +, + [ + 1, + ] +, + + True, + + None, + 1, + + "{}", + ] +, + _configuration=self._configuration + ) + + def test_non_unique_array_of_integers_is_invalid_fails(self): + # non-unique array of integers is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + UniqueitemsValidation._from_openapi_data( + [ + 1, + 1, + ] +, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_validation.py deleted file mode 100644 index a0d4c00017a..00000000000 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_validation.py +++ /dev/null @@ -1,98 +0,0 @@ -# coding: utf-8 - -""" - openapi 3.0.3 sample spec - - sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 - - The version of the OpenAPI document: 0.0.1 - Generated by: https://openapi-generator.tech -""" - -import re # noqa: F401 -import sys # noqa: F401 -import typing # noqa: F401 -import functools # noqa: F401 - -from frozendict import frozendict # noqa: F401 - -import decimal # noqa: F401 -from datetime import date, datetime # noqa: F401 -from frozendict import frozendict # noqa: F401 - -from unit_test_api.schemas import ( # noqa: F401 - AnyTypeSchema, - ComposedSchema, - DictSchema, - ListSchema, - StrSchema, - IntSchema, - Int32Schema, - Int64Schema, - Float32Schema, - Float64Schema, - NumberSchema, - UUIDSchema, - DateSchema, - DateTimeSchema, - DecimalSchema, - BoolSchema, - BinarySchema, - NoneSchema, - none_type, - Configuration, - Unset, - unset, - ComposedBase, - ListBase, - DictBase, - NoneBase, - StrBase, - IntBase, - Int32Base, - Int64Base, - Float32Base, - Float64Base, - NumberBase, - UUIDBase, - DateBase, - DateTimeBase, - BoolBase, - BinaryBase, - Schema, - _SchemaValidator, - _SchemaTypeChecker, - _SchemaEnumMaker -) - - -class RequiredValidation( - AnyTypeSchema -): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - _required_property_names = set(( - 'foo', - )) - foo = AnyTypeSchema - bar = AnyTypeSchema - - def __new__( - cls, - *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - foo: foo, - bar: typing.Union[bar, Unset] = unset, - _configuration: typing.Optional[Configuration] = None, - **kwargs: typing.Type[Schema], - ) -> 'RequiredValidation': - return super().__new__( - cls, - *args, - foo=foo, - bar=bar, - _configuration=_configuration, - **kwargs, - ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_with_empty_array.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/uniqueitems_false_validation.py similarity index 92% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_with_empty_array.py rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/uniqueitems_false_validation.py index 4a7a203a126..43b48358347 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_with_empty_array.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/uniqueitems_false_validation.py @@ -66,7 +66,9 @@ from unit_test_api.schemas import ( # noqa: F401 ) -class RequiredWithEmptyArray( +class UniqueitemsFalseValidation( + _SchemaValidator( + ), AnyTypeSchema ): """NOTE: This class is auto generated by OpenAPI Generator. @@ -74,19 +76,16 @@ class RequiredWithEmptyArray( Do not edit the class manually. """ - foo = AnyTypeSchema def __new__( cls, *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - foo: typing.Union[foo, Unset] = unset, _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Type[Schema], - ) -> 'RequiredWithEmptyArray': + ) -> 'UniqueitemsFalseValidation': return super().__new__( cls, *args, - foo=foo, _configuration=_configuration, **kwargs, ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_default_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/uniqueitems_validation.py similarity index 91% rename from samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_default_validation.py rename to samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/uniqueitems_validation.py index 94993796890..7680173ee8b 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_default_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/uniqueitems_validation.py @@ -66,7 +66,10 @@ from unit_test_api.schemas import ( # noqa: F401 ) -class RequiredDefaultValidation( +class UniqueitemsValidation( + _SchemaValidator( + unique_items=True, + ), AnyTypeSchema ): """NOTE: This class is auto generated by OpenAPI Generator. @@ -74,19 +77,16 @@ class RequiredDefaultValidation( Do not edit the class manually. """ - foo = AnyTypeSchema def __new__( cls, *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], - foo: typing.Union[foo, Unset] = unset, _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Type[Schema], - ) -> 'RequiredDefaultValidation': + ) -> 'UniqueitemsValidation': return super().__new__( cls, *args, - foo=foo, _configuration=_configuration, **kwargs, ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py index 8ab6a510e3c..d53848a9d42 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py @@ -11,6 +11,5 @@ # import sys # sys.setrecursionlimit(n) -from unit_test_api.model.required_default_validation import RequiredDefaultValidation -from unit_test_api.model.required_validation import RequiredValidation -from unit_test_api.model.required_with_empty_array import RequiredWithEmptyArray +from unit_test_api.model.uniqueitems_false_validation import UniqueitemsFalseValidation +from unit_test_api.model.uniqueitems_validation import UniqueitemsValidation diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/schemas.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/schemas.py index 0b78a94e7c4..2755f47f4e0 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/schemas.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/schemas.py @@ -228,10 +228,11 @@ class ValidatorBase: if (cls.__is_json_validation_enabled('uniqueItems', validation_metadata.configuration) and 'unique_items' in validations and validations['unique_items'] and input_values): - unique_items = [] + unique_items = set() for item in input_values: - if item not in unique_items: - unique_items.append(item) + pair = (item, item.__class__) + if pair not in unique_items: + unique_items.add(pair) if len(input_values) > len(unique_items): cls.__raise_validation_error_message( value=input_values, -- GitLab From ded487f760c59547d3619a336364653d6bc93b4b Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Wed, 29 Jun 2022 14:28:14 -0700 Subject: [PATCH 34/43] Fixes build error / javadoc warning --- .../main/java/org/openapitools/codegen/DefaultCodegen.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index c265d8b7b80..a6541b554ba 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -2703,8 +2703,8 @@ public class DefaultCodegen implements CodegenConfig { /** * A method that allows generators to pre-process test example payloads * This can be useful if one needs to change how values like null in string are represnted - * @param data - * @return + * @param data the test data payload + * @return the updated test data payload */ protected Object processTestExampleData(Object data) { return data; -- GitLab From bed626601fefaf0a6d8b2c6f21419c6ba333a2e7 Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Wed, 29 Jun 2022 14:50:42 -0700 Subject: [PATCH 35/43] Fixes uniqueItems bug in python-experimental --- .../python-experimental/schemas.handlebars | 31 ++++++++++++++++--- .../.openapi-generator/FILES | 2 -- .../unit_test_api/schemas.py | 31 ++++++++++++++++--- 3 files changed, 52 insertions(+), 12 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/python-experimental/schemas.handlebars b/modules/openapi-generator/src/main/resources/python-experimental/schemas.handlebars index e0e72256a84..9db3075849e 100644 --- a/modules/openapi-generator/src/main/resources/python-experimental/schemas.handlebars +++ b/modules/openapi-generator/src/main/resources/python-experimental/schemas.handlebars @@ -194,6 +194,31 @@ class ValidatorBase: path_to_item=validation_metadata.path_to_item ) + @classmethod + def __data_with_boolclass_instead_of_bool(cls, data: typing.Any) -> typing.Any: + """ + In python bool is a subclass of int so 1 == True and 0 == False + This prevents code from being able to see the difference between 1 and True and 0 and False + To fix this swap in BoolClass singletons for True and False so they will differ from integers + """ + if isinstance(data, (list, tuple)): + new_data = [] + for item in data: + new_item = cls.__data_with_boolclass_instead_of_bool(item) + new_data.append(new_item) + return tuple(new_data) + elif isinstance(data, (dict, frozendict)): + new_data = {} + for key, value in data.items(): + new_value = cls.__data_with_boolclass_instead_of_bool(value) + new_data[key] = new_value + return frozendict(new_data) + elif isinstance(data, bool): + if data: + return BoolClass.TRUE + return BoolClass.FALSE + return data + @classmethod def __check_tuple_validations( cls, validations, input_values, @@ -221,11 +246,7 @@ class ValidatorBase: if (cls.__is_json_validation_enabled('uniqueItems', validation_metadata.configuration) and 'unique_items' in validations and validations['unique_items'] and input_values): - unique_items = set() - for item in input_values: - pair = (item, item.__class__) - if pair not in unique_items: - unique_items.add(pair) + unique_items = set(cls.__data_with_boolclass_instead_of_bool(input_values)) if len(input_values) > len(unique_items): cls.__raise_validation_error_message( value=input_values, diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index 1d8b38d3a2d..fad79331681 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -10,8 +10,6 @@ setup.cfg setup.py test-requirements.txt test/__init__.py -test/test_uniqueitems_false_validation.py -test/test_uniqueitems_validation.py tox.ini unit_test_api/__init__.py unit_test_api/api/__init__.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/schemas.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/schemas.py index 2755f47f4e0..ad7860b5ca1 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/schemas.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/schemas.py @@ -201,6 +201,31 @@ class ValidatorBase: path_to_item=validation_metadata.path_to_item ) + @classmethod + def __data_with_boolclass_instead_of_bool(cls, data: typing.Any) -> typing.Any: + """ + In python bool is a subclass of int so 1 == True and 0 == False + This prevents code from being able to see the difference between 1 and True and 0 and False + To fix this swap in BoolClass singletons for True and False so they will differ from integers + """ + if isinstance(data, (list, tuple)): + new_data = [] + for item in data: + new_item = cls.__data_with_boolclass_instead_of_bool(item) + new_data.append(new_item) + return tuple(new_data) + elif isinstance(data, (dict, frozendict)): + new_data = {} + for key, value in data.items(): + new_value = cls.__data_with_boolclass_instead_of_bool(value) + new_data[key] = new_value + return frozendict(new_data) + elif isinstance(data, bool): + if data: + return BoolClass.TRUE + return BoolClass.FALSE + return data + @classmethod def __check_tuple_validations( cls, validations, input_values, @@ -228,11 +253,7 @@ class ValidatorBase: if (cls.__is_json_validation_enabled('uniqueItems', validation_metadata.configuration) and 'unique_items' in validations and validations['unique_items'] and input_values): - unique_items = set() - for item in input_values: - pair = (item, item.__class__) - if pair not in unique_items: - unique_items.add(pair) + unique_items = set(cls.__data_with_boolclass_instead_of_bool(input_values)) if len(input_values) > len(unique_items): cls.__raise_validation_error_message( value=input_values, -- GitLab From 889c1176b48b30943834312fad066b28a0632516 Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Wed, 29 Jun 2022 15:10:19 -0700 Subject: [PATCH 36/43] Turns all tests back on --- .../unit_test_spec/3_0_3_unit_test_spec.yaml | 1351 +++++++++++++++++ .../3_0/unit_test_spec/spec_writer.py | 83 +- .../.openapi-generator/FILES | 170 +++ .../python-experimental/README.md | 56 + ...pertiesAllowsASchemaWhichShouldValidate.md | 11 + ...AdditionalpropertiesAreAllowedByDefault.md | 11 + .../AdditionalpropertiesCanExistByItself.md | 9 + ...nalpropertiesShouldNotLookInApplicators.md | 9 + .../docs/ArrayTypeMatchesArrays.md | 8 + .../docs/BooleanTypeMatchesBooleans.md | 8 + .../python-experimental/docs/ByInt.md | 9 + .../python-experimental/docs/ByNumber.md | 9 + .../python-experimental/docs/BySmallNumber.md | 9 + .../docs/DateTimeFormat.md | 9 + .../python-experimental/docs/EmailFormat.md | 9 + .../docs/EnumWith0DoesNotMatchFalse.md | 8 + .../docs/EnumWith1DoesNotMatchTrue.md | 8 + .../docs/EnumWithEscapedCharacters.md | 9 + .../docs/EnumWithFalseDoesNotMatch0.md | 8 + .../docs/EnumWithTrueDoesNotMatch1.md | 8 + .../docs/EnumsInProperties.md | 11 + .../docs/ForbiddenProperty.md | 10 + .../docs/HostnameFormat.md | 9 + .../docs/IntegerTypeMatchesIntegers.md | 8 + ...ShouldNotRaiseErrorWhenFloatDivisionInf.md | 8 + .../docs/InvalidStringValueForDefault.md | 10 + .../python-experimental/docs/Ipv4Format.md | 9 + .../python-experimental/docs/Ipv6Format.md | 9 + .../docs/JsonPointerFormat.md | 9 + .../docs/MaximumValidation.md | 9 + .../MaximumValidationWithUnsignedInteger.md | 9 + .../docs/MaxitemsValidation.md | 9 + .../docs/MaxlengthValidation.md | 9 + .../Maxproperties0MeansTheObjectIsEmpty.md | 9 + .../docs/MaxpropertiesValidation.md | 9 + .../docs/MinimumValidation.md | 9 + .../MinimumValidationWithSignedInteger.md | 9 + .../docs/MinitemsValidation.md | 9 + .../docs/MinlengthValidation.md | 9 + .../docs/MinpropertiesValidation.md | 9 + .../python-experimental/docs/ModelNot.md | 9 + .../python-experimental/docs/NestedItems.md | 8 + .../docs/NotMoreComplexSchema.md | 9 + .../docs/NulCharactersInStrings.md | 8 + .../docs/NullTypeMatchesOnlyTheNullObject.md | 8 + .../docs/NumberTypeMatchesNumbers.md | 8 + .../docs/ObjectPropertiesValidation.md | 11 + .../docs/PatternIsNotAnchored.md | 9 + .../docs/PatternValidation.md | 9 + .../docs/PropertiesWithEscapedCharacters.md | 15 + .../PropertyNamedRefThatIsNotAReference.md | 10 + .../docs/RequiredDefaultValidation.md | 10 + .../docs/RequiredValidation.md | 11 + .../docs/RequiredWithEmptyArray.md | 10 + .../docs/SimpleEnumValidation.md | 8 + .../docs/StringTypeMatchesStrings.md | 8 + ...DoesNotDoAnythingIfThePropertyIsMissing.md | 10 + .../python-experimental/docs/UriFormat.md | 9 + .../docs/UriReferenceFormat.md | 9 + .../docs/UriTemplateFormat.md | 9 + ...s_allows_a_schema_which_should_validate.py | 75 + ...tionalproperties_are_allowed_by_default.py | 44 + ...dditionalproperties_can_exist_by_itself.py | 51 + ...operties_should_not_look_in_applicators.py | 42 + .../test/test_array_type_matches_arrays.py | 87 ++ .../test_boolean_type_matches_booleans.py | 112 ++ .../python-experimental/test/test_by_int.py | 48 + .../test/test_by_number.py | 47 + .../test/test_by_small_number.py | 40 + .../test/test_date_time_format.py | 73 + .../test/test_email_format.py | 73 + .../test_enum_with0_does_not_match_false.py | 48 + .../test_enum_with1_does_not_match_true.py | 48 + .../test/test_enum_with_escaped_characters.py | 50 + .../test_enum_with_false_does_not_match0.py | 49 + .../test_enum_with_true_does_not_match1.py | 49 + .../test/test_enums_in_properties.py | 115 ++ .../test/test_forbidden_property.py | 56 + .../test/test_hostname_format.py | 73 + .../test_integer_type_matches_integers.py | 103 ++ ...not_raise_error_when_float_division_inf.py | 33 + .../test_invalid_string_value_for_default.py | 47 + .../test/test_ipv4_format.py | 73 + .../test/test_ipv6_format.py | 73 + .../test/test_json_pointer_format.py | 73 + .../test/test_maximum_validation.py | 55 + ...aximum_validation_with_unsigned_integer.py | 54 + .../test/test_maxitems_validation.py | 67 + .../test/test_maxlength_validation.py | 65 + ...axproperties0_means_the_object_is_empty.py | 47 + .../test/test_maxproperties_validation.py | 98 ++ .../test/test_minimum_validation.py | 55 + ..._minimum_validation_with_signed_integer.py | 77 + .../test/test_minitems_validation.py | 64 + .../test/test_minlength_validation.py | 66 + .../test/test_minproperties_validation.py | 86 ++ .../test/test_model_not.py | 41 + .../test/test_nested_items.py | 163 ++ .../test/test_not_more_complex_schema.py | 58 + .../test/test_nul_characters_in_strings.py | 42 + ..._null_type_matches_only_the_null_object.py | 113 ++ .../test/test_number_type_matches_numbers.py | 102 ++ .../test/test_object_properties_validation.py | 109 ++ .../test/test_pattern_is_not_anchored.py | 33 + .../test/test_pattern_validation.py | 90 ++ ...test_properties_with_escaped_characters.py | 86 ++ ...perty_named_ref_that_is_not_a_reference.py | 51 + .../test/test_required_default_validation.py | 34 + .../test/test_required_validation.py | 74 + .../test/test_required_with_empty_array.py | 34 + .../test/test_simple_enum_validation.py | 40 + .../test/test_string_type_matches_strings.py | 103 ++ ..._do_anything_if_the_property_is_missing.py | 59 + .../test/test_uri_format.py | 73 + .../test/test_uri_reference_format.py | 73 + .../test/test_uri_template_format.py | 73 + ...s_allows_a_schema_which_should_validate.py | 97 ++ ...tionalproperties_are_allowed_by_default.py | 95 ++ ...dditionalproperties_can_exist_by_itself.py | 91 ++ ...operties_should_not_look_in_applicators.py | 114 ++ .../model/array_type_matches_arrays.py | 77 + .../model/boolean_type_matches_booleans.py | 67 + .../unit_test_api/model/by_int.py | 92 ++ .../unit_test_api/model/by_number.py | 92 ++ .../unit_test_api/model/by_small_number.py | 92 ++ .../unit_test_api/model/date_time_format.py | 67 + .../unit_test_api/model/email_format.py | 67 + .../model/enum_with0_does_not_match_false.py | 86 ++ .../model/enum_with1_does_not_match_true.py | 86 ++ .../model/enum_with_escaped_characters.py | 94 ++ .../model/enum_with_false_does_not_match0.py | 86 ++ .../model/enum_with_true_does_not_match1.py | 86 ++ .../model/enums_in_properties.py | 127 ++ .../unit_test_api/model/forbidden_property.py | 132 ++ .../unit_test_api/model/hostname_format.py | 67 + .../model/integer_type_matches_integers.py | 67 + ...not_raise_error_when_float_division_inf.py | 80 + .../model/invalid_string_value_for_default.py | 100 ++ .../unit_test_api/model/ipv4_format.py | 67 + .../unit_test_api/model/ipv6_format.py | 67 + .../model/json_pointer_format.py | 67 + .../unit_test_api/model/maximum_validation.py | 92 ++ ...aximum_validation_with_unsigned_integer.py | 92 ++ .../model/maxitems_validation.py | 92 ++ .../model/maxlength_validation.py | 92 ++ ...axproperties0_means_the_object_is_empty.py | 92 ++ .../model/maxproperties_validation.py | 92 ++ .../unit_test_api/model/minimum_validation.py | 92 ++ .../minimum_validation_with_signed_integer.py | 92 ++ .../model/minitems_validation.py | 92 ++ .../model/minlength_validation.py | 92 ++ .../model/minproperties_validation.py | 92 ++ .../unit_test_api/model/model_not.py | 112 ++ .../unit_test_api/model/nested_items.py | 92 ++ .../model/not_more_complex_schema.py | 133 ++ .../model/nul_characters_in_strings.py | 86 ++ .../null_type_matches_only_the_null_object.py | 67 + .../model/number_type_matches_numbers.py | 67 + .../model/object_properties_validation.py | 95 ++ .../model/pattern_is_not_anchored.py | 94 ++ .../unit_test_api/model/pattern_validation.py | 94 ++ .../properties_with_escaped_characters.py | 107 ++ ...perty_named_ref_that_is_not_a_reference.py | 92 ++ .../model/required_default_validation.py | 92 ++ .../model/required_validation.py | 98 ++ .../model/required_with_empty_array.py | 92 ++ .../model/simple_enum_validation.py | 98 ++ .../model/string_type_matches_strings.py | 67 + ..._do_anything_if_the_property_is_missing.py | 101 ++ .../unit_test_api/model/uri_format.py | 67 + .../model/uri_reference_format.py | 67 + .../model/uri_template_format.py | 67 + .../unit_test_api/models/__init__.py | 56 + 173 files changed, 10920 insertions(+), 38 deletions(-) create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAreAllowedByDefault.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesCanExistByItself.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesShouldNotLookInApplicators.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ArrayTypeMatchesArrays.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/BooleanTypeMatchesBooleans.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ByInt.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ByNumber.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/BySmallNumber.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/DateTimeFormat.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EmailFormat.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWith0DoesNotMatchFalse.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWith1DoesNotMatchTrue.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithEscapedCharacters.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithFalseDoesNotMatch0.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithTrueDoesNotMatch1.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumsInProperties.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ForbiddenProperty.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/HostnameFormat.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/IntegerTypeMatchesIntegers.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidStringValueForDefault.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Ipv4Format.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Ipv6Format.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/JsonPointerFormat.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaximumValidation.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaximumValidationWithUnsignedInteger.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxitemsValidation.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxlengthValidation.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Maxproperties0MeansTheObjectIsEmpty.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxpropertiesValidation.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinimumValidation.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinimumValidationWithSignedInteger.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinitemsValidation.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinlengthValidation.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinpropertiesValidation.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ModelNot.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedItems.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NotMoreComplexSchema.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NulCharactersInStrings.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NullTypeMatchesOnlyTheNullObject.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NumberTypeMatchesNumbers.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ObjectPropertiesValidation.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PatternIsNotAnchored.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PatternValidation.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PropertiesWithEscapedCharacters.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PropertyNamedRefThatIsNotAReference.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredDefaultValidation.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredValidation.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredWithEmptyArray.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/SimpleEnumValidation.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/StringTypeMatchesStrings.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/UriFormat.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/UriReferenceFormat.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/UriTemplateFormat.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_int.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_number.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_small_number.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_date_time_format.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_email_format.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with0_does_not_match_false.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with1_does_not_match_true.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_escaped_characters.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_false_does_not_match0.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_true_does_not_match1.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enums_in_properties.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_forbidden_property.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_hostname_format.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_instance_should_not_raise_error_when_float_division_inf.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_string_value_for_default.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ipv4_format.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ipv6_format.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_json_pointer_format.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation_with_unsigned_integer.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxitems_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxlength_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties0_means_the_object_is_empty.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation_with_signed_integer.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minitems_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minlength_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minproperties_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_model_not.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_items.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_not_more_complex_schema.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nul_characters_in_strings.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_object_properties_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_is_not_anchored.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_property_named_ref_that_is_not_a_reference.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_default_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_with_empty_array.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_simple_enum_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_format.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_reference_format.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_template_format.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_allows_a_schema_which_should_validate.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_are_allowed_by_default.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_can_exist_by_itself.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_should_not_look_in_applicators.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/array_type_matches_arrays.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/boolean_type_matches_booleans.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_int.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_number.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_small_number.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/date_time_format.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/email_format.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with0_does_not_match_false.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with1_does_not_match_true.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_escaped_characters.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_false_does_not_match0.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_true_does_not_match1.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enums_in_properties.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/forbidden_property.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/hostname_format.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/integer_type_matches_integers.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_instance_should_not_raise_error_when_float_division_inf.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_string_value_for_default.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ipv4_format.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ipv6_format.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/json_pointer_format.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maximum_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maximum_validation_with_unsigned_integer.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxitems_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxlength_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxproperties0_means_the_object_is_empty.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxproperties_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minimum_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minimum_validation_with_signed_integer.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minitems_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minlength_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minproperties_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/model_not.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_items.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/not_more_complex_schema.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nul_characters_in_strings.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/null_type_matches_only_the_null_object.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/number_type_matches_numbers.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/object_properties_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/pattern_is_not_anchored.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/pattern_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/properties_with_escaped_characters.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/property_named_ref_that_is_not_a_reference.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_default_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_with_empty_array.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/simple_enum_validation.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/string_type_matches_strings.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/the_default_keyword_does_not_do_anything_if_the_property_is_missing.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/uri_format.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/uri_reference_format.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/uri_template_format.py diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml index fa19c2ebd6c..7334798e558 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml @@ -7,11 +7,1362 @@ info: paths: {} components: schemas: + AdditionalpropertiesAllowsASchemaWhichShouldValidate: + properties: + foo: {} + bar: {} + additionalProperties: + type: boolean + AdditionalpropertiesCanExistByItself: + additionalProperties: + type: boolean + AdditionalpropertiesAreAllowedByDefault: + properties: + foo: {} + bar: {} + AdditionalpropertiesShouldNotLookInApplicators: + allOf: + - properties: + foo: {} + additionalProperties: + type: boolean + InvalidStringValueForDefault: + properties: + bar: + type: string + minLength: 4 + default: bad + TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing: + type: object + properties: + alpha: + type: number + maximum: 3 + default: 5 + SimpleEnumValidation: + enum: + - 1 + - 2 + - 3 + EnumsInProperties: + type: object + properties: + foo: + enum: + - foo + bar: + enum: + - bar + required: + - bar + EnumWithEscapedCharacters: + enum: + - 'foo + + bar' + - "foo\rbar" + EnumWithFalseDoesNotMatch0: + enum: + - false + EnumWithTrueDoesNotMatch1: + enum: + - true + EnumWith0DoesNotMatchFalse: + enum: + - 0 + EnumWith1DoesNotMatchTrue: + enum: + - 1 + NulCharactersInStrings: + enum: + - "hello\0there" + EmailFormat: + format: email + Ipv4Format: + format: ipv4 + Ipv6Format: + format: ipv6 + HostnameFormat: + format: hostname + DateTimeFormat: + format: date-time + JsonPointerFormat: + format: json-pointer + UriFormat: + format: uri + UriReferenceFormat: + format: uri-reference + UriTemplateFormat: + format: uri-template + NestedItems: + type: array + items: + type: array + items: + type: array + items: + type: array + items: + type: number + MaximumValidation: + maximum: 3.0 + MaximumValidationWithUnsignedInteger: + maximum: 300 + MaxitemsValidation: + maxItems: 2 + MaxlengthValidation: + maxLength: 2 + MaxpropertiesValidation: + maxProperties: 2 + Maxproperties0MeansTheObjectIsEmpty: + maxProperties: 0 + MinimumValidation: + minimum: 1.1 + MinimumValidationWithSignedInteger: + minimum: -2 + MinitemsValidation: + minItems: 1 + MinlengthValidation: + minLength: 2 + MinpropertiesValidation: + minProperties: 1 + ByInt: + multipleOf: 2 + ByNumber: + multipleOf: 1.5 + BySmallNumber: + multipleOf: 0.0001 + InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf: + type: integer + multipleOf: 0.123456789 + Not: + not: + type: integer + NotMoreComplexSchema: + not: + type: object + properties: + foo: + type: string + ForbiddenProperty: + properties: + foo: + not: {} + PatternValidation: + pattern: ^a*$ + PatternIsNotAnchored: + pattern: a+ + ObjectPropertiesValidation: + properties: + foo: + type: integer + bar: + type: string + PropertiesWithEscapedCharacters: + properties: + ? 'foo + + bar' + : type: number + foo"bar: + type: number + foo\bar: + type: number + "foo\rbar": + type: number + "foo\tbar": + type: number + "foo\fbar": + type: number + PropertyNamedRefThatIsNotAReference: + properties: + $ref: + type: string + RequiredValidation: + properties: + foo: {} + bar: {} + required: + - foo + RequiredDefaultValidation: + properties: + foo: {} + RequiredWithEmptyArray: + properties: + foo: {} + required: [] + IntegerTypeMatchesIntegers: + type: integer + NumberTypeMatchesNumbers: + type: number + StringTypeMatchesStrings: + type: string + ObjectTypeMatchesObjects: + type: object + BooleanTypeMatchesBooleans: + type: boolean + NullTypeMatchesOnlyTheNullObject: + type: 'null' + ArrayTypeMatchesArrays: + type: array + items: {} UniqueitemsValidation: uniqueItems: true UniqueitemsFalseValidation: uniqueItems: false x-schema-test-examples: + AdditionalpropertiesAllowsASchemaWhichShouldValidate: + NoAdditionalPropertiesIsValid: + description: no additional properties is valid + data: + foo: 1 + valid: true + AnAdditionalValidPropertyIsValid: + description: an additional valid property is valid + data: + foo: 1 + bar: 2 + quux: true + valid: true + AnAdditionalInvalidPropertyIsInvalid: + description: an additional invalid property is invalid + data: + foo: 1 + bar: 2 + quux: 12 + valid: false + AdditionalpropertiesCanExistByItself: + AnAdditionalValidPropertyIsValid: + description: an additional valid property is valid + data: + foo: true + valid: true + AnAdditionalInvalidPropertyIsInvalid: + description: an additional invalid property is invalid + data: + foo: 1 + valid: false + AdditionalpropertiesAreAllowedByDefault: + AdditionalPropertiesAreAllowed: + description: additional properties are allowed + data: + foo: 1 + bar: 2 + quux: true + valid: true + AdditionalpropertiesShouldNotLookInApplicators: + PropertiesDefinedInAllofAreNotExamined: + description: properties defined in allOf are not examined + data: + foo: 1 + bar: true + valid: false + InvalidStringValueForDefault: + ValidWhenPropertyIsSpecified: + description: valid when property is specified + data: + bar: good + valid: true + StillValidWhenTheInvalidDefaultIsUsed: + description: still valid when the invalid default is used + data: {} + valid: true + TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing: + AnExplicitPropertyValueIsCheckedAgainstMaximumPassing: + description: an explicit property value is checked against maximum (passing) + data: + alpha: 1 + valid: true + AnExplicitPropertyValueIsCheckedAgainstMaximumFailing: + description: an explicit property value is checked against maximum (failing) + data: + alpha: 5 + valid: false + MissingPropertiesAreNotFilledInWithTheDefault: + description: missing properties are not filled in with the default + data: {} + valid: true + SimpleEnumValidation: + OneOfTheEnumIsValid: + description: one of the enum is valid + data: 1 + valid: true + SomethingElseIsInvalid: + description: something else is invalid + data: 4 + valid: false + EnumsInProperties: + BothPropertiesAreValid: + description: both properties are valid + data: + foo: foo + bar: bar + valid: true + WrongFooValue: + description: wrong foo value + data: + foo: foot + bar: bar + valid: false + WrongBarValue: + description: wrong bar value + data: + foo: foo + bar: bart + valid: false + MissingOptionalPropertyIsValid: + description: missing optional property is valid + data: + bar: bar + valid: true + MissingRequiredPropertyIsInvalid: + description: missing required property is invalid + data: + foo: foo + valid: false + MissingAllPropertiesIsInvalid: + description: missing all properties is invalid + data: {} + valid: false + EnumWithEscapedCharacters: + Member1IsValid: + description: member 1 is valid + data: 'foo + + bar' + valid: true + Member2IsValid: + description: member 2 is valid + data: "foo\rbar" + valid: true + AnotherStringIsInvalid: + description: another string is invalid + data: abc + valid: false + EnumWithFalseDoesNotMatch0: + FalseIsValid: + description: false is valid + data: false + valid: true + IntegerZeroIsInvalid: + description: integer zero is invalid + data: 0 + valid: false + FloatZeroIsInvalid: + description: float zero is invalid + data: 0.0 + valid: false + EnumWithTrueDoesNotMatch1: + TrueIsValid: + description: true is valid + data: true + valid: true + IntegerOneIsInvalid: + description: integer one is invalid + data: 1 + valid: false + FloatOneIsInvalid: + description: float one is invalid + data: 1.0 + valid: false + EnumWith0DoesNotMatchFalse: + FalseIsInvalid: + description: false is invalid + data: false + valid: false + IntegerZeroIsValid: + description: integer zero is valid + data: 0 + valid: true + FloatZeroIsValid: + description: float zero is valid + data: 0.0 + valid: true + EnumWith1DoesNotMatchTrue: + TrueIsInvalid: + description: true is invalid + data: true + valid: false + IntegerOneIsValid: + description: integer one is valid + data: 1 + valid: true + FloatOneIsValid: + description: float one is valid + data: 1.0 + valid: true + NulCharactersInStrings: + MatchStringWithNul: + description: match string with nul + data: "hello\0there" + valid: true + DoNotMatchStringLackingNul: + description: do not match string lacking nul + data: hellothere + valid: false + EmailFormat: + AllStringFormatsIgnoreIntegers: + description: all string formats ignore integers + data: 12 + valid: true + AllStringFormatsIgnoreFloats: + description: all string formats ignore floats + data: 13.7 + valid: true + AllStringFormatsIgnoreObjects: + description: all string formats ignore objects + data: {} + valid: true + AllStringFormatsIgnoreArrays: + description: all string formats ignore arrays + data: [] + valid: true + AllStringFormatsIgnoreBooleans: + description: all string formats ignore booleans + data: false + valid: true + AllStringFormatsIgnoreNulls: + description: all string formats ignore nulls + data: null + valid: true + Ipv4Format: + AllStringFormatsIgnoreIntegers: + description: all string formats ignore integers + data: 12 + valid: true + AllStringFormatsIgnoreFloats: + description: all string formats ignore floats + data: 13.7 + valid: true + AllStringFormatsIgnoreObjects: + description: all string formats ignore objects + data: {} + valid: true + AllStringFormatsIgnoreArrays: + description: all string formats ignore arrays + data: [] + valid: true + AllStringFormatsIgnoreBooleans: + description: all string formats ignore booleans + data: false + valid: true + AllStringFormatsIgnoreNulls: + description: all string formats ignore nulls + data: null + valid: true + Ipv6Format: + AllStringFormatsIgnoreIntegers: + description: all string formats ignore integers + data: 12 + valid: true + AllStringFormatsIgnoreFloats: + description: all string formats ignore floats + data: 13.7 + valid: true + AllStringFormatsIgnoreObjects: + description: all string formats ignore objects + data: {} + valid: true + AllStringFormatsIgnoreArrays: + description: all string formats ignore arrays + data: [] + valid: true + AllStringFormatsIgnoreBooleans: + description: all string formats ignore booleans + data: false + valid: true + AllStringFormatsIgnoreNulls: + description: all string formats ignore nulls + data: null + valid: true + HostnameFormat: + AllStringFormatsIgnoreIntegers: + description: all string formats ignore integers + data: 12 + valid: true + AllStringFormatsIgnoreFloats: + description: all string formats ignore floats + data: 13.7 + valid: true + AllStringFormatsIgnoreObjects: + description: all string formats ignore objects + data: {} + valid: true + AllStringFormatsIgnoreArrays: + description: all string formats ignore arrays + data: [] + valid: true + AllStringFormatsIgnoreBooleans: + description: all string formats ignore booleans + data: false + valid: true + AllStringFormatsIgnoreNulls: + description: all string formats ignore nulls + data: null + valid: true + DateTimeFormat: + AllStringFormatsIgnoreIntegers: + description: all string formats ignore integers + data: 12 + valid: true + AllStringFormatsIgnoreFloats: + description: all string formats ignore floats + data: 13.7 + valid: true + AllStringFormatsIgnoreObjects: + description: all string formats ignore objects + data: {} + valid: true + AllStringFormatsIgnoreArrays: + description: all string formats ignore arrays + data: [] + valid: true + AllStringFormatsIgnoreBooleans: + description: all string formats ignore booleans + data: false + valid: true + AllStringFormatsIgnoreNulls: + description: all string formats ignore nulls + data: null + valid: true + JsonPointerFormat: + AllStringFormatsIgnoreIntegers: + description: all string formats ignore integers + data: 12 + valid: true + AllStringFormatsIgnoreFloats: + description: all string formats ignore floats + data: 13.7 + valid: true + AllStringFormatsIgnoreObjects: + description: all string formats ignore objects + data: {} + valid: true + AllStringFormatsIgnoreArrays: + description: all string formats ignore arrays + data: [] + valid: true + AllStringFormatsIgnoreBooleans: + description: all string formats ignore booleans + data: false + valid: true + AllStringFormatsIgnoreNulls: + description: all string formats ignore nulls + data: null + valid: true + UriFormat: + AllStringFormatsIgnoreIntegers: + description: all string formats ignore integers + data: 12 + valid: true + AllStringFormatsIgnoreFloats: + description: all string formats ignore floats + data: 13.7 + valid: true + AllStringFormatsIgnoreObjects: + description: all string formats ignore objects + data: {} + valid: true + AllStringFormatsIgnoreArrays: + description: all string formats ignore arrays + data: [] + valid: true + AllStringFormatsIgnoreBooleans: + description: all string formats ignore booleans + data: false + valid: true + AllStringFormatsIgnoreNulls: + description: all string formats ignore nulls + data: null + valid: true + UriReferenceFormat: + AllStringFormatsIgnoreIntegers: + description: all string formats ignore integers + data: 12 + valid: true + AllStringFormatsIgnoreFloats: + description: all string formats ignore floats + data: 13.7 + valid: true + AllStringFormatsIgnoreObjects: + description: all string formats ignore objects + data: {} + valid: true + AllStringFormatsIgnoreArrays: + description: all string formats ignore arrays + data: [] + valid: true + AllStringFormatsIgnoreBooleans: + description: all string formats ignore booleans + data: false + valid: true + AllStringFormatsIgnoreNulls: + description: all string formats ignore nulls + data: null + valid: true + UriTemplateFormat: + AllStringFormatsIgnoreIntegers: + description: all string formats ignore integers + data: 12 + valid: true + AllStringFormatsIgnoreFloats: + description: all string formats ignore floats + data: 13.7 + valid: true + AllStringFormatsIgnoreObjects: + description: all string formats ignore objects + data: {} + valid: true + AllStringFormatsIgnoreArrays: + description: all string formats ignore arrays + data: [] + valid: true + AllStringFormatsIgnoreBooleans: + description: all string formats ignore booleans + data: false + valid: true + AllStringFormatsIgnoreNulls: + description: all string formats ignore nulls + data: null + valid: true + NestedItems: + ValidNestedArray: + description: valid nested array + data: + - - - - 1 + - - - 2 + - - 3 + - - - - 4 + - - 5 + - - 6 + valid: true + NestedArrayWithInvalidType: + description: nested array with invalid type + data: + - - - - '1' + - - - 2 + - - 3 + - - - - 4 + - - 5 + - - 6 + valid: false + NotDeepEnough: + description: not deep enough + data: + - - - 1 + - - 2 + - - 3 + - - - 4 + - - 5 + - - 6 + valid: false + MaximumValidation: + BelowTheMaximumIsValid: + description: below the maximum is valid + data: 2.6 + valid: true + BoundaryPointIsValid: + description: boundary point is valid + data: 3.0 + valid: true + AboveTheMaximumIsInvalid: + description: above the maximum is invalid + data: 3.5 + valid: false + IgnoresNonNumbers: + description: ignores non-numbers + data: x + valid: true + MaximumValidationWithUnsignedInteger: + BelowTheMaximumIsInvalid: + description: below the maximum is invalid + data: 299.97 + valid: true + BoundaryPointIntegerIsValid: + description: boundary point integer is valid + data: 300 + valid: true + BoundaryPointFloatIsValid: + description: boundary point float is valid + data: 300.0 + valid: true + AboveTheMaximumIsInvalid: + description: above the maximum is invalid + data: 300.5 + valid: false + MaxitemsValidation: + ShorterIsValid: + description: shorter is valid + data: + - 1 + valid: true + ExactLengthIsValid: + description: exact length is valid + data: + - 1 + - 2 + valid: true + TooLongIsInvalid: + description: too long is invalid + data: + - 1 + - 2 + - 3 + valid: false + IgnoresNonArrays: + description: ignores non-arrays + data: foobar + valid: true + MaxlengthValidation: + ShorterIsValid: + description: shorter is valid + data: f + valid: true + ExactLengthIsValid: + description: exact length is valid + data: fo + valid: true + TooLongIsInvalid: + description: too long is invalid + data: foo + valid: false + IgnoresNonStrings: + description: ignores non-strings + data: 100 + valid: true + TwoSupplementaryUnicodeCodePointsIsLongEnough: + description: two supplementary Unicode code points is long enough + data: "\U0001F4A9\U0001F4A9" + valid: true + MaxpropertiesValidation: + ShorterIsValid: + description: shorter is valid + data: + foo: 1 + valid: true + ExactLengthIsValid: + description: exact length is valid + data: + foo: 1 + bar: 2 + valid: true + TooLongIsInvalid: + description: too long is invalid + data: + foo: 1 + bar: 2 + baz: 3 + valid: false + IgnoresArrays: + description: ignores arrays + data: + - 1 + - 2 + - 3 + valid: true + IgnoresStrings: + description: ignores strings + data: foobar + valid: true + IgnoresOtherNonObjects: + description: ignores other non-objects + data: 12 + valid: true + Maxproperties0MeansTheObjectIsEmpty: + NoPropertiesIsValid: + description: no properties is valid + data: {} + valid: true + OnePropertyIsInvalid: + description: one property is invalid + data: + foo: 1 + valid: false + MinimumValidation: + AboveTheMinimumIsValid: + description: above the minimum is valid + data: 2.6 + valid: true + BoundaryPointIsValid: + description: boundary point is valid + data: 1.1 + valid: true + BelowTheMinimumIsInvalid: + description: below the minimum is invalid + data: 0.6 + valid: false + IgnoresNonNumbers: + description: ignores non-numbers + data: x + valid: true + MinimumValidationWithSignedInteger: + NegativeAboveTheMinimumIsValid: + description: negative above the minimum is valid + data: -1 + valid: true + PositiveAboveTheMinimumIsValid: + description: positive above the minimum is valid + data: 0 + valid: true + BoundaryPointIsValid: + description: boundary point is valid + data: -2 + valid: true + BoundaryPointWithFloatIsValid: + description: boundary point with float is valid + data: -2.0 + valid: true + FloatBelowTheMinimumIsInvalid: + description: float below the minimum is invalid + data: -2.0001 + valid: false + IntBelowTheMinimumIsInvalid: + description: int below the minimum is invalid + data: -3 + valid: false + IgnoresNonNumbers: + description: ignores non-numbers + data: x + valid: true + MinitemsValidation: + LongerIsValid: + description: longer is valid + data: + - 1 + - 2 + valid: true + ExactLengthIsValid: + description: exact length is valid + data: + - 1 + valid: true + TooShortIsInvalid: + description: too short is invalid + data: [] + valid: false + IgnoresNonArrays: + description: ignores non-arrays + data: '' + valid: true + MinlengthValidation: + LongerIsValid: + description: longer is valid + data: foo + valid: true + ExactLengthIsValid: + description: exact length is valid + data: fo + valid: true + TooShortIsInvalid: + description: too short is invalid + data: f + valid: false + IgnoresNonStrings: + description: ignores non-strings + data: 1 + valid: true + OneSupplementaryUnicodeCodePointIsNotLongEnough: + description: one supplementary Unicode code point is not long enough + data: "\U0001F4A9" + valid: false + MinpropertiesValidation: + LongerIsValid: + description: longer is valid + data: + foo: 1 + bar: 2 + valid: true + ExactLengthIsValid: + description: exact length is valid + data: + foo: 1 + valid: true + TooShortIsInvalid: + description: too short is invalid + data: {} + valid: false + IgnoresArrays: + description: ignores arrays + data: [] + valid: true + IgnoresStrings: + description: ignores strings + data: '' + valid: true + IgnoresOtherNonObjects: + description: ignores other non-objects + data: 12 + valid: true + ByInt: + IntByInt: + description: int by int + data: 10 + valid: true + IntByIntFail: + description: int by int fail + data: 7 + valid: false + IgnoresNonNumbers: + description: ignores non-numbers + data: foo + valid: true + ByNumber: + ZeroIsMultipleOfAnything: + description: zero is multiple of anything + data: 0 + valid: true + 45IsMultipleOf15: + description: 4.5 is multiple of 1.5 + data: 4.5 + valid: true + 35IsNotMultipleOf15: + description: 35 is not multiple of 1.5 + data: 35 + valid: false + BySmallNumber: + 00075IsMultipleOf00001: + description: 0.0075 is multiple of 0.0001 + data: 0.0075 + valid: true + 000751IsNotMultipleOf00001: + description: 0.00751 is not multiple of 0.0001 + data: 0.00751 + valid: false + InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf: + AlwaysInvalidButNaiveImplementationsMayRaiseAnOverflowError: + description: always invalid, but naive implementations may raise an overflow + error + data: 1.0e+308 + valid: false + Not: + Allowed: + description: allowed + data: foo + valid: true + Disallowed: + description: disallowed + data: 1 + valid: false + NotMoreComplexSchema: + Match: + description: match + data: 1 + valid: true + OtherMatch: + description: other match + data: + foo: 1 + valid: true + Mismatch: + description: mismatch + data: + foo: bar + valid: false + ForbiddenProperty: + PropertyPresent: + description: property present + data: + foo: 1 + bar: 2 + valid: false + PropertyAbsent: + description: property absent + data: + bar: 1 + baz: 2 + valid: true + PatternValidation: + AMatchingPatternIsValid: + description: a matching pattern is valid + data: aaa + valid: true + ANonMatchingPatternIsInvalid: + description: a non-matching pattern is invalid + data: abc + valid: false + IgnoresBooleans: + description: ignores booleans + data: true + valid: true + IgnoresIntegers: + description: ignores integers + data: 123 + valid: true + IgnoresFloats: + description: ignores floats + data: 1.0 + valid: true + IgnoresObjects: + description: ignores objects + data: {} + valid: true + IgnoresArrays: + description: ignores arrays + data: [] + valid: true + IgnoresNull: + description: ignores null + data: null + valid: true + PatternIsNotAnchored: + MatchesASubstring: + description: matches a substring + data: xxaayy + valid: true + ObjectPropertiesValidation: + BothPropertiesPresentAndValidIsValid: + description: both properties present and valid is valid + data: + foo: 1 + bar: baz + valid: true + OnePropertyInvalidIsInvalid: + description: one property invalid is invalid + data: + foo: 1 + bar: {} + valid: false + BothPropertiesInvalidIsInvalid: + description: both properties invalid is invalid + data: + foo: [] + bar: {} + valid: false + DoesnTInvalidateOtherProperties: + description: doesn't invalidate other properties + data: + quux: [] + valid: true + IgnoresArrays: + description: ignores arrays + data: [] + valid: true + IgnoresOtherNonObjects: + description: ignores other non-objects + data: 12 + valid: true + PropertiesWithEscapedCharacters: + ObjectWithAllNumbersIsValid: + description: object with all numbers is valid + data: + ? 'foo + + bar' + : 1 + foo"bar: 1 + foo\bar: 1 + "foo\rbar": 1 + "foo\tbar": 1 + "foo\fbar": 1 + valid: true + ObjectWithStringsIsInvalid: + description: object with strings is invalid + data: + ? 'foo + + bar' + : '1' + foo"bar: '1' + foo\bar: '1' + "foo\rbar": '1' + "foo\tbar": '1' + "foo\fbar": '1' + valid: false + PropertyNamedRefThatIsNotAReference: + PropertyNamedRefValid: + description: property named $ref valid + data: + $ref: a + valid: true + PropertyNamedRefInvalid: + description: property named $ref invalid + data: + $ref: 2 + valid: false + RequiredValidation: + PresentRequiredPropertyIsValid: + description: present required property is valid + data: + foo: 1 + valid: true + NonPresentRequiredPropertyIsInvalid: + description: non-present required property is invalid + data: + bar: 1 + valid: false + IgnoresArrays: + description: ignores arrays + data: [] + valid: true + IgnoresStrings: + description: ignores strings + data: '' + valid: true + IgnoresOtherNonObjects: + description: ignores other non-objects + data: 12 + valid: true + RequiredDefaultValidation: + NotRequiredByDefault: + description: not required by default + data: {} + valid: true + RequiredWithEmptyArray: + PropertyNotRequired: + description: property not required + data: {} + valid: true + IntegerTypeMatchesIntegers: + AnIntegerIsAnInteger: + description: an integer is an integer + data: 1 + valid: true + AFloatWithZeroFractionalPartIsAnInteger: + description: a float with zero fractional part is an integer + data: 1.0 + valid: true + AFloatIsNotAnInteger: + description: a float is not an integer + data: 1.1 + valid: false + AStringIsNotAnInteger: + description: a string is not an integer + data: foo + valid: false + AStringIsStillNotAnIntegerEvenIfItLooksLikeOne: + description: a string is still not an integer, even if it looks like one + data: '1' + valid: false + AnObjectIsNotAnInteger: + description: an object is not an integer + data: {} + valid: false + AnArrayIsNotAnInteger: + description: an array is not an integer + data: [] + valid: false + ABooleanIsNotAnInteger: + description: a boolean is not an integer + data: true + valid: false + NullIsNotAnInteger: + description: null is not an integer + data: null + valid: false + NumberTypeMatchesNumbers: + AnIntegerIsANumber: + description: an integer is a number + data: 1 + valid: true + AFloatWithZeroFractionalPartIsANumberAndAnInteger: + description: a float with zero fractional part is a number (and an integer) + data: 1.0 + valid: true + AFloatIsANumber: + description: a float is a number + data: 1.1 + valid: true + AStringIsNotANumber: + description: a string is not a number + data: foo + valid: false + AStringIsStillNotANumberEvenIfItLooksLikeOne: + description: a string is still not a number, even if it looks like one + data: '1' + valid: false + AnObjectIsNotANumber: + description: an object is not a number + data: {} + valid: false + AnArrayIsNotANumber: + description: an array is not a number + data: [] + valid: false + ABooleanIsNotANumber: + description: a boolean is not a number + data: true + valid: false + NullIsNotANumber: + description: null is not a number + data: null + valid: false + StringTypeMatchesStrings: + 1IsNotAString: + description: 1 is not a string + data: 1 + valid: false + AFloatIsNotAString: + description: a float is not a string + data: 1.1 + valid: false + AStringIsAString: + description: a string is a string + data: foo + valid: true + AStringIsStillAStringEvenIfItLooksLikeANumber: + description: a string is still a string, even if it looks like a number + data: '1' + valid: true + AnEmptyStringIsStillAString: + description: an empty string is still a string + data: '' + valid: true + AnObjectIsNotAString: + description: an object is not a string + data: {} + valid: false + AnArrayIsNotAString: + description: an array is not a string + data: [] + valid: false + ABooleanIsNotAString: + description: a boolean is not a string + data: true + valid: false + NullIsNotAString: + description: null is not a string + data: null + valid: false + ObjectTypeMatchesObjects: + AnIntegerIsNotAnObject: + description: an integer is not an object + data: 1 + valid: false + AFloatIsNotAnObject: + description: a float is not an object + data: 1.1 + valid: false + AStringIsNotAnObject: + description: a string is not an object + data: foo + valid: false + AnObjectIsAnObject: + description: an object is an object + data: {} + valid: true + AnArrayIsNotAnObject: + description: an array is not an object + data: [] + valid: false + ABooleanIsNotAnObject: + description: a boolean is not an object + data: true + valid: false + NullIsNotAnObject: + description: null is not an object + data: null + valid: false + BooleanTypeMatchesBooleans: + AnIntegerIsNotABoolean: + description: an integer is not a boolean + data: 1 + valid: false + ZeroIsNotABoolean: + description: zero is not a boolean + data: 0 + valid: false + AFloatIsNotABoolean: + description: a float is not a boolean + data: 1.1 + valid: false + AStringIsNotABoolean: + description: a string is not a boolean + data: foo + valid: false + AnEmptyStringIsNotABoolean: + description: an empty string is not a boolean + data: '' + valid: false + AnObjectIsNotABoolean: + description: an object is not a boolean + data: {} + valid: false + AnArrayIsNotABoolean: + description: an array is not a boolean + data: [] + valid: false + TrueIsABoolean: + description: true is a boolean + data: true + valid: true + FalseIsABoolean: + description: false is a boolean + data: false + valid: true + NullIsNotABoolean: + description: null is not a boolean + data: null + valid: false + NullTypeMatchesOnlyTheNullObject: + AnIntegerIsNotNull: + description: an integer is not null + data: 1 + valid: false + AFloatIsNotNull: + description: a float is not null + data: 1.1 + valid: false + ZeroIsNotNull: + description: zero is not null + data: 0 + valid: false + AStringIsNotNull: + description: a string is not null + data: foo + valid: false + AnEmptyStringIsNotNull: + description: an empty string is not null + data: '' + valid: false + AnObjectIsNotNull: + description: an object is not null + data: {} + valid: false + AnArrayIsNotNull: + description: an array is not null + data: [] + valid: false + TrueIsNotNull: + description: true is not null + data: true + valid: false + FalseIsNotNull: + description: false is not null + data: false + valid: false + NullIsNull: + description: null is null + data: null + valid: true + ArrayTypeMatchesArrays: + AnIntegerIsNotAnArray: + description: an integer is not an array + data: 1 + valid: false + AFloatIsNotAnArray: + description: a float is not an array + data: 1.1 + valid: false + AStringIsNotAnArray: + description: a string is not an array + data: foo + valid: false + AnObjectIsNotAnArray: + description: an object is not an array + data: {} + valid: false + AnArrayIsAnArray: + description: an array is an array + data: [] + valid: true + ABooleanIsNotAnArray: + description: a boolean is not an array + data: true + valid: false + NullIsNotAnArray: + description: null is not an array + data: null + valid: false UniqueitemsValidation: UniqueArrayOfIntegersIsValid: description: unique array of integers is valid diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index 92fc510c7ac..e57538afc73 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -74,6 +74,7 @@ class JsonSchemaTestSchema: description: str schema: JsonSchema tests: typing.List[JsonSchemaTestCase] + comment: typing.Optional[str] = None class ExclusionReason: @@ -100,17 +101,14 @@ class ExclusionReason: component_ref_component_bug = 'A component refing another component does not work, issue at https://github.com/OpenAPITools/openapi-generator/issues/12730' not_running_the_localhost_server = 'the openapo-generator is not running the localhost server needed to serve remoteRef files' required_vars_missing_for_anytype_schema_bug = 'fails because of a bug where required vars are forgotten, see issue https://github.com/OpenAPITools/openapi-generator/issues/8906' + v303_requires_that_the_default_value_is_an_allowed_type = 'v3.0.3 requires that the default value is an allowed type per the schema' json_schema_test_draft = 'draft6' openapi_additions = 'openapi_additions' FILEPATH_TO_EXCLUDED_CASE_AND_REASON = { - (json_schema_test_draft, 'type.json'): { - 'multiple types can be specified in an array': ExclusionReason.v303_does_not_support_array_of_types, - 'type as array with one item': ExclusionReason.v303_does_not_support_array_of_types, - 'type: array or object': ExclusionReason.v303_does_not_support_array_of_types, - 'type: array, object or null': ExclusionReason.v303_does_not_support_array_of_types, - 'array type matches arrays': ExclusionReason.v303_requires_array_have_items, + (json_schema_test_draft, 'default.json'): { + 'invalid type for default': ExclusionReason.v303_requires_that_the_default_value_is_an_allowed_type, }, (json_schema_test_draft, 'enum.json'): { 'heterogeneous enum validation': ExclusionReason.swagger_parser_enum_type_bug, @@ -181,6 +179,13 @@ FILEPATH_TO_EXCLUDED_CASE_AND_REASON = { (json_schema_test_draft, 'required.json'): { 'required with escaped characters': ExclusionReason.required_vars_missing_for_anytype_schema_bug, }, + (json_schema_test_draft, 'type.json'): { + 'multiple types can be specified in an array': ExclusionReason.v303_does_not_support_array_of_types, + 'type as array with one item': ExclusionReason.v303_does_not_support_array_of_types, + 'type: array or object': ExclusionReason.v303_does_not_support_array_of_types, + 'type: array, object or null': ExclusionReason.v303_does_not_support_array_of_types, + 'array type matches arrays': ExclusionReason.v303_requires_array_have_items, + }, (json_schema_test_draft, 'uniqueItems.json'): { 'uniqueItems with an array of items': ExclusionReason.v303_does_not_support_items_schema_array, 'uniqueItems=false with an array of items': ExclusionReason.v303_does_not_support_items_schema_array, @@ -200,46 +205,48 @@ FILEPATH_TO_EXCLUDE_REASON = { (json_schema_test_draft, 'id.json'): ExclusionReason.v303_does_not_support_id, (json_schema_test_draft, 'patternProperties.json'): ExclusionReason.v303_does_not_support_patternProperties, (json_schema_test_draft, 'propertyNames.json'): ExclusionReason.v303_does_not_support_propertyNames, + (json_schema_test_draft, 'unknownKeyword.json'): ExclusionReason.v303_does_not_support_definitions, } JSON_SCHEMA_TEST_FILE_TO_FOLDERS = { -# 'additionalItems.json': (json_schema_test_draft,), -# 'additionalProperties.json': (json_schema_test_draft,), + 'additionalItems.json': (json_schema_test_draft,), + 'additionalProperties.json': (json_schema_test_draft,), # 'allOf.json': (json_schema_test_draft,), # activate later after fixing composition processing # 'anyOf.json': (json_schema_test_draft,), # activate later after fixing composition processing -# 'boolean_schema.json': (json_schema_test_draft,), -# 'const.json': (json_schema_test_draft,), -# 'contains.json': (json_schema_test_draft,), -# 'default.json': (json_schema_test_draft,), -# 'definitions.json': (json_schema_test_draft,), -# 'dependencies.json': (json_schema_test_draft,), -# 'enum.json': (json_schema_test_draft,), -# 'exclusiveMaximum.json': (json_schema_test_draft,), -# 'exclusiveMinimum.json': (json_schema_test_draft,), -# 'format.json': (json_schema_test_draft,), -# 'id.json': (json_schema_test_draft,), + 'boolean_schema.json': (json_schema_test_draft,), + 'const.json': (json_schema_test_draft,), + 'contains.json': (json_schema_test_draft,), + 'default.json': (json_schema_test_draft,), + 'definitions.json': (json_schema_test_draft,), + 'dependencies.json': (json_schema_test_draft,), + 'enum.json': (json_schema_test_draft,), + 'exclusiveMaximum.json': (json_schema_test_draft,), + 'exclusiveMinimum.json': (json_schema_test_draft,), + 'format.json': (json_schema_test_draft,), + 'id.json': (json_schema_test_draft,), # 'infinite-loop-detection.json': (json_schema_test_draft,), # activate after fixing this -# 'items.json': (json_schema_test_draft,), -# 'maximum.json': (json_schema_test_draft,), -# 'maxItems.json': (json_schema_test_draft,), -# 'maxLength.json': (json_schema_test_draft,), -# 'maxProperties.json': (json_schema_test_draft,), -# 'minimum.json': (json_schema_test_draft,), -# 'minItems.json': (json_schema_test_draft,), -# 'minLength.json': (json_schema_test_draft,), -# 'minProperties.json': (json_schema_test_draft,), -# 'multipleOf.json': (json_schema_test_draft,), -# 'not.json': (json_schema_test_draft,), + 'items.json': (json_schema_test_draft,), + 'maximum.json': (json_schema_test_draft,), + 'maxItems.json': (json_schema_test_draft,), + 'maxLength.json': (json_schema_test_draft,), + 'maxProperties.json': (json_schema_test_draft,), + 'minimum.json': (json_schema_test_draft,), + 'minItems.json': (json_schema_test_draft,), + 'minLength.json': (json_schema_test_draft,), + 'minProperties.json': (json_schema_test_draft,), + 'multipleOf.json': (json_schema_test_draft,), + 'not.json': (json_schema_test_draft,), # 'oneOf.json': (json_schema_test_draft,), # activate after fixing this -# 'pattern.json': (json_schema_test_draft,), -# 'patternProperties.json': (json_schema_test_draft,), -# 'properties.json': (json_schema_test_draft,), -# 'propertyNames.json': (json_schema_test_draft,), -# 'ref.json': (json_schema_test_draft, openapi_additions), -# 'refRemote.json': (json_schema_test_draft,), -# 'required.json': (json_schema_test_draft,), -# 'type.json': (json_schema_test_draft, openapi_additions), + 'pattern.json': (json_schema_test_draft,), + 'patternProperties.json': (json_schema_test_draft,), + 'properties.json': (json_schema_test_draft,), + 'propertyNames.json': (json_schema_test_draft,), + 'ref.json': (json_schema_test_draft, openapi_additions), + 'refRemote.json': (json_schema_test_draft,), + 'required.json': (json_schema_test_draft,), + 'type.json': (json_schema_test_draft, openapi_additions), 'uniqueItems.json': (json_schema_test_draft,), + 'unknownKeyword.json': (json_schema_test_draft,), } def get_json_schema_test_schemas(file_path: typing.Tuple[str]) -> typing.List[JsonSchemaTestSchema]: diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index fad79331681..3606e2e5cdd 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -2,14 +2,128 @@ .gitlab-ci.yml .travis.yml README.md +docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md +docs/AdditionalpropertiesAreAllowedByDefault.md +docs/AdditionalpropertiesCanExistByItself.md +docs/AdditionalpropertiesShouldNotLookInApplicators.md +docs/ArrayTypeMatchesArrays.md +docs/BooleanTypeMatchesBooleans.md +docs/ByInt.md +docs/ByNumber.md +docs/BySmallNumber.md +docs/DateTimeFormat.md +docs/EmailFormat.md +docs/EnumWith0DoesNotMatchFalse.md +docs/EnumWith1DoesNotMatchTrue.md +docs/EnumWithEscapedCharacters.md +docs/EnumWithFalseDoesNotMatch0.md +docs/EnumWithTrueDoesNotMatch1.md +docs/EnumsInProperties.md +docs/ForbiddenProperty.md +docs/HostnameFormat.md +docs/IntegerTypeMatchesIntegers.md +docs/InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf.md +docs/InvalidStringValueForDefault.md +docs/Ipv4Format.md +docs/Ipv6Format.md +docs/JsonPointerFormat.md +docs/MaximumValidation.md +docs/MaximumValidationWithUnsignedInteger.md +docs/MaxitemsValidation.md +docs/MaxlengthValidation.md +docs/Maxproperties0MeansTheObjectIsEmpty.md +docs/MaxpropertiesValidation.md +docs/MinimumValidation.md +docs/MinimumValidationWithSignedInteger.md +docs/MinitemsValidation.md +docs/MinlengthValidation.md +docs/MinpropertiesValidation.md +docs/ModelNot.md +docs/NestedItems.md +docs/NotMoreComplexSchema.md +docs/NulCharactersInStrings.md +docs/NullTypeMatchesOnlyTheNullObject.md +docs/NumberTypeMatchesNumbers.md +docs/ObjectPropertiesValidation.md +docs/PatternIsNotAnchored.md +docs/PatternValidation.md +docs/PropertiesWithEscapedCharacters.md +docs/PropertyNamedRefThatIsNotAReference.md +docs/RequiredDefaultValidation.md +docs/RequiredValidation.md +docs/RequiredWithEmptyArray.md +docs/SimpleEnumValidation.md +docs/StringTypeMatchesStrings.md +docs/TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md docs/UniqueitemsFalseValidation.md docs/UniqueitemsValidation.md +docs/UriFormat.md +docs/UriReferenceFormat.md +docs/UriTemplateFormat.md git_push.sh requirements.txt setup.cfg setup.py test-requirements.txt test/__init__.py +test/test_additionalproperties_allows_a_schema_which_should_validate.py +test/test_additionalproperties_are_allowed_by_default.py +test/test_additionalproperties_can_exist_by_itself.py +test/test_additionalproperties_should_not_look_in_applicators.py +test/test_array_type_matches_arrays.py +test/test_boolean_type_matches_booleans.py +test/test_by_int.py +test/test_by_number.py +test/test_by_small_number.py +test/test_date_time_format.py +test/test_email_format.py +test/test_enum_with0_does_not_match_false.py +test/test_enum_with1_does_not_match_true.py +test/test_enum_with_escaped_characters.py +test/test_enum_with_false_does_not_match0.py +test/test_enum_with_true_does_not_match1.py +test/test_enums_in_properties.py +test/test_forbidden_property.py +test/test_hostname_format.py +test/test_integer_type_matches_integers.py +test/test_invalid_instance_should_not_raise_error_when_float_division_inf.py +test/test_invalid_string_value_for_default.py +test/test_ipv4_format.py +test/test_ipv6_format.py +test/test_json_pointer_format.py +test/test_maximum_validation.py +test/test_maximum_validation_with_unsigned_integer.py +test/test_maxitems_validation.py +test/test_maxlength_validation.py +test/test_maxproperties0_means_the_object_is_empty.py +test/test_maxproperties_validation.py +test/test_minimum_validation.py +test/test_minimum_validation_with_signed_integer.py +test/test_minitems_validation.py +test/test_minlength_validation.py +test/test_minproperties_validation.py +test/test_model_not.py +test/test_nested_items.py +test/test_not_more_complex_schema.py +test/test_nul_characters_in_strings.py +test/test_null_type_matches_only_the_null_object.py +test/test_number_type_matches_numbers.py +test/test_object_properties_validation.py +test/test_pattern_is_not_anchored.py +test/test_pattern_validation.py +test/test_properties_with_escaped_characters.py +test/test_property_named_ref_that_is_not_a_reference.py +test/test_required_default_validation.py +test/test_required_validation.py +test/test_required_with_empty_array.py +test/test_simple_enum_validation.py +test/test_string_type_matches_strings.py +test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py +test/test_uniqueitems_false_validation.py +test/test_uniqueitems_validation.py +test/test_uri_format.py +test/test_uri_reference_format.py +test/test_uri_template_format.py tox.ini unit_test_api/__init__.py unit_test_api/api/__init__.py @@ -18,8 +132,64 @@ unit_test_api/apis/__init__.py unit_test_api/configuration.py unit_test_api/exceptions.py unit_test_api/model/__init__.py +unit_test_api/model/additionalproperties_allows_a_schema_which_should_validate.py +unit_test_api/model/additionalproperties_are_allowed_by_default.py +unit_test_api/model/additionalproperties_can_exist_by_itself.py +unit_test_api/model/additionalproperties_should_not_look_in_applicators.py +unit_test_api/model/array_type_matches_arrays.py +unit_test_api/model/boolean_type_matches_booleans.py +unit_test_api/model/by_int.py +unit_test_api/model/by_number.py +unit_test_api/model/by_small_number.py +unit_test_api/model/date_time_format.py +unit_test_api/model/email_format.py +unit_test_api/model/enum_with0_does_not_match_false.py +unit_test_api/model/enum_with1_does_not_match_true.py +unit_test_api/model/enum_with_escaped_characters.py +unit_test_api/model/enum_with_false_does_not_match0.py +unit_test_api/model/enum_with_true_does_not_match1.py +unit_test_api/model/enums_in_properties.py +unit_test_api/model/forbidden_property.py +unit_test_api/model/hostname_format.py +unit_test_api/model/integer_type_matches_integers.py +unit_test_api/model/invalid_instance_should_not_raise_error_when_float_division_inf.py +unit_test_api/model/invalid_string_value_for_default.py +unit_test_api/model/ipv4_format.py +unit_test_api/model/ipv6_format.py +unit_test_api/model/json_pointer_format.py +unit_test_api/model/maximum_validation.py +unit_test_api/model/maximum_validation_with_unsigned_integer.py +unit_test_api/model/maxitems_validation.py +unit_test_api/model/maxlength_validation.py +unit_test_api/model/maxproperties0_means_the_object_is_empty.py +unit_test_api/model/maxproperties_validation.py +unit_test_api/model/minimum_validation.py +unit_test_api/model/minimum_validation_with_signed_integer.py +unit_test_api/model/minitems_validation.py +unit_test_api/model/minlength_validation.py +unit_test_api/model/minproperties_validation.py +unit_test_api/model/model_not.py +unit_test_api/model/nested_items.py +unit_test_api/model/not_more_complex_schema.py +unit_test_api/model/nul_characters_in_strings.py +unit_test_api/model/null_type_matches_only_the_null_object.py +unit_test_api/model/number_type_matches_numbers.py +unit_test_api/model/object_properties_validation.py +unit_test_api/model/pattern_is_not_anchored.py +unit_test_api/model/pattern_validation.py +unit_test_api/model/properties_with_escaped_characters.py +unit_test_api/model/property_named_ref_that_is_not_a_reference.py +unit_test_api/model/required_default_validation.py +unit_test_api/model/required_validation.py +unit_test_api/model/required_with_empty_array.py +unit_test_api/model/simple_enum_validation.py +unit_test_api/model/string_type_matches_strings.py +unit_test_api/model/the_default_keyword_does_not_do_anything_if_the_property_is_missing.py unit_test_api/model/uniqueitems_false_validation.py unit_test_api/model/uniqueitems_validation.py +unit_test_api/model/uri_format.py +unit_test_api/model/uri_reference_format.py +unit_test_api/model/uri_template_format.py unit_test_api/models/__init__.py unit_test_api/rest.py unit_test_api/schemas.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md index f9c665e5b7b..ce2ca8dc8c2 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md @@ -62,8 +62,64 @@ Class | Method | HTTP request | Description ## Documentation For Models + - [AdditionalpropertiesAllowsASchemaWhichShouldValidate](docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md) + - [AdditionalpropertiesAreAllowedByDefault](docs/AdditionalpropertiesAreAllowedByDefault.md) + - [AdditionalpropertiesCanExistByItself](docs/AdditionalpropertiesCanExistByItself.md) + - [AdditionalpropertiesShouldNotLookInApplicators](docs/AdditionalpropertiesShouldNotLookInApplicators.md) + - [ArrayTypeMatchesArrays](docs/ArrayTypeMatchesArrays.md) + - [BooleanTypeMatchesBooleans](docs/BooleanTypeMatchesBooleans.md) + - [ByInt](docs/ByInt.md) + - [ByNumber](docs/ByNumber.md) + - [BySmallNumber](docs/BySmallNumber.md) + - [DateTimeFormat](docs/DateTimeFormat.md) + - [EmailFormat](docs/EmailFormat.md) + - [EnumWith0DoesNotMatchFalse](docs/EnumWith0DoesNotMatchFalse.md) + - [EnumWith1DoesNotMatchTrue](docs/EnumWith1DoesNotMatchTrue.md) + - [EnumWithEscapedCharacters](docs/EnumWithEscapedCharacters.md) + - [EnumWithFalseDoesNotMatch0](docs/EnumWithFalseDoesNotMatch0.md) + - [EnumWithTrueDoesNotMatch1](docs/EnumWithTrueDoesNotMatch1.md) + - [EnumsInProperties](docs/EnumsInProperties.md) + - [ForbiddenProperty](docs/ForbiddenProperty.md) + - [HostnameFormat](docs/HostnameFormat.md) + - [IntegerTypeMatchesIntegers](docs/IntegerTypeMatchesIntegers.md) + - [InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf](docs/InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf.md) + - [InvalidStringValueForDefault](docs/InvalidStringValueForDefault.md) + - [Ipv4Format](docs/Ipv4Format.md) + - [Ipv6Format](docs/Ipv6Format.md) + - [JsonPointerFormat](docs/JsonPointerFormat.md) + - [MaximumValidation](docs/MaximumValidation.md) + - [MaximumValidationWithUnsignedInteger](docs/MaximumValidationWithUnsignedInteger.md) + - [MaxitemsValidation](docs/MaxitemsValidation.md) + - [MaxlengthValidation](docs/MaxlengthValidation.md) + - [Maxproperties0MeansTheObjectIsEmpty](docs/Maxproperties0MeansTheObjectIsEmpty.md) + - [MaxpropertiesValidation](docs/MaxpropertiesValidation.md) + - [MinimumValidation](docs/MinimumValidation.md) + - [MinimumValidationWithSignedInteger](docs/MinimumValidationWithSignedInteger.md) + - [MinitemsValidation](docs/MinitemsValidation.md) + - [MinlengthValidation](docs/MinlengthValidation.md) + - [MinpropertiesValidation](docs/MinpropertiesValidation.md) + - [ModelNot](docs/ModelNot.md) + - [NestedItems](docs/NestedItems.md) + - [NotMoreComplexSchema](docs/NotMoreComplexSchema.md) + - [NulCharactersInStrings](docs/NulCharactersInStrings.md) + - [NullTypeMatchesOnlyTheNullObject](docs/NullTypeMatchesOnlyTheNullObject.md) + - [NumberTypeMatchesNumbers](docs/NumberTypeMatchesNumbers.md) + - [ObjectPropertiesValidation](docs/ObjectPropertiesValidation.md) + - [PatternIsNotAnchored](docs/PatternIsNotAnchored.md) + - [PatternValidation](docs/PatternValidation.md) + - [PropertiesWithEscapedCharacters](docs/PropertiesWithEscapedCharacters.md) + - [PropertyNamedRefThatIsNotAReference](docs/PropertyNamedRefThatIsNotAReference.md) + - [RequiredDefaultValidation](docs/RequiredDefaultValidation.md) + - [RequiredValidation](docs/RequiredValidation.md) + - [RequiredWithEmptyArray](docs/RequiredWithEmptyArray.md) + - [SimpleEnumValidation](docs/SimpleEnumValidation.md) + - [StringTypeMatchesStrings](docs/StringTypeMatchesStrings.md) + - [TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing](docs/TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md) - [UniqueitemsFalseValidation](docs/UniqueitemsFalseValidation.md) - [UniqueitemsValidation](docs/UniqueitemsValidation.md) + - [UriFormat](docs/UriFormat.md) + - [UriReferenceFormat](docs/UriReferenceFormat.md) + - [UriTemplateFormat](docs/UriTemplateFormat.md) ## Documentation For Authorization diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md new file mode 100644 index 00000000000..d9981bf45a7 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md @@ -0,0 +1,11 @@ +# AdditionalpropertiesAllowsASchemaWhichShouldValidate + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**foo** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] +**bar** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] +**any string name** | **bool** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAreAllowedByDefault.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAreAllowedByDefault.md new file mode 100644 index 00000000000..d5e7d2747ee --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesAreAllowedByDefault.md @@ -0,0 +1,11 @@ +# AdditionalpropertiesAreAllowedByDefault + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**foo** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] +**bar** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesCanExistByItself.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesCanExistByItself.md new file mode 100644 index 00000000000..72b091b888a --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesCanExistByItself.md @@ -0,0 +1,9 @@ +# AdditionalpropertiesCanExistByItself + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesShouldNotLookInApplicators.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesShouldNotLookInApplicators.md new file mode 100644 index 00000000000..31efeb974b1 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/AdditionalpropertiesShouldNotLookInApplicators.md @@ -0,0 +1,9 @@ +# AdditionalpropertiesShouldNotLookInApplicators + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ArrayTypeMatchesArrays.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ArrayTypeMatchesArrays.md new file mode 100644 index 00000000000..bf72f2c35bc --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ArrayTypeMatchesArrays.md @@ -0,0 +1,8 @@ +# ArrayTypeMatchesArrays + +Type | Description | Notes +------------- | ------------- | ------------- +**[bool, date, datetime, dict, float, int, list, str, none_type]** | | + +[[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/3_0_3_unit_test/python-experimental/docs/BooleanTypeMatchesBooleans.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/BooleanTypeMatchesBooleans.md new file mode 100644 index 00000000000..fa68a60fd2b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/BooleanTypeMatchesBooleans.md @@ -0,0 +1,8 @@ +# BooleanTypeMatchesBooleans + +Type | Description | Notes +------------- | ------------- | ------------- +**bool** | | + +[[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/3_0_3_unit_test/python-experimental/docs/ByInt.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ByInt.md new file mode 100644 index 00000000000..7e089ed79bb --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ByInt.md @@ -0,0 +1,9 @@ +# ByInt + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ByNumber.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ByNumber.md new file mode 100644 index 00000000000..8c272d66b6d --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ByNumber.md @@ -0,0 +1,9 @@ +# ByNumber + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/BySmallNumber.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/BySmallNumber.md new file mode 100644 index 00000000000..3671c33f9c9 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/BySmallNumber.md @@ -0,0 +1,9 @@ +# BySmallNumber + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/DateTimeFormat.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/DateTimeFormat.md new file mode 100644 index 00000000000..308c3ad9e35 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/DateTimeFormat.md @@ -0,0 +1,9 @@ +# DateTimeFormat + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EmailFormat.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EmailFormat.md new file mode 100644 index 00000000000..25144b9cf41 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EmailFormat.md @@ -0,0 +1,9 @@ +# EmailFormat + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWith0DoesNotMatchFalse.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWith0DoesNotMatchFalse.md new file mode 100644 index 00000000000..d5a6a187010 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWith0DoesNotMatchFalse.md @@ -0,0 +1,8 @@ +# EnumWith0DoesNotMatchFalse + +Type | Description | Notes +------------- | ------------- | ------------- +**float** | | must be one of [0, ] + +[[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/3_0_3_unit_test/python-experimental/docs/EnumWith1DoesNotMatchTrue.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWith1DoesNotMatchTrue.md new file mode 100644 index 00000000000..302b358dc61 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWith1DoesNotMatchTrue.md @@ -0,0 +1,8 @@ +# EnumWith1DoesNotMatchTrue + +Type | Description | Notes +------------- | ------------- | ------------- +**float** | | must be one of [1, ] + +[[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/3_0_3_unit_test/python-experimental/docs/EnumWithEscapedCharacters.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithEscapedCharacters.md new file mode 100644 index 00000000000..d13b6ca704f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithEscapedCharacters.md @@ -0,0 +1,9 @@ +# EnumWithEscapedCharacters + +Type | Description | Notes +------------- | ------------- | ------------- +**str** | | must be one of ['''foo +bar''', '''foo bar''', ] + +[[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/3_0_3_unit_test/python-experimental/docs/EnumWithFalseDoesNotMatch0.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithFalseDoesNotMatch0.md new file mode 100644 index 00000000000..f1cef961444 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithFalseDoesNotMatch0.md @@ -0,0 +1,8 @@ +# EnumWithFalseDoesNotMatch0 + +Type | Description | Notes +------------- | ------------- | ------------- +**bool** | | must be one of [False, ] + +[[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/3_0_3_unit_test/python-experimental/docs/EnumWithTrueDoesNotMatch1.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithTrueDoesNotMatch1.md new file mode 100644 index 00000000000..09723bcb68c --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithTrueDoesNotMatch1.md @@ -0,0 +1,8 @@ +# EnumWithTrueDoesNotMatch1 + +Type | Description | Notes +------------- | ------------- | ------------- +**bool** | | must be one of [True, ] + +[[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/3_0_3_unit_test/python-experimental/docs/EnumsInProperties.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumsInProperties.md new file mode 100644 index 00000000000..7b058dabb44 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumsInProperties.md @@ -0,0 +1,11 @@ +# EnumsInProperties + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**foo** | **str** | | [optional] +**bar** | **str** | | +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ForbiddenProperty.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ForbiddenProperty.md new file mode 100644 index 00000000000..acb9f23b22f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ForbiddenProperty.md @@ -0,0 +1,10 @@ +# ForbiddenProperty + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**foo** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/HostnameFormat.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/HostnameFormat.md new file mode 100644 index 00000000000..abe7728baa5 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/HostnameFormat.md @@ -0,0 +1,9 @@ +# HostnameFormat + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/IntegerTypeMatchesIntegers.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/IntegerTypeMatchesIntegers.md new file mode 100644 index 00000000000..141e17fd9ae --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/IntegerTypeMatchesIntegers.md @@ -0,0 +1,8 @@ +# IntegerTypeMatchesIntegers + +Type | Description | Notes +------------- | ------------- | ------------- +**int** | | + +[[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/3_0_3_unit_test/python-experimental/docs/InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf.md new file mode 100644 index 00000000000..9acc3f6353a --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf.md @@ -0,0 +1,8 @@ +# InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf + +Type | Description | Notes +------------- | ------------- | ------------- +**int** | | + +[[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/3_0_3_unit_test/python-experimental/docs/InvalidStringValueForDefault.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidStringValueForDefault.md new file mode 100644 index 00000000000..ae129438132 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/InvalidStringValueForDefault.md @@ -0,0 +1,10 @@ +# InvalidStringValueForDefault + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**bar** | **str** | | [optional] if omitted the server will use the default value of "bad" +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Ipv4Format.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Ipv4Format.md new file mode 100644 index 00000000000..545514e2b80 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Ipv4Format.md @@ -0,0 +1,9 @@ +# Ipv4Format + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Ipv6Format.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Ipv6Format.md new file mode 100644 index 00000000000..84f13f968ad --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Ipv6Format.md @@ -0,0 +1,9 @@ +# Ipv6Format + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/JsonPointerFormat.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/JsonPointerFormat.md new file mode 100644 index 00000000000..be35740ae68 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/JsonPointerFormat.md @@ -0,0 +1,9 @@ +# JsonPointerFormat + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaximumValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaximumValidation.md new file mode 100644 index 00000000000..2060e3a0d40 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaximumValidation.md @@ -0,0 +1,9 @@ +# MaximumValidation + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaximumValidationWithUnsignedInteger.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaximumValidationWithUnsignedInteger.md new file mode 100644 index 00000000000..9a20b4b7bc9 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaximumValidationWithUnsignedInteger.md @@ -0,0 +1,9 @@ +# MaximumValidationWithUnsignedInteger + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxitemsValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxitemsValidation.md new file mode 100644 index 00000000000..8c60872ae01 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxitemsValidation.md @@ -0,0 +1,9 @@ +# MaxitemsValidation + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxlengthValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxlengthValidation.md new file mode 100644 index 00000000000..0f9d27bd44f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxlengthValidation.md @@ -0,0 +1,9 @@ +# MaxlengthValidation + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Maxproperties0MeansTheObjectIsEmpty.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Maxproperties0MeansTheObjectIsEmpty.md new file mode 100644 index 00000000000..ed97994d653 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/Maxproperties0MeansTheObjectIsEmpty.md @@ -0,0 +1,9 @@ +# Maxproperties0MeansTheObjectIsEmpty + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxpropertiesValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxpropertiesValidation.md new file mode 100644 index 00000000000..d92c1f77f9c --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MaxpropertiesValidation.md @@ -0,0 +1,9 @@ +# MaxpropertiesValidation + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinimumValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinimumValidation.md new file mode 100644 index 00000000000..0a787d59fe5 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinimumValidation.md @@ -0,0 +1,9 @@ +# MinimumValidation + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinimumValidationWithSignedInteger.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinimumValidationWithSignedInteger.md new file mode 100644 index 00000000000..e43ddb81712 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinimumValidationWithSignedInteger.md @@ -0,0 +1,9 @@ +# MinimumValidationWithSignedInteger + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinitemsValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinitemsValidation.md new file mode 100644 index 00000000000..14e1884d056 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinitemsValidation.md @@ -0,0 +1,9 @@ +# MinitemsValidation + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinlengthValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinlengthValidation.md new file mode 100644 index 00000000000..c914c02f01b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinlengthValidation.md @@ -0,0 +1,9 @@ +# MinlengthValidation + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinpropertiesValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinpropertiesValidation.md new file mode 100644 index 00000000000..b549f694557 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/MinpropertiesValidation.md @@ -0,0 +1,9 @@ +# MinpropertiesValidation + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ModelNot.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ModelNot.md new file mode 100644 index 00000000000..bac67e76808 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ModelNot.md @@ -0,0 +1,9 @@ +# ModelNot + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedItems.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedItems.md new file mode 100644 index 00000000000..c64b37b1669 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NestedItems.md @@ -0,0 +1,8 @@ +# NestedItems + +Type | Description | Notes +------------- | ------------- | ------------- +**[[[[int, float]]]]** | | + +[[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/3_0_3_unit_test/python-experimental/docs/NotMoreComplexSchema.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NotMoreComplexSchema.md new file mode 100644 index 00000000000..2ea5b209ccd --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NotMoreComplexSchema.md @@ -0,0 +1,9 @@ +# NotMoreComplexSchema + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NulCharactersInStrings.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NulCharactersInStrings.md new file mode 100644 index 00000000000..d90b761591a --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NulCharactersInStrings.md @@ -0,0 +1,8 @@ +# NulCharactersInStrings + +Type | Description | Notes +------------- | ------------- | ------------- +**str** | | must be one of ["hello\x00there", ] + +[[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/3_0_3_unit_test/python-experimental/docs/NullTypeMatchesOnlyTheNullObject.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NullTypeMatchesOnlyTheNullObject.md new file mode 100644 index 00000000000..54a530d1d33 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NullTypeMatchesOnlyTheNullObject.md @@ -0,0 +1,8 @@ +# NullTypeMatchesOnlyTheNullObject + +Type | Description | Notes +------------- | ------------- | ------------- +**none_type** | | + +[[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/3_0_3_unit_test/python-experimental/docs/NumberTypeMatchesNumbers.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NumberTypeMatchesNumbers.md new file mode 100644 index 00000000000..8348aeef2bc --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/NumberTypeMatchesNumbers.md @@ -0,0 +1,8 @@ +# NumberTypeMatchesNumbers + +Type | Description | Notes +------------- | ------------- | ------------- +**float** | | + +[[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/3_0_3_unit_test/python-experimental/docs/ObjectPropertiesValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ObjectPropertiesValidation.md new file mode 100644 index 00000000000..9307469f5bb --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/ObjectPropertiesValidation.md @@ -0,0 +1,11 @@ +# ObjectPropertiesValidation + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**foo** | **int** | | [optional] +**bar** | **str** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PatternIsNotAnchored.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PatternIsNotAnchored.md new file mode 100644 index 00000000000..bca3d004ba4 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PatternIsNotAnchored.md @@ -0,0 +1,9 @@ +# PatternIsNotAnchored + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PatternValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PatternValidation.md new file mode 100644 index 00000000000..ed358b81563 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PatternValidation.md @@ -0,0 +1,9 @@ +# PatternValidation + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PropertiesWithEscapedCharacters.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PropertiesWithEscapedCharacters.md new file mode 100644 index 00000000000..e585f0e8e14 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PropertiesWithEscapedCharacters.md @@ -0,0 +1,15 @@ +# PropertiesWithEscapedCharacters + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**foo\nbar** | **int, float** | | [optional] +**foo\"bar** | **int, float** | | [optional] +**foo\\bar** | **int, float** | | [optional] +**foo\rbar** | **int, float** | | [optional] +**foo\tbar** | **int, float** | | [optional] +**foo\fbar** | **int, float** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PropertyNamedRefThatIsNotAReference.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PropertyNamedRefThatIsNotAReference.md new file mode 100644 index 00000000000..7f51dc33bb9 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/PropertyNamedRefThatIsNotAReference.md @@ -0,0 +1,10 @@ +# PropertyNamedRefThatIsNotAReference + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**$ref** | **str** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredDefaultValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredDefaultValidation.md new file mode 100644 index 00000000000..46c719866d7 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredDefaultValidation.md @@ -0,0 +1,10 @@ +# RequiredDefaultValidation + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**foo** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredValidation.md new file mode 100644 index 00000000000..31ab7e70c48 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredValidation.md @@ -0,0 +1,11 @@ +# RequiredValidation + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**foo** | **bool, date, datetime, dict, float, int, list, str, none_type** | | +**bar** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredWithEmptyArray.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredWithEmptyArray.md new file mode 100644 index 00000000000..c243bc4b3d2 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RequiredWithEmptyArray.md @@ -0,0 +1,10 @@ +# RequiredWithEmptyArray + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**foo** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/SimpleEnumValidation.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/SimpleEnumValidation.md new file mode 100644 index 00000000000..81e6b4f5e6c --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/SimpleEnumValidation.md @@ -0,0 +1,8 @@ +# SimpleEnumValidation + +Type | Description | Notes +------------- | ------------- | ------------- +**float** | | must be one of [1, 2, 3, ] + +[[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/3_0_3_unit_test/python-experimental/docs/StringTypeMatchesStrings.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/StringTypeMatchesStrings.md new file mode 100644 index 00000000000..cd1125671ab --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/StringTypeMatchesStrings.md @@ -0,0 +1,8 @@ +# StringTypeMatchesStrings + +Type | Description | Notes +------------- | ------------- | ------------- +**str** | | + +[[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/3_0_3_unit_test/python-experimental/docs/TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md new file mode 100644 index 00000000000..61162c71aa0 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md @@ -0,0 +1,10 @@ +# TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**alpha** | **int, float** | | [optional] if omitted the server will use the default value of 5 +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/UriFormat.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/UriFormat.md new file mode 100644 index 00000000000..45565b815dc --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/UriFormat.md @@ -0,0 +1,9 @@ +# UriFormat + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/UriReferenceFormat.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/UriReferenceFormat.md new file mode 100644 index 00000000000..5e3d85e8fda --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/UriReferenceFormat.md @@ -0,0 +1,9 @@ +# UriReferenceFormat + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/UriTemplateFormat.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/UriTemplateFormat.md new file mode 100644 index 00000000000..5b661945b3e --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/UriTemplateFormat.md @@ -0,0 +1,9 @@ +# UriTemplateFormat + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py new file mode 100644 index 00000000000..994760b620c --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py @@ -0,0 +1,75 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.additionalproperties_allows_a_schema_which_should_validate import AdditionalpropertiesAllowsASchemaWhichShouldValidate +from unit_test_api import configuration + + +class TestAdditionalpropertiesAllowsASchemaWhichShouldValidate(unittest.TestCase): + """AdditionalpropertiesAllowsASchemaWhichShouldValidate unit test stubs""" + _configuration = configuration.Configuration() + + def test_no_additional_properties_is_valid_passes(self): + # no additional properties is valid + AdditionalpropertiesAllowsASchemaWhichShouldValidate._from_openapi_data( + { + + "foo": + 1, + } +, + _configuration=self._configuration + ) + + def test_an_additional_invalid_property_is_invalid_fails(self): + # an additional invalid property is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + AdditionalpropertiesAllowsASchemaWhichShouldValidate._from_openapi_data( + { + + "foo": + 1, + + "bar": + 2, + + "quux": + 12, + } +, + _configuration=self._configuration + ) + + def test_an_additional_valid_property_is_valid_passes(self): + # an additional valid property is valid + AdditionalpropertiesAllowsASchemaWhichShouldValidate._from_openapi_data( + { + + "foo": + 1, + + "bar": + 2, + + "quux": + + True, + } +, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py new file mode 100644 index 00000000000..483dbd4372b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py @@ -0,0 +1,44 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.additionalproperties_are_allowed_by_default import AdditionalpropertiesAreAllowedByDefault +from unit_test_api import configuration + + +class TestAdditionalpropertiesAreAllowedByDefault(unittest.TestCase): + """AdditionalpropertiesAreAllowedByDefault unit test stubs""" + _configuration = configuration.Configuration() + + def test_additional_properties_are_allowed_passes(self): + # additional properties are allowed + AdditionalpropertiesAreAllowedByDefault._from_openapi_data( + { + + "foo": + 1, + + "bar": + 2, + + "quux": + + True, + } +, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py new file mode 100644 index 00000000000..e22296dc29e --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py @@ -0,0 +1,51 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.additionalproperties_can_exist_by_itself import AdditionalpropertiesCanExistByItself +from unit_test_api import configuration + + +class TestAdditionalpropertiesCanExistByItself(unittest.TestCase): + """AdditionalpropertiesCanExistByItself unit test stubs""" + _configuration = configuration.Configuration() + + def test_an_additional_invalid_property_is_invalid_fails(self): + # an additional invalid property is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + AdditionalpropertiesCanExistByItself._from_openapi_data( + { + + "foo": + 1, + } +, + _configuration=self._configuration + ) + + def test_an_additional_valid_property_is_valid_passes(self): + # an additional valid property is valid + AdditionalpropertiesCanExistByItself._from_openapi_data( + { + + "foo": + + True, + } +, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py new file mode 100644 index 00000000000..f39cd8294b3 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py @@ -0,0 +1,42 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.additionalproperties_should_not_look_in_applicators import AdditionalpropertiesShouldNotLookInApplicators +from unit_test_api import configuration + + +class TestAdditionalpropertiesShouldNotLookInApplicators(unittest.TestCase): + """AdditionalpropertiesShouldNotLookInApplicators unit test stubs""" + _configuration = configuration.Configuration() + + def test_properties_defined_in_allof_are_not_examined_fails(self): + # properties defined in allOf are not examined + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + AdditionalpropertiesShouldNotLookInApplicators._from_openapi_data( + { + + "foo": + 1, + + "bar": + + True, + } +, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py new file mode 100644 index 00000000000..c41228c3dc7 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py @@ -0,0 +1,87 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.array_type_matches_arrays import ArrayTypeMatchesArrays +from unit_test_api import configuration + + +class TestArrayTypeMatchesArrays(unittest.TestCase): + """ArrayTypeMatchesArrays unit test stubs""" + _configuration = configuration.Configuration() + + def test_a_float_is_not_an_array_fails(self): + # a float is not an array + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + ArrayTypeMatchesArrays._from_openapi_data( + 1.1, + _configuration=self._configuration + ) + + def test_a_boolean_is_not_an_array_fails(self): + # a boolean is not an array + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + ArrayTypeMatchesArrays._from_openapi_data( + + True, + _configuration=self._configuration + ) + + def test_null_is_not_an_array_fails(self): + # null is not an array + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + ArrayTypeMatchesArrays._from_openapi_data( + + None, + _configuration=self._configuration + ) + + def test_an_object_is_not_an_array_fails(self): + # an object is not an array + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + ArrayTypeMatchesArrays._from_openapi_data( + { + } +, + _configuration=self._configuration + ) + + def test_a_string_is_not_an_array_fails(self): + # a string is not an array + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + ArrayTypeMatchesArrays._from_openapi_data( + + "foo", + _configuration=self._configuration + ) + + def test_an_array_is_an_array_passes(self): + # an array is an array + ArrayTypeMatchesArrays._from_openapi_data( + [ + ] +, + _configuration=self._configuration + ) + + def test_an_integer_is_not_an_array_fails(self): + # an integer is not an array + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + ArrayTypeMatchesArrays._from_openapi_data( + 1, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py new file mode 100644 index 00000000000..205e7803b3d --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py @@ -0,0 +1,112 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.boolean_type_matches_booleans import BooleanTypeMatchesBooleans +from unit_test_api import configuration + + +class TestBooleanTypeMatchesBooleans(unittest.TestCase): + """BooleanTypeMatchesBooleans unit test stubs""" + _configuration = configuration.Configuration() + + def test_an_empty_string_is_not_a_boolean_fails(self): + # an empty string is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + BooleanTypeMatchesBooleans._from_openapi_data( + + "", + _configuration=self._configuration + ) + + def test_a_float_is_not_a_boolean_fails(self): + # a float is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + BooleanTypeMatchesBooleans._from_openapi_data( + 1.1, + _configuration=self._configuration + ) + + def test_null_is_not_a_boolean_fails(self): + # null is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + BooleanTypeMatchesBooleans._from_openapi_data( + + None, + _configuration=self._configuration + ) + + def test_zero_is_not_a_boolean_fails(self): + # zero is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + BooleanTypeMatchesBooleans._from_openapi_data( + 0, + _configuration=self._configuration + ) + + def test_an_array_is_not_a_boolean_fails(self): + # an array is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + BooleanTypeMatchesBooleans._from_openapi_data( + [ + ] +, + _configuration=self._configuration + ) + + def test_a_string_is_not_a_boolean_fails(self): + # a string is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + BooleanTypeMatchesBooleans._from_openapi_data( + + "foo", + _configuration=self._configuration + ) + + def test_false_is_a_boolean_passes(self): + # false is a boolean + BooleanTypeMatchesBooleans._from_openapi_data( + + False, + _configuration=self._configuration + ) + + def test_an_integer_is_not_a_boolean_fails(self): + # an integer is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + BooleanTypeMatchesBooleans._from_openapi_data( + 1, + _configuration=self._configuration + ) + + def test_true_is_a_boolean_passes(self): + # true is a boolean + BooleanTypeMatchesBooleans._from_openapi_data( + + True, + _configuration=self._configuration + ) + + def test_an_object_is_not_a_boolean_fails(self): + # an object is not a boolean + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + BooleanTypeMatchesBooleans._from_openapi_data( + { + } +, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_int.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_int.py new file mode 100644 index 00000000000..9efc39152bd --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_int.py @@ -0,0 +1,48 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.by_int import ByInt +from unit_test_api import configuration + + +class TestByInt(unittest.TestCase): + """ByInt unit test stubs""" + _configuration = configuration.Configuration() + + def test_int_by_int_fail_fails(self): + # int by int fail + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + ByInt._from_openapi_data( + 7, + _configuration=self._configuration + ) + + def test_int_by_int_passes(self): + # int by int + ByInt._from_openapi_data( + 10, + _configuration=self._configuration + ) + + def test_ignores_non_numbers_passes(self): + # ignores non-numbers + ByInt._from_openapi_data( + + "foo", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_number.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_number.py new file mode 100644 index 00000000000..af5e0d80911 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_number.py @@ -0,0 +1,47 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.by_number import ByNumber +from unit_test_api import configuration + + +class TestByNumber(unittest.TestCase): + """ByNumber unit test stubs""" + _configuration = configuration.Configuration() + + def test_45_is_multiple_of15_passes(self): + # 4.5 is multiple of 1.5 + ByNumber._from_openapi_data( + 4.5, + _configuration=self._configuration + ) + + def test_35_is_not_multiple_of15_fails(self): + # 35 is not multiple of 1.5 + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + ByNumber._from_openapi_data( + 35, + _configuration=self._configuration + ) + + def test_zero_is_multiple_of_anything_passes(self): + # zero is multiple of anything + ByNumber._from_openapi_data( + 0, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_small_number.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_small_number.py new file mode 100644 index 00000000000..1c89fab3167 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_small_number.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.by_small_number import BySmallNumber +from unit_test_api import configuration + + +class TestBySmallNumber(unittest.TestCase): + """BySmallNumber unit test stubs""" + _configuration = configuration.Configuration() + + def test_000751_is_not_multiple_of00001_fails(self): + # 0.00751 is not multiple of 0.0001 + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + BySmallNumber._from_openapi_data( + 0.00751, + _configuration=self._configuration + ) + + def test_00075_is_multiple_of00001_passes(self): + # 0.0075 is multiple of 0.0001 + BySmallNumber._from_openapi_data( + 0.0075, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_date_time_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_date_time_format.py new file mode 100644 index 00000000000..c78c16d7f38 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_date_time_format.py @@ -0,0 +1,73 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.date_time_format import DateTimeFormat +from unit_test_api import configuration + + +class TestDateTimeFormat(unittest.TestCase): + """DateTimeFormat unit test stubs""" + _configuration = configuration.Configuration() + + def test_all_string_formats_ignore_objects_passes(self): + # all string formats ignore objects + DateTimeFormat._from_openapi_data( + { + } +, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_booleans_passes(self): + # all string formats ignore booleans + DateTimeFormat._from_openapi_data( + + False, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_integers_passes(self): + # all string formats ignore integers + DateTimeFormat._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_floats_passes(self): + # all string formats ignore floats + DateTimeFormat._from_openapi_data( + 13.7, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_arrays_passes(self): + # all string formats ignore arrays + DateTimeFormat._from_openapi_data( + [ + ] +, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_nulls_passes(self): + # all string formats ignore nulls + DateTimeFormat._from_openapi_data( + + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_email_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_email_format.py new file mode 100644 index 00000000000..4011d06bc9e --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_email_format.py @@ -0,0 +1,73 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.email_format import EmailFormat +from unit_test_api import configuration + + +class TestEmailFormat(unittest.TestCase): + """EmailFormat unit test stubs""" + _configuration = configuration.Configuration() + + def test_all_string_formats_ignore_objects_passes(self): + # all string formats ignore objects + EmailFormat._from_openapi_data( + { + } +, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_booleans_passes(self): + # all string formats ignore booleans + EmailFormat._from_openapi_data( + + False, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_integers_passes(self): + # all string formats ignore integers + EmailFormat._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_floats_passes(self): + # all string formats ignore floats + EmailFormat._from_openapi_data( + 13.7, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_arrays_passes(self): + # all string formats ignore arrays + EmailFormat._from_openapi_data( + [ + ] +, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_nulls_passes(self): + # all string formats ignore nulls + EmailFormat._from_openapi_data( + + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with0_does_not_match_false.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with0_does_not_match_false.py new file mode 100644 index 00000000000..69d576b5dba --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with0_does_not_match_false.py @@ -0,0 +1,48 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.enum_with0_does_not_match_false import EnumWith0DoesNotMatchFalse +from unit_test_api import configuration + + +class TestEnumWith0DoesNotMatchFalse(unittest.TestCase): + """EnumWith0DoesNotMatchFalse unit test stubs""" + _configuration = configuration.Configuration() + + def test_integer_zero_is_valid_passes(self): + # integer zero is valid + EnumWith0DoesNotMatchFalse._from_openapi_data( + 0, + _configuration=self._configuration + ) + + def test_float_zero_is_valid_passes(self): + # float zero is valid + EnumWith0DoesNotMatchFalse._from_openapi_data( + 0.0, + _configuration=self._configuration + ) + + def test_false_is_invalid_fails(self): + # false is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + EnumWith0DoesNotMatchFalse._from_openapi_data( + + False, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with1_does_not_match_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with1_does_not_match_true.py new file mode 100644 index 00000000000..e1ad8fa4f08 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with1_does_not_match_true.py @@ -0,0 +1,48 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.enum_with1_does_not_match_true import EnumWith1DoesNotMatchTrue +from unit_test_api import configuration + + +class TestEnumWith1DoesNotMatchTrue(unittest.TestCase): + """EnumWith1DoesNotMatchTrue unit test stubs""" + _configuration = configuration.Configuration() + + def test_true_is_invalid_fails(self): + # true is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + EnumWith1DoesNotMatchTrue._from_openapi_data( + + True, + _configuration=self._configuration + ) + + def test_integer_one_is_valid_passes(self): + # integer one is valid + EnumWith1DoesNotMatchTrue._from_openapi_data( + 1, + _configuration=self._configuration + ) + + def test_float_one_is_valid_passes(self): + # float one is valid + EnumWith1DoesNotMatchTrue._from_openapi_data( + 1.0, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_escaped_characters.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_escaped_characters.py new file mode 100644 index 00000000000..b7b774156b9 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_escaped_characters.py @@ -0,0 +1,50 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.enum_with_escaped_characters import EnumWithEscapedCharacters +from unit_test_api import configuration + + +class TestEnumWithEscapedCharacters(unittest.TestCase): + """EnumWithEscapedCharacters unit test stubs""" + _configuration = configuration.Configuration() + + def test_member2_is_valid_passes(self): + # member 2 is valid + EnumWithEscapedCharacters._from_openapi_data( + + "foo\rbar", + _configuration=self._configuration + ) + + def test_member1_is_valid_passes(self): + # member 1 is valid + EnumWithEscapedCharacters._from_openapi_data( + + "foo\nbar", + _configuration=self._configuration + ) + + def test_another_string_is_invalid_fails(self): + # another string is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + EnumWithEscapedCharacters._from_openapi_data( + + "abc", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_false_does_not_match0.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_false_does_not_match0.py new file mode 100644 index 00000000000..d3a59f18ee8 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_false_does_not_match0.py @@ -0,0 +1,49 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.enum_with_false_does_not_match0 import EnumWithFalseDoesNotMatch0 +from unit_test_api import configuration + + +class TestEnumWithFalseDoesNotMatch0(unittest.TestCase): + """EnumWithFalseDoesNotMatch0 unit test stubs""" + _configuration = configuration.Configuration() + + def test_false_is_valid_passes(self): + # false is valid + EnumWithFalseDoesNotMatch0._from_openapi_data( + + False, + _configuration=self._configuration + ) + + def test_float_zero_is_invalid_fails(self): + # float zero is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + EnumWithFalseDoesNotMatch0._from_openapi_data( + 0.0, + _configuration=self._configuration + ) + + def test_integer_zero_is_invalid_fails(self): + # integer zero is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + EnumWithFalseDoesNotMatch0._from_openapi_data( + 0, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_true_does_not_match1.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_true_does_not_match1.py new file mode 100644 index 00000000000..52ca73287ea --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_true_does_not_match1.py @@ -0,0 +1,49 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.enum_with_true_does_not_match1 import EnumWithTrueDoesNotMatch1 +from unit_test_api import configuration + + +class TestEnumWithTrueDoesNotMatch1(unittest.TestCase): + """EnumWithTrueDoesNotMatch1 unit test stubs""" + _configuration = configuration.Configuration() + + def test_float_one_is_invalid_fails(self): + # float one is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + EnumWithTrueDoesNotMatch1._from_openapi_data( + 1.0, + _configuration=self._configuration + ) + + def test_true_is_valid_passes(self): + # true is valid + EnumWithTrueDoesNotMatch1._from_openapi_data( + + True, + _configuration=self._configuration + ) + + def test_integer_one_is_invalid_fails(self): + # integer one is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + EnumWithTrueDoesNotMatch1._from_openapi_data( + 1, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enums_in_properties.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enums_in_properties.py new file mode 100644 index 00000000000..790e7e06a67 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enums_in_properties.py @@ -0,0 +1,115 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.enums_in_properties import EnumsInProperties +from unit_test_api import configuration + + +class TestEnumsInProperties(unittest.TestCase): + """EnumsInProperties unit test stubs""" + _configuration = configuration.Configuration() + + def test_missing_optional_property_is_valid_passes(self): + # missing optional property is valid + EnumsInProperties._from_openapi_data( + { + + "bar": + + "bar", + } +, + _configuration=self._configuration + ) + + def test_wrong_foo_value_fails(self): + # wrong foo value + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + EnumsInProperties._from_openapi_data( + { + + "foo": + + "foot", + + "bar": + + "bar", + } +, + _configuration=self._configuration + ) + + def test_both_properties_are_valid_passes(self): + # both properties are valid + EnumsInProperties._from_openapi_data( + { + + "foo": + + "foo", + + "bar": + + "bar", + } +, + _configuration=self._configuration + ) + + def test_wrong_bar_value_fails(self): + # wrong bar value + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + EnumsInProperties._from_openapi_data( + { + + "foo": + + "foo", + + "bar": + + "bart", + } +, + _configuration=self._configuration + ) + + def test_missing_all_properties_is_invalid_fails(self): + # missing all properties is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + EnumsInProperties._from_openapi_data( + { + } +, + _configuration=self._configuration + ) + + def test_missing_required_property_is_invalid_fails(self): + # missing required property is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + EnumsInProperties._from_openapi_data( + { + + "foo": + + "foo", + } +, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_forbidden_property.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_forbidden_property.py new file mode 100644 index 00000000000..b6921c8efea --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_forbidden_property.py @@ -0,0 +1,56 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.forbidden_property import ForbiddenProperty +from unit_test_api import configuration + + +class TestForbiddenProperty(unittest.TestCase): + """ForbiddenProperty unit test stubs""" + _configuration = configuration.Configuration() + + def test_property_present_fails(self): + # property present + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + ForbiddenProperty._from_openapi_data( + { + + "foo": + 1, + + "bar": + 2, + } +, + _configuration=self._configuration + ) + + def test_property_absent_passes(self): + # property absent + ForbiddenProperty._from_openapi_data( + { + + "bar": + 1, + + "baz": + 2, + } +, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_hostname_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_hostname_format.py new file mode 100644 index 00000000000..e1bfb5600f0 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_hostname_format.py @@ -0,0 +1,73 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.hostname_format import HostnameFormat +from unit_test_api import configuration + + +class TestHostnameFormat(unittest.TestCase): + """HostnameFormat unit test stubs""" + _configuration = configuration.Configuration() + + def test_all_string_formats_ignore_objects_passes(self): + # all string formats ignore objects + HostnameFormat._from_openapi_data( + { + } +, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_booleans_passes(self): + # all string formats ignore booleans + HostnameFormat._from_openapi_data( + + False, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_integers_passes(self): + # all string formats ignore integers + HostnameFormat._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_floats_passes(self): + # all string formats ignore floats + HostnameFormat._from_openapi_data( + 13.7, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_arrays_passes(self): + # all string formats ignore arrays + HostnameFormat._from_openapi_data( + [ + ] +, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_nulls_passes(self): + # all string formats ignore nulls + HostnameFormat._from_openapi_data( + + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py new file mode 100644 index 00000000000..db960e3a8a9 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.integer_type_matches_integers import IntegerTypeMatchesIntegers +from unit_test_api import configuration + + +class TestIntegerTypeMatchesIntegers(unittest.TestCase): + """IntegerTypeMatchesIntegers unit test stubs""" + _configuration = configuration.Configuration() + + def test_an_object_is_not_an_integer_fails(self): + # an object is not an integer + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + IntegerTypeMatchesIntegers._from_openapi_data( + { + } +, + _configuration=self._configuration + ) + + def test_a_string_is_not_an_integer_fails(self): + # a string is not an integer + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + IntegerTypeMatchesIntegers._from_openapi_data( + + "foo", + _configuration=self._configuration + ) + + def test_null_is_not_an_integer_fails(self): + # null is not an integer + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + IntegerTypeMatchesIntegers._from_openapi_data( + + None, + _configuration=self._configuration + ) + + def test_a_float_with_zero_fractional_part_is_an_integer_passes(self): + # a float with zero fractional part is an integer + IntegerTypeMatchesIntegers._from_openapi_data( + 1.0, + _configuration=self._configuration + ) + + def test_a_float_is_not_an_integer_fails(self): + # a float is not an integer + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + IntegerTypeMatchesIntegers._from_openapi_data( + 1.1, + _configuration=self._configuration + ) + + def test_a_boolean_is_not_an_integer_fails(self): + # a boolean is not an integer + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + IntegerTypeMatchesIntegers._from_openapi_data( + + True, + _configuration=self._configuration + ) + + def test_an_integer_is_an_integer_passes(self): + # an integer is an integer + IntegerTypeMatchesIntegers._from_openapi_data( + 1, + _configuration=self._configuration + ) + + def test_a_string_is_still_not_an_integer_even_if_it_looks_like_one_fails(self): + # a string is still not an integer, even if it looks like one + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + IntegerTypeMatchesIntegers._from_openapi_data( + + "1", + _configuration=self._configuration + ) + + def test_an_array_is_not_an_integer_fails(self): + # an array is not an integer + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + IntegerTypeMatchesIntegers._from_openapi_data( + [ + ] +, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_instance_should_not_raise_error_when_float_division_inf.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_instance_should_not_raise_error_when_float_division_inf.py new file mode 100644 index 00000000000..0b3d9760867 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_instance_should_not_raise_error_when_float_division_inf.py @@ -0,0 +1,33 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.invalid_instance_should_not_raise_error_when_float_division_inf import InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf +from unit_test_api import configuration + + +class TestInvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf(unittest.TestCase): + """InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf unit test stubs""" + _configuration = configuration.Configuration() + + def test_always_invalid_but_naive_implementations_may_raise_an_overflow_error_fails(self): + # always invalid, but naive implementations may raise an overflow error + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf._from_openapi_data( + 1.0E308, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_string_value_for_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_string_value_for_default.py new file mode 100644 index 00000000000..6e5c92b388f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_string_value_for_default.py @@ -0,0 +1,47 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.invalid_string_value_for_default import InvalidStringValueForDefault +from unit_test_api import configuration + + +class TestInvalidStringValueForDefault(unittest.TestCase): + """InvalidStringValueForDefault unit test stubs""" + _configuration = configuration.Configuration() + + def test_valid_when_property_is_specified_passes(self): + # valid when property is specified + InvalidStringValueForDefault._from_openapi_data( + { + + "bar": + + "good", + } +, + _configuration=self._configuration + ) + + def test_still_valid_when_the_invalid_default_is_used_passes(self): + # still valid when the invalid default is used + InvalidStringValueForDefault._from_openapi_data( + { + } +, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ipv4_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ipv4_format.py new file mode 100644 index 00000000000..ad07e265276 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ipv4_format.py @@ -0,0 +1,73 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.ipv4_format import Ipv4Format +from unit_test_api import configuration + + +class TestIpv4Format(unittest.TestCase): + """Ipv4Format unit test stubs""" + _configuration = configuration.Configuration() + + def test_all_string_formats_ignore_objects_passes(self): + # all string formats ignore objects + Ipv4Format._from_openapi_data( + { + } +, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_booleans_passes(self): + # all string formats ignore booleans + Ipv4Format._from_openapi_data( + + False, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_integers_passes(self): + # all string formats ignore integers + Ipv4Format._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_floats_passes(self): + # all string formats ignore floats + Ipv4Format._from_openapi_data( + 13.7, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_arrays_passes(self): + # all string formats ignore arrays + Ipv4Format._from_openapi_data( + [ + ] +, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_nulls_passes(self): + # all string formats ignore nulls + Ipv4Format._from_openapi_data( + + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ipv6_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ipv6_format.py new file mode 100644 index 00000000000..569d8401957 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ipv6_format.py @@ -0,0 +1,73 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.ipv6_format import Ipv6Format +from unit_test_api import configuration + + +class TestIpv6Format(unittest.TestCase): + """Ipv6Format unit test stubs""" + _configuration = configuration.Configuration() + + def test_all_string_formats_ignore_objects_passes(self): + # all string formats ignore objects + Ipv6Format._from_openapi_data( + { + } +, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_booleans_passes(self): + # all string formats ignore booleans + Ipv6Format._from_openapi_data( + + False, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_integers_passes(self): + # all string formats ignore integers + Ipv6Format._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_floats_passes(self): + # all string formats ignore floats + Ipv6Format._from_openapi_data( + 13.7, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_arrays_passes(self): + # all string formats ignore arrays + Ipv6Format._from_openapi_data( + [ + ] +, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_nulls_passes(self): + # all string formats ignore nulls + Ipv6Format._from_openapi_data( + + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_json_pointer_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_json_pointer_format.py new file mode 100644 index 00000000000..b53440098e1 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_json_pointer_format.py @@ -0,0 +1,73 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.json_pointer_format import JsonPointerFormat +from unit_test_api import configuration + + +class TestJsonPointerFormat(unittest.TestCase): + """JsonPointerFormat unit test stubs""" + _configuration = configuration.Configuration() + + def test_all_string_formats_ignore_objects_passes(self): + # all string formats ignore objects + JsonPointerFormat._from_openapi_data( + { + } +, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_booleans_passes(self): + # all string formats ignore booleans + JsonPointerFormat._from_openapi_data( + + False, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_integers_passes(self): + # all string formats ignore integers + JsonPointerFormat._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_floats_passes(self): + # all string formats ignore floats + JsonPointerFormat._from_openapi_data( + 13.7, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_arrays_passes(self): + # all string formats ignore arrays + JsonPointerFormat._from_openapi_data( + [ + ] +, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_nulls_passes(self): + # all string formats ignore nulls + JsonPointerFormat._from_openapi_data( + + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation.py new file mode 100644 index 00000000000..708b5be1f1a --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation.py @@ -0,0 +1,55 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.maximum_validation import MaximumValidation +from unit_test_api import configuration + + +class TestMaximumValidation(unittest.TestCase): + """MaximumValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_below_the_maximum_is_valid_passes(self): + # below the maximum is valid + MaximumValidation._from_openapi_data( + 2.6, + _configuration=self._configuration + ) + + def test_boundary_point_is_valid_passes(self): + # boundary point is valid + MaximumValidation._from_openapi_data( + 3.0, + _configuration=self._configuration + ) + + def test_above_the_maximum_is_invalid_fails(self): + # above the maximum is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + MaximumValidation._from_openapi_data( + 3.5, + _configuration=self._configuration + ) + + def test_ignores_non_numbers_passes(self): + # ignores non-numbers + MaximumValidation._from_openapi_data( + + "x", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation_with_unsigned_integer.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation_with_unsigned_integer.py new file mode 100644 index 00000000000..14dab7b966e --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation_with_unsigned_integer.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.maximum_validation_with_unsigned_integer import MaximumValidationWithUnsignedInteger +from unit_test_api import configuration + + +class TestMaximumValidationWithUnsignedInteger(unittest.TestCase): + """MaximumValidationWithUnsignedInteger unit test stubs""" + _configuration = configuration.Configuration() + + def test_below_the_maximum_is_invalid_passes(self): + # below the maximum is invalid + MaximumValidationWithUnsignedInteger._from_openapi_data( + 299.97, + _configuration=self._configuration + ) + + def test_above_the_maximum_is_invalid_fails(self): + # above the maximum is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + MaximumValidationWithUnsignedInteger._from_openapi_data( + 300.5, + _configuration=self._configuration + ) + + def test_boundary_point_integer_is_valid_passes(self): + # boundary point integer is valid + MaximumValidationWithUnsignedInteger._from_openapi_data( + 300, + _configuration=self._configuration + ) + + def test_boundary_point_float_is_valid_passes(self): + # boundary point float is valid + MaximumValidationWithUnsignedInteger._from_openapi_data( + 300.0, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxitems_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxitems_validation.py new file mode 100644 index 00000000000..ec11cefd860 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxitems_validation.py @@ -0,0 +1,67 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.maxitems_validation import MaxitemsValidation +from unit_test_api import configuration + + +class TestMaxitemsValidation(unittest.TestCase): + """MaxitemsValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_too_long_is_invalid_fails(self): + # too long is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + MaxitemsValidation._from_openapi_data( + [ + 1, + 2, + 3, + ] +, + _configuration=self._configuration + ) + + def test_ignores_non_arrays_passes(self): + # ignores non-arrays + MaxitemsValidation._from_openapi_data( + + "foobar", + _configuration=self._configuration + ) + + def test_shorter_is_valid_passes(self): + # shorter is valid + MaxitemsValidation._from_openapi_data( + [ + 1, + ] +, + _configuration=self._configuration + ) + + def test_exact_length_is_valid_passes(self): + # exact length is valid + MaxitemsValidation._from_openapi_data( + [ + 1, + 2, + ] +, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxlength_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxlength_validation.py new file mode 100644 index 00000000000..6447e4804d1 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxlength_validation.py @@ -0,0 +1,65 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.maxlength_validation import MaxlengthValidation +from unit_test_api import configuration + + +class TestMaxlengthValidation(unittest.TestCase): + """MaxlengthValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_too_long_is_invalid_fails(self): + # too long is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + MaxlengthValidation._from_openapi_data( + + "foo", + _configuration=self._configuration + ) + + def test_ignores_non_strings_passes(self): + # ignores non-strings + MaxlengthValidation._from_openapi_data( + 100, + _configuration=self._configuration + ) + + def test_shorter_is_valid_passes(self): + # shorter is valid + MaxlengthValidation._from_openapi_data( + + "f", + _configuration=self._configuration + ) + + def test_two_supplementary_unicode_code_points_is_long_enough_passes(self): + # two supplementary Unicode code points is long enough + MaxlengthValidation._from_openapi_data( + + "💩💩", + _configuration=self._configuration + ) + + def test_exact_length_is_valid_passes(self): + # exact length is valid + MaxlengthValidation._from_openapi_data( + + "fo", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties0_means_the_object_is_empty.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties0_means_the_object_is_empty.py new file mode 100644 index 00000000000..3c276fbc5fa --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties0_means_the_object_is_empty.py @@ -0,0 +1,47 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.maxproperties0_means_the_object_is_empty import Maxproperties0MeansTheObjectIsEmpty +from unit_test_api import configuration + + +class TestMaxproperties0MeansTheObjectIsEmpty(unittest.TestCase): + """Maxproperties0MeansTheObjectIsEmpty unit test stubs""" + _configuration = configuration.Configuration() + + def test_no_properties_is_valid_passes(self): + # no properties is valid + Maxproperties0MeansTheObjectIsEmpty._from_openapi_data( + { + } +, + _configuration=self._configuration + ) + + def test_one_property_is_invalid_fails(self): + # one property is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + Maxproperties0MeansTheObjectIsEmpty._from_openapi_data( + { + + "foo": + 1, + } +, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties_validation.py new file mode 100644 index 00000000000..03218918dcc --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties_validation.py @@ -0,0 +1,98 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.maxproperties_validation import MaxpropertiesValidation +from unit_test_api import configuration + + +class TestMaxpropertiesValidation(unittest.TestCase): + """MaxpropertiesValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_too_long_is_invalid_fails(self): + # too long is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + MaxpropertiesValidation._from_openapi_data( + { + + "foo": + 1, + + "bar": + 2, + + "baz": + 3, + } +, + _configuration=self._configuration + ) + + def test_ignores_arrays_passes(self): + # ignores arrays + MaxpropertiesValidation._from_openapi_data( + [ + 1, + 2, + 3, + ] +, + _configuration=self._configuration + ) + + def test_ignores_other_non_objects_passes(self): + # ignores other non-objects + MaxpropertiesValidation._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_ignores_strings_passes(self): + # ignores strings + MaxpropertiesValidation._from_openapi_data( + + "foobar", + _configuration=self._configuration + ) + + def test_shorter_is_valid_passes(self): + # shorter is valid + MaxpropertiesValidation._from_openapi_data( + { + + "foo": + 1, + } +, + _configuration=self._configuration + ) + + def test_exact_length_is_valid_passes(self): + # exact length is valid + MaxpropertiesValidation._from_openapi_data( + { + + "foo": + 1, + + "bar": + 2, + } +, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation.py new file mode 100644 index 00000000000..c74720ce511 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation.py @@ -0,0 +1,55 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.minimum_validation import MinimumValidation +from unit_test_api import configuration + + +class TestMinimumValidation(unittest.TestCase): + """MinimumValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_boundary_point_is_valid_passes(self): + # boundary point is valid + MinimumValidation._from_openapi_data( + 1.1, + _configuration=self._configuration + ) + + def test_below_the_minimum_is_invalid_fails(self): + # below the minimum is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + MinimumValidation._from_openapi_data( + 0.6, + _configuration=self._configuration + ) + + def test_above_the_minimum_is_valid_passes(self): + # above the minimum is valid + MinimumValidation._from_openapi_data( + 2.6, + _configuration=self._configuration + ) + + def test_ignores_non_numbers_passes(self): + # ignores non-numbers + MinimumValidation._from_openapi_data( + + "x", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation_with_signed_integer.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation_with_signed_integer.py new file mode 100644 index 00000000000..8a3c09c9111 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation_with_signed_integer.py @@ -0,0 +1,77 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.minimum_validation_with_signed_integer import MinimumValidationWithSignedInteger +from unit_test_api import configuration + + +class TestMinimumValidationWithSignedInteger(unittest.TestCase): + """MinimumValidationWithSignedInteger unit test stubs""" + _configuration = configuration.Configuration() + + def test_boundary_point_is_valid_passes(self): + # boundary point is valid + MinimumValidationWithSignedInteger._from_openapi_data( + -2, + _configuration=self._configuration + ) + + def test_positive_above_the_minimum_is_valid_passes(self): + # positive above the minimum is valid + MinimumValidationWithSignedInteger._from_openapi_data( + 0, + _configuration=self._configuration + ) + + def test_int_below_the_minimum_is_invalid_fails(self): + # int below the minimum is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + MinimumValidationWithSignedInteger._from_openapi_data( + -3, + _configuration=self._configuration + ) + + def test_float_below_the_minimum_is_invalid_fails(self): + # float below the minimum is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + MinimumValidationWithSignedInteger._from_openapi_data( + -2.0001, + _configuration=self._configuration + ) + + def test_boundary_point_with_float_is_valid_passes(self): + # boundary point with float is valid + MinimumValidationWithSignedInteger._from_openapi_data( + -2.0, + _configuration=self._configuration + ) + + def test_negative_above_the_minimum_is_valid_passes(self): + # negative above the minimum is valid + MinimumValidationWithSignedInteger._from_openapi_data( + -1, + _configuration=self._configuration + ) + + def test_ignores_non_numbers_passes(self): + # ignores non-numbers + MinimumValidationWithSignedInteger._from_openapi_data( + + "x", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minitems_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minitems_validation.py new file mode 100644 index 00000000000..e2ae443d4f8 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minitems_validation.py @@ -0,0 +1,64 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.minitems_validation import MinitemsValidation +from unit_test_api import configuration + + +class TestMinitemsValidation(unittest.TestCase): + """MinitemsValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_too_short_is_invalid_fails(self): + # too short is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + MinitemsValidation._from_openapi_data( + [ + ] +, + _configuration=self._configuration + ) + + def test_ignores_non_arrays_passes(self): + # ignores non-arrays + MinitemsValidation._from_openapi_data( + + "", + _configuration=self._configuration + ) + + def test_longer_is_valid_passes(self): + # longer is valid + MinitemsValidation._from_openapi_data( + [ + 1, + 2, + ] +, + _configuration=self._configuration + ) + + def test_exact_length_is_valid_passes(self): + # exact length is valid + MinitemsValidation._from_openapi_data( + [ + 1, + ] +, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minlength_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minlength_validation.py new file mode 100644 index 00000000000..0349cd358c5 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minlength_validation.py @@ -0,0 +1,66 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.minlength_validation import MinlengthValidation +from unit_test_api import configuration + + +class TestMinlengthValidation(unittest.TestCase): + """MinlengthValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_too_short_is_invalid_fails(self): + # too short is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + MinlengthValidation._from_openapi_data( + + "f", + _configuration=self._configuration + ) + + def test_one_supplementary_unicode_code_point_is_not_long_enough_fails(self): + # one supplementary Unicode code point is not long enough + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + MinlengthValidation._from_openapi_data( + + "💩", + _configuration=self._configuration + ) + + def test_longer_is_valid_passes(self): + # longer is valid + MinlengthValidation._from_openapi_data( + + "foo", + _configuration=self._configuration + ) + + def test_ignores_non_strings_passes(self): + # ignores non-strings + MinlengthValidation._from_openapi_data( + 1, + _configuration=self._configuration + ) + + def test_exact_length_is_valid_passes(self): + # exact length is valid + MinlengthValidation._from_openapi_data( + + "fo", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minproperties_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minproperties_validation.py new file mode 100644 index 00000000000..2536ecea876 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minproperties_validation.py @@ -0,0 +1,86 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.minproperties_validation import MinpropertiesValidation +from unit_test_api import configuration + + +class TestMinpropertiesValidation(unittest.TestCase): + """MinpropertiesValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_ignores_arrays_passes(self): + # ignores arrays + MinpropertiesValidation._from_openapi_data( + [ + ] +, + _configuration=self._configuration + ) + + def test_ignores_other_non_objects_passes(self): + # ignores other non-objects + MinpropertiesValidation._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_too_short_is_invalid_fails(self): + # too short is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + MinpropertiesValidation._from_openapi_data( + { + } +, + _configuration=self._configuration + ) + + def test_ignores_strings_passes(self): + # ignores strings + MinpropertiesValidation._from_openapi_data( + + "", + _configuration=self._configuration + ) + + def test_longer_is_valid_passes(self): + # longer is valid + MinpropertiesValidation._from_openapi_data( + { + + "foo": + 1, + + "bar": + 2, + } +, + _configuration=self._configuration + ) + + def test_exact_length_is_valid_passes(self): + # exact length is valid + MinpropertiesValidation._from_openapi_data( + { + + "foo": + 1, + } +, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_model_not.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_model_not.py new file mode 100644 index 00000000000..fa5d57a0a00 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_model_not.py @@ -0,0 +1,41 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.model_not import ModelNot +from unit_test_api import configuration + + +class TestModelNot(unittest.TestCase): + """ModelNot unit test stubs""" + _configuration = configuration.Configuration() + + def test_allowed_passes(self): + # allowed + ModelNot._from_openapi_data( + + "foo", + _configuration=self._configuration + ) + + def test_disallowed_fails(self): + # disallowed + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + ModelNot._from_openapi_data( + 1, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_items.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_items.py new file mode 100644 index 00000000000..f9cd1696b2a --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_items.py @@ -0,0 +1,163 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.nested_items import NestedItems +from unit_test_api import configuration + + +class TestNestedItems(unittest.TestCase): + """NestedItems unit test stubs""" + _configuration = configuration.Configuration() + + def test_valid_nested_array_passes(self): + # valid nested array + NestedItems._from_openapi_data( + [ + [ + [ + [ + 1, + ] +, + ] +, + [ + [ + 2, + ] +, + [ + 3, + ] +, + ] +, + ] +, + [ + [ + [ + 4, + ] +, + [ + 5, + ] +, + [ + 6, + ] +, + ] +, + ] +, + ] +, + _configuration=self._configuration + ) + + def test_nested_array_with_invalid_type_fails(self): + # nested array with invalid type + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NestedItems._from_openapi_data( + [ + [ + [ + [ + + "1", + ] +, + ] +, + [ + [ + 2, + ] +, + [ + 3, + ] +, + ] +, + ] +, + [ + [ + [ + 4, + ] +, + [ + 5, + ] +, + [ + 6, + ] +, + ] +, + ] +, + ] +, + _configuration=self._configuration + ) + + def test_not_deep_enough_fails(self): + # not deep enough + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NestedItems._from_openapi_data( + [ + [ + [ + 1, + ] +, + [ + 2, + ] +, + [ + 3, + ] +, + ] +, + [ + [ + 4, + ] +, + [ + 5, + ] +, + [ + 6, + ] +, + ] +, + ] +, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_not_more_complex_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_not_more_complex_schema.py new file mode 100644 index 00000000000..3c9e98a74ce --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_not_more_complex_schema.py @@ -0,0 +1,58 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.not_more_complex_schema import NotMoreComplexSchema +from unit_test_api import configuration + + +class TestNotMoreComplexSchema(unittest.TestCase): + """NotMoreComplexSchema unit test stubs""" + _configuration = configuration.Configuration() + + def test_other_match_passes(self): + # other match + NotMoreComplexSchema._from_openapi_data( + { + + "foo": + 1, + } +, + _configuration=self._configuration + ) + + def test_mismatch_fails(self): + # mismatch + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NotMoreComplexSchema._from_openapi_data( + { + + "foo": + + "bar", + } +, + _configuration=self._configuration + ) + + def test_match_passes(self): + # match + NotMoreComplexSchema._from_openapi_data( + 1, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nul_characters_in_strings.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nul_characters_in_strings.py new file mode 100644 index 00000000000..cb6ee4fe896 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nul_characters_in_strings.py @@ -0,0 +1,42 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.nul_characters_in_strings import NulCharactersInStrings +from unit_test_api import configuration + + +class TestNulCharactersInStrings(unittest.TestCase): + """NulCharactersInStrings unit test stubs""" + _configuration = configuration.Configuration() + + def test_match_string_with_nul_passes(self): + # match string with nul + NulCharactersInStrings._from_openapi_data( + + "hello\\x00there", + _configuration=self._configuration + ) + + def test_do_not_match_string_lacking_nul_fails(self): + # do not match string lacking nul + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NulCharactersInStrings._from_openapi_data( + + "hellothere", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py new file mode 100644 index 00000000000..a03cc120afc --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py @@ -0,0 +1,113 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.null_type_matches_only_the_null_object import NullTypeMatchesOnlyTheNullObject +from unit_test_api import configuration + + +class TestNullTypeMatchesOnlyTheNullObject(unittest.TestCase): + """NullTypeMatchesOnlyTheNullObject unit test stubs""" + _configuration = configuration.Configuration() + + def test_a_float_is_not_null_fails(self): + # a float is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NullTypeMatchesOnlyTheNullObject._from_openapi_data( + 1.1, + _configuration=self._configuration + ) + + def test_an_object_is_not_null_fails(self): + # an object is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NullTypeMatchesOnlyTheNullObject._from_openapi_data( + { + } +, + _configuration=self._configuration + ) + + def test_false_is_not_null_fails(self): + # false is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NullTypeMatchesOnlyTheNullObject._from_openapi_data( + + False, + _configuration=self._configuration + ) + + def test_an_integer_is_not_null_fails(self): + # an integer is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NullTypeMatchesOnlyTheNullObject._from_openapi_data( + 1, + _configuration=self._configuration + ) + + def test_true_is_not_null_fails(self): + # true is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NullTypeMatchesOnlyTheNullObject._from_openapi_data( + + True, + _configuration=self._configuration + ) + + def test_zero_is_not_null_fails(self): + # zero is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NullTypeMatchesOnlyTheNullObject._from_openapi_data( + 0, + _configuration=self._configuration + ) + + def test_an_empty_string_is_not_null_fails(self): + # an empty string is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NullTypeMatchesOnlyTheNullObject._from_openapi_data( + + "", + _configuration=self._configuration + ) + + def test_null_is_null_passes(self): + # null is null + NullTypeMatchesOnlyTheNullObject._from_openapi_data( + + None, + _configuration=self._configuration + ) + + def test_an_array_is_not_null_fails(self): + # an array is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NullTypeMatchesOnlyTheNullObject._from_openapi_data( + [ + ] +, + _configuration=self._configuration + ) + + def test_a_string_is_not_null_fails(self): + # a string is not null + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NullTypeMatchesOnlyTheNullObject._from_openapi_data( + + "foo", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py new file mode 100644 index 00000000000..c1488496508 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py @@ -0,0 +1,102 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.number_type_matches_numbers import NumberTypeMatchesNumbers +from unit_test_api import configuration + + +class TestNumberTypeMatchesNumbers(unittest.TestCase): + """NumberTypeMatchesNumbers unit test stubs""" + _configuration = configuration.Configuration() + + def test_an_array_is_not_a_number_fails(self): + # an array is not a number + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NumberTypeMatchesNumbers._from_openapi_data( + [ + ] +, + _configuration=self._configuration + ) + + def test_null_is_not_a_number_fails(self): + # null is not a number + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NumberTypeMatchesNumbers._from_openapi_data( + + None, + _configuration=self._configuration + ) + + def test_an_object_is_not_a_number_fails(self): + # an object is not a number + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NumberTypeMatchesNumbers._from_openapi_data( + { + } +, + _configuration=self._configuration + ) + + def test_a_boolean_is_not_a_number_fails(self): + # a boolean is not a number + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NumberTypeMatchesNumbers._from_openapi_data( + + True, + _configuration=self._configuration + ) + + def test_a_float_is_a_number_passes(self): + # a float is a number + NumberTypeMatchesNumbers._from_openapi_data( + 1.1, + _configuration=self._configuration + ) + + def test_a_string_is_still_not_a_number_even_if_it_looks_like_one_fails(self): + # a string is still not a number, even if it looks like one + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NumberTypeMatchesNumbers._from_openapi_data( + + "1", + _configuration=self._configuration + ) + + def test_a_string_is_not_a_number_fails(self): + # a string is not a number + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + NumberTypeMatchesNumbers._from_openapi_data( + + "foo", + _configuration=self._configuration + ) + + def test_an_integer_is_a_number_passes(self): + # an integer is a number + NumberTypeMatchesNumbers._from_openapi_data( + 1, + _configuration=self._configuration + ) + + def test_a_float_with_zero_fractional_part_is_a_number_and_an_integer_passes(self): + # a float with zero fractional part is a number (and an integer) + NumberTypeMatchesNumbers._from_openapi_data( + 1.0, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_object_properties_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_object_properties_validation.py new file mode 100644 index 00000000000..7acd54635bd --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_object_properties_validation.py @@ -0,0 +1,109 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.object_properties_validation import ObjectPropertiesValidation +from unit_test_api import configuration + + +class TestObjectPropertiesValidation(unittest.TestCase): + """ObjectPropertiesValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_ignores_arrays_passes(self): + # ignores arrays + ObjectPropertiesValidation._from_openapi_data( + [ + ] +, + _configuration=self._configuration + ) + + def test_ignores_other_non_objects_passes(self): + # ignores other non-objects + ObjectPropertiesValidation._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_one_property_invalid_is_invalid_fails(self): + # one property invalid is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + ObjectPropertiesValidation._from_openapi_data( + { + + "foo": + 1, + + "bar": + { + } +, + } +, + _configuration=self._configuration + ) + + def test_both_properties_present_and_valid_is_valid_passes(self): + # both properties present and valid is valid + ObjectPropertiesValidation._from_openapi_data( + { + + "foo": + 1, + + "bar": + + "baz", + } +, + _configuration=self._configuration + ) + + def test_doesn_t_invalidate_other_properties_passes(self): + # doesn't invalidate other properties + ObjectPropertiesValidation._from_openapi_data( + { + + "quux": + [ + ] +, + } +, + _configuration=self._configuration + ) + + def test_both_properties_invalid_is_invalid_fails(self): + # both properties invalid is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + ObjectPropertiesValidation._from_openapi_data( + { + + "foo": + [ + ] +, + + "bar": + { + } +, + } +, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_is_not_anchored.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_is_not_anchored.py new file mode 100644 index 00000000000..6c28c64b369 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_is_not_anchored.py @@ -0,0 +1,33 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.pattern_is_not_anchored import PatternIsNotAnchored +from unit_test_api import configuration + + +class TestPatternIsNotAnchored(unittest.TestCase): + """PatternIsNotAnchored unit test stubs""" + _configuration = configuration.Configuration() + + def test_matches_a_substring_passes(self): + # matches a substring + PatternIsNotAnchored._from_openapi_data( + + "xxaayy", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_validation.py new file mode 100644 index 00000000000..d9bc1e1750f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_validation.py @@ -0,0 +1,90 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.pattern_validation import PatternValidation +from unit_test_api import configuration + + +class TestPatternValidation(unittest.TestCase): + """PatternValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_ignores_arrays_passes(self): + # ignores arrays + PatternValidation._from_openapi_data( + [ + ] +, + _configuration=self._configuration + ) + + def test_ignores_objects_passes(self): + # ignores objects + PatternValidation._from_openapi_data( + { + } +, + _configuration=self._configuration + ) + + def test_ignores_null_passes(self): + # ignores null + PatternValidation._from_openapi_data( + + None, + _configuration=self._configuration + ) + + def test_ignores_floats_passes(self): + # ignores floats + PatternValidation._from_openapi_data( + 1.0, + _configuration=self._configuration + ) + + def test_a_non_matching_pattern_is_invalid_fails(self): + # a non-matching pattern is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + PatternValidation._from_openapi_data( + + "abc", + _configuration=self._configuration + ) + + def test_ignores_booleans_passes(self): + # ignores booleans + PatternValidation._from_openapi_data( + + True, + _configuration=self._configuration + ) + + def test_a_matching_pattern_is_valid_passes(self): + # a matching pattern is valid + PatternValidation._from_openapi_data( + + "aaa", + _configuration=self._configuration + ) + + def test_ignores_integers_passes(self): + # ignores integers + PatternValidation._from_openapi_data( + 123, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py new file mode 100644 index 00000000000..5c114a79bd4 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py @@ -0,0 +1,86 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.properties_with_escaped_characters import PropertiesWithEscapedCharacters +from unit_test_api import configuration + + +class TestPropertiesWithEscapedCharacters(unittest.TestCase): + """PropertiesWithEscapedCharacters unit test stubs""" + _configuration = configuration.Configuration() + + def test_object_with_all_numbers_is_valid_passes(self): + # object with all numbers is valid + PropertiesWithEscapedCharacters._from_openapi_data( + { + + "foo\nbar": + 1, + + "foo\"bar": + 1, + + "foo\\bar": + 1, + + "foo\rbar": + 1, + + "foo\tbar": + 1, + + "foo\fbar": + 1, + } +, + _configuration=self._configuration + ) + + def test_object_with_strings_is_invalid_fails(self): + # object with strings is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + PropertiesWithEscapedCharacters._from_openapi_data( + { + + "foo\nbar": + + "1", + + "foo\"bar": + + "1", + + "foo\\bar": + + "1", + + "foo\rbar": + + "1", + + "foo\tbar": + + "1", + + "foo\fbar": + + "1", + } +, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_property_named_ref_that_is_not_a_reference.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_property_named_ref_that_is_not_a_reference.py new file mode 100644 index 00000000000..0b099e71700 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_property_named_ref_that_is_not_a_reference.py @@ -0,0 +1,51 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.property_named_ref_that_is_not_a_reference import PropertyNamedRefThatIsNotAReference +from unit_test_api import configuration + + +class TestPropertyNamedRefThatIsNotAReference(unittest.TestCase): + """PropertyNamedRefThatIsNotAReference unit test stubs""" + _configuration = configuration.Configuration() + + def test_property_named_ref_valid_passes(self): + # property named $ref valid + PropertyNamedRefThatIsNotAReference._from_openapi_data( + { + + "$ref": + + "a", + } +, + _configuration=self._configuration + ) + + def test_property_named_ref_invalid_fails(self): + # property named $ref invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + PropertyNamedRefThatIsNotAReference._from_openapi_data( + { + + "$ref": + 2, + } +, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_default_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_default_validation.py new file mode 100644 index 00000000000..6321d617382 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_default_validation.py @@ -0,0 +1,34 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.required_default_validation import RequiredDefaultValidation +from unit_test_api import configuration + + +class TestRequiredDefaultValidation(unittest.TestCase): + """RequiredDefaultValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_not_required_by_default_passes(self): + # not required by default + RequiredDefaultValidation._from_openapi_data( + { + } +, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_validation.py new file mode 100644 index 00000000000..b358c6bd044 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_validation.py @@ -0,0 +1,74 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.required_validation import RequiredValidation +from unit_test_api import configuration + + +class TestRequiredValidation(unittest.TestCase): + """RequiredValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_ignores_arrays_passes(self): + # ignores arrays + RequiredValidation._from_openapi_data( + [ + ] +, + _configuration=self._configuration + ) + + def test_present_required_property_is_valid_passes(self): + # present required property is valid + RequiredValidation._from_openapi_data( + { + + "foo": + 1, + } +, + _configuration=self._configuration + ) + + def test_ignores_other_non_objects_passes(self): + # ignores other non-objects + RequiredValidation._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_ignores_strings_passes(self): + # ignores strings + RequiredValidation._from_openapi_data( + + "", + _configuration=self._configuration + ) + + def test_non_present_required_property_is_invalid_fails(self): + # non-present required property is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + RequiredValidation._from_openapi_data( + { + + "bar": + 1, + } +, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_with_empty_array.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_with_empty_array.py new file mode 100644 index 00000000000..ef045be9fe1 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_with_empty_array.py @@ -0,0 +1,34 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.required_with_empty_array import RequiredWithEmptyArray +from unit_test_api import configuration + + +class TestRequiredWithEmptyArray(unittest.TestCase): + """RequiredWithEmptyArray unit test stubs""" + _configuration = configuration.Configuration() + + def test_property_not_required_passes(self): + # property not required + RequiredWithEmptyArray._from_openapi_data( + { + } +, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_simple_enum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_simple_enum_validation.py new file mode 100644 index 00000000000..92fc4a0c3d0 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_simple_enum_validation.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.simple_enum_validation import SimpleEnumValidation +from unit_test_api import configuration + + +class TestSimpleEnumValidation(unittest.TestCase): + """SimpleEnumValidation unit test stubs""" + _configuration = configuration.Configuration() + + def test_something_else_is_invalid_fails(self): + # something else is invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + SimpleEnumValidation._from_openapi_data( + 4, + _configuration=self._configuration + ) + + def test_one_of_the_enum_is_valid_passes(self): + # one of the enum is valid + SimpleEnumValidation._from_openapi_data( + 1, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py new file mode 100644 index 00000000000..9e85997f5f6 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.string_type_matches_strings import StringTypeMatchesStrings +from unit_test_api import configuration + + +class TestStringTypeMatchesStrings(unittest.TestCase): + """StringTypeMatchesStrings unit test stubs""" + _configuration = configuration.Configuration() + + def test_1_is_not_a_string_fails(self): + # 1 is not a string + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + StringTypeMatchesStrings._from_openapi_data( + 1, + _configuration=self._configuration + ) + + def test_a_string_is_still_a_string_even_if_it_looks_like_a_number_passes(self): + # a string is still a string, even if it looks like a number + StringTypeMatchesStrings._from_openapi_data( + + "1", + _configuration=self._configuration + ) + + def test_an_empty_string_is_still_a_string_passes(self): + # an empty string is still a string + StringTypeMatchesStrings._from_openapi_data( + + "", + _configuration=self._configuration + ) + + def test_a_float_is_not_a_string_fails(self): + # a float is not a string + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + StringTypeMatchesStrings._from_openapi_data( + 1.1, + _configuration=self._configuration + ) + + def test_an_object_is_not_a_string_fails(self): + # an object is not a string + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + StringTypeMatchesStrings._from_openapi_data( + { + } +, + _configuration=self._configuration + ) + + def test_an_array_is_not_a_string_fails(self): + # an array is not a string + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + StringTypeMatchesStrings._from_openapi_data( + [ + ] +, + _configuration=self._configuration + ) + + def test_a_boolean_is_not_a_string_fails(self): + # a boolean is not a string + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + StringTypeMatchesStrings._from_openapi_data( + + True, + _configuration=self._configuration + ) + + def test_null_is_not_a_string_fails(self): + # null is not a string + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + StringTypeMatchesStrings._from_openapi_data( + + None, + _configuration=self._configuration + ) + + def test_a_string_is_a_string_passes(self): + # a string is a string + StringTypeMatchesStrings._from_openapi_data( + + "foo", + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py new file mode 100644 index 00000000000..1908fdd11fe --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py @@ -0,0 +1,59 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.the_default_keyword_does_not_do_anything_if_the_property_is_missing import TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing +from unit_test_api import configuration + + +class TestTheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing(unittest.TestCase): + """TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing unit test stubs""" + _configuration = configuration.Configuration() + + def test_missing_properties_are_not_filled_in_with_the_default_passes(self): + # missing properties are not filled in with the default + TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing._from_openapi_data( + { + } +, + _configuration=self._configuration + ) + + def test_an_explicit_property_value_is_checked_against_maximum_passing_passes(self): + # an explicit property value is checked against maximum (passing) + TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing._from_openapi_data( + { + + "alpha": + 1, + } +, + _configuration=self._configuration + ) + + def test_an_explicit_property_value_is_checked_against_maximum_failing_fails(self): + # an explicit property value is checked against maximum (failing) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing._from_openapi_data( + { + + "alpha": + 5, + } +, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_format.py new file mode 100644 index 00000000000..819617170a4 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_format.py @@ -0,0 +1,73 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.uri_format import UriFormat +from unit_test_api import configuration + + +class TestUriFormat(unittest.TestCase): + """UriFormat unit test stubs""" + _configuration = configuration.Configuration() + + def test_all_string_formats_ignore_objects_passes(self): + # all string formats ignore objects + UriFormat._from_openapi_data( + { + } +, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_booleans_passes(self): + # all string formats ignore booleans + UriFormat._from_openapi_data( + + False, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_integers_passes(self): + # all string formats ignore integers + UriFormat._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_floats_passes(self): + # all string formats ignore floats + UriFormat._from_openapi_data( + 13.7, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_arrays_passes(self): + # all string formats ignore arrays + UriFormat._from_openapi_data( + [ + ] +, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_nulls_passes(self): + # all string formats ignore nulls + UriFormat._from_openapi_data( + + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_reference_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_reference_format.py new file mode 100644 index 00000000000..c01fac6b3f6 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_reference_format.py @@ -0,0 +1,73 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.uri_reference_format import UriReferenceFormat +from unit_test_api import configuration + + +class TestUriReferenceFormat(unittest.TestCase): + """UriReferenceFormat unit test stubs""" + _configuration = configuration.Configuration() + + def test_all_string_formats_ignore_objects_passes(self): + # all string formats ignore objects + UriReferenceFormat._from_openapi_data( + { + } +, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_booleans_passes(self): + # all string formats ignore booleans + UriReferenceFormat._from_openapi_data( + + False, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_integers_passes(self): + # all string formats ignore integers + UriReferenceFormat._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_floats_passes(self): + # all string formats ignore floats + UriReferenceFormat._from_openapi_data( + 13.7, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_arrays_passes(self): + # all string formats ignore arrays + UriReferenceFormat._from_openapi_data( + [ + ] +, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_nulls_passes(self): + # all string formats ignore nulls + UriReferenceFormat._from_openapi_data( + + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_template_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_template_format.py new file mode 100644 index 00000000000..da2e4c435e4 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_template_format.py @@ -0,0 +1,73 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.uri_template_format import UriTemplateFormat +from unit_test_api import configuration + + +class TestUriTemplateFormat(unittest.TestCase): + """UriTemplateFormat unit test stubs""" + _configuration = configuration.Configuration() + + def test_all_string_formats_ignore_objects_passes(self): + # all string formats ignore objects + UriTemplateFormat._from_openapi_data( + { + } +, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_booleans_passes(self): + # all string formats ignore booleans + UriTemplateFormat._from_openapi_data( + + False, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_integers_passes(self): + # all string formats ignore integers + UriTemplateFormat._from_openapi_data( + 12, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_floats_passes(self): + # all string formats ignore floats + UriTemplateFormat._from_openapi_data( + 13.7, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_arrays_passes(self): + # all string formats ignore arrays + UriTemplateFormat._from_openapi_data( + [ + ] +, + _configuration=self._configuration + ) + + def test_all_string_formats_ignore_nulls_passes(self): + # all string formats ignore nulls + UriTemplateFormat._from_openapi_data( + + None, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_allows_a_schema_which_should_validate.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_allows_a_schema_which_should_validate.py new file mode 100644 index 00000000000..8e986da86fc --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_allows_a_schema_which_should_validate.py @@ -0,0 +1,97 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class AdditionalpropertiesAllowsASchemaWhichShouldValidate( + DictSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + foo = AnyTypeSchema + bar = AnyTypeSchema + _additional_properties = BoolSchema + + + def __new__( + cls, + *args: typing.Union[dict, frozendict, ], + foo: typing.Union[foo, Unset] = unset, + bar: typing.Union[bar, Unset] = unset, + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'AdditionalpropertiesAllowsASchemaWhichShouldValidate': + return super().__new__( + cls, + *args, + foo=foo, + bar=bar, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_are_allowed_by_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_are_allowed_by_default.py new file mode 100644 index 00000000000..2251b2f815a --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_are_allowed_by_default.py @@ -0,0 +1,95 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class AdditionalpropertiesAreAllowedByDefault( + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + foo = AnyTypeSchema + bar = AnyTypeSchema + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + foo: typing.Union[foo, Unset] = unset, + bar: typing.Union[bar, Unset] = unset, + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'AdditionalpropertiesAreAllowedByDefault': + return super().__new__( + cls, + *args, + foo=foo, + bar=bar, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_can_exist_by_itself.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_can_exist_by_itself.py new file mode 100644 index 00000000000..383a01af174 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_can_exist_by_itself.py @@ -0,0 +1,91 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class AdditionalpropertiesCanExistByItself( + DictSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + _additional_properties = BoolSchema + + + def __new__( + cls, + *args: typing.Union[dict, frozendict, ], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'AdditionalpropertiesCanExistByItself': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_should_not_look_in_applicators.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_should_not_look_in_applicators.py new file mode 100644 index 00000000000..66547528189 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/additionalproperties_should_not_look_in_applicators.py @@ -0,0 +1,114 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class AdditionalpropertiesShouldNotLookInApplicators( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + _additional_properties = BoolSchema + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 + allOf_0 = AnyTypeSchema + return { + 'allOf': [ + allOf_0, + ], + 'oneOf': [ + ], + 'anyOf': [ + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'AdditionalpropertiesShouldNotLookInApplicators': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/array_type_matches_arrays.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/array_type_matches_arrays.py new file mode 100644 index 00000000000..583f9843b64 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/array_type_matches_arrays.py @@ -0,0 +1,77 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class ArrayTypeMatchesArrays( + ListSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + _items = AnyTypeSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/boolean_type_matches_booleans.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/boolean_type_matches_booleans.py new file mode 100644 index 00000000000..93cd0a0505f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/boolean_type_matches_booleans.py @@ -0,0 +1,67 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) +BooleanTypeMatchesBooleans = BoolSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_int.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_int.py new file mode 100644 index 00000000000..c5c44fbdc31 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_int.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class ByInt( + _SchemaValidator( + multiple_of=[2], + ), + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'ByInt': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_number.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_number.py new file mode 100644 index 00000000000..3bab9445575 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_number.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class ByNumber( + _SchemaValidator( + multiple_of=[1.5], + ), + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'ByNumber': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_small_number.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_small_number.py new file mode 100644 index 00000000000..5f96f0cdbdb --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/by_small_number.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class BySmallNumber( + _SchemaValidator( + multiple_of=[0.00010], + ), + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'BySmallNumber': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/date_time_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/date_time_format.py new file mode 100644 index 00000000000..0983f2f5e02 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/date_time_format.py @@ -0,0 +1,67 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) +DateTimeFormat = AnyTypeSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/email_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/email_format.py new file mode 100644 index 00000000000..e2922a13474 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/email_format.py @@ -0,0 +1,67 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) +EmailFormat = AnyTypeSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with0_does_not_match_false.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with0_does_not_match_false.py new file mode 100644 index 00000000000..6cb61f6f053 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with0_does_not_match_false.py @@ -0,0 +1,86 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class EnumWith0DoesNotMatchFalse( + _SchemaEnumMaker( + enum_value_to_name={ + 0: "POSITIVE_0", + } + ), + NumberSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + def POSITIVE_0(cls): + return cls(0) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with1_does_not_match_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with1_does_not_match_true.py new file mode 100644 index 00000000000..6904cda7fa3 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with1_does_not_match_true.py @@ -0,0 +1,86 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class EnumWith1DoesNotMatchTrue( + _SchemaEnumMaker( + enum_value_to_name={ + 1: "POSITIVE_1", + } + ), + NumberSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + def POSITIVE_1(cls): + return cls(1) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_escaped_characters.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_escaped_characters.py new file mode 100644 index 00000000000..3354101f399 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_escaped_characters.py @@ -0,0 +1,94 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class EnumWithEscapedCharacters( + _SchemaEnumMaker( + enum_value_to_name={ + '''foo +bar''': "FOO_BAR", + '''foo bar''': "FOO_BAR", + } + ), + StrSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + def FOO_BAR(cls): + return cls('''foo +bar''') + + @classmethod + @property + def FOO_BAR(cls): + return cls('''foo bar''') diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_false_does_not_match0.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_false_does_not_match0.py new file mode 100644 index 00000000000..223022bb57b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_false_does_not_match0.py @@ -0,0 +1,86 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class EnumWithFalseDoesNotMatch0( + _SchemaEnumMaker( + enum_value_to_name={ + False: "FALSE", + } + ), + BoolSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + def FALSE(cls): + return cls(False) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_true_does_not_match1.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_true_does_not_match1.py new file mode 100644 index 00000000000..6e997008625 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_true_does_not_match1.py @@ -0,0 +1,86 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class EnumWithTrueDoesNotMatch1( + _SchemaEnumMaker( + enum_value_to_name={ + True: "TRUE", + } + ), + BoolSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + def TRUE(cls): + return cls(True) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enums_in_properties.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enums_in_properties.py new file mode 100644 index 00000000000..192305479fc --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enums_in_properties.py @@ -0,0 +1,127 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class EnumsInProperties( + DictSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + _required_property_names = set(( + 'bar', + )) + + + class foo( + _SchemaEnumMaker( + enum_value_to_name={ + "foo": "FOO", + } + ), + StrSchema + ): + + @classmethod + @property + def FOO(cls): + return cls("foo") + + + class bar( + _SchemaEnumMaker( + enum_value_to_name={ + "bar": "BAR", + } + ), + StrSchema + ): + + @classmethod + @property + def BAR(cls): + return cls("bar") + + + def __new__( + cls, + *args: typing.Union[dict, frozendict, ], + bar: bar, + foo: typing.Union[foo, Unset] = unset, + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'EnumsInProperties': + return super().__new__( + cls, + *args, + bar=bar, + foo=foo, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/forbidden_property.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/forbidden_property.py new file mode 100644 index 00000000000..0b1dc6f6a5d --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/forbidden_property.py @@ -0,0 +1,132 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class ForbiddenProperty( + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + + class foo( + ComposedSchema + ): + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 + NotSchema = AnyTypeSchema + return { + 'allOf': [ + ], + 'oneOf': [ + ], + 'anyOf': [ + ], + 'not': + NotSchema + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'foo': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + foo: typing.Union[foo, Unset] = unset, + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'ForbiddenProperty': + return super().__new__( + cls, + *args, + foo=foo, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/hostname_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/hostname_format.py new file mode 100644 index 00000000000..89778b24464 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/hostname_format.py @@ -0,0 +1,67 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) +HostnameFormat = AnyTypeSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/integer_type_matches_integers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/integer_type_matches_integers.py new file mode 100644 index 00000000000..472bd37aa71 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/integer_type_matches_integers.py @@ -0,0 +1,67 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) +IntegerTypeMatchesIntegers = IntSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_instance_should_not_raise_error_when_float_division_inf.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_instance_should_not_raise_error_when_float_division_inf.py new file mode 100644 index 00000000000..84dcad131b2 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_instance_should_not_raise_error_when_float_division_inf.py @@ -0,0 +1,80 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf( + _SchemaValidator( + multiple_of=[0.123456789], + ), + IntSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + pass diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_string_value_for_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_string_value_for_default.py new file mode 100644 index 00000000000..07ad386d3b8 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/invalid_string_value_for_default.py @@ -0,0 +1,100 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class InvalidStringValueForDefault( + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + + class bar( + _SchemaValidator( + min_length=4, + ), + StrSchema + ): + pass + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + bar: typing.Union[bar, Unset] = unset, + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'InvalidStringValueForDefault': + return super().__new__( + cls, + *args, + bar=bar, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ipv4_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ipv4_format.py new file mode 100644 index 00000000000..b882729f886 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ipv4_format.py @@ -0,0 +1,67 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) +Ipv4Format = AnyTypeSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ipv6_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ipv6_format.py new file mode 100644 index 00000000000..9fa12e3fca7 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ipv6_format.py @@ -0,0 +1,67 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) +Ipv6Format = AnyTypeSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/json_pointer_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/json_pointer_format.py new file mode 100644 index 00000000000..670fd1785a1 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/json_pointer_format.py @@ -0,0 +1,67 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) +JsonPointerFormat = AnyTypeSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maximum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maximum_validation.py new file mode 100644 index 00000000000..155a514da50 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maximum_validation.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class MaximumValidation( + _SchemaValidator( + inclusive_maximum=3.0, + ), + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'MaximumValidation': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maximum_validation_with_unsigned_integer.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maximum_validation_with_unsigned_integer.py new file mode 100644 index 00000000000..0aa1cb53eb9 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maximum_validation_with_unsigned_integer.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class MaximumValidationWithUnsignedInteger( + _SchemaValidator( + inclusive_maximum=300, + ), + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'MaximumValidationWithUnsignedInteger': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxitems_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxitems_validation.py new file mode 100644 index 00000000000..20b1c37f9fc --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxitems_validation.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class MaxitemsValidation( + _SchemaValidator( + max_items=2, + ), + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'MaxitemsValidation': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxlength_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxlength_validation.py new file mode 100644 index 00000000000..daf2ce82f75 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxlength_validation.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class MaxlengthValidation( + _SchemaValidator( + max_length=2, + ), + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'MaxlengthValidation': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxproperties0_means_the_object_is_empty.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxproperties0_means_the_object_is_empty.py new file mode 100644 index 00000000000..12231672ec2 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxproperties0_means_the_object_is_empty.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class Maxproperties0MeansTheObjectIsEmpty( + _SchemaValidator( + max_properties=0, + ), + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'Maxproperties0MeansTheObjectIsEmpty': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxproperties_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxproperties_validation.py new file mode 100644 index 00000000000..30b4e4d2158 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/maxproperties_validation.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class MaxpropertiesValidation( + _SchemaValidator( + max_properties=2, + ), + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'MaxpropertiesValidation': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minimum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minimum_validation.py new file mode 100644 index 00000000000..bbe4414e080 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minimum_validation.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class MinimumValidation( + _SchemaValidator( + inclusive_minimum=1.1, + ), + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'MinimumValidation': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minimum_validation_with_signed_integer.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minimum_validation_with_signed_integer.py new file mode 100644 index 00000000000..c0996a1a84b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minimum_validation_with_signed_integer.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class MinimumValidationWithSignedInteger( + _SchemaValidator( + inclusive_minimum=-2, + ), + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'MinimumValidationWithSignedInteger': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minitems_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minitems_validation.py new file mode 100644 index 00000000000..14a07dd3414 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minitems_validation.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class MinitemsValidation( + _SchemaValidator( + min_items=1, + ), + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'MinitemsValidation': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minlength_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minlength_validation.py new file mode 100644 index 00000000000..a4ac28a41cb --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minlength_validation.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class MinlengthValidation( + _SchemaValidator( + min_length=2, + ), + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'MinlengthValidation': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minproperties_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minproperties_validation.py new file mode 100644 index 00000000000..74861d0b1ff --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/minproperties_validation.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class MinpropertiesValidation( + _SchemaValidator( + min_properties=1, + ), + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'MinpropertiesValidation': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/model_not.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/model_not.py new file mode 100644 index 00000000000..1b1c92f096d --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/model_not.py @@ -0,0 +1,112 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class ModelNot( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 + NotSchema = IntSchema + return { + 'allOf': [ + ], + 'oneOf': [ + ], + 'anyOf': [ + ], + 'not': + NotSchema + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'ModelNot': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_items.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_items.py new file mode 100644 index 00000000000..9b5e65ef0a3 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nested_items.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class NestedItems( + ListSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + + class _items( + ListSchema + ): + + + class _items( + ListSchema + ): + + + class _items( + ListSchema + ): + _items = NumberSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/not_more_complex_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/not_more_complex_schema.py new file mode 100644 index 00000000000..66f38098b51 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/not_more_complex_schema.py @@ -0,0 +1,133 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class NotMoreComplexSchema( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 + + + class NotSchema( + DictSchema + ): + foo = StrSchema + + + def __new__( + cls, + *args: typing.Union[dict, frozendict, ], + foo: typing.Union[foo, Unset] = unset, + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'NotSchema': + return super().__new__( + cls, + *args, + foo=foo, + _configuration=_configuration, + **kwargs, + ) + return { + 'allOf': [ + ], + 'oneOf': [ + ], + 'anyOf': [ + ], + 'not': + NotSchema + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'NotMoreComplexSchema': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nul_characters_in_strings.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nul_characters_in_strings.py new file mode 100644 index 00000000000..04ff26fd643 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/nul_characters_in_strings.py @@ -0,0 +1,86 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class NulCharactersInStrings( + _SchemaEnumMaker( + enum_value_to_name={ + "hello\x00there": "HELLOTHERE", + } + ), + StrSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + def HELLOTHERE(cls): + return cls("hello\x00there") diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/null_type_matches_only_the_null_object.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/null_type_matches_only_the_null_object.py new file mode 100644 index 00000000000..3ed5b3d6b3b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/null_type_matches_only_the_null_object.py @@ -0,0 +1,67 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) +NullTypeMatchesOnlyTheNullObject = NoneSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/number_type_matches_numbers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/number_type_matches_numbers.py new file mode 100644 index 00000000000..3b33c38f4cd --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/number_type_matches_numbers.py @@ -0,0 +1,67 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) +NumberTypeMatchesNumbers = NumberSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/object_properties_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/object_properties_validation.py new file mode 100644 index 00000000000..a5ac3ccf95d --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/object_properties_validation.py @@ -0,0 +1,95 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class ObjectPropertiesValidation( + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + foo = IntSchema + bar = StrSchema + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + foo: typing.Union[foo, Unset] = unset, + bar: typing.Union[bar, Unset] = unset, + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'ObjectPropertiesValidation': + return super().__new__( + cls, + *args, + foo=foo, + bar=bar, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/pattern_is_not_anchored.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/pattern_is_not_anchored.py new file mode 100644 index 00000000000..63923788782 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/pattern_is_not_anchored.py @@ -0,0 +1,94 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class PatternIsNotAnchored( + _SchemaValidator( + regex=[{ + 'pattern': r'a+', # noqa: E501 + }], + ), + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'PatternIsNotAnchored': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/pattern_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/pattern_validation.py new file mode 100644 index 00000000000..60d4530a637 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/pattern_validation.py @@ -0,0 +1,94 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class PatternValidation( + _SchemaValidator( + regex=[{ + 'pattern': r'^a*$', # noqa: E501 + }], + ), + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'PatternValidation': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/properties_with_escaped_characters.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/properties_with_escaped_characters.py new file mode 100644 index 00000000000..5b1aceb23a4 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/properties_with_escaped_characters.py @@ -0,0 +1,107 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class PropertiesWithEscapedCharacters( + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + foobar = NumberSchema + locals()["foo\nbar"] = foobar + del locals()['foobar'] + foobar = NumberSchema + locals()["foo\"bar"] = foobar + del locals()['foobar'] + foo_bar = NumberSchema + locals()["foo\\bar"] = foo_bar + del locals()['foo_bar'] + foobar = NumberSchema + locals()["foo\rbar"] = foobar + del locals()['foobar'] + foobar = NumberSchema + locals()["foo\tbar"] = foobar + del locals()['foobar'] + foobar = NumberSchema + locals()["foo\fbar"] = foobar + del locals()['foobar'] + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'PropertiesWithEscapedCharacters': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/property_named_ref_that_is_not_a_reference.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/property_named_ref_that_is_not_a_reference.py new file mode 100644 index 00000000000..0f3628abc04 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/property_named_ref_that_is_not_a_reference.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class PropertyNamedRefThatIsNotAReference( + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + ref = StrSchema + locals()["$ref"] = ref + del locals()['ref'] + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'PropertyNamedRefThatIsNotAReference': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_default_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_default_validation.py new file mode 100644 index 00000000000..94993796890 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_default_validation.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class RequiredDefaultValidation( + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + foo = AnyTypeSchema + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + foo: typing.Union[foo, Unset] = unset, + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'RequiredDefaultValidation': + return super().__new__( + cls, + *args, + foo=foo, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_validation.py new file mode 100644 index 00000000000..a0d4c00017a --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_validation.py @@ -0,0 +1,98 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class RequiredValidation( + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + _required_property_names = set(( + 'foo', + )) + foo = AnyTypeSchema + bar = AnyTypeSchema + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + foo: foo, + bar: typing.Union[bar, Unset] = unset, + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'RequiredValidation': + return super().__new__( + cls, + *args, + foo=foo, + bar=bar, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_with_empty_array.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_with_empty_array.py new file mode 100644 index 00000000000..4a7a203a126 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/required_with_empty_array.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class RequiredWithEmptyArray( + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + foo = AnyTypeSchema + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + foo: typing.Union[foo, Unset] = unset, + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'RequiredWithEmptyArray': + return super().__new__( + cls, + *args, + foo=foo, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/simple_enum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/simple_enum_validation.py new file mode 100644 index 00000000000..86f28a9dae3 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/simple_enum_validation.py @@ -0,0 +1,98 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class SimpleEnumValidation( + _SchemaEnumMaker( + enum_value_to_name={ + 1: "POSITIVE_1", + 2: "POSITIVE_2", + 3: "POSITIVE_3", + } + ), + NumberSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + def POSITIVE_1(cls): + return cls(1) + + @classmethod + @property + def POSITIVE_2(cls): + return cls(2) + + @classmethod + @property + def POSITIVE_3(cls): + return cls(3) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/string_type_matches_strings.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/string_type_matches_strings.py new file mode 100644 index 00000000000..f1c3c9a0302 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/string_type_matches_strings.py @@ -0,0 +1,67 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) +StringTypeMatchesStrings = StrSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/the_default_keyword_does_not_do_anything_if_the_property_is_missing.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/the_default_keyword_does_not_do_anything_if_the_property_is_missing.py new file mode 100644 index 00000000000..d59150db52b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/the_default_keyword_does_not_do_anything_if_the_property_is_missing.py @@ -0,0 +1,101 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing( + DictSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + + class alpha( + _SchemaValidator( + inclusive_maximum=3, + ), + NumberSchema + ): + pass + + + def __new__( + cls, + *args: typing.Union[dict, frozendict, ], + alpha: typing.Union[alpha, Unset] = unset, + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing': + return super().__new__( + cls, + *args, + alpha=alpha, + _configuration=_configuration, + **kwargs, + ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/uri_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/uri_format.py new file mode 100644 index 00000000000..61c87a3c4cf --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/uri_format.py @@ -0,0 +1,67 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) +UriFormat = AnyTypeSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/uri_reference_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/uri_reference_format.py new file mode 100644 index 00000000000..92c7c4fc73f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/uri_reference_format.py @@ -0,0 +1,67 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) +UriReferenceFormat = AnyTypeSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/uri_template_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/uri_template_format.py new file mode 100644 index 00000000000..636b9b2f272 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/uri_template_format.py @@ -0,0 +1,67 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) +UriTemplateFormat = AnyTypeSchema diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py index d53848a9d42..7f40cc8e240 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py @@ -11,5 +11,61 @@ # import sys # sys.setrecursionlimit(n) +from unit_test_api.model.additionalproperties_allows_a_schema_which_should_validate import AdditionalpropertiesAllowsASchemaWhichShouldValidate +from unit_test_api.model.additionalproperties_are_allowed_by_default import AdditionalpropertiesAreAllowedByDefault +from unit_test_api.model.additionalproperties_can_exist_by_itself import AdditionalpropertiesCanExistByItself +from unit_test_api.model.additionalproperties_should_not_look_in_applicators import AdditionalpropertiesShouldNotLookInApplicators +from unit_test_api.model.array_type_matches_arrays import ArrayTypeMatchesArrays +from unit_test_api.model.boolean_type_matches_booleans import BooleanTypeMatchesBooleans +from unit_test_api.model.by_int import ByInt +from unit_test_api.model.by_number import ByNumber +from unit_test_api.model.by_small_number import BySmallNumber +from unit_test_api.model.date_time_format import DateTimeFormat +from unit_test_api.model.email_format import EmailFormat +from unit_test_api.model.enum_with0_does_not_match_false import EnumWith0DoesNotMatchFalse +from unit_test_api.model.enum_with1_does_not_match_true import EnumWith1DoesNotMatchTrue +from unit_test_api.model.enum_with_escaped_characters import EnumWithEscapedCharacters +from unit_test_api.model.enum_with_false_does_not_match0 import EnumWithFalseDoesNotMatch0 +from unit_test_api.model.enum_with_true_does_not_match1 import EnumWithTrueDoesNotMatch1 +from unit_test_api.model.enums_in_properties import EnumsInProperties +from unit_test_api.model.forbidden_property import ForbiddenProperty +from unit_test_api.model.hostname_format import HostnameFormat +from unit_test_api.model.integer_type_matches_integers import IntegerTypeMatchesIntegers +from unit_test_api.model.invalid_instance_should_not_raise_error_when_float_division_inf import InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf +from unit_test_api.model.invalid_string_value_for_default import InvalidStringValueForDefault +from unit_test_api.model.ipv4_format import Ipv4Format +from unit_test_api.model.ipv6_format import Ipv6Format +from unit_test_api.model.json_pointer_format import JsonPointerFormat +from unit_test_api.model.maximum_validation import MaximumValidation +from unit_test_api.model.maximum_validation_with_unsigned_integer import MaximumValidationWithUnsignedInteger +from unit_test_api.model.maxitems_validation import MaxitemsValidation +from unit_test_api.model.maxlength_validation import MaxlengthValidation +from unit_test_api.model.maxproperties0_means_the_object_is_empty import Maxproperties0MeansTheObjectIsEmpty +from unit_test_api.model.maxproperties_validation import MaxpropertiesValidation +from unit_test_api.model.minimum_validation import MinimumValidation +from unit_test_api.model.minimum_validation_with_signed_integer import MinimumValidationWithSignedInteger +from unit_test_api.model.minitems_validation import MinitemsValidation +from unit_test_api.model.minlength_validation import MinlengthValidation +from unit_test_api.model.minproperties_validation import MinpropertiesValidation +from unit_test_api.model.model_not import ModelNot +from unit_test_api.model.nested_items import NestedItems +from unit_test_api.model.not_more_complex_schema import NotMoreComplexSchema +from unit_test_api.model.nul_characters_in_strings import NulCharactersInStrings +from unit_test_api.model.null_type_matches_only_the_null_object import NullTypeMatchesOnlyTheNullObject +from unit_test_api.model.number_type_matches_numbers import NumberTypeMatchesNumbers +from unit_test_api.model.object_properties_validation import ObjectPropertiesValidation +from unit_test_api.model.pattern_is_not_anchored import PatternIsNotAnchored +from unit_test_api.model.pattern_validation import PatternValidation +from unit_test_api.model.properties_with_escaped_characters import PropertiesWithEscapedCharacters +from unit_test_api.model.property_named_ref_that_is_not_a_reference import PropertyNamedRefThatIsNotAReference +from unit_test_api.model.required_default_validation import RequiredDefaultValidation +from unit_test_api.model.required_validation import RequiredValidation +from unit_test_api.model.required_with_empty_array import RequiredWithEmptyArray +from unit_test_api.model.simple_enum_validation import SimpleEnumValidation +from unit_test_api.model.string_type_matches_strings import StringTypeMatchesStrings +from unit_test_api.model.the_default_keyword_does_not_do_anything_if_the_property_is_missing import TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing from unit_test_api.model.uniqueitems_false_validation import UniqueitemsFalseValidation from unit_test_api.model.uniqueitems_validation import UniqueitemsValidation +from unit_test_api.model.uri_format import UriFormat +from unit_test_api.model.uri_reference_format import UriReferenceFormat +from unit_test_api.model.uri_template_format import UriTemplateFormat -- GitLab From f4f521794b13300cf0a9d23daf27e21588dfaf74 Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Wed, 29 Jun 2022 15:42:07 -0700 Subject: [PATCH 37/43] Fixes 2 failing tests, all python tests pass --- .../PythonExperimentalClientCodegen.java | 21 ++++++------------- .../payload_renderer.handlebars | 2 +- .../python-experimental/model_test.handlebars | 2 +- .../docs/EnumWithEscapedCharacters.md | 3 +-- ...s_allows_a_schema_which_should_validate.py | 2 +- ...dditionalproperties_can_exist_by_itself.py | 2 +- ...operties_should_not_look_in_applicators.py | 2 +- .../test/test_array_type_matches_arrays.py | 12 +++++------ .../test_boolean_type_matches_booleans.py | 16 +++++++------- .../python-experimental/test/test_by_int.py | 2 +- .../test/test_by_number.py | 2 +- .../test/test_by_small_number.py | 2 +- .../test_enum_with0_does_not_match_false.py | 2 +- .../test_enum_with1_does_not_match_true.py | 2 +- .../test/test_enum_with_escaped_characters.py | 2 +- .../test_enum_with_false_does_not_match0.py | 4 ++-- .../test_enum_with_true_does_not_match1.py | 4 ++-- .../test/test_enums_in_properties.py | 8 +++---- .../test/test_forbidden_property.py | 2 +- .../test_integer_type_matches_integers.py | 14 ++++++------- ...not_raise_error_when_float_division_inf.py | 2 +- .../test/test_maximum_validation.py | 2 +- ...aximum_validation_with_unsigned_integer.py | 2 +- .../test/test_maxitems_validation.py | 2 +- .../test/test_maxlength_validation.py | 2 +- ...axproperties0_means_the_object_is_empty.py | 2 +- .../test/test_maxproperties_validation.py | 2 +- .../test/test_minimum_validation.py | 2 +- ..._minimum_validation_with_signed_integer.py | 4 ++-- .../test/test_minitems_validation.py | 2 +- .../test/test_minlength_validation.py | 4 ++-- .../test/test_minproperties_validation.py | 2 +- .../test/test_model_not.py | 2 +- .../test/test_nested_items.py | 4 ++-- .../test/test_not_more_complex_schema.py | 2 +- .../test/test_nul_characters_in_strings.py | 4 ++-- ..._null_type_matches_only_the_null_object.py | 18 ++++++++-------- .../test/test_number_type_matches_numbers.py | 12 +++++------ .../test/test_object_properties_validation.py | 4 ++-- .../test/test_pattern_validation.py | 2 +- ...test_properties_with_escaped_characters.py | 2 +- ...perty_named_ref_that_is_not_a_reference.py | 2 +- .../test/test_required_validation.py | 2 +- .../test/test_simple_enum_validation.py | 2 +- .../test/test_string_type_matches_strings.py | 12 +++++------ ..._do_anything_if_the_property_is_missing.py | 2 +- .../test/test_uniqueitems_validation.py | 20 +++++++++--------- .../model/enum_with_escaped_characters.py | 10 ++++----- 48 files changed, 111 insertions(+), 123 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java index 2988ca07677..fed96db5c3c 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java @@ -1129,7 +1129,8 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen { } else if ("bool".equals(datatype)) { return value.substring(0, 1).toUpperCase(Locale.ROOT) + value.substring(1); } else { - return ensureQuotes(value); + String fixedValue = (String) processTestExampleData(value); + return ensureQuotes(fixedValue); } } @@ -1159,20 +1160,20 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen { } protected Object processTestExampleData(Object value) { - String nullChar = "\0"; if (value instanceof Integer){ return value; } else if (value instanceof Double || value instanceof Float || value instanceof Boolean){ return value; } else if (value instanceof String) { String stringValue = (String) value; - if (stringValue.contains(nullChar)) { - stringValue = stringValue.replace(nullChar, "\\x00"); - } String backslash = "\\"; if (stringValue.contains(backslash)) { stringValue = stringValue.replace(backslash, "\\\\"); } + String nullChar = "\0"; + if (stringValue.contains(nullChar)) { + stringValue = stringValue.replace(nullChar, "\\x00"); + } String doubleQuoteChar = "\""; if (stringValue.contains(doubleQuoteChar)) { stringValue = stringValue.replace(doubleQuoteChar, "\\\""); @@ -1451,20 +1452,10 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen { * @return quoted string */ private String ensureQuotes(String in) { - Pattern pattern = Pattern.compile("\r\n|\r|\n"); - Matcher matcher = pattern.matcher(in); - if (matcher.find()) { - // if a string has a new line in it add triple quotes to make it a python multiline string - return "'''" + in + "'''"; - } String strPattern = "^['\"].*?['\"]$"; if (in.matches(strPattern)) { return in; } - String nullChar = "\0"; - if (in.contains(nullChar)) { - in = in.replace(nullChar, "\\x00"); - } return "\"" + in + "\""; } diff --git a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars index 29507a82fb0..74b732e73f8 100644 --- a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars +++ b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars @@ -21,4 +21,4 @@ True{{else}} False{{/if}}{{/if}}{{#if isNull}} None{{/if}}{{#if isString}} -{{#if isMultilineString}}"""{{{value}}}"""{{else}}"{{{value}}}"{{/if}}{{/if}}{{/if}}{{/if}} \ No newline at end of file +"{{{value}}}"{{/if}}{{/if}}{{/if}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python-experimental/model_test.handlebars b/modules/openapi-generator/src/main/resources/python-experimental/model_test.handlebars index 031185e090c..1d8263084d7 100644 --- a/modules/openapi-generator/src/main/resources/python-experimental/model_test.handlebars +++ b/modules/openapi-generator/src/main/resources/python-experimental/model_test.handlebars @@ -26,7 +26,7 @@ class Test{{classname}}(unittest.TestCase): _configuration=self._configuration ) {{else}} - with self.assertRaises(({{packageName}}.ApiValueError, {{packageName}}.ApiTypeError, TypeError)): + with self.assertRaises(({{packageName}}.ApiValueError, {{packageName}}.ApiTypeError)): {{classname}}._from_openapi_data( {{#with data}} {{>model_templates/payload_renderer}}{{/with}}, diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithEscapedCharacters.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithEscapedCharacters.md index d13b6ca704f..df7d014c642 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithEscapedCharacters.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/EnumWithEscapedCharacters.md @@ -2,8 +2,7 @@ Type | Description | Notes ------------- | ------------- | ------------- -**str** | | must be one of ['''foo -bar''', '''foo bar''', ] +**str** | | must be one of ["foo\nbar", "foo\rbar", ] [[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/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py index 994760b620c..10b19045eb0 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py @@ -34,7 +34,7 @@ class TestAdditionalpropertiesAllowsASchemaWhichShouldValidate(unittest.TestCase def test_an_additional_invalid_property_is_invalid_fails(self): # an additional invalid property is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): AdditionalpropertiesAllowsASchemaWhichShouldValidate._from_openapi_data( { diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py index e22296dc29e..173d336032c 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py @@ -22,7 +22,7 @@ class TestAdditionalpropertiesCanExistByItself(unittest.TestCase): def test_an_additional_invalid_property_is_invalid_fails(self): # an additional invalid property is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): AdditionalpropertiesCanExistByItself._from_openapi_data( { diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py index f39cd8294b3..c3875c10d37 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py @@ -22,7 +22,7 @@ class TestAdditionalpropertiesShouldNotLookInApplicators(unittest.TestCase): def test_properties_defined_in_allof_are_not_examined_fails(self): # properties defined in allOf are not examined - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): AdditionalpropertiesShouldNotLookInApplicators._from_openapi_data( { diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py index c41228c3dc7..af8b1509f5d 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py @@ -22,7 +22,7 @@ class TestArrayTypeMatchesArrays(unittest.TestCase): def test_a_float_is_not_an_array_fails(self): # a float is not an array - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): ArrayTypeMatchesArrays._from_openapi_data( 1.1, _configuration=self._configuration @@ -30,7 +30,7 @@ class TestArrayTypeMatchesArrays(unittest.TestCase): def test_a_boolean_is_not_an_array_fails(self): # a boolean is not an array - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): ArrayTypeMatchesArrays._from_openapi_data( True, @@ -39,7 +39,7 @@ class TestArrayTypeMatchesArrays(unittest.TestCase): def test_null_is_not_an_array_fails(self): # null is not an array - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): ArrayTypeMatchesArrays._from_openapi_data( None, @@ -48,7 +48,7 @@ class TestArrayTypeMatchesArrays(unittest.TestCase): def test_an_object_is_not_an_array_fails(self): # an object is not an array - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): ArrayTypeMatchesArrays._from_openapi_data( { } @@ -58,7 +58,7 @@ class TestArrayTypeMatchesArrays(unittest.TestCase): def test_a_string_is_not_an_array_fails(self): # a string is not an array - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): ArrayTypeMatchesArrays._from_openapi_data( "foo", @@ -76,7 +76,7 @@ class TestArrayTypeMatchesArrays(unittest.TestCase): def test_an_integer_is_not_an_array_fails(self): # an integer is not an array - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): ArrayTypeMatchesArrays._from_openapi_data( 1, _configuration=self._configuration diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py index 205e7803b3d..bc47db7d540 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py @@ -22,7 +22,7 @@ class TestBooleanTypeMatchesBooleans(unittest.TestCase): def test_an_empty_string_is_not_a_boolean_fails(self): # an empty string is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): BooleanTypeMatchesBooleans._from_openapi_data( "", @@ -31,7 +31,7 @@ class TestBooleanTypeMatchesBooleans(unittest.TestCase): def test_a_float_is_not_a_boolean_fails(self): # a float is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): BooleanTypeMatchesBooleans._from_openapi_data( 1.1, _configuration=self._configuration @@ -39,7 +39,7 @@ class TestBooleanTypeMatchesBooleans(unittest.TestCase): def test_null_is_not_a_boolean_fails(self): # null is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): BooleanTypeMatchesBooleans._from_openapi_data( None, @@ -48,7 +48,7 @@ class TestBooleanTypeMatchesBooleans(unittest.TestCase): def test_zero_is_not_a_boolean_fails(self): # zero is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): BooleanTypeMatchesBooleans._from_openapi_data( 0, _configuration=self._configuration @@ -56,7 +56,7 @@ class TestBooleanTypeMatchesBooleans(unittest.TestCase): def test_an_array_is_not_a_boolean_fails(self): # an array is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): BooleanTypeMatchesBooleans._from_openapi_data( [ ] @@ -66,7 +66,7 @@ class TestBooleanTypeMatchesBooleans(unittest.TestCase): def test_a_string_is_not_a_boolean_fails(self): # a string is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): BooleanTypeMatchesBooleans._from_openapi_data( "foo", @@ -83,7 +83,7 @@ class TestBooleanTypeMatchesBooleans(unittest.TestCase): def test_an_integer_is_not_a_boolean_fails(self): # an integer is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): BooleanTypeMatchesBooleans._from_openapi_data( 1, _configuration=self._configuration @@ -99,7 +99,7 @@ class TestBooleanTypeMatchesBooleans(unittest.TestCase): def test_an_object_is_not_a_boolean_fails(self): # an object is not a boolean - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): BooleanTypeMatchesBooleans._from_openapi_data( { } diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_int.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_int.py index 9efc39152bd..d427cfcef91 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_int.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_int.py @@ -22,7 +22,7 @@ class TestByInt(unittest.TestCase): def test_int_by_int_fail_fails(self): # int by int fail - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): ByInt._from_openapi_data( 7, _configuration=self._configuration diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_number.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_number.py index af5e0d80911..3d8b9b5e502 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_number.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_number.py @@ -29,7 +29,7 @@ class TestByNumber(unittest.TestCase): def test_35_is_not_multiple_of15_fails(self): # 35 is not multiple of 1.5 - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): ByNumber._from_openapi_data( 35, _configuration=self._configuration diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_small_number.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_small_number.py index 1c89fab3167..5285fbe8208 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_small_number.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_small_number.py @@ -22,7 +22,7 @@ class TestBySmallNumber(unittest.TestCase): def test_000751_is_not_multiple_of00001_fails(self): # 0.00751 is not multiple of 0.0001 - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): BySmallNumber._from_openapi_data( 0.00751, _configuration=self._configuration diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with0_does_not_match_false.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with0_does_not_match_false.py index 69d576b5dba..8a91c50da03 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with0_does_not_match_false.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with0_does_not_match_false.py @@ -36,7 +36,7 @@ class TestEnumWith0DoesNotMatchFalse(unittest.TestCase): def test_false_is_invalid_fails(self): # false is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): EnumWith0DoesNotMatchFalse._from_openapi_data( False, diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with1_does_not_match_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with1_does_not_match_true.py index e1ad8fa4f08..62102e01482 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with1_does_not_match_true.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with1_does_not_match_true.py @@ -22,7 +22,7 @@ class TestEnumWith1DoesNotMatchTrue(unittest.TestCase): def test_true_is_invalid_fails(self): # true is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): EnumWith1DoesNotMatchTrue._from_openapi_data( True, diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_escaped_characters.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_escaped_characters.py index b7b774156b9..1b21a892b58 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_escaped_characters.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_escaped_characters.py @@ -38,7 +38,7 @@ class TestEnumWithEscapedCharacters(unittest.TestCase): def test_another_string_is_invalid_fails(self): # another string is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): EnumWithEscapedCharacters._from_openapi_data( "abc", diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_false_does_not_match0.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_false_does_not_match0.py index d3a59f18ee8..24d1ef2d2ee 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_false_does_not_match0.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_false_does_not_match0.py @@ -30,7 +30,7 @@ class TestEnumWithFalseDoesNotMatch0(unittest.TestCase): def test_float_zero_is_invalid_fails(self): # float zero is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): EnumWithFalseDoesNotMatch0._from_openapi_data( 0.0, _configuration=self._configuration @@ -38,7 +38,7 @@ class TestEnumWithFalseDoesNotMatch0(unittest.TestCase): def test_integer_zero_is_invalid_fails(self): # integer zero is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): EnumWithFalseDoesNotMatch0._from_openapi_data( 0, _configuration=self._configuration diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_true_does_not_match1.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_true_does_not_match1.py index 52ca73287ea..773430f9624 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_true_does_not_match1.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_true_does_not_match1.py @@ -22,7 +22,7 @@ class TestEnumWithTrueDoesNotMatch1(unittest.TestCase): def test_float_one_is_invalid_fails(self): # float one is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): EnumWithTrueDoesNotMatch1._from_openapi_data( 1.0, _configuration=self._configuration @@ -38,7 +38,7 @@ class TestEnumWithTrueDoesNotMatch1(unittest.TestCase): def test_integer_one_is_invalid_fails(self): # integer one is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): EnumWithTrueDoesNotMatch1._from_openapi_data( 1, _configuration=self._configuration diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enums_in_properties.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enums_in_properties.py index 790e7e06a67..132ed9b04e3 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enums_in_properties.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enums_in_properties.py @@ -35,7 +35,7 @@ class TestEnumsInProperties(unittest.TestCase): def test_wrong_foo_value_fails(self): # wrong foo value - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): EnumsInProperties._from_openapi_data( { @@ -70,7 +70,7 @@ class TestEnumsInProperties(unittest.TestCase): def test_wrong_bar_value_fails(self): # wrong bar value - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): EnumsInProperties._from_openapi_data( { @@ -88,7 +88,7 @@ class TestEnumsInProperties(unittest.TestCase): def test_missing_all_properties_is_invalid_fails(self): # missing all properties is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): EnumsInProperties._from_openapi_data( { } @@ -98,7 +98,7 @@ class TestEnumsInProperties(unittest.TestCase): def test_missing_required_property_is_invalid_fails(self): # missing required property is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): EnumsInProperties._from_openapi_data( { diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_forbidden_property.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_forbidden_property.py index b6921c8efea..82b42176abd 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_forbidden_property.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_forbidden_property.py @@ -22,7 +22,7 @@ class TestForbiddenProperty(unittest.TestCase): def test_property_present_fails(self): # property present - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): ForbiddenProperty._from_openapi_data( { diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py index db960e3a8a9..ec738a9259a 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py @@ -22,7 +22,7 @@ class TestIntegerTypeMatchesIntegers(unittest.TestCase): def test_an_object_is_not_an_integer_fails(self): # an object is not an integer - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): IntegerTypeMatchesIntegers._from_openapi_data( { } @@ -32,7 +32,7 @@ class TestIntegerTypeMatchesIntegers(unittest.TestCase): def test_a_string_is_not_an_integer_fails(self): # a string is not an integer - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): IntegerTypeMatchesIntegers._from_openapi_data( "foo", @@ -41,7 +41,7 @@ class TestIntegerTypeMatchesIntegers(unittest.TestCase): def test_null_is_not_an_integer_fails(self): # null is not an integer - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): IntegerTypeMatchesIntegers._from_openapi_data( None, @@ -57,7 +57,7 @@ class TestIntegerTypeMatchesIntegers(unittest.TestCase): def test_a_float_is_not_an_integer_fails(self): # a float is not an integer - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): IntegerTypeMatchesIntegers._from_openapi_data( 1.1, _configuration=self._configuration @@ -65,7 +65,7 @@ class TestIntegerTypeMatchesIntegers(unittest.TestCase): def test_a_boolean_is_not_an_integer_fails(self): # a boolean is not an integer - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): IntegerTypeMatchesIntegers._from_openapi_data( True, @@ -81,7 +81,7 @@ class TestIntegerTypeMatchesIntegers(unittest.TestCase): def test_a_string_is_still_not_an_integer_even_if_it_looks_like_one_fails(self): # a string is still not an integer, even if it looks like one - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): IntegerTypeMatchesIntegers._from_openapi_data( "1", @@ -90,7 +90,7 @@ class TestIntegerTypeMatchesIntegers(unittest.TestCase): def test_an_array_is_not_an_integer_fails(self): # an array is not an integer - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): IntegerTypeMatchesIntegers._from_openapi_data( [ ] diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_instance_should_not_raise_error_when_float_division_inf.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_instance_should_not_raise_error_when_float_division_inf.py index 0b3d9760867..1adbd02515b 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_instance_should_not_raise_error_when_float_division_inf.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_instance_should_not_raise_error_when_float_division_inf.py @@ -22,7 +22,7 @@ class TestInvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf(unittest.TestCa def test_always_invalid_but_naive_implementations_may_raise_an_overflow_error_fails(self): # always invalid, but naive implementations may raise an overflow error - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf._from_openapi_data( 1.0E308, _configuration=self._configuration diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation.py index 708b5be1f1a..023a7b6658f 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation.py @@ -36,7 +36,7 @@ class TestMaximumValidation(unittest.TestCase): def test_above_the_maximum_is_invalid_fails(self): # above the maximum is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): MaximumValidation._from_openapi_data( 3.5, _configuration=self._configuration diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation_with_unsigned_integer.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation_with_unsigned_integer.py index 14dab7b966e..71db49f9870 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation_with_unsigned_integer.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation_with_unsigned_integer.py @@ -29,7 +29,7 @@ class TestMaximumValidationWithUnsignedInteger(unittest.TestCase): def test_above_the_maximum_is_invalid_fails(self): # above the maximum is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): MaximumValidationWithUnsignedInteger._from_openapi_data( 300.5, _configuration=self._configuration diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxitems_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxitems_validation.py index ec11cefd860..2c41c45e6f5 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxitems_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxitems_validation.py @@ -22,7 +22,7 @@ class TestMaxitemsValidation(unittest.TestCase): def test_too_long_is_invalid_fails(self): # too long is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): MaxitemsValidation._from_openapi_data( [ 1, diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxlength_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxlength_validation.py index 6447e4804d1..2eb9ee39779 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxlength_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxlength_validation.py @@ -22,7 +22,7 @@ class TestMaxlengthValidation(unittest.TestCase): def test_too_long_is_invalid_fails(self): # too long is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): MaxlengthValidation._from_openapi_data( "foo", diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties0_means_the_object_is_empty.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties0_means_the_object_is_empty.py index 3c276fbc5fa..a565ead0c8a 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties0_means_the_object_is_empty.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties0_means_the_object_is_empty.py @@ -31,7 +31,7 @@ class TestMaxproperties0MeansTheObjectIsEmpty(unittest.TestCase): def test_one_property_is_invalid_fails(self): # one property is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): Maxproperties0MeansTheObjectIsEmpty._from_openapi_data( { diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties_validation.py index 03218918dcc..c80c43ab4a8 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties_validation.py @@ -22,7 +22,7 @@ class TestMaxpropertiesValidation(unittest.TestCase): def test_too_long_is_invalid_fails(self): # too long is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): MaxpropertiesValidation._from_openapi_data( { diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation.py index c74720ce511..4c870234124 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation.py @@ -29,7 +29,7 @@ class TestMinimumValidation(unittest.TestCase): def test_below_the_minimum_is_invalid_fails(self): # below the minimum is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): MinimumValidation._from_openapi_data( 0.6, _configuration=self._configuration diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation_with_signed_integer.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation_with_signed_integer.py index 8a3c09c9111..3ab04123abe 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation_with_signed_integer.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation_with_signed_integer.py @@ -36,7 +36,7 @@ class TestMinimumValidationWithSignedInteger(unittest.TestCase): def test_int_below_the_minimum_is_invalid_fails(self): # int below the minimum is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): MinimumValidationWithSignedInteger._from_openapi_data( -3, _configuration=self._configuration @@ -44,7 +44,7 @@ class TestMinimumValidationWithSignedInteger(unittest.TestCase): def test_float_below_the_minimum_is_invalid_fails(self): # float below the minimum is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): MinimumValidationWithSignedInteger._from_openapi_data( -2.0001, _configuration=self._configuration diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minitems_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minitems_validation.py index e2ae443d4f8..eb25e0bc517 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minitems_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minitems_validation.py @@ -22,7 +22,7 @@ class TestMinitemsValidation(unittest.TestCase): def test_too_short_is_invalid_fails(self): # too short is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): MinitemsValidation._from_openapi_data( [ ] diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minlength_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minlength_validation.py index 0349cd358c5..c7f7c27f6f3 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minlength_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minlength_validation.py @@ -22,7 +22,7 @@ class TestMinlengthValidation(unittest.TestCase): def test_too_short_is_invalid_fails(self): # too short is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): MinlengthValidation._from_openapi_data( "f", @@ -31,7 +31,7 @@ class TestMinlengthValidation(unittest.TestCase): def test_one_supplementary_unicode_code_point_is_not_long_enough_fails(self): # one supplementary Unicode code point is not long enough - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): MinlengthValidation._from_openapi_data( "💩", diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minproperties_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minproperties_validation.py index 2536ecea876..6ed23ecf670 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minproperties_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minproperties_validation.py @@ -38,7 +38,7 @@ class TestMinpropertiesValidation(unittest.TestCase): def test_too_short_is_invalid_fails(self): # too short is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): MinpropertiesValidation._from_openapi_data( { } diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_model_not.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_model_not.py index fa5d57a0a00..26e4c451d3a 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_model_not.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_model_not.py @@ -30,7 +30,7 @@ class TestModelNot(unittest.TestCase): def test_disallowed_fails(self): # disallowed - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): ModelNot._from_openapi_data( 1, _configuration=self._configuration diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_items.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_items.py index f9cd1696b2a..46453d6eb7d 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_items.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_items.py @@ -70,7 +70,7 @@ class TestNestedItems(unittest.TestCase): def test_nested_array_with_invalid_type_fails(self): # nested array with invalid type - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NestedItems._from_openapi_data( [ [ @@ -120,7 +120,7 @@ class TestNestedItems(unittest.TestCase): def test_not_deep_enough_fails(self): # not deep enough - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NestedItems._from_openapi_data( [ [ diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_not_more_complex_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_not_more_complex_schema.py index 3c9e98a74ce..bac1d81f1e4 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_not_more_complex_schema.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_not_more_complex_schema.py @@ -34,7 +34,7 @@ class TestNotMoreComplexSchema(unittest.TestCase): def test_mismatch_fails(self): # mismatch - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NotMoreComplexSchema._from_openapi_data( { diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nul_characters_in_strings.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nul_characters_in_strings.py index cb6ee4fe896..ca8e0f4113f 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nul_characters_in_strings.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nul_characters_in_strings.py @@ -24,13 +24,13 @@ class TestNulCharactersInStrings(unittest.TestCase): # match string with nul NulCharactersInStrings._from_openapi_data( - "hello\\x00there", + "hello\x00there", _configuration=self._configuration ) def test_do_not_match_string_lacking_nul_fails(self): # do not match string lacking nul - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NulCharactersInStrings._from_openapi_data( "hellothere", diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py index a03cc120afc..b6025f1011a 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py @@ -22,7 +22,7 @@ class TestNullTypeMatchesOnlyTheNullObject(unittest.TestCase): def test_a_float_is_not_null_fails(self): # a float is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NullTypeMatchesOnlyTheNullObject._from_openapi_data( 1.1, _configuration=self._configuration @@ -30,7 +30,7 @@ class TestNullTypeMatchesOnlyTheNullObject(unittest.TestCase): def test_an_object_is_not_null_fails(self): # an object is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NullTypeMatchesOnlyTheNullObject._from_openapi_data( { } @@ -40,7 +40,7 @@ class TestNullTypeMatchesOnlyTheNullObject(unittest.TestCase): def test_false_is_not_null_fails(self): # false is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NullTypeMatchesOnlyTheNullObject._from_openapi_data( False, @@ -49,7 +49,7 @@ class TestNullTypeMatchesOnlyTheNullObject(unittest.TestCase): def test_an_integer_is_not_null_fails(self): # an integer is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NullTypeMatchesOnlyTheNullObject._from_openapi_data( 1, _configuration=self._configuration @@ -57,7 +57,7 @@ class TestNullTypeMatchesOnlyTheNullObject(unittest.TestCase): def test_true_is_not_null_fails(self): # true is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NullTypeMatchesOnlyTheNullObject._from_openapi_data( True, @@ -66,7 +66,7 @@ class TestNullTypeMatchesOnlyTheNullObject(unittest.TestCase): def test_zero_is_not_null_fails(self): # zero is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NullTypeMatchesOnlyTheNullObject._from_openapi_data( 0, _configuration=self._configuration @@ -74,7 +74,7 @@ class TestNullTypeMatchesOnlyTheNullObject(unittest.TestCase): def test_an_empty_string_is_not_null_fails(self): # an empty string is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NullTypeMatchesOnlyTheNullObject._from_openapi_data( "", @@ -91,7 +91,7 @@ class TestNullTypeMatchesOnlyTheNullObject(unittest.TestCase): def test_an_array_is_not_null_fails(self): # an array is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NullTypeMatchesOnlyTheNullObject._from_openapi_data( [ ] @@ -101,7 +101,7 @@ class TestNullTypeMatchesOnlyTheNullObject(unittest.TestCase): def test_a_string_is_not_null_fails(self): # a string is not null - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NullTypeMatchesOnlyTheNullObject._from_openapi_data( "foo", diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py index c1488496508..86178158723 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py @@ -22,7 +22,7 @@ class TestNumberTypeMatchesNumbers(unittest.TestCase): def test_an_array_is_not_a_number_fails(self): # an array is not a number - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NumberTypeMatchesNumbers._from_openapi_data( [ ] @@ -32,7 +32,7 @@ class TestNumberTypeMatchesNumbers(unittest.TestCase): def test_null_is_not_a_number_fails(self): # null is not a number - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NumberTypeMatchesNumbers._from_openapi_data( None, @@ -41,7 +41,7 @@ class TestNumberTypeMatchesNumbers(unittest.TestCase): def test_an_object_is_not_a_number_fails(self): # an object is not a number - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NumberTypeMatchesNumbers._from_openapi_data( { } @@ -51,7 +51,7 @@ class TestNumberTypeMatchesNumbers(unittest.TestCase): def test_a_boolean_is_not_a_number_fails(self): # a boolean is not a number - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NumberTypeMatchesNumbers._from_openapi_data( True, @@ -67,7 +67,7 @@ class TestNumberTypeMatchesNumbers(unittest.TestCase): def test_a_string_is_still_not_a_number_even_if_it_looks_like_one_fails(self): # a string is still not a number, even if it looks like one - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NumberTypeMatchesNumbers._from_openapi_data( "1", @@ -76,7 +76,7 @@ class TestNumberTypeMatchesNumbers(unittest.TestCase): def test_a_string_is_not_a_number_fails(self): # a string is not a number - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NumberTypeMatchesNumbers._from_openapi_data( "foo", diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_object_properties_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_object_properties_validation.py index 7acd54635bd..bc26f21348f 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_object_properties_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_object_properties_validation.py @@ -38,7 +38,7 @@ class TestObjectPropertiesValidation(unittest.TestCase): def test_one_property_invalid_is_invalid_fails(self): # one property invalid is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): ObjectPropertiesValidation._from_openapi_data( { @@ -86,7 +86,7 @@ class TestObjectPropertiesValidation(unittest.TestCase): def test_both_properties_invalid_is_invalid_fails(self): # both properties invalid is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): ObjectPropertiesValidation._from_openapi_data( { diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_validation.py index d9bc1e1750f..1413ba855d3 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_validation.py @@ -55,7 +55,7 @@ class TestPatternValidation(unittest.TestCase): def test_a_non_matching_pattern_is_invalid_fails(self): # a non-matching pattern is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): PatternValidation._from_openapi_data( "abc", diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py index 5c114a79bd4..cfdf5c47250 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py @@ -49,7 +49,7 @@ class TestPropertiesWithEscapedCharacters(unittest.TestCase): def test_object_with_strings_is_invalid_fails(self): # object with strings is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): PropertiesWithEscapedCharacters._from_openapi_data( { diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_property_named_ref_that_is_not_a_reference.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_property_named_ref_that_is_not_a_reference.py index 0b099e71700..ed14673ad76 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_property_named_ref_that_is_not_a_reference.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_property_named_ref_that_is_not_a_reference.py @@ -35,7 +35,7 @@ class TestPropertyNamedRefThatIsNotAReference(unittest.TestCase): def test_property_named_ref_invalid_fails(self): # property named $ref invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): PropertyNamedRefThatIsNotAReference._from_openapi_data( { diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_validation.py index b358c6bd044..395869ff228 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_validation.py @@ -58,7 +58,7 @@ class TestRequiredValidation(unittest.TestCase): def test_non_present_required_property_is_invalid_fails(self): # non-present required property is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): RequiredValidation._from_openapi_data( { diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_simple_enum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_simple_enum_validation.py index 92fc4a0c3d0..391e9ff39d6 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_simple_enum_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_simple_enum_validation.py @@ -22,7 +22,7 @@ class TestSimpleEnumValidation(unittest.TestCase): def test_something_else_is_invalid_fails(self): # something else is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): SimpleEnumValidation._from_openapi_data( 4, _configuration=self._configuration diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py index 9e85997f5f6..d6bdee13053 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py @@ -22,7 +22,7 @@ class TestStringTypeMatchesStrings(unittest.TestCase): def test_1_is_not_a_string_fails(self): # 1 is not a string - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): StringTypeMatchesStrings._from_openapi_data( 1, _configuration=self._configuration @@ -46,7 +46,7 @@ class TestStringTypeMatchesStrings(unittest.TestCase): def test_a_float_is_not_a_string_fails(self): # a float is not a string - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): StringTypeMatchesStrings._from_openapi_data( 1.1, _configuration=self._configuration @@ -54,7 +54,7 @@ class TestStringTypeMatchesStrings(unittest.TestCase): def test_an_object_is_not_a_string_fails(self): # an object is not a string - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): StringTypeMatchesStrings._from_openapi_data( { } @@ -64,7 +64,7 @@ class TestStringTypeMatchesStrings(unittest.TestCase): def test_an_array_is_not_a_string_fails(self): # an array is not a string - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): StringTypeMatchesStrings._from_openapi_data( [ ] @@ -74,7 +74,7 @@ class TestStringTypeMatchesStrings(unittest.TestCase): def test_a_boolean_is_not_a_string_fails(self): # a boolean is not a string - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): StringTypeMatchesStrings._from_openapi_data( True, @@ -83,7 +83,7 @@ class TestStringTypeMatchesStrings(unittest.TestCase): def test_null_is_not_a_string_fails(self): # null is not a string - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): StringTypeMatchesStrings._from_openapi_data( None, diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py index 1908fdd11fe..6f33ffe3eee 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py @@ -43,7 +43,7 @@ class TestTheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing(unittest.Test def test_an_explicit_property_value_is_checked_against_maximum_failing_fails(self): # an explicit property value is checked against maximum (failing) - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing._from_openapi_data( { diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uniqueitems_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uniqueitems_validation.py index 1a87d4d91a6..1e0c948ccb9 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uniqueitems_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uniqueitems_validation.py @@ -67,7 +67,7 @@ class TestUniqueitemsValidation(unittest.TestCase): def test_non_unique_heterogeneous_types_are_invalid_fails(self): # non-unique heterogeneous types are invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): UniqueitemsValidation._from_openapi_data( [ { @@ -142,7 +142,7 @@ class TestUniqueitemsValidation(unittest.TestCase): def test_numbers_are_unique_if_mathematically_unequal_fails(self): # numbers are unique if mathematically unequal - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): UniqueitemsValidation._from_openapi_data( [ 1.0, @@ -204,7 +204,7 @@ class TestUniqueitemsValidation(unittest.TestCase): def test_non_unique_array_of_nested_objects_is_invalid_fails(self): # non-unique array of nested objects is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): UniqueitemsValidation._from_openapi_data( [ { @@ -248,7 +248,7 @@ class TestUniqueitemsValidation(unittest.TestCase): def test_non_unique_array_of_more_than_two_integers_is_invalid_fails(self): # non-unique array of more than two integers is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): UniqueitemsValidation._from_openapi_data( [ 1, @@ -273,7 +273,7 @@ class TestUniqueitemsValidation(unittest.TestCase): def test_objects_are_non_unique_despite_key_order_fails(self): # objects are non-unique despite key order - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): UniqueitemsValidation._from_openapi_data( [ { @@ -372,7 +372,7 @@ class TestUniqueitemsValidation(unittest.TestCase): def test_non_unique_array_of_more_than_two_arrays_is_invalid_fails(self): # non-unique array of more than two arrays is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): UniqueitemsValidation._from_openapi_data( [ [ @@ -397,7 +397,7 @@ class TestUniqueitemsValidation(unittest.TestCase): def test_non_unique_array_of_objects_is_invalid_fails(self): # non-unique array of objects is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): UniqueitemsValidation._from_openapi_data( [ { @@ -464,7 +464,7 @@ class TestUniqueitemsValidation(unittest.TestCase): def test_non_unique_array_of_arrays_is_invalid_fails(self): # non-unique array of arrays is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): UniqueitemsValidation._from_openapi_data( [ [ @@ -484,7 +484,7 @@ class TestUniqueitemsValidation(unittest.TestCase): def test_non_unique_array_of_strings_is_invalid_fails(self): # non-unique array of strings is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): UniqueitemsValidation._from_openapi_data( [ @@ -551,7 +551,7 @@ class TestUniqueitemsValidation(unittest.TestCase): def test_non_unique_array_of_integers_is_invalid_fails(self): # non-unique array of integers is invalid - with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError, TypeError)): + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): UniqueitemsValidation._from_openapi_data( [ 1, diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_escaped_characters.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_escaped_characters.py index 3354101f399..7db769c23e7 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_escaped_characters.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/enum_with_escaped_characters.py @@ -69,9 +69,8 @@ from unit_test_api.schemas import ( # noqa: F401 class EnumWithEscapedCharacters( _SchemaEnumMaker( enum_value_to_name={ - '''foo -bar''': "FOO_BAR", - '''foo bar''': "FOO_BAR", + "foo\nbar": "FOO_BAR", + "foo\rbar": "FOO_BAR", } ), StrSchema @@ -85,10 +84,9 @@ bar''': "FOO_BAR", @classmethod @property def FOO_BAR(cls): - return cls('''foo -bar''') + return cls("foo\nbar") @classmethod @property def FOO_BAR(cls): - return cls('''foo bar''') + return cls("foo\rbar") -- GitLab From 30bb9bcc6f9d510d7f1bd6c615771bad0542549a Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Wed, 29 Jun 2022 17:51:40 -0700 Subject: [PATCH 38/43] Fixes java npe errors --- .../java/org/openapitools/codegen/DefaultCodegen.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index a6541b554ba..7d26b12d0cd 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -2752,9 +2752,6 @@ public class DefaultCodegen implements CodegenConfig { */ @Override public CodegenModel fromModel(String name, Schema schema) { - HashMap<String, Object> vendorExtensions = (HashMap<String, Object>) openAPI.getComponents().getExtensions(); - HashMap<String, SchemaTestCase> schemaTestCases = extractSchemaTestCases(name, vendorExtensions); - Map<String, Schema> allDefinitions = ModelUtils.getSchemas(this.openAPI); if (typeAliases == null) { // Only do this once during first call @@ -2770,7 +2767,11 @@ public class DefaultCodegen implements CodegenConfig { CodegenModel m = CodegenModelFactory.newInstance(CodegenModelType.MODEL); ModelUtils.syncValidationProperties(schema, m); - m.testCases = schemaTestCases; + if (openAPI != null) { + HashMap<String, Object> vendorExtensions = (HashMap<String, Object>) openAPI.getComponents().getExtensions(); + HashMap<String, SchemaTestCase> schemaTestCases = extractSchemaTestCases(name, vendorExtensions); + m.testCases = schemaTestCases; + } if (reservedWords.contains(name)) { m.name = escapeReservedWord(name); -- GitLab From 22ac2cf27998c21a1fe7597ff0f261c419752e21 Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Wed, 29 Jun 2022 23:32:35 -0700 Subject: [PATCH 39/43] Fixes formatting of tests, indentation fixed --- .../python-experimental/comma.handlebars | 1 + .../payload_renderer.handlebars | 53 +- .../python-experimental/model_test.handlebars | 16 +- ...s_allows_a_schema_which_should_validate.py | 35 +- ...tionalproperties_are_allowed_by_default.py | 13 +- ...dditionalproperties_can_exist_by_itself.py | 15 +- ...operties_should_not_look_in_applicators.py | 10 +- .../test/test_array_type_matches_arrays.py | 17 +- .../test_boolean_type_matches_booleans.py | 21 +- .../python-experimental/test/test_by_int.py | 5 +- .../test/test_by_number.py | 6 +- .../test/test_by_small_number.py | 4 +- .../test/test_date_time_format.py | 16 +- .../test/test_email_format.py | 16 +- .../test_enum_with0_does_not_match_false.py | 5 +- .../test_enum_with1_does_not_match_true.py | 5 +- .../test/test_enum_with_escaped_characters.py | 3 - .../test_enum_with_false_does_not_match0.py | 5 +- .../test_enum_with_true_does_not_match1.py | 5 +- .../test/test_enums_in_properties.py | 46 +- .../test/test_forbidden_property.py | 22 +- .../test/test_hostname_format.py | 16 +- .../test_integer_type_matches_integers.py | 20 +- ...not_raise_error_when_float_division_inf.py | 2 +- .../test_invalid_string_value_for_default.py | 12 +- .../test/test_ipv4_format.py | 16 +- .../test/test_ipv6_format.py | 16 +- .../test/test_json_pointer_format.py | 16 +- .../test/test_maximum_validation.py | 7 +- ...aximum_validation_with_unsigned_integer.py | 8 +- .../test/test_maxitems_validation.py | 28 +- .../test/test_maxlength_validation.py | 6 +- ...axproperties0_means_the_object_is_empty.py | 13 +- .../test/test_maxproperties_validation.py | 47 +- .../test/test_minimum_validation.py | 7 +- ..._minimum_validation_with_signed_integer.py | 13 +- .../test/test_minitems_validation.py | 22 +- .../test/test_minlength_validation.py | 6 +- .../test/test_minproperties_validation.py | 32 +- .../test/test_model_not.py | 3 +- .../test/test_nested_items.py | 198 +++---- .../test/test_not_more_complex_schema.py | 17 +- .../test/test_nul_characters_in_strings.py | 2 - ..._null_type_matches_only_the_null_object.py | 21 +- .../test/test_number_type_matches_numbers.py | 20 +- .../test/test_object_properties_validation.py | 59 +-- .../test/test_pattern_is_not_anchored.py | 1 - .../test/test_pattern_validation.py | 18 +- ...test_properties_with_escaped_characters.py | 40 +- ...perty_named_ref_that_is_not_a_reference.py | 15 +- .../test/test_required_default_validation.py | 5 +- .../test/test_required_validation.py | 24 +- .../test/test_required_with_empty_array.py | 5 +- .../test/test_simple_enum_validation.py | 4 +- .../test/test_string_type_matches_strings.py | 19 +- ..._do_anything_if_the_property_is_missing.py | 21 +- .../test/test_uniqueitems_false_validation.py | 266 ++++------ .../test/test_uniqueitems_validation.py | 491 +++++++----------- .../test/test_uri_format.py | 16 +- .../test/test_uri_reference_format.py | 16 +- .../test/test_uri_template_format.py | 16 +- 61 files changed, 699 insertions(+), 1184 deletions(-) create mode 100644 modules/openapi-generator/src/main/resources/python-experimental/comma.handlebars diff --git a/modules/openapi-generator/src/main/resources/python-experimental/comma.handlebars b/modules/openapi-generator/src/main/resources/python-experimental/comma.handlebars new file mode 100644 index 00000000000..41622b47209 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python-experimental/comma.handlebars @@ -0,0 +1 @@ +, \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars index 74b732e73f8..cc5451785b0 100644 --- a/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars +++ b/modules/openapi-generator/src/main/resources/python-experimental/model_templates/payload_renderer.handlebars @@ -1,24 +1,35 @@ +{{#if isMap}} +{ +{{#each value}} +{{#with @key}} + {{> model_templates/payload_renderer endChar=':'}} +{{/with}} +{{#with this}} + {{> model_templates/payload_renderer endChar=','}} +{{/with}} +{{/each}} +}{{endChar}} +{{/if}} {{#if isArray}} [ - {{#each value}} - {{> model_templates/payload_renderer }}, - {{/each}} -] +{{#each value}} + {{> model_templates/payload_renderer endChar=','}} +{{/each}} +]{{endChar}} +{{/if}} +{{#or isNumber isUnboundedInteger}} +{{value}}{{endChar}} +{{/or}} +{{#if isBoolean}} +{{#if value}} +True{{endChar}} {{else}} -{{#if isMap}} -{ - {{#each value}} - {{#with @key}} - {{> model_templates/payload_renderer }}: - {{/with}} - {{#with this}} - {{> model_templates/payload_renderer }}, - {{/with}} - {{/each}} -} -{{else}}{{#or isNumber isUnboundedInteger}} -{{value}}{{/or}}{{#if isBoolean}}{{#if value}} -True{{else}} -False{{/if}}{{/if}}{{#if isNull}} -None{{/if}}{{#if isString}} -"{{{value}}}"{{/if}}{{/if}}{{/if}} \ No newline at end of file +False{{endChar}} +{{/if}} +{{/if}} +{{#if isNull}} +None{{endChar}} +{{/if}} +{{#if isString}} +"{{{value}}}"{{endChar}} +{{/if}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python-experimental/model_test.handlebars b/modules/openapi-generator/src/main/resources/python-experimental/model_test.handlebars index 1d8263084d7..174fe3a1763 100644 --- a/modules/openapi-generator/src/main/resources/python-experimental/model_test.handlebars +++ b/modules/openapi-generator/src/main/resources/python-experimental/model_test.handlebars @@ -16,24 +16,26 @@ class Test{{classname}}(unittest.TestCase): _configuration = configuration.Configuration() {{#each testCases}} - {{#with this }} +{{#with this }} def test_{{@key}}_{{#if valid}}passes{{else}}fails{{/if}}(self): # {{description}} - {{#if valid}} +{{#if valid}} {{classname}}._from_openapi_data( {{#with data}} - {{>model_templates/payload_renderer}}{{/with}}, + {{> model_templates/payload_renderer endChar=',' }} +{{/with}} _configuration=self._configuration ) - {{else}} +{{else}} with self.assertRaises(({{packageName}}.ApiValueError, {{packageName}}.ApiTypeError)): {{classname}}._from_openapi_data( {{#with data}} - {{>model_templates/payload_renderer}}{{/with}}, + {{> model_templates/payload_renderer endChar=','}} +{{/with}} _configuration=self._configuration ) - {{/if}} - {{/with}} +{{/if}} +{{/with}} {{/each}} {{/with}} diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py index 10b19045eb0..9d9c82d710e 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_allows_a_schema_which_should_validate.py @@ -23,12 +23,10 @@ class TestAdditionalpropertiesAllowsASchemaWhichShouldValidate(unittest.TestCase def test_no_additional_properties_is_valid_passes(self): # no additional properties is valid AdditionalpropertiesAllowsASchemaWhichShouldValidate._from_openapi_data( - { - + { "foo": - 1, - } -, + 1, + }, _configuration=self._configuration ) @@ -36,37 +34,28 @@ class TestAdditionalpropertiesAllowsASchemaWhichShouldValidate(unittest.TestCase # an additional invalid property is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): AdditionalpropertiesAllowsASchemaWhichShouldValidate._from_openapi_data( - { - + { "foo": - 1, - + 1, "bar": - 2, - + 2, "quux": - 12, - } -, + 12, + }, _configuration=self._configuration ) def test_an_additional_valid_property_is_valid_passes(self): # an additional valid property is valid AdditionalpropertiesAllowsASchemaWhichShouldValidate._from_openapi_data( - { - + { "foo": - 1, - + 1, "bar": - 2, - + 2, "quux": - True, - } -, + }, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py index 483dbd4372b..e52b193fdb3 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_are_allowed_by_default.py @@ -23,19 +23,14 @@ class TestAdditionalpropertiesAreAllowedByDefault(unittest.TestCase): def test_additional_properties_are_allowed_passes(self): # additional properties are allowed AdditionalpropertiesAreAllowedByDefault._from_openapi_data( - { - + { "foo": - 1, - + 1, "bar": - 2, - + 2, "quux": - True, - } -, + }, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py index 173d336032c..3a6473f23ba 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_can_exist_by_itself.py @@ -24,25 +24,20 @@ class TestAdditionalpropertiesCanExistByItself(unittest.TestCase): # an additional invalid property is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): AdditionalpropertiesCanExistByItself._from_openapi_data( - { - + { "foo": - 1, - } -, + 1, + }, _configuration=self._configuration ) def test_an_additional_valid_property_is_valid_passes(self): # an additional valid property is valid AdditionalpropertiesCanExistByItself._from_openapi_data( - { - + { "foo": - True, - } -, + }, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py index c3875c10d37..f296b2ad621 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_additionalproperties_should_not_look_in_applicators.py @@ -24,16 +24,12 @@ class TestAdditionalpropertiesShouldNotLookInApplicators(unittest.TestCase): # properties defined in allOf are not examined with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): AdditionalpropertiesShouldNotLookInApplicators._from_openapi_data( - { - + { "foo": - 1, - + 1, "bar": - True, - } -, + }, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py index af8b1509f5d..b8bc156e18b 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_array_type_matches_arrays.py @@ -24,7 +24,7 @@ class TestArrayTypeMatchesArrays(unittest.TestCase): # a float is not an array with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): ArrayTypeMatchesArrays._from_openapi_data( - 1.1, + 1.1, _configuration=self._configuration ) @@ -32,7 +32,6 @@ class TestArrayTypeMatchesArrays(unittest.TestCase): # a boolean is not an array with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): ArrayTypeMatchesArrays._from_openapi_data( - True, _configuration=self._configuration ) @@ -41,7 +40,6 @@ class TestArrayTypeMatchesArrays(unittest.TestCase): # null is not an array with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): ArrayTypeMatchesArrays._from_openapi_data( - None, _configuration=self._configuration ) @@ -50,9 +48,8 @@ class TestArrayTypeMatchesArrays(unittest.TestCase): # an object is not an array with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): ArrayTypeMatchesArrays._from_openapi_data( - { - } -, + { + }, _configuration=self._configuration ) @@ -60,7 +57,6 @@ class TestArrayTypeMatchesArrays(unittest.TestCase): # a string is not an array with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): ArrayTypeMatchesArrays._from_openapi_data( - "foo", _configuration=self._configuration ) @@ -68,9 +64,8 @@ class TestArrayTypeMatchesArrays(unittest.TestCase): def test_an_array_is_an_array_passes(self): # an array is an array ArrayTypeMatchesArrays._from_openapi_data( - [ - ] -, + [ + ], _configuration=self._configuration ) @@ -78,7 +73,7 @@ class TestArrayTypeMatchesArrays(unittest.TestCase): # an integer is not an array with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): ArrayTypeMatchesArrays._from_openapi_data( - 1, + 1, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py index bc47db7d540..3ffb73ed957 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_boolean_type_matches_booleans.py @@ -24,7 +24,6 @@ class TestBooleanTypeMatchesBooleans(unittest.TestCase): # an empty string is not a boolean with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): BooleanTypeMatchesBooleans._from_openapi_data( - "", _configuration=self._configuration ) @@ -33,7 +32,7 @@ class TestBooleanTypeMatchesBooleans(unittest.TestCase): # a float is not a boolean with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): BooleanTypeMatchesBooleans._from_openapi_data( - 1.1, + 1.1, _configuration=self._configuration ) @@ -41,7 +40,6 @@ class TestBooleanTypeMatchesBooleans(unittest.TestCase): # null is not a boolean with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): BooleanTypeMatchesBooleans._from_openapi_data( - None, _configuration=self._configuration ) @@ -50,7 +48,7 @@ class TestBooleanTypeMatchesBooleans(unittest.TestCase): # zero is not a boolean with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): BooleanTypeMatchesBooleans._from_openapi_data( - 0, + 0, _configuration=self._configuration ) @@ -58,9 +56,8 @@ class TestBooleanTypeMatchesBooleans(unittest.TestCase): # an array is not a boolean with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): BooleanTypeMatchesBooleans._from_openapi_data( - [ - ] -, + [ + ], _configuration=self._configuration ) @@ -68,7 +65,6 @@ class TestBooleanTypeMatchesBooleans(unittest.TestCase): # a string is not a boolean with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): BooleanTypeMatchesBooleans._from_openapi_data( - "foo", _configuration=self._configuration ) @@ -76,7 +72,6 @@ class TestBooleanTypeMatchesBooleans(unittest.TestCase): def test_false_is_a_boolean_passes(self): # false is a boolean BooleanTypeMatchesBooleans._from_openapi_data( - False, _configuration=self._configuration ) @@ -85,14 +80,13 @@ class TestBooleanTypeMatchesBooleans(unittest.TestCase): # an integer is not a boolean with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): BooleanTypeMatchesBooleans._from_openapi_data( - 1, + 1, _configuration=self._configuration ) def test_true_is_a_boolean_passes(self): # true is a boolean BooleanTypeMatchesBooleans._from_openapi_data( - True, _configuration=self._configuration ) @@ -101,9 +95,8 @@ class TestBooleanTypeMatchesBooleans(unittest.TestCase): # an object is not a boolean with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): BooleanTypeMatchesBooleans._from_openapi_data( - { - } -, + { + }, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_int.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_int.py index d427cfcef91..26254a7aaa8 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_int.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_int.py @@ -24,21 +24,20 @@ class TestByInt(unittest.TestCase): # int by int fail with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): ByInt._from_openapi_data( - 7, + 7, _configuration=self._configuration ) def test_int_by_int_passes(self): # int by int ByInt._from_openapi_data( - 10, + 10, _configuration=self._configuration ) def test_ignores_non_numbers_passes(self): # ignores non-numbers ByInt._from_openapi_data( - "foo", _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_number.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_number.py index 3d8b9b5e502..928b8f3c645 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_number.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_number.py @@ -23,7 +23,7 @@ class TestByNumber(unittest.TestCase): def test_45_is_multiple_of15_passes(self): # 4.5 is multiple of 1.5 ByNumber._from_openapi_data( - 4.5, + 4.5, _configuration=self._configuration ) @@ -31,14 +31,14 @@ class TestByNumber(unittest.TestCase): # 35 is not multiple of 1.5 with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): ByNumber._from_openapi_data( - 35, + 35, _configuration=self._configuration ) def test_zero_is_multiple_of_anything_passes(self): # zero is multiple of anything ByNumber._from_openapi_data( - 0, + 0, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_small_number.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_small_number.py index 5285fbe8208..cc683feebe2 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_small_number.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_by_small_number.py @@ -24,14 +24,14 @@ class TestBySmallNumber(unittest.TestCase): # 0.00751 is not multiple of 0.0001 with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): BySmallNumber._from_openapi_data( - 0.00751, + 0.00751, _configuration=self._configuration ) def test_00075_is_multiple_of00001_passes(self): # 0.0075 is multiple of 0.0001 BySmallNumber._from_openapi_data( - 0.0075, + 0.0075, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_date_time_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_date_time_format.py index c78c16d7f38..b3a2b154373 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_date_time_format.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_date_time_format.py @@ -23,16 +23,14 @@ class TestDateTimeFormat(unittest.TestCase): def test_all_string_formats_ignore_objects_passes(self): # all string formats ignore objects DateTimeFormat._from_openapi_data( - { - } -, + { + }, _configuration=self._configuration ) def test_all_string_formats_ignore_booleans_passes(self): # all string formats ignore booleans DateTimeFormat._from_openapi_data( - False, _configuration=self._configuration ) @@ -40,30 +38,28 @@ class TestDateTimeFormat(unittest.TestCase): def test_all_string_formats_ignore_integers_passes(self): # all string formats ignore integers DateTimeFormat._from_openapi_data( - 12, + 12, _configuration=self._configuration ) def test_all_string_formats_ignore_floats_passes(self): # all string formats ignore floats DateTimeFormat._from_openapi_data( - 13.7, + 13.7, _configuration=self._configuration ) def test_all_string_formats_ignore_arrays_passes(self): # all string formats ignore arrays DateTimeFormat._from_openapi_data( - [ - ] -, + [ + ], _configuration=self._configuration ) def test_all_string_formats_ignore_nulls_passes(self): # all string formats ignore nulls DateTimeFormat._from_openapi_data( - None, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_email_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_email_format.py index 4011d06bc9e..c6b2d51c19c 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_email_format.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_email_format.py @@ -23,16 +23,14 @@ class TestEmailFormat(unittest.TestCase): def test_all_string_formats_ignore_objects_passes(self): # all string formats ignore objects EmailFormat._from_openapi_data( - { - } -, + { + }, _configuration=self._configuration ) def test_all_string_formats_ignore_booleans_passes(self): # all string formats ignore booleans EmailFormat._from_openapi_data( - False, _configuration=self._configuration ) @@ -40,30 +38,28 @@ class TestEmailFormat(unittest.TestCase): def test_all_string_formats_ignore_integers_passes(self): # all string formats ignore integers EmailFormat._from_openapi_data( - 12, + 12, _configuration=self._configuration ) def test_all_string_formats_ignore_floats_passes(self): # all string formats ignore floats EmailFormat._from_openapi_data( - 13.7, + 13.7, _configuration=self._configuration ) def test_all_string_formats_ignore_arrays_passes(self): # all string formats ignore arrays EmailFormat._from_openapi_data( - [ - ] -, + [ + ], _configuration=self._configuration ) def test_all_string_formats_ignore_nulls_passes(self): # all string formats ignore nulls EmailFormat._from_openapi_data( - None, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with0_does_not_match_false.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with0_does_not_match_false.py index 8a91c50da03..f2917a571bc 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with0_does_not_match_false.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with0_does_not_match_false.py @@ -23,14 +23,14 @@ class TestEnumWith0DoesNotMatchFalse(unittest.TestCase): def test_integer_zero_is_valid_passes(self): # integer zero is valid EnumWith0DoesNotMatchFalse._from_openapi_data( - 0, + 0, _configuration=self._configuration ) def test_float_zero_is_valid_passes(self): # float zero is valid EnumWith0DoesNotMatchFalse._from_openapi_data( - 0.0, + 0.0, _configuration=self._configuration ) @@ -38,7 +38,6 @@ class TestEnumWith0DoesNotMatchFalse(unittest.TestCase): # false is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): EnumWith0DoesNotMatchFalse._from_openapi_data( - False, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with1_does_not_match_true.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with1_does_not_match_true.py index 62102e01482..8b498180763 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with1_does_not_match_true.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with1_does_not_match_true.py @@ -24,7 +24,6 @@ class TestEnumWith1DoesNotMatchTrue(unittest.TestCase): # true is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): EnumWith1DoesNotMatchTrue._from_openapi_data( - True, _configuration=self._configuration ) @@ -32,14 +31,14 @@ class TestEnumWith1DoesNotMatchTrue(unittest.TestCase): def test_integer_one_is_valid_passes(self): # integer one is valid EnumWith1DoesNotMatchTrue._from_openapi_data( - 1, + 1, _configuration=self._configuration ) def test_float_one_is_valid_passes(self): # float one is valid EnumWith1DoesNotMatchTrue._from_openapi_data( - 1.0, + 1.0, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_escaped_characters.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_escaped_characters.py index 1b21a892b58..658588f2b0d 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_escaped_characters.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_escaped_characters.py @@ -23,7 +23,6 @@ class TestEnumWithEscapedCharacters(unittest.TestCase): def test_member2_is_valid_passes(self): # member 2 is valid EnumWithEscapedCharacters._from_openapi_data( - "foo\rbar", _configuration=self._configuration ) @@ -31,7 +30,6 @@ class TestEnumWithEscapedCharacters(unittest.TestCase): def test_member1_is_valid_passes(self): # member 1 is valid EnumWithEscapedCharacters._from_openapi_data( - "foo\nbar", _configuration=self._configuration ) @@ -40,7 +38,6 @@ class TestEnumWithEscapedCharacters(unittest.TestCase): # another string is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): EnumWithEscapedCharacters._from_openapi_data( - "abc", _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_false_does_not_match0.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_false_does_not_match0.py index 24d1ef2d2ee..c62d5f79091 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_false_does_not_match0.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_false_does_not_match0.py @@ -23,7 +23,6 @@ class TestEnumWithFalseDoesNotMatch0(unittest.TestCase): def test_false_is_valid_passes(self): # false is valid EnumWithFalseDoesNotMatch0._from_openapi_data( - False, _configuration=self._configuration ) @@ -32,7 +31,7 @@ class TestEnumWithFalseDoesNotMatch0(unittest.TestCase): # float zero is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): EnumWithFalseDoesNotMatch0._from_openapi_data( - 0.0, + 0.0, _configuration=self._configuration ) @@ -40,7 +39,7 @@ class TestEnumWithFalseDoesNotMatch0(unittest.TestCase): # integer zero is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): EnumWithFalseDoesNotMatch0._from_openapi_data( - 0, + 0, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_true_does_not_match1.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_true_does_not_match1.py index 773430f9624..9339856f4f5 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_true_does_not_match1.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enum_with_true_does_not_match1.py @@ -24,14 +24,13 @@ class TestEnumWithTrueDoesNotMatch1(unittest.TestCase): # float one is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): EnumWithTrueDoesNotMatch1._from_openapi_data( - 1.0, + 1.0, _configuration=self._configuration ) def test_true_is_valid_passes(self): # true is valid EnumWithTrueDoesNotMatch1._from_openapi_data( - True, _configuration=self._configuration ) @@ -40,7 +39,7 @@ class TestEnumWithTrueDoesNotMatch1(unittest.TestCase): # integer one is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): EnumWithTrueDoesNotMatch1._from_openapi_data( - 1, + 1, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enums_in_properties.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enums_in_properties.py index 132ed9b04e3..87c5112a3fb 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enums_in_properties.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_enums_in_properties.py @@ -23,13 +23,10 @@ class TestEnumsInProperties(unittest.TestCase): def test_missing_optional_property_is_valid_passes(self): # missing optional property is valid EnumsInProperties._from_openapi_data( - { - + { "bar": - "bar", - } -, + }, _configuration=self._configuration ) @@ -37,34 +34,24 @@ class TestEnumsInProperties(unittest.TestCase): # wrong foo value with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): EnumsInProperties._from_openapi_data( - { - + { "foo": - "foot", - "bar": - "bar", - } -, + }, _configuration=self._configuration ) def test_both_properties_are_valid_passes(self): # both properties are valid EnumsInProperties._from_openapi_data( - { - + { "foo": - "foo", - "bar": - "bar", - } -, + }, _configuration=self._configuration ) @@ -72,17 +59,12 @@ class TestEnumsInProperties(unittest.TestCase): # wrong bar value with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): EnumsInProperties._from_openapi_data( - { - + { "foo": - "foo", - "bar": - "bart", - } -, + }, _configuration=self._configuration ) @@ -90,9 +72,8 @@ class TestEnumsInProperties(unittest.TestCase): # missing all properties is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): EnumsInProperties._from_openapi_data( - { - } -, + { + }, _configuration=self._configuration ) @@ -100,13 +81,10 @@ class TestEnumsInProperties(unittest.TestCase): # missing required property is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): EnumsInProperties._from_openapi_data( - { - + { "foo": - "foo", - } -, + }, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_forbidden_property.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_forbidden_property.py index 82b42176abd..b48d39902f6 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_forbidden_property.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_forbidden_property.py @@ -24,30 +24,24 @@ class TestForbiddenProperty(unittest.TestCase): # property present with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): ForbiddenProperty._from_openapi_data( - { - + { "foo": - 1, - + 1, "bar": - 2, - } -, + 2, + }, _configuration=self._configuration ) def test_property_absent_passes(self): # property absent ForbiddenProperty._from_openapi_data( - { - + { "bar": - 1, - + 1, "baz": - 2, - } -, + 2, + }, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_hostname_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_hostname_format.py index e1bfb5600f0..32a6f0d003e 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_hostname_format.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_hostname_format.py @@ -23,16 +23,14 @@ class TestHostnameFormat(unittest.TestCase): def test_all_string_formats_ignore_objects_passes(self): # all string formats ignore objects HostnameFormat._from_openapi_data( - { - } -, + { + }, _configuration=self._configuration ) def test_all_string_formats_ignore_booleans_passes(self): # all string formats ignore booleans HostnameFormat._from_openapi_data( - False, _configuration=self._configuration ) @@ -40,30 +38,28 @@ class TestHostnameFormat(unittest.TestCase): def test_all_string_formats_ignore_integers_passes(self): # all string formats ignore integers HostnameFormat._from_openapi_data( - 12, + 12, _configuration=self._configuration ) def test_all_string_formats_ignore_floats_passes(self): # all string formats ignore floats HostnameFormat._from_openapi_data( - 13.7, + 13.7, _configuration=self._configuration ) def test_all_string_formats_ignore_arrays_passes(self): # all string formats ignore arrays HostnameFormat._from_openapi_data( - [ - ] -, + [ + ], _configuration=self._configuration ) def test_all_string_formats_ignore_nulls_passes(self): # all string formats ignore nulls HostnameFormat._from_openapi_data( - None, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py index ec738a9259a..ecf83a0586c 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_integer_type_matches_integers.py @@ -24,9 +24,8 @@ class TestIntegerTypeMatchesIntegers(unittest.TestCase): # an object is not an integer with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): IntegerTypeMatchesIntegers._from_openapi_data( - { - } -, + { + }, _configuration=self._configuration ) @@ -34,7 +33,6 @@ class TestIntegerTypeMatchesIntegers(unittest.TestCase): # a string is not an integer with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): IntegerTypeMatchesIntegers._from_openapi_data( - "foo", _configuration=self._configuration ) @@ -43,7 +41,6 @@ class TestIntegerTypeMatchesIntegers(unittest.TestCase): # null is not an integer with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): IntegerTypeMatchesIntegers._from_openapi_data( - None, _configuration=self._configuration ) @@ -51,7 +48,7 @@ class TestIntegerTypeMatchesIntegers(unittest.TestCase): def test_a_float_with_zero_fractional_part_is_an_integer_passes(self): # a float with zero fractional part is an integer IntegerTypeMatchesIntegers._from_openapi_data( - 1.0, + 1.0, _configuration=self._configuration ) @@ -59,7 +56,7 @@ class TestIntegerTypeMatchesIntegers(unittest.TestCase): # a float is not an integer with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): IntegerTypeMatchesIntegers._from_openapi_data( - 1.1, + 1.1, _configuration=self._configuration ) @@ -67,7 +64,6 @@ class TestIntegerTypeMatchesIntegers(unittest.TestCase): # a boolean is not an integer with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): IntegerTypeMatchesIntegers._from_openapi_data( - True, _configuration=self._configuration ) @@ -75,7 +71,7 @@ class TestIntegerTypeMatchesIntegers(unittest.TestCase): def test_an_integer_is_an_integer_passes(self): # an integer is an integer IntegerTypeMatchesIntegers._from_openapi_data( - 1, + 1, _configuration=self._configuration ) @@ -83,7 +79,6 @@ class TestIntegerTypeMatchesIntegers(unittest.TestCase): # a string is still not an integer, even if it looks like one with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): IntegerTypeMatchesIntegers._from_openapi_data( - "1", _configuration=self._configuration ) @@ -92,9 +87,8 @@ class TestIntegerTypeMatchesIntegers(unittest.TestCase): # an array is not an integer with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): IntegerTypeMatchesIntegers._from_openapi_data( - [ - ] -, + [ + ], _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_instance_should_not_raise_error_when_float_division_inf.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_instance_should_not_raise_error_when_float_division_inf.py index 1adbd02515b..67ce05d42f6 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_instance_should_not_raise_error_when_float_division_inf.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_instance_should_not_raise_error_when_float_division_inf.py @@ -24,7 +24,7 @@ class TestInvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf(unittest.TestCa # always invalid, but naive implementations may raise an overflow error with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf._from_openapi_data( - 1.0E308, + 1.0E308, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_string_value_for_default.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_string_value_for_default.py index 6e5c92b388f..50f165727b5 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_string_value_for_default.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_invalid_string_value_for_default.py @@ -23,22 +23,18 @@ class TestInvalidStringValueForDefault(unittest.TestCase): def test_valid_when_property_is_specified_passes(self): # valid when property is specified InvalidStringValueForDefault._from_openapi_data( - { - + { "bar": - "good", - } -, + }, _configuration=self._configuration ) def test_still_valid_when_the_invalid_default_is_used_passes(self): # still valid when the invalid default is used InvalidStringValueForDefault._from_openapi_data( - { - } -, + { + }, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ipv4_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ipv4_format.py index ad07e265276..cd4cd9a69d9 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ipv4_format.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ipv4_format.py @@ -23,16 +23,14 @@ class TestIpv4Format(unittest.TestCase): def test_all_string_formats_ignore_objects_passes(self): # all string formats ignore objects Ipv4Format._from_openapi_data( - { - } -, + { + }, _configuration=self._configuration ) def test_all_string_formats_ignore_booleans_passes(self): # all string formats ignore booleans Ipv4Format._from_openapi_data( - False, _configuration=self._configuration ) @@ -40,30 +38,28 @@ class TestIpv4Format(unittest.TestCase): def test_all_string_formats_ignore_integers_passes(self): # all string formats ignore integers Ipv4Format._from_openapi_data( - 12, + 12, _configuration=self._configuration ) def test_all_string_formats_ignore_floats_passes(self): # all string formats ignore floats Ipv4Format._from_openapi_data( - 13.7, + 13.7, _configuration=self._configuration ) def test_all_string_formats_ignore_arrays_passes(self): # all string formats ignore arrays Ipv4Format._from_openapi_data( - [ - ] -, + [ + ], _configuration=self._configuration ) def test_all_string_formats_ignore_nulls_passes(self): # all string formats ignore nulls Ipv4Format._from_openapi_data( - None, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ipv6_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ipv6_format.py index 569d8401957..e9e10a48905 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ipv6_format.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ipv6_format.py @@ -23,16 +23,14 @@ class TestIpv6Format(unittest.TestCase): def test_all_string_formats_ignore_objects_passes(self): # all string formats ignore objects Ipv6Format._from_openapi_data( - { - } -, + { + }, _configuration=self._configuration ) def test_all_string_formats_ignore_booleans_passes(self): # all string formats ignore booleans Ipv6Format._from_openapi_data( - False, _configuration=self._configuration ) @@ -40,30 +38,28 @@ class TestIpv6Format(unittest.TestCase): def test_all_string_formats_ignore_integers_passes(self): # all string formats ignore integers Ipv6Format._from_openapi_data( - 12, + 12, _configuration=self._configuration ) def test_all_string_formats_ignore_floats_passes(self): # all string formats ignore floats Ipv6Format._from_openapi_data( - 13.7, + 13.7, _configuration=self._configuration ) def test_all_string_formats_ignore_arrays_passes(self): # all string formats ignore arrays Ipv6Format._from_openapi_data( - [ - ] -, + [ + ], _configuration=self._configuration ) def test_all_string_formats_ignore_nulls_passes(self): # all string formats ignore nulls Ipv6Format._from_openapi_data( - None, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_json_pointer_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_json_pointer_format.py index b53440098e1..f20c6aff949 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_json_pointer_format.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_json_pointer_format.py @@ -23,16 +23,14 @@ class TestJsonPointerFormat(unittest.TestCase): def test_all_string_formats_ignore_objects_passes(self): # all string formats ignore objects JsonPointerFormat._from_openapi_data( - { - } -, + { + }, _configuration=self._configuration ) def test_all_string_formats_ignore_booleans_passes(self): # all string formats ignore booleans JsonPointerFormat._from_openapi_data( - False, _configuration=self._configuration ) @@ -40,30 +38,28 @@ class TestJsonPointerFormat(unittest.TestCase): def test_all_string_formats_ignore_integers_passes(self): # all string formats ignore integers JsonPointerFormat._from_openapi_data( - 12, + 12, _configuration=self._configuration ) def test_all_string_formats_ignore_floats_passes(self): # all string formats ignore floats JsonPointerFormat._from_openapi_data( - 13.7, + 13.7, _configuration=self._configuration ) def test_all_string_formats_ignore_arrays_passes(self): # all string formats ignore arrays JsonPointerFormat._from_openapi_data( - [ - ] -, + [ + ], _configuration=self._configuration ) def test_all_string_formats_ignore_nulls_passes(self): # all string formats ignore nulls JsonPointerFormat._from_openapi_data( - None, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation.py index 023a7b6658f..5c0e51f822a 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation.py @@ -23,14 +23,14 @@ class TestMaximumValidation(unittest.TestCase): def test_below_the_maximum_is_valid_passes(self): # below the maximum is valid MaximumValidation._from_openapi_data( - 2.6, + 2.6, _configuration=self._configuration ) def test_boundary_point_is_valid_passes(self): # boundary point is valid MaximumValidation._from_openapi_data( - 3.0, + 3.0, _configuration=self._configuration ) @@ -38,14 +38,13 @@ class TestMaximumValidation(unittest.TestCase): # above the maximum is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): MaximumValidation._from_openapi_data( - 3.5, + 3.5, _configuration=self._configuration ) def test_ignores_non_numbers_passes(self): # ignores non-numbers MaximumValidation._from_openapi_data( - "x", _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation_with_unsigned_integer.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation_with_unsigned_integer.py index 71db49f9870..4bc8a4f8372 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation_with_unsigned_integer.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maximum_validation_with_unsigned_integer.py @@ -23,7 +23,7 @@ class TestMaximumValidationWithUnsignedInteger(unittest.TestCase): def test_below_the_maximum_is_invalid_passes(self): # below the maximum is invalid MaximumValidationWithUnsignedInteger._from_openapi_data( - 299.97, + 299.97, _configuration=self._configuration ) @@ -31,21 +31,21 @@ class TestMaximumValidationWithUnsignedInteger(unittest.TestCase): # above the maximum is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): MaximumValidationWithUnsignedInteger._from_openapi_data( - 300.5, + 300.5, _configuration=self._configuration ) def test_boundary_point_integer_is_valid_passes(self): # boundary point integer is valid MaximumValidationWithUnsignedInteger._from_openapi_data( - 300, + 300, _configuration=self._configuration ) def test_boundary_point_float_is_valid_passes(self): # boundary point float is valid MaximumValidationWithUnsignedInteger._from_openapi_data( - 300.0, + 300.0, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxitems_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxitems_validation.py index 2c41c45e6f5..10804599c31 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxitems_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxitems_validation.py @@ -24,19 +24,17 @@ class TestMaxitemsValidation(unittest.TestCase): # too long is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): MaxitemsValidation._from_openapi_data( - [ - 1, - 2, - 3, - ] -, + [ + 1, + 2, + 3, + ], _configuration=self._configuration ) def test_ignores_non_arrays_passes(self): # ignores non-arrays MaxitemsValidation._from_openapi_data( - "foobar", _configuration=self._configuration ) @@ -44,21 +42,19 @@ class TestMaxitemsValidation(unittest.TestCase): def test_shorter_is_valid_passes(self): # shorter is valid MaxitemsValidation._from_openapi_data( - [ - 1, - ] -, + [ + 1, + ], _configuration=self._configuration ) def test_exact_length_is_valid_passes(self): # exact length is valid MaxitemsValidation._from_openapi_data( - [ - 1, - 2, - ] -, + [ + 1, + 2, + ], _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxlength_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxlength_validation.py index 2eb9ee39779..e5871ed0f1c 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxlength_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxlength_validation.py @@ -24,7 +24,6 @@ class TestMaxlengthValidation(unittest.TestCase): # too long is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): MaxlengthValidation._from_openapi_data( - "foo", _configuration=self._configuration ) @@ -32,14 +31,13 @@ class TestMaxlengthValidation(unittest.TestCase): def test_ignores_non_strings_passes(self): # ignores non-strings MaxlengthValidation._from_openapi_data( - 100, + 100, _configuration=self._configuration ) def test_shorter_is_valid_passes(self): # shorter is valid MaxlengthValidation._from_openapi_data( - "f", _configuration=self._configuration ) @@ -47,7 +45,6 @@ class TestMaxlengthValidation(unittest.TestCase): def test_two_supplementary_unicode_code_points_is_long_enough_passes(self): # two supplementary Unicode code points is long enough MaxlengthValidation._from_openapi_data( - "💩💩", _configuration=self._configuration ) @@ -55,7 +52,6 @@ class TestMaxlengthValidation(unittest.TestCase): def test_exact_length_is_valid_passes(self): # exact length is valid MaxlengthValidation._from_openapi_data( - "fo", _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties0_means_the_object_is_empty.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties0_means_the_object_is_empty.py index a565ead0c8a..57764ac4a84 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties0_means_the_object_is_empty.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties0_means_the_object_is_empty.py @@ -23,9 +23,8 @@ class TestMaxproperties0MeansTheObjectIsEmpty(unittest.TestCase): def test_no_properties_is_valid_passes(self): # no properties is valid Maxproperties0MeansTheObjectIsEmpty._from_openapi_data( - { - } -, + { + }, _configuration=self._configuration ) @@ -33,12 +32,10 @@ class TestMaxproperties0MeansTheObjectIsEmpty(unittest.TestCase): # one property is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): Maxproperties0MeansTheObjectIsEmpty._from_openapi_data( - { - + { "foo": - 1, - } -, + 1, + }, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties_validation.py index c80c43ab4a8..cd87cbfc645 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_maxproperties_validation.py @@ -24,44 +24,38 @@ class TestMaxpropertiesValidation(unittest.TestCase): # too long is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): MaxpropertiesValidation._from_openapi_data( - { - + { "foo": - 1, - + 1, "bar": - 2, - + 2, "baz": - 3, - } -, + 3, + }, _configuration=self._configuration ) def test_ignores_arrays_passes(self): # ignores arrays MaxpropertiesValidation._from_openapi_data( - [ - 1, - 2, - 3, - ] -, + [ + 1, + 2, + 3, + ], _configuration=self._configuration ) def test_ignores_other_non_objects_passes(self): # ignores other non-objects MaxpropertiesValidation._from_openapi_data( - 12, + 12, _configuration=self._configuration ) def test_ignores_strings_passes(self): # ignores strings MaxpropertiesValidation._from_openapi_data( - "foobar", _configuration=self._configuration ) @@ -69,27 +63,22 @@ class TestMaxpropertiesValidation(unittest.TestCase): def test_shorter_is_valid_passes(self): # shorter is valid MaxpropertiesValidation._from_openapi_data( - { - + { "foo": - 1, - } -, + 1, + }, _configuration=self._configuration ) def test_exact_length_is_valid_passes(self): # exact length is valid MaxpropertiesValidation._from_openapi_data( - { - + { "foo": - 1, - + 1, "bar": - 2, - } -, + 2, + }, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation.py index 4c870234124..d72abd6e1f8 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation.py @@ -23,7 +23,7 @@ class TestMinimumValidation(unittest.TestCase): def test_boundary_point_is_valid_passes(self): # boundary point is valid MinimumValidation._from_openapi_data( - 1.1, + 1.1, _configuration=self._configuration ) @@ -31,21 +31,20 @@ class TestMinimumValidation(unittest.TestCase): # below the minimum is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): MinimumValidation._from_openapi_data( - 0.6, + 0.6, _configuration=self._configuration ) def test_above_the_minimum_is_valid_passes(self): # above the minimum is valid MinimumValidation._from_openapi_data( - 2.6, + 2.6, _configuration=self._configuration ) def test_ignores_non_numbers_passes(self): # ignores non-numbers MinimumValidation._from_openapi_data( - "x", _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation_with_signed_integer.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation_with_signed_integer.py index 3ab04123abe..d4f2307a2a7 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation_with_signed_integer.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minimum_validation_with_signed_integer.py @@ -23,14 +23,14 @@ class TestMinimumValidationWithSignedInteger(unittest.TestCase): def test_boundary_point_is_valid_passes(self): # boundary point is valid MinimumValidationWithSignedInteger._from_openapi_data( - -2, + -2, _configuration=self._configuration ) def test_positive_above_the_minimum_is_valid_passes(self): # positive above the minimum is valid MinimumValidationWithSignedInteger._from_openapi_data( - 0, + 0, _configuration=self._configuration ) @@ -38,7 +38,7 @@ class TestMinimumValidationWithSignedInteger(unittest.TestCase): # int below the minimum is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): MinimumValidationWithSignedInteger._from_openapi_data( - -3, + -3, _configuration=self._configuration ) @@ -46,28 +46,27 @@ class TestMinimumValidationWithSignedInteger(unittest.TestCase): # float below the minimum is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): MinimumValidationWithSignedInteger._from_openapi_data( - -2.0001, + -2.0001, _configuration=self._configuration ) def test_boundary_point_with_float_is_valid_passes(self): # boundary point with float is valid MinimumValidationWithSignedInteger._from_openapi_data( - -2.0, + -2.0, _configuration=self._configuration ) def test_negative_above_the_minimum_is_valid_passes(self): # negative above the minimum is valid MinimumValidationWithSignedInteger._from_openapi_data( - -1, + -1, _configuration=self._configuration ) def test_ignores_non_numbers_passes(self): # ignores non-numbers MinimumValidationWithSignedInteger._from_openapi_data( - "x", _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minitems_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minitems_validation.py index eb25e0bc517..bca2643fcc8 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minitems_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minitems_validation.py @@ -24,16 +24,14 @@ class TestMinitemsValidation(unittest.TestCase): # too short is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): MinitemsValidation._from_openapi_data( - [ - ] -, + [ + ], _configuration=self._configuration ) def test_ignores_non_arrays_passes(self): # ignores non-arrays MinitemsValidation._from_openapi_data( - "", _configuration=self._configuration ) @@ -41,21 +39,19 @@ class TestMinitemsValidation(unittest.TestCase): def test_longer_is_valid_passes(self): # longer is valid MinitemsValidation._from_openapi_data( - [ - 1, - 2, - ] -, + [ + 1, + 2, + ], _configuration=self._configuration ) def test_exact_length_is_valid_passes(self): # exact length is valid MinitemsValidation._from_openapi_data( - [ - 1, - ] -, + [ + 1, + ], _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minlength_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minlength_validation.py index c7f7c27f6f3..515b2958eb8 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minlength_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minlength_validation.py @@ -24,7 +24,6 @@ class TestMinlengthValidation(unittest.TestCase): # too short is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): MinlengthValidation._from_openapi_data( - "f", _configuration=self._configuration ) @@ -33,7 +32,6 @@ class TestMinlengthValidation(unittest.TestCase): # one supplementary Unicode code point is not long enough with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): MinlengthValidation._from_openapi_data( - "💩", _configuration=self._configuration ) @@ -41,7 +39,6 @@ class TestMinlengthValidation(unittest.TestCase): def test_longer_is_valid_passes(self): # longer is valid MinlengthValidation._from_openapi_data( - "foo", _configuration=self._configuration ) @@ -49,14 +46,13 @@ class TestMinlengthValidation(unittest.TestCase): def test_ignores_non_strings_passes(self): # ignores non-strings MinlengthValidation._from_openapi_data( - 1, + 1, _configuration=self._configuration ) def test_exact_length_is_valid_passes(self): # exact length is valid MinlengthValidation._from_openapi_data( - "fo", _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minproperties_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minproperties_validation.py index 6ed23ecf670..b8202eb3465 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minproperties_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_minproperties_validation.py @@ -23,16 +23,15 @@ class TestMinpropertiesValidation(unittest.TestCase): def test_ignores_arrays_passes(self): # ignores arrays MinpropertiesValidation._from_openapi_data( - [ - ] -, + [ + ], _configuration=self._configuration ) def test_ignores_other_non_objects_passes(self): # ignores other non-objects MinpropertiesValidation._from_openapi_data( - 12, + 12, _configuration=self._configuration ) @@ -40,16 +39,14 @@ class TestMinpropertiesValidation(unittest.TestCase): # too short is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): MinpropertiesValidation._from_openapi_data( - { - } -, + { + }, _configuration=self._configuration ) def test_ignores_strings_passes(self): # ignores strings MinpropertiesValidation._from_openapi_data( - "", _configuration=self._configuration ) @@ -57,27 +54,22 @@ class TestMinpropertiesValidation(unittest.TestCase): def test_longer_is_valid_passes(self): # longer is valid MinpropertiesValidation._from_openapi_data( - { - + { "foo": - 1, - + 1, "bar": - 2, - } -, + 2, + }, _configuration=self._configuration ) def test_exact_length_is_valid_passes(self): # exact length is valid MinpropertiesValidation._from_openapi_data( - { - + { "foo": - 1, - } -, + 1, + }, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_model_not.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_model_not.py index 26e4c451d3a..7bc1095617d 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_model_not.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_model_not.py @@ -23,7 +23,6 @@ class TestModelNot(unittest.TestCase): def test_allowed_passes(self): # allowed ModelNot._from_openapi_data( - "foo", _configuration=self._configuration ) @@ -32,7 +31,7 @@ class TestModelNot(unittest.TestCase): # disallowed with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): ModelNot._from_openapi_data( - 1, + 1, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_items.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_items.py index 46453d6eb7d..e6d42516d3f 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_items.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nested_items.py @@ -23,48 +23,36 @@ class TestNestedItems(unittest.TestCase): def test_valid_nested_array_passes(self): # valid nested array NestedItems._from_openapi_data( + [ + [ + [ [ - [ - [ - [ - 1, - ] -, - ] -, - [ - [ - 2, - ] -, - [ - 3, - ] -, - ] -, - ] -, - [ - [ - [ - 4, - ] -, - [ - 5, - ] -, - [ - 6, - ] -, - ] -, - ] -, - ] -, + 1, + ], + ], + [ + [ + 2, + ], + [ + 3, + ], + ], + ], + [ + [ + [ + 4, + ], + [ + 5, + ], + [ + 6, + ], + ], + ], + ], _configuration=self._configuration ) @@ -72,49 +60,36 @@ class TestNestedItems(unittest.TestCase): # nested array with invalid type with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NestedItems._from_openapi_data( - [ - [ - [ - [ - + [ + [ + [ + [ "1", - ] -, - ] -, - [ - [ - 2, - ] -, - [ - 3, - ] -, - ] -, - ] -, - [ - [ - [ - 4, - ] -, - [ - 5, - ] -, - [ - 6, - ] -, - ] -, - ] -, - ] -, + ], + ], + [ + [ + 2, + ], + [ + 3, + ], + ], + ], + [ + [ + [ + 4, + ], + [ + 5, + ], + [ + 6, + ], + ], + ], + ], _configuration=self._configuration ) @@ -122,39 +97,30 @@ class TestNestedItems(unittest.TestCase): # not deep enough with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NestedItems._from_openapi_data( - [ - [ - [ - 1, - ] -, - [ - 2, - ] -, - [ - 3, - ] -, - ] -, - [ - [ - 4, - ] -, - [ - 5, - ] -, - [ - 6, - ] -, - ] -, - ] -, + [ + [ + [ + 1, + ], + [ + 2, + ], + [ + 3, + ], + ], + [ + [ + 4, + ], + [ + 5, + ], + [ + 6, + ], + ], + ], _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_not_more_complex_schema.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_not_more_complex_schema.py index bac1d81f1e4..b7ab21dadd4 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_not_more_complex_schema.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_not_more_complex_schema.py @@ -23,12 +23,10 @@ class TestNotMoreComplexSchema(unittest.TestCase): def test_other_match_passes(self): # other match NotMoreComplexSchema._from_openapi_data( - { - + { "foo": - 1, - } -, + 1, + }, _configuration=self._configuration ) @@ -36,20 +34,17 @@ class TestNotMoreComplexSchema(unittest.TestCase): # mismatch with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NotMoreComplexSchema._from_openapi_data( - { - + { "foo": - "bar", - } -, + }, _configuration=self._configuration ) def test_match_passes(self): # match NotMoreComplexSchema._from_openapi_data( - 1, + 1, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nul_characters_in_strings.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nul_characters_in_strings.py index ca8e0f4113f..5f9465d8687 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nul_characters_in_strings.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_nul_characters_in_strings.py @@ -23,7 +23,6 @@ class TestNulCharactersInStrings(unittest.TestCase): def test_match_string_with_nul_passes(self): # match string with nul NulCharactersInStrings._from_openapi_data( - "hello\x00there", _configuration=self._configuration ) @@ -32,7 +31,6 @@ class TestNulCharactersInStrings(unittest.TestCase): # do not match string lacking nul with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NulCharactersInStrings._from_openapi_data( - "hellothere", _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py index b6025f1011a..0057f89b2b1 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_null_type_matches_only_the_null_object.py @@ -24,7 +24,7 @@ class TestNullTypeMatchesOnlyTheNullObject(unittest.TestCase): # a float is not null with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NullTypeMatchesOnlyTheNullObject._from_openapi_data( - 1.1, + 1.1, _configuration=self._configuration ) @@ -32,9 +32,8 @@ class TestNullTypeMatchesOnlyTheNullObject(unittest.TestCase): # an object is not null with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NullTypeMatchesOnlyTheNullObject._from_openapi_data( - { - } -, + { + }, _configuration=self._configuration ) @@ -42,7 +41,6 @@ class TestNullTypeMatchesOnlyTheNullObject(unittest.TestCase): # false is not null with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NullTypeMatchesOnlyTheNullObject._from_openapi_data( - False, _configuration=self._configuration ) @@ -51,7 +49,7 @@ class TestNullTypeMatchesOnlyTheNullObject(unittest.TestCase): # an integer is not null with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NullTypeMatchesOnlyTheNullObject._from_openapi_data( - 1, + 1, _configuration=self._configuration ) @@ -59,7 +57,6 @@ class TestNullTypeMatchesOnlyTheNullObject(unittest.TestCase): # true is not null with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NullTypeMatchesOnlyTheNullObject._from_openapi_data( - True, _configuration=self._configuration ) @@ -68,7 +65,7 @@ class TestNullTypeMatchesOnlyTheNullObject(unittest.TestCase): # zero is not null with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NullTypeMatchesOnlyTheNullObject._from_openapi_data( - 0, + 0, _configuration=self._configuration ) @@ -76,7 +73,6 @@ class TestNullTypeMatchesOnlyTheNullObject(unittest.TestCase): # an empty string is not null with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NullTypeMatchesOnlyTheNullObject._from_openapi_data( - "", _configuration=self._configuration ) @@ -84,7 +80,6 @@ class TestNullTypeMatchesOnlyTheNullObject(unittest.TestCase): def test_null_is_null_passes(self): # null is null NullTypeMatchesOnlyTheNullObject._from_openapi_data( - None, _configuration=self._configuration ) @@ -93,9 +88,8 @@ class TestNullTypeMatchesOnlyTheNullObject(unittest.TestCase): # an array is not null with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NullTypeMatchesOnlyTheNullObject._from_openapi_data( - [ - ] -, + [ + ], _configuration=self._configuration ) @@ -103,7 +97,6 @@ class TestNullTypeMatchesOnlyTheNullObject(unittest.TestCase): # a string is not null with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NullTypeMatchesOnlyTheNullObject._from_openapi_data( - "foo", _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py index 86178158723..c71c9a01f74 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_number_type_matches_numbers.py @@ -24,9 +24,8 @@ class TestNumberTypeMatchesNumbers(unittest.TestCase): # an array is not a number with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NumberTypeMatchesNumbers._from_openapi_data( - [ - ] -, + [ + ], _configuration=self._configuration ) @@ -34,7 +33,6 @@ class TestNumberTypeMatchesNumbers(unittest.TestCase): # null is not a number with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NumberTypeMatchesNumbers._from_openapi_data( - None, _configuration=self._configuration ) @@ -43,9 +41,8 @@ class TestNumberTypeMatchesNumbers(unittest.TestCase): # an object is not a number with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NumberTypeMatchesNumbers._from_openapi_data( - { - } -, + { + }, _configuration=self._configuration ) @@ -53,7 +50,6 @@ class TestNumberTypeMatchesNumbers(unittest.TestCase): # a boolean is not a number with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NumberTypeMatchesNumbers._from_openapi_data( - True, _configuration=self._configuration ) @@ -61,7 +57,7 @@ class TestNumberTypeMatchesNumbers(unittest.TestCase): def test_a_float_is_a_number_passes(self): # a float is a number NumberTypeMatchesNumbers._from_openapi_data( - 1.1, + 1.1, _configuration=self._configuration ) @@ -69,7 +65,6 @@ class TestNumberTypeMatchesNumbers(unittest.TestCase): # a string is still not a number, even if it looks like one with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NumberTypeMatchesNumbers._from_openapi_data( - "1", _configuration=self._configuration ) @@ -78,7 +73,6 @@ class TestNumberTypeMatchesNumbers(unittest.TestCase): # a string is not a number with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): NumberTypeMatchesNumbers._from_openapi_data( - "foo", _configuration=self._configuration ) @@ -86,14 +80,14 @@ class TestNumberTypeMatchesNumbers(unittest.TestCase): def test_an_integer_is_a_number_passes(self): # an integer is a number NumberTypeMatchesNumbers._from_openapi_data( - 1, + 1, _configuration=self._configuration ) def test_a_float_with_zero_fractional_part_is_a_number_and_an_integer_passes(self): # a float with zero fractional part is a number (and an integer) NumberTypeMatchesNumbers._from_openapi_data( - 1.0, + 1.0, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_object_properties_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_object_properties_validation.py index bc26f21348f..f4e44b15adc 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_object_properties_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_object_properties_validation.py @@ -23,16 +23,15 @@ class TestObjectPropertiesValidation(unittest.TestCase): def test_ignores_arrays_passes(self): # ignores arrays ObjectPropertiesValidation._from_openapi_data( - [ - ] -, + [ + ], _configuration=self._configuration ) def test_ignores_other_non_objects_passes(self): # ignores other non-objects ObjectPropertiesValidation._from_openapi_data( - 12, + 12, _configuration=self._configuration ) @@ -40,47 +39,36 @@ class TestObjectPropertiesValidation(unittest.TestCase): # one property invalid is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): ObjectPropertiesValidation._from_openapi_data( - { - + { "foo": - 1, - + 1, "bar": - { - } -, - } -, + { + }, + }, _configuration=self._configuration ) def test_both_properties_present_and_valid_is_valid_passes(self): # both properties present and valid is valid ObjectPropertiesValidation._from_openapi_data( - { - + { "foo": - 1, - + 1, "bar": - "baz", - } -, + }, _configuration=self._configuration ) def test_doesn_t_invalidate_other_properties_passes(self): # doesn't invalidate other properties ObjectPropertiesValidation._from_openapi_data( - { - + { "quux": - [ - ] -, - } -, + [ + ], + }, _configuration=self._configuration ) @@ -88,19 +76,14 @@ class TestObjectPropertiesValidation(unittest.TestCase): # both properties invalid is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): ObjectPropertiesValidation._from_openapi_data( - { - + { "foo": - [ - ] -, - + [ + ], "bar": - { - } -, - } -, + { + }, + }, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_is_not_anchored.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_is_not_anchored.py index 6c28c64b369..15eb5c25586 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_is_not_anchored.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_is_not_anchored.py @@ -23,7 +23,6 @@ class TestPatternIsNotAnchored(unittest.TestCase): def test_matches_a_substring_passes(self): # matches a substring PatternIsNotAnchored._from_openapi_data( - "xxaayy", _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_validation.py index 1413ba855d3..fc76731c830 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_pattern_validation.py @@ -23,25 +23,22 @@ class TestPatternValidation(unittest.TestCase): def test_ignores_arrays_passes(self): # ignores arrays PatternValidation._from_openapi_data( - [ - ] -, + [ + ], _configuration=self._configuration ) def test_ignores_objects_passes(self): # ignores objects PatternValidation._from_openapi_data( - { - } -, + { + }, _configuration=self._configuration ) def test_ignores_null_passes(self): # ignores null PatternValidation._from_openapi_data( - None, _configuration=self._configuration ) @@ -49,7 +46,7 @@ class TestPatternValidation(unittest.TestCase): def test_ignores_floats_passes(self): # ignores floats PatternValidation._from_openapi_data( - 1.0, + 1.0, _configuration=self._configuration ) @@ -57,7 +54,6 @@ class TestPatternValidation(unittest.TestCase): # a non-matching pattern is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): PatternValidation._from_openapi_data( - "abc", _configuration=self._configuration ) @@ -65,7 +61,6 @@ class TestPatternValidation(unittest.TestCase): def test_ignores_booleans_passes(self): # ignores booleans PatternValidation._from_openapi_data( - True, _configuration=self._configuration ) @@ -73,7 +68,6 @@ class TestPatternValidation(unittest.TestCase): def test_a_matching_pattern_is_valid_passes(self): # a matching pattern is valid PatternValidation._from_openapi_data( - "aaa", _configuration=self._configuration ) @@ -81,7 +75,7 @@ class TestPatternValidation(unittest.TestCase): def test_ignores_integers_passes(self): # ignores integers PatternValidation._from_openapi_data( - 123, + 123, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py index cfdf5c47250..d7a0c7b9196 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_properties_with_escaped_characters.py @@ -23,27 +23,20 @@ class TestPropertiesWithEscapedCharacters(unittest.TestCase): def test_object_with_all_numbers_is_valid_passes(self): # object with all numbers is valid PropertiesWithEscapedCharacters._from_openapi_data( - { - + { "foo\nbar": - 1, - + 1, "foo\"bar": - 1, - + 1, "foo\\bar": - 1, - + 1, "foo\rbar": - 1, - + 1, "foo\tbar": - 1, - + 1, "foo\fbar": - 1, - } -, + 1, + }, _configuration=self._configuration ) @@ -51,33 +44,20 @@ class TestPropertiesWithEscapedCharacters(unittest.TestCase): # object with strings is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): PropertiesWithEscapedCharacters._from_openapi_data( - { - + { "foo\nbar": - "1", - "foo\"bar": - "1", - "foo\\bar": - "1", - "foo\rbar": - "1", - "foo\tbar": - "1", - "foo\fbar": - "1", - } -, + }, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_property_named_ref_that_is_not_a_reference.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_property_named_ref_that_is_not_a_reference.py index ed14673ad76..2599fd45d40 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_property_named_ref_that_is_not_a_reference.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_property_named_ref_that_is_not_a_reference.py @@ -23,13 +23,10 @@ class TestPropertyNamedRefThatIsNotAReference(unittest.TestCase): def test_property_named_ref_valid_passes(self): # property named $ref valid PropertyNamedRefThatIsNotAReference._from_openapi_data( - { - + { "$ref": - "a", - } -, + }, _configuration=self._configuration ) @@ -37,12 +34,10 @@ class TestPropertyNamedRefThatIsNotAReference(unittest.TestCase): # property named $ref invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): PropertyNamedRefThatIsNotAReference._from_openapi_data( - { - + { "$ref": - 2, - } -, + 2, + }, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_default_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_default_validation.py index 6321d617382..c17d16842b7 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_default_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_default_validation.py @@ -23,9 +23,8 @@ class TestRequiredDefaultValidation(unittest.TestCase): def test_not_required_by_default_passes(self): # not required by default RequiredDefaultValidation._from_openapi_data( - { - } -, + { + }, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_validation.py index 395869ff228..559f0be8d52 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_validation.py @@ -23,35 +23,31 @@ class TestRequiredValidation(unittest.TestCase): def test_ignores_arrays_passes(self): # ignores arrays RequiredValidation._from_openapi_data( - [ - ] -, + [ + ], _configuration=self._configuration ) def test_present_required_property_is_valid_passes(self): # present required property is valid RequiredValidation._from_openapi_data( - { - + { "foo": - 1, - } -, + 1, + }, _configuration=self._configuration ) def test_ignores_other_non_objects_passes(self): # ignores other non-objects RequiredValidation._from_openapi_data( - 12, + 12, _configuration=self._configuration ) def test_ignores_strings_passes(self): # ignores strings RequiredValidation._from_openapi_data( - "", _configuration=self._configuration ) @@ -60,12 +56,10 @@ class TestRequiredValidation(unittest.TestCase): # non-present required property is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): RequiredValidation._from_openapi_data( - { - + { "bar": - 1, - } -, + 1, + }, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_with_empty_array.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_with_empty_array.py index ef045be9fe1..aced932c703 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_with_empty_array.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_required_with_empty_array.py @@ -23,9 +23,8 @@ class TestRequiredWithEmptyArray(unittest.TestCase): def test_property_not_required_passes(self): # property not required RequiredWithEmptyArray._from_openapi_data( - { - } -, + { + }, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_simple_enum_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_simple_enum_validation.py index 391e9ff39d6..56d2746b84a 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_simple_enum_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_simple_enum_validation.py @@ -24,14 +24,14 @@ class TestSimpleEnumValidation(unittest.TestCase): # something else is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): SimpleEnumValidation._from_openapi_data( - 4, + 4, _configuration=self._configuration ) def test_one_of_the_enum_is_valid_passes(self): # one of the enum is valid SimpleEnumValidation._from_openapi_data( - 1, + 1, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py index d6bdee13053..807e2afe1c9 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_string_type_matches_strings.py @@ -24,14 +24,13 @@ class TestStringTypeMatchesStrings(unittest.TestCase): # 1 is not a string with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): StringTypeMatchesStrings._from_openapi_data( - 1, + 1, _configuration=self._configuration ) def test_a_string_is_still_a_string_even_if_it_looks_like_a_number_passes(self): # a string is still a string, even if it looks like a number StringTypeMatchesStrings._from_openapi_data( - "1", _configuration=self._configuration ) @@ -39,7 +38,6 @@ class TestStringTypeMatchesStrings(unittest.TestCase): def test_an_empty_string_is_still_a_string_passes(self): # an empty string is still a string StringTypeMatchesStrings._from_openapi_data( - "", _configuration=self._configuration ) @@ -48,7 +46,7 @@ class TestStringTypeMatchesStrings(unittest.TestCase): # a float is not a string with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): StringTypeMatchesStrings._from_openapi_data( - 1.1, + 1.1, _configuration=self._configuration ) @@ -56,9 +54,8 @@ class TestStringTypeMatchesStrings(unittest.TestCase): # an object is not a string with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): StringTypeMatchesStrings._from_openapi_data( - { - } -, + { + }, _configuration=self._configuration ) @@ -66,9 +63,8 @@ class TestStringTypeMatchesStrings(unittest.TestCase): # an array is not a string with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): StringTypeMatchesStrings._from_openapi_data( - [ - ] -, + [ + ], _configuration=self._configuration ) @@ -76,7 +72,6 @@ class TestStringTypeMatchesStrings(unittest.TestCase): # a boolean is not a string with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): StringTypeMatchesStrings._from_openapi_data( - True, _configuration=self._configuration ) @@ -85,7 +80,6 @@ class TestStringTypeMatchesStrings(unittest.TestCase): # null is not a string with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): StringTypeMatchesStrings._from_openapi_data( - None, _configuration=self._configuration ) @@ -93,7 +87,6 @@ class TestStringTypeMatchesStrings(unittest.TestCase): def test_a_string_is_a_string_passes(self): # a string is a string StringTypeMatchesStrings._from_openapi_data( - "foo", _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py index 6f33ffe3eee..4f8e583c41a 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_the_default_keyword_does_not_do_anything_if_the_property_is_missing.py @@ -23,21 +23,18 @@ class TestTheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing(unittest.Test def test_missing_properties_are_not_filled_in_with_the_default_passes(self): # missing properties are not filled in with the default TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing._from_openapi_data( - { - } -, + { + }, _configuration=self._configuration ) def test_an_explicit_property_value_is_checked_against_maximum_passing_passes(self): # an explicit property value is checked against maximum (passing) TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing._from_openapi_data( - { - + { "alpha": - 1, - } -, + 1, + }, _configuration=self._configuration ) @@ -45,12 +42,10 @@ class TestTheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing(unittest.Test # an explicit property value is checked against maximum (failing) with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing._from_openapi_data( - { - + { "alpha": - 5, - } -, + 5, + }, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uniqueitems_false_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uniqueitems_false_validation.py index f18fcfa0705..afe2f481d7e 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uniqueitems_false_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uniqueitems_false_validation.py @@ -23,297 +23,221 @@ class TestUniqueitemsFalseValidation(unittest.TestCase): def test_non_unique_array_of_integers_is_valid_passes(self): # non-unique array of integers is valid UniqueitemsFalseValidation._from_openapi_data( - [ - 1, - 1, - ] -, + [ + 1, + 1, + ], _configuration=self._configuration ) def test_unique_array_of_objects_is_valid_passes(self): # unique array of objects is valid UniqueitemsFalseValidation._from_openapi_data( - [ - { - + [ + { "foo": - "bar", - } -, - { - + }, + { "foo": - "baz", - } -, - ] -, + }, + ], _configuration=self._configuration ) def test_non_unique_array_of_nested_objects_is_valid_passes(self): # non-unique array of nested objects is valid UniqueitemsFalseValidation._from_openapi_data( - [ - { - + [ + { "foo": - { - + { "bar": - { - + { "baz": - True, - } -, - } -, - } -, - { - + }, + }, + }, + { "foo": - { - + { "bar": - { - + { "baz": - True, - } -, - } -, - } -, - ] -, + }, + }, + }, + ], _configuration=self._configuration ) def test_non_unique_array_of_objects_is_valid_passes(self): # non-unique array of objects is valid UniqueitemsFalseValidation._from_openapi_data( - [ - { - + [ + { "foo": - "bar", - } -, - { - + }, + { "foo": - "bar", - } -, - ] -, + }, + ], _configuration=self._configuration ) def test_1_and_true_are_unique_passes(self): # 1 and true are unique UniqueitemsFalseValidation._from_openapi_data( - [ - 1, - + [ + 1, True, - ] -, + ], _configuration=self._configuration ) def test_unique_array_of_integers_is_valid_passes(self): # unique array of integers is valid UniqueitemsFalseValidation._from_openapi_data( - [ - 1, - 2, - ] -, + [ + 1, + 2, + ], _configuration=self._configuration ) def test_non_unique_array_of_arrays_is_valid_passes(self): # non-unique array of arrays is valid UniqueitemsFalseValidation._from_openapi_data( - [ - [ - + [ + [ "foo", - ] -, - [ - + ], + [ "foo", - ] -, - ] -, + ], + ], _configuration=self._configuration ) def test_numbers_are_unique_if_mathematically_unequal_passes(self): # numbers are unique if mathematically unequal UniqueitemsFalseValidation._from_openapi_data( - [ - 1.0, - 1.0, - 1, - ] -, + [ + 1.0, + 1.0, + 1, + ], _configuration=self._configuration ) def test_false_is_not_equal_to_zero_passes(self): # false is not equal to zero UniqueitemsFalseValidation._from_openapi_data( - [ - 0, - + [ + 0, False, - ] -, + ], _configuration=self._configuration ) def test_unique_array_of_nested_objects_is_valid_passes(self): # unique array of nested objects is valid UniqueitemsFalseValidation._from_openapi_data( - [ - { - + [ + { "foo": - { - + { "bar": - { - + { "baz": - True, - } -, - } -, - } -, - { - + }, + }, + }, + { "foo": - { - + { "bar": - { - + { "baz": - False, - } -, - } -, - } -, - ] -, + }, + }, + }, + ], _configuration=self._configuration ) def test_0_and_false_are_unique_passes(self): # 0 and false are unique UniqueitemsFalseValidation._from_openapi_data( - [ - 0, - + [ + 0, False, - ] -, + ], _configuration=self._configuration ) def test_unique_array_of_arrays_is_valid_passes(self): # unique array of arrays is valid UniqueitemsFalseValidation._from_openapi_data( - [ - [ - + [ + [ "foo", - ] -, - [ - + ], + [ "bar", - ] -, - ] -, + ], + ], _configuration=self._configuration ) def test_true_is_not_equal_to_one_passes(self): # true is not equal to one UniqueitemsFalseValidation._from_openapi_data( - [ - 1, - + [ + 1, True, - ] -, + ], _configuration=self._configuration ) def test_non_unique_heterogeneous_types_are_valid_passes(self): # non-unique heterogeneous types are valid UniqueitemsFalseValidation._from_openapi_data( - [ - { - } -, - [ - 1, - ] -, - + [ + { + }, + [ + 1, + ], True, - None, - { - } -, - 1, - ] -, + { + }, + 1, + ], _configuration=self._configuration ) def test_unique_heterogeneous_types_are_valid_passes(self): # unique heterogeneous types are valid UniqueitemsFalseValidation._from_openapi_data( - [ - { - } -, - [ - 1, - ] -, - + [ + { + }, + [ + 1, + ], True, - None, - 1, - ] -, + 1, + ], _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uniqueitems_validation.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uniqueitems_validation.py index 1e0c948ccb9..f4032887b69 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uniqueitems_validation.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uniqueitems_validation.py @@ -23,45 +23,32 @@ class TestUniqueitemsValidation(unittest.TestCase): def test_unique_array_of_objects_is_valid_passes(self): # unique array of objects is valid UniqueitemsValidation._from_openapi_data( - [ - { - + [ + { "foo": - "bar", - } -, - { - + }, + { "foo": - "baz", - } -, - ] -, + }, + ], _configuration=self._configuration ) def test_a_true_and_a1_are_unique_passes(self): # {"a": true} and {"a": 1} are unique UniqueitemsValidation._from_openapi_data( - [ - { - + [ + { "a": - True, - } -, - { - + }, + { "a": - 1, - } -, - ] -, + 1, + }, + ], _configuration=self._configuration ) @@ -69,74 +56,54 @@ class TestUniqueitemsValidation(unittest.TestCase): # non-unique heterogeneous types are invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): UniqueitemsValidation._from_openapi_data( - [ - { - } -, - [ - 1, - ] -, - + [ + { + }, + [ + 1, + ], True, - None, - { - } -, - 1, - ] -, + { + }, + 1, + ], _configuration=self._configuration ) def test_nested0_and_false_are_unique_passes(self): # nested [0] and [false] are unique UniqueitemsValidation._from_openapi_data( - [ - [ - [ - 0, - ] -, - + [ + [ + [ + 0, + ], "foo", - ] -, - [ - [ - + ], + [ + [ False, - ] -, - + ], "foo", - ] -, - ] -, + ], + ], _configuration=self._configuration ) def test_a_false_and_a0_are_unique_passes(self): # {"a": false} and {"a": 0} are unique UniqueitemsValidation._from_openapi_data( - [ - { - + [ + { "a": - False, - } -, - { - + }, + { "a": - 0, - } -, - ] -, + 0, + }, + ], _configuration=self._configuration ) @@ -144,61 +111,49 @@ class TestUniqueitemsValidation(unittest.TestCase): # numbers are unique if mathematically unequal with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): UniqueitemsValidation._from_openapi_data( - [ - 1.0, - 1.0, - 1, - ] -, + [ + 1.0, + 1.0, + 1, + ], _configuration=self._configuration ) def test_false_is_not_equal_to_zero_passes(self): # false is not equal to zero UniqueitemsValidation._from_openapi_data( - [ - 0, - + [ + 0, False, - ] -, + ], _configuration=self._configuration ) def test_0_and_false_are_unique_passes(self): # [0] and [false] are unique UniqueitemsValidation._from_openapi_data( - [ - [ - 0, - ] -, - [ - + [ + [ + 0, + ], + [ False, - ] -, - ] -, + ], + ], _configuration=self._configuration ) def test_unique_array_of_arrays_is_valid_passes(self): # unique array of arrays is valid UniqueitemsValidation._from_openapi_data( - [ - [ - + [ + [ "foo", - ] -, - [ - + ], + [ "bar", - ] -, - ] -, + ], + ], _configuration=self._configuration ) @@ -206,43 +161,28 @@ class TestUniqueitemsValidation(unittest.TestCase): # non-unique array of nested objects is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): UniqueitemsValidation._from_openapi_data( - [ - { - + [ + { "foo": - { - + { "bar": - { - + { "baz": - True, - } -, - } -, - } -, - { - + }, + }, + }, + { "foo": - { - + { "bar": - { - + { "baz": - True, - } -, - } -, - } -, - ] -, + }, + }, + }, + ], _configuration=self._configuration ) @@ -250,24 +190,21 @@ class TestUniqueitemsValidation(unittest.TestCase): # non-unique array of more than two integers is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): UniqueitemsValidation._from_openapi_data( - [ - 1, - 2, - 1, - ] -, + [ + 1, + 2, + 1, + ], _configuration=self._configuration ) def test_true_is_not_equal_to_one_passes(self): # true is not equal to one UniqueitemsValidation._from_openapi_data( - [ - 1, - + [ + 1, True, - ] -, + ], _configuration=self._configuration ) @@ -275,98 +212,75 @@ class TestUniqueitemsValidation(unittest.TestCase): # objects are non-unique despite key order with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): UniqueitemsValidation._from_openapi_data( - [ - { - + [ + { "a": - 1, - + 1, "b": - 2, - } -, - { - + 2, + }, + { "b": - 2, - + 2, "a": - 1, - } -, - ] -, + 1, + }, + ], _configuration=self._configuration ) def test_unique_array_of_strings_is_valid_passes(self): # unique array of strings is valid UniqueitemsValidation._from_openapi_data( - [ - + [ "foo", - "bar", - "baz", - ] -, + ], _configuration=self._configuration ) def test_1_and_true_are_unique_passes(self): # [1] and [true] are unique UniqueitemsValidation._from_openapi_data( - [ - [ - 1, - ] -, - [ - + [ + [ + 1, + ], + [ True, - ] -, - ] -, + ], + ], _configuration=self._configuration ) def test_different_objects_are_unique_passes(self): # different objects are unique UniqueitemsValidation._from_openapi_data( - [ - { - + [ + { "a": - 1, - + 1, "b": - 2, - } -, - { - + 2, + }, + { "a": - 2, - + 2, "b": - 1, - } -, - ] -, + 1, + }, + ], _configuration=self._configuration ) def test_unique_array_of_integers_is_valid_passes(self): # unique array of integers is valid UniqueitemsValidation._from_openapi_data( - [ - 1, - 2, - ] -, + [ + 1, + 2, + ], _configuration=self._configuration ) @@ -374,24 +288,17 @@ class TestUniqueitemsValidation(unittest.TestCase): # non-unique array of more than two arrays is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): UniqueitemsValidation._from_openapi_data( - [ - [ - + [ + [ "foo", - ] -, - [ - + ], + [ "bar", - ] -, - [ - + ], + [ "foo", - ] -, - ] -, + ], + ], _configuration=self._configuration ) @@ -399,66 +306,44 @@ class TestUniqueitemsValidation(unittest.TestCase): # non-unique array of objects is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): UniqueitemsValidation._from_openapi_data( - [ - { - + [ + { "foo": - "bar", - } -, - { - + }, + { "foo": - "bar", - } -, - ] -, + }, + ], _configuration=self._configuration ) def test_unique_array_of_nested_objects_is_valid_passes(self): # unique array of nested objects is valid UniqueitemsValidation._from_openapi_data( - [ - { - + [ + { "foo": - { - + { "bar": - { - + { "baz": - True, - } -, - } -, - } -, - { - + }, + }, + }, + { "foo": - { - + { "bar": - { - + { "baz": - False, - } -, - } -, - } -, - ] -, + }, + }, + }, + ], _configuration=self._configuration ) @@ -466,19 +351,14 @@ class TestUniqueitemsValidation(unittest.TestCase): # non-unique array of arrays is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): UniqueitemsValidation._from_openapi_data( - [ - [ - + [ + [ "foo", - ] -, - [ - + ], + [ "foo", - ] -, - ] -, + ], + ], _configuration=self._configuration ) @@ -486,66 +366,48 @@ class TestUniqueitemsValidation(unittest.TestCase): # non-unique array of strings is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): UniqueitemsValidation._from_openapi_data( - [ - + [ "foo", - "bar", - "foo", - ] -, + ], _configuration=self._configuration ) def test_nested1_and_true_are_unique_passes(self): # nested [1] and [true] are unique UniqueitemsValidation._from_openapi_data( - [ - [ - [ - 1, - ] -, - + [ + [ + [ + 1, + ], "foo", - ] -, - [ - [ - + ], + [ + [ True, - ] -, - + ], "foo", - ] -, - ] -, + ], + ], _configuration=self._configuration ) def test_unique_heterogeneous_types_are_valid_passes(self): # unique heterogeneous types are valid UniqueitemsValidation._from_openapi_data( - [ - { - } -, - [ - 1, - ] -, - + [ + { + }, + [ + 1, + ], True, - None, - 1, - + 1, "{}", - ] -, + ], _configuration=self._configuration ) @@ -553,11 +415,10 @@ class TestUniqueitemsValidation(unittest.TestCase): # non-unique array of integers is invalid with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): UniqueitemsValidation._from_openapi_data( - [ - 1, - 1, - ] -, + [ + 1, + 1, + ], _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_format.py index 819617170a4..2f6def90243 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_format.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_format.py @@ -23,16 +23,14 @@ class TestUriFormat(unittest.TestCase): def test_all_string_formats_ignore_objects_passes(self): # all string formats ignore objects UriFormat._from_openapi_data( - { - } -, + { + }, _configuration=self._configuration ) def test_all_string_formats_ignore_booleans_passes(self): # all string formats ignore booleans UriFormat._from_openapi_data( - False, _configuration=self._configuration ) @@ -40,30 +38,28 @@ class TestUriFormat(unittest.TestCase): def test_all_string_formats_ignore_integers_passes(self): # all string formats ignore integers UriFormat._from_openapi_data( - 12, + 12, _configuration=self._configuration ) def test_all_string_formats_ignore_floats_passes(self): # all string formats ignore floats UriFormat._from_openapi_data( - 13.7, + 13.7, _configuration=self._configuration ) def test_all_string_formats_ignore_arrays_passes(self): # all string formats ignore arrays UriFormat._from_openapi_data( - [ - ] -, + [ + ], _configuration=self._configuration ) def test_all_string_formats_ignore_nulls_passes(self): # all string formats ignore nulls UriFormat._from_openapi_data( - None, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_reference_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_reference_format.py index c01fac6b3f6..c5508b68bc6 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_reference_format.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_reference_format.py @@ -23,16 +23,14 @@ class TestUriReferenceFormat(unittest.TestCase): def test_all_string_formats_ignore_objects_passes(self): # all string formats ignore objects UriReferenceFormat._from_openapi_data( - { - } -, + { + }, _configuration=self._configuration ) def test_all_string_formats_ignore_booleans_passes(self): # all string formats ignore booleans UriReferenceFormat._from_openapi_data( - False, _configuration=self._configuration ) @@ -40,30 +38,28 @@ class TestUriReferenceFormat(unittest.TestCase): def test_all_string_formats_ignore_integers_passes(self): # all string formats ignore integers UriReferenceFormat._from_openapi_data( - 12, + 12, _configuration=self._configuration ) def test_all_string_formats_ignore_floats_passes(self): # all string formats ignore floats UriReferenceFormat._from_openapi_data( - 13.7, + 13.7, _configuration=self._configuration ) def test_all_string_formats_ignore_arrays_passes(self): # all string formats ignore arrays UriReferenceFormat._from_openapi_data( - [ - ] -, + [ + ], _configuration=self._configuration ) def test_all_string_formats_ignore_nulls_passes(self): # all string formats ignore nulls UriReferenceFormat._from_openapi_data( - None, _configuration=self._configuration ) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_template_format.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_template_format.py index da2e4c435e4..456c0794ad0 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_template_format.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_uri_template_format.py @@ -23,16 +23,14 @@ class TestUriTemplateFormat(unittest.TestCase): def test_all_string_formats_ignore_objects_passes(self): # all string formats ignore objects UriTemplateFormat._from_openapi_data( - { - } -, + { + }, _configuration=self._configuration ) def test_all_string_formats_ignore_booleans_passes(self): # all string formats ignore booleans UriTemplateFormat._from_openapi_data( - False, _configuration=self._configuration ) @@ -40,30 +38,28 @@ class TestUriTemplateFormat(unittest.TestCase): def test_all_string_formats_ignore_integers_passes(self): # all string formats ignore integers UriTemplateFormat._from_openapi_data( - 12, + 12, _configuration=self._configuration ) def test_all_string_formats_ignore_floats_passes(self): # all string formats ignore floats UriTemplateFormat._from_openapi_data( - 13.7, + 13.7, _configuration=self._configuration ) def test_all_string_formats_ignore_arrays_passes(self): # all string formats ignore arrays UriTemplateFormat._from_openapi_data( - [ - ] -, + [ + ], _configuration=self._configuration ) def test_all_string_formats_ignore_nulls_passes(self): # all string formats ignore nulls UriTemplateFormat._from_openapi_data( - None, _configuration=self._configuration ) -- GitLab From 8054788339a609f334ed4db163540d944c8dccb1 Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Thu, 30 Jun 2022 15:32:38 -0700 Subject: [PATCH 40/43] Test fase name fixed to toTestCaseName, docstring added to ObjectWithTypeBooleans --- .../org/openapitools/codegen/DefaultCodegen.java | 4 ++-- .../openapitools/codegen/ObjectWithTypeBooleans.java | 12 ++++++++---- .../languages/PythonExperimentalClientCodegen.java | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index 7d26b12d0cd..bc93c143f77 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -2696,7 +2696,7 @@ public class DefaultCodegen implements CodegenConfig { setAddProps(schema, m); } - protected String toTesCaseName(String specTestCaseName) { + protected String toTestCaseName(String specTestCaseName) { return specTestCaseName; } @@ -2731,7 +2731,7 @@ public class DefaultCodegen implements CodegenConfig { LinkedHashMap<String, LinkedHashMap<String, Object>> testNameToTesCase = (LinkedHashMap<String, LinkedHashMap<String, Object>>) schemaNameToTestCases.get(schemaName); for (Entry<String, LinkedHashMap<String, Object>> entry: testNameToTesCase.entrySet()) { LinkedHashMap<String, Object> testExample = (LinkedHashMap<String, Object>) entry.getValue(); - String nameInSnakeCase = toTesCaseName(entry.getKey()); + String nameInSnakeCase = toTestCaseName(entry.getKey()); Object data = processTestExampleData(testExample.get("data")); SchemaTestCase testCase = new SchemaTestCase( (String) testExample.getOrDefault("description", ""), diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/ObjectWithTypeBooleans.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/ObjectWithTypeBooleans.java index 9b2f8ed3c6b..049e25ae810 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/ObjectWithTypeBooleans.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/ObjectWithTypeBooleans.java @@ -8,13 +8,20 @@ public class ObjectWithTypeBooleans { public boolean isUnboundedInteger; public boolean isNumber; public boolean isString; - public boolean isMultilineString; public boolean isMap; public boolean isArray; public boolean isBoolean; public boolean isNull; public Object value; + /** + * A wrapper class that is used to store payloads to be ingested by schemas + * This class includes the payload value in the valye property + * Other booleans: isUnboundedInteger/isNumber/isString/isMap/isArray/isBoolean/isNull + * allow generator templates to decide how to render each payload into code + * based upon what type it is. The booleans isX describe the value in value. + * @param value the input payload that is stored + */ public ObjectWithTypeBooleans(Object value) { Object usedValue = null; if (value instanceof Integer){ @@ -26,9 +33,6 @@ public class ObjectWithTypeBooleans { } else if (value instanceof String) { this.isString = true; this.value = value; - if (((String) value).contains("\n") || ((String) value).contains("\r")) { - this.isMultilineString = true; - } } else if (value instanceof LinkedHashMap) { LinkedHashMap<String, Object> castValue = (LinkedHashMap<String, Object>) value; LinkedHashMap<ObjectWithTypeBooleans, ObjectWithTypeBooleans> castMap = new LinkedHashMap<>(); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java index fed96db5c3c..19d2f6db89d 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java @@ -1155,7 +1155,7 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen { model.dataType = getTypeString(schema, "", "", referencedModelNames); } - protected String toTesCaseName(String specTestCaseName) { + protected String toTestCaseName(String specTestCaseName) { return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, specTestCaseName); } -- GitLab From 5137fbbe3d003b6703eeb589d71eed0fabb66c98 Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Thu, 30 Jun 2022 15:35:31 -0700 Subject: [PATCH 41/43] Fixes typo --- .../java/org/openapitools/codegen/ObjectWithTypeBooleans.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/ObjectWithTypeBooleans.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/ObjectWithTypeBooleans.java index 049e25ae810..28038f46912 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/ObjectWithTypeBooleans.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/ObjectWithTypeBooleans.java @@ -16,7 +16,7 @@ public class ObjectWithTypeBooleans { /** * A wrapper class that is used to store payloads to be ingested by schemas - * This class includes the payload value in the valye property + * This class includes the payload value in the value property * Other booleans: isUnboundedInteger/isNumber/isString/isMap/isArray/isBoolean/isNull * allow generator templates to decide how to render each payload into code * based upon what type it is. The booleans isX describe the value in value. -- GitLab From cb156e63cf22e4109c269c4dfcf3d0d475a75331 Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Thu, 30 Jun 2022 16:51:56 -0700 Subject: [PATCH 42/43] Adds test deletion to samples generation, samples regenerated --- bin/generate-samples.sh | 2 ++ .../.openapi-generator/VERSION | 2 +- .../python-experimental/docs/StringEnum.md | 4 +-- .../fake_api_endpoints/endpoint_parameters.py | 2 +- .../petstore_api/model/format_test.py | 2 +- .../petstore_api/model/model200_response.py | 2 +- .../petstore_api/model/model_return.py | 2 +- .../petstore_api/model/name.py | 2 +- .../object_with_difficultly_named_props.py | 6 ++-- .../petstore_api/model/string_enum.py | 12 +++---- .../petstore_api/schemas.py | 35 +++++++++++++++---- 11 files changed, 45 insertions(+), 26 deletions(-) diff --git a/bin/generate-samples.sh b/bin/generate-samples.sh index 81c6cc9c6d1..483d6dc7970 100755 --- a/bin/generate-samples.sh +++ b/bin/generate-samples.sh @@ -55,6 +55,8 @@ else echo "Please press CTRL+C to stop or the script will continue in 5 seconds." sleep 5 + # delete the 3_0_3 python-experimental tests because they are autogenerated our tooling needs to see differences + rm -rf "${root}/samples/openapi3/client/3_0_3_unit_test/python-experimental/test" if [ ${#files[@]} -eq 0 ]; then files=("${root}"/bin/configs/*.yaml) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/VERSION b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/VERSION index 717311e32e3..89648de3311 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/VERSION +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/VERSION @@ -1 +1 @@ -unset \ No newline at end of file +6.0.1-SNAPSHOT \ No newline at end of file diff --git a/samples/openapi3/client/petstore/python-experimental/docs/StringEnum.md b/samples/openapi3/client/petstore/python-experimental/docs/StringEnum.md index bf610d10285..cb911992441 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/StringEnum.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/StringEnum.md @@ -2,9 +2,7 @@ Type | Description | Notes ------------- | ------------- | ------------- -typing.Union[str, None, ] | | must be one of ["placed", "approved", "delivered", "single quoted", '''multiple -lines''', '''double quote - with newline''', ] +typing.Union[str, None, ] | | must be one of ["placed", "approved", "delivered", "single quoted", "multiple\nlines", "double quote \n with newline", ] [[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/api/fake_api_endpoints/endpoint_parameters.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/api/fake_api_endpoints/endpoint_parameters.py index 51d08760c8b..39daed76072 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/api/fake_api_endpoints/endpoint_parameters.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/api/fake_api_endpoints/endpoint_parameters.py @@ -112,7 +112,7 @@ class SchemaForRequestBodyApplicationXWwwFormUrlencoded( Float32Schema ): pass - locals()['float'] = _float + locals()["float"] = _float del locals()['_float'] diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/format_test.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/format_test.py index f9b32e23273..d64a93e001a 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/format_test.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/format_test.py @@ -124,7 +124,7 @@ class FormatTest( Float32Schema ): pass - locals()['float'] = _float + locals()["float"] = _float del locals()['_float'] float32 = Float32Schema diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/model200_response.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/model200_response.py index 8d1c230153e..c3741abc664 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/model200_response.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/model200_response.py @@ -78,7 +78,7 @@ class Model200Response( """ name = Int32Schema _class = StrSchema - locals()['class'] = _class + locals()["class"] = _class del locals()['_class'] def __new__( diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/model_return.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/model_return.py index f963afda001..de277a4a893 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/model_return.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/model_return.py @@ -77,7 +77,7 @@ class ModelReturn( Model for testing reserved words """ _return = Int32Schema - locals()['return'] = _return + locals()["return"] = _return del locals()['_return'] def __new__( diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/name.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/name.py index 1fcc02437f5..c908733cdf8 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/name.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/name.py @@ -82,7 +82,7 @@ class Name( name = Int32Schema snake_case = Int32Schema _property = StrSchema - locals()['property'] = _property + locals()["property"] = _property del locals()['_property'] def __new__( diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/object_with_difficultly_named_props.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/object_with_difficultly_named_props.py index a657bead060..4b1255298a2 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/object_with_difficultly_named_props.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/object_with_difficultly_named_props.py @@ -80,13 +80,13 @@ class ObjectWithDifficultlyNamedProps( '123-list', )) special_property_name = Int64Schema - locals()['$special[property.name]'] = special_property_name + locals()["$special[property.name]"] = special_property_name del locals()['special_property_name'] _123_list = StrSchema - locals()['123-list'] = _123_list + locals()["123-list"] = _123_list del locals()['_123_list'] _123_number = IntSchema - locals()['123Number'] = _123_number + locals()["123Number"] = _123_number del locals()['_123_number'] diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum.py index 93ff2076912..3d1ababa10f 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum.py @@ -75,10 +75,8 @@ class StringEnum( "approved": "APPROVED", "delivered": "DELIVERED", "single quoted": "SINGLE_QUOTED", - '''multiple -lines''': "MULTIPLE_LINES", - '''double quote - with newline''': "DOUBLE_QUOTE_WITH_NEWLINE", + "multiple\nlines": "MULTIPLE_LINES", + "double quote \n with newline": "DOUBLE_QUOTE_WITH_NEWLINE", } ), StrBase, @@ -119,14 +117,12 @@ lines''': "MULTIPLE_LINES", @classmethod @property def MULTIPLE_LINES(cls): - return cls('''multiple -lines''') + return cls("multiple\nlines") @classmethod @property def DOUBLE_QUOTE_WITH_NEWLINE(cls): - return cls('''double quote - with newline''') + return cls("double quote \n with newline") def __new__( cls, diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/schemas.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/schemas.py index 10985d6986c..1338d43bfa1 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/schemas.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/schemas.py @@ -201,6 +201,31 @@ class ValidatorBase: path_to_item=validation_metadata.path_to_item ) + @classmethod + def __data_with_boolclass_instead_of_bool(cls, data: typing.Any) -> typing.Any: + """ + In python bool is a subclass of int so 1 == True and 0 == False + This prevents code from being able to see the difference between 1 and True and 0 and False + To fix this swap in BoolClass singletons for True and False so they will differ from integers + """ + if isinstance(data, (list, tuple)): + new_data = [] + for item in data: + new_item = cls.__data_with_boolclass_instead_of_bool(item) + new_data.append(new_item) + return tuple(new_data) + elif isinstance(data, (dict, frozendict)): + new_data = {} + for key, value in data.items(): + new_value = cls.__data_with_boolclass_instead_of_bool(value) + new_data[key] = new_value + return frozendict(new_data) + elif isinstance(data, bool): + if data: + return BoolClass.TRUE + return BoolClass.FALSE + return data + @classmethod def __check_tuple_validations( cls, validations, input_values, @@ -228,10 +253,7 @@ class ValidatorBase: if (cls.__is_json_validation_enabled('uniqueItems', validation_metadata.configuration) and 'unique_items' in validations and validations['unique_items'] and input_values): - unique_items = [] - for item in input_values: - if item not in unique_items: - unique_items.append(item) + unique_items = set(cls.__data_with_boolclass_instead_of_bool(input_values)) if len(input_values) > len(unique_items): cls.__raise_validation_error_message( value=input_values, @@ -1872,8 +1894,9 @@ class IntBase(NumberBase): @classmethod def _validate_format(cls, arg: typing.Optional[decimal.Decimal], validation_metadata: ValidationMetadata): if isinstance(arg, decimal.Decimal): - exponent = arg.as_tuple().exponent - if exponent != 0: + + denominator = arg.as_integer_ratio()[-1] + if denominator != 1: raise ApiValueError( "Invalid value '{}' for type integer at {}".format(arg, validation_metadata.path_to_item) ) -- GitLab From f3867f2cd890619118e26f29ae56042499c1d923 Mon Sep 17 00:00:00 2001 From: Justin Black <justin.a.black@gmail.com> Date: Fri, 1 Jul 2022 13:23:49 -0700 Subject: [PATCH 43/43] Updates python-exp unit test sample, includes new ref examples --- .../unit_test_spec/3_0_3_unit_test_spec.yaml | 89 +++++++++++ .../unit_test_spec/openapi_additions/ref.json | 148 ++++++++++++++++++ .../3_0/unit_test_spec/spec_writer.py | 2 + .../.openapi-generator/FILES | 18 +++ .../python-experimental/README.md | 6 + .../docs/RefInAdditionalproperties.md | 9 ++ .../python-experimental/docs/RefInAllof.md | 9 ++ .../python-experimental/docs/RefInAnyof.md | 9 ++ .../python-experimental/docs/RefInItems.md | 8 + .../python-experimental/docs/RefInOneof.md | 9 ++ .../python-experimental/docs/RefInProperty.md | 10 ++ .../test/test_ref_in_additionalproperties.py | 52 ++++++ .../test/test_ref_in_allof.py | 46 ++++++ .../test/test_ref_in_anyof.py | 46 ++++++ .../test/test_ref_in_items.py | 50 ++++++ .../test/test_ref_in_oneof.py | 46 ++++++ .../test/test_ref_in_property.py | 52 ++++++ .../model/ref_in_additionalproperties.py | 97 ++++++++++++ .../unit_test_api/model/ref_in_allof.py | 114 ++++++++++++++ .../unit_test_api/model/ref_in_anyof.py | 114 ++++++++++++++ .../unit_test_api/model/ref_in_items.py | 83 ++++++++++ .../unit_test_api/model/ref_in_oneof.py | 114 ++++++++++++++ .../unit_test_api/model/ref_in_property.py | 98 ++++++++++++ .../unit_test_api/models/__init__.py | 6 + 24 files changed, 1235 insertions(+) create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RefInAdditionalproperties.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RefInAllof.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RefInAnyof.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RefInItems.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RefInOneof.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RefInProperty.md create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_additionalproperties.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_allof.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_anyof.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_items.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_oneof.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_property.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ref_in_additionalproperties.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ref_in_allof.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ref_in_anyof.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ref_in_items.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ref_in_oneof.py create mode 100644 samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ref_in_property.py diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml index 7334798e558..c2bf8c421bc 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml @@ -178,6 +178,25 @@ components: properties: $ref: type: string + RefInAdditionalproperties: + additionalProperties: + $ref: '#/components/schemas/PropertyNamedRefThatIsNotAReference' + RefInItems: + items: + $ref: '#/components/schemas/PropertyNamedRefThatIsNotAReference' + RefInProperty: + properties: + a: + $ref: '#/components/schemas/PropertyNamedRefThatIsNotAReference' + RefInAllof: + allOf: + - $ref: '#/components/schemas/PropertyNamedRefThatIsNotAReference' + RefInOneof: + oneOf: + - $ref: '#/components/schemas/PropertyNamedRefThatIsNotAReference' + RefInAnyof: + anyOf: + - $ref: '#/components/schemas/PropertyNamedRefThatIsNotAReference' RequiredValidation: properties: foo: {} @@ -1079,6 +1098,76 @@ components: data: $ref: 2 valid: false + RefInAdditionalproperties: + PropertyNamedRefValid: + description: property named $ref valid + data: + someProp: + $ref: a + valid: true + PropertyNamedRefInvalid: + description: property named $ref invalid + data: + someProp: + $ref: 2 + valid: false + RefInItems: + PropertyNamedRefValid: + description: property named $ref valid + data: + - $ref: a + valid: true + PropertyNamedRefInvalid: + description: property named $ref invalid + data: + - $ref: 2 + valid: false + RefInProperty: + PropertyNamedRefValid: + description: property named $ref valid + data: + a: + $ref: a + valid: true + PropertyNamedRefInvalid: + description: property named $ref invalid + data: + a: + $ref: 2 + valid: false + RefInAllof: + PropertyNamedRefValid: + description: property named $ref valid + data: + $ref: a + valid: true + PropertyNamedRefInvalid: + description: property named $ref invalid + data: + $ref: 2 + valid: false + RefInOneof: + PropertyNamedRefValid: + description: property named $ref valid + data: + $ref: a + valid: true + PropertyNamedRefInvalid: + description: property named $ref invalid + data: + $ref: 2 + valid: false + RefInAnyof: + PropertyNamedRefValid: + description: property named $ref valid + data: + $ref: a + valid: true + PropertyNamedRefInvalid: + description: property named $ref invalid + data: + $ref: 2 + valid: false RequiredValidation: PresentRequiredPropertyIsValid: description: present required property is valid diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/openapi_additions/ref.json b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/openapi_additions/ref.json index ec4aad9d92b..f3e14f6e017 100755 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/openapi_additions/ref.json +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/openapi_additions/ref.json @@ -68,5 +68,153 @@ "valid": false } ] + }, + { + "description": "ref in additionalProperties", + "schema": { + "additionalProperties": { + "$ref": "#/components/schemas/PropertyNamedRefThatIsNotAReference" + } + }, + "tests": [ + { + "description": "property named $ref valid", + "data": {"someProp": {"$ref": "a"}}, + "valid": true + }, + { + "description": "property named $ref invalid", + "data": {"someProp": {"$ref": 2}}, + "valid": false + } + ] + }, + { + "description": "ref in items", + "schema": { + "items": { + "$ref": "#/components/schemas/PropertyNamedRefThatIsNotAReference" + } + }, + "tests": [ + { + "description": "property named $ref valid", + "data": [{"$ref": "a"}], + "valid": true + }, + { + "description": "property named $ref invalid", + "data": [{"$ref": 2}], + "valid": false + } + ] + }, + { + "description": "ref in property", + "schema": { + "properties": { + "a": { + "$ref": "#/components/schemas/PropertyNamedRefThatIsNotAReference" + } + } + }, + "tests": [ + { + "description": "property named $ref valid", + "data": {"a": {"$ref": "a"}}, + "valid": true + }, + { + "description": "property named $ref invalid", + "data": {"a": {"$ref": 2}}, + "valid": false + } + ] + }, + { + "description": "ref in allOf", + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/PropertyNamedRefThatIsNotAReference" + } + ] + }, + "tests": [ + { + "description": "property named $ref valid", + "data": {"$ref": "a"}, + "valid": true + }, + { + "description": "property named $ref invalid", + "data": {"$ref": 2}, + "valid": false + } + ] + }, + { + "description": "ref in oneOf", + "schema": { + "oneOf": [ + { + "$ref": "#/components/schemas/PropertyNamedRefThatIsNotAReference" + } + ] + }, + "tests": [ + { + "description": "property named $ref valid", + "data": {"$ref": "a"}, + "valid": true + }, + { + "description": "property named $ref invalid", + "data": {"$ref": 2}, + "valid": false + } + ] + }, + { + "description": "ref in anyOf", + "schema": { + "anyOf": [ + { + "$ref": "#/components/schemas/PropertyNamedRefThatIsNotAReference" + } + ] + }, + "tests": [ + { + "description": "property named $ref valid", + "data": {"$ref": "a"}, + "valid": true + }, + { + "description": "property named $ref invalid", + "data": {"$ref": 2}, + "valid": false + } + ] + }, + { + "description": "ref in not", + "schema": { + "not": { + "$ref": "#/components/schemas/PropertyNamedRefThatIsNotAReference" + } + }, + "tests": [ + { + "description": "property named $ref invalid", + "data": {"$ref": "a"}, + "valid": false + }, + { + "description": "property named $ref valid", + "data": {"$ref": 2}, + "valid": true + } + ] } ] diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index e57538afc73..d4cd2c5b7e4 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -102,6 +102,7 @@ class ExclusionReason: not_running_the_localhost_server = 'the openapo-generator is not running the localhost server needed to serve remoteRef files' required_vars_missing_for_anytype_schema_bug = 'fails because of a bug where required vars are forgotten, see issue https://github.com/OpenAPITools/openapi-generator/issues/8906' v303_requires_that_the_default_value_is_an_allowed_type = 'v3.0.3 requires that the default value is an allowed type per the schema' + not_ref_import_missing = 'this test fails because of this open issue https://github.com/OpenAPITools/openapi-generator/issues/12756' json_schema_test_draft = 'draft6' openapi_additions = 'openapi_additions' @@ -165,6 +166,7 @@ FILEPATH_TO_EXCLUDED_CASE_AND_REASON = { 'property refs adjacent property': ExclusionReason.ref_to_adjacent_property_bug, 'property refs containing component schema': ExclusionReason.swagger_parser_anytype_bug, 'component refs another component': ExclusionReason.component_ref_component_bug, + 'ref in not': ExclusionReason.not_ref_import_missing }, (json_schema_test_draft, 'refRemote.json'): { 'base URI change - change folder': ExclusionReason.v303_does_not_support_id, diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index 3606e2e5cdd..9d9faaf0c3f 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -49,6 +49,12 @@ docs/PatternIsNotAnchored.md docs/PatternValidation.md docs/PropertiesWithEscapedCharacters.md docs/PropertyNamedRefThatIsNotAReference.md +docs/RefInAdditionalproperties.md +docs/RefInAllof.md +docs/RefInAnyof.md +docs/RefInItems.md +docs/RefInOneof.md +docs/RefInProperty.md docs/RequiredDefaultValidation.md docs/RequiredValidation.md docs/RequiredWithEmptyArray.md @@ -113,6 +119,12 @@ test/test_pattern_is_not_anchored.py test/test_pattern_validation.py test/test_properties_with_escaped_characters.py test/test_property_named_ref_that_is_not_a_reference.py +test/test_ref_in_additionalproperties.py +test/test_ref_in_allof.py +test/test_ref_in_anyof.py +test/test_ref_in_items.py +test/test_ref_in_oneof.py +test/test_ref_in_property.py test/test_required_default_validation.py test/test_required_validation.py test/test_required_with_empty_array.py @@ -179,6 +191,12 @@ unit_test_api/model/pattern_is_not_anchored.py unit_test_api/model/pattern_validation.py unit_test_api/model/properties_with_escaped_characters.py unit_test_api/model/property_named_ref_that_is_not_a_reference.py +unit_test_api/model/ref_in_additionalproperties.py +unit_test_api/model/ref_in_allof.py +unit_test_api/model/ref_in_anyof.py +unit_test_api/model/ref_in_items.py +unit_test_api/model/ref_in_oneof.py +unit_test_api/model/ref_in_property.py unit_test_api/model/required_default_validation.py unit_test_api/model/required_validation.py unit_test_api/model/required_with_empty_array.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md index ce2ca8dc8c2..a5feaa4ef0f 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md @@ -109,6 +109,12 @@ Class | Method | HTTP request | Description - [PatternValidation](docs/PatternValidation.md) - [PropertiesWithEscapedCharacters](docs/PropertiesWithEscapedCharacters.md) - [PropertyNamedRefThatIsNotAReference](docs/PropertyNamedRefThatIsNotAReference.md) + - [RefInAdditionalproperties](docs/RefInAdditionalproperties.md) + - [RefInAllof](docs/RefInAllof.md) + - [RefInAnyof](docs/RefInAnyof.md) + - [RefInItems](docs/RefInItems.md) + - [RefInOneof](docs/RefInOneof.md) + - [RefInProperty](docs/RefInProperty.md) - [RequiredDefaultValidation](docs/RequiredDefaultValidation.md) - [RequiredValidation](docs/RequiredValidation.md) - [RequiredWithEmptyArray](docs/RequiredWithEmptyArray.md) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RefInAdditionalproperties.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RefInAdditionalproperties.md new file mode 100644 index 00000000000..d65f094ff7d --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RefInAdditionalproperties.md @@ -0,0 +1,9 @@ +# RefInAdditionalproperties + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **PropertyNamedRefThatIsNotAReference** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RefInAllof.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RefInAllof.md new file mode 100644 index 00000000000..5c193c05ad2 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RefInAllof.md @@ -0,0 +1,9 @@ +# RefInAllof + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RefInAnyof.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RefInAnyof.md new file mode 100644 index 00000000000..317cc9a1741 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RefInAnyof.md @@ -0,0 +1,9 @@ +# RefInAnyof + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RefInItems.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RefInItems.md new file mode 100644 index 00000000000..618c1522152 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RefInItems.md @@ -0,0 +1,8 @@ +# RefInItems + +Type | Description | Notes +------------- | ------------- | ------------- +**[PropertyNamedRefThatIsNotAReference]** | | + +[[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/3_0_3_unit_test/python-experimental/docs/RefInOneof.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RefInOneof.md new file mode 100644 index 00000000000..e063bf5a11d --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RefInOneof.md @@ -0,0 +1,9 @@ +# RefInOneof + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RefInProperty.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RefInProperty.md new file mode 100644 index 00000000000..5e912fa825a --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/RefInProperty.md @@ -0,0 +1,10 @@ +# RefInProperty + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**a** | [**PropertyNamedRefThatIsNotAReference**](PropertyNamedRefThatIsNotAReference.md) | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_additionalproperties.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_additionalproperties.py new file mode 100644 index 00000000000..3079918ced1 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_additionalproperties.py @@ -0,0 +1,52 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.ref_in_additionalproperties import RefInAdditionalproperties +from unit_test_api import configuration + + +class TestRefInAdditionalproperties(unittest.TestCase): + """RefInAdditionalproperties unit test stubs""" + _configuration = configuration.Configuration() + + def test_property_named_ref_valid_passes(self): + # property named $ref valid + RefInAdditionalproperties._from_openapi_data( + { + "someProp": + { + "$ref": + "a", + }, + }, + _configuration=self._configuration + ) + + def test_property_named_ref_invalid_fails(self): + # property named $ref invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + RefInAdditionalproperties._from_openapi_data( + { + "someProp": + { + "$ref": + 2, + }, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_allof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_allof.py new file mode 100644 index 00000000000..a1bcc365091 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_allof.py @@ -0,0 +1,46 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.ref_in_allof import RefInAllof +from unit_test_api import configuration + + +class TestRefInAllof(unittest.TestCase): + """RefInAllof unit test stubs""" + _configuration = configuration.Configuration() + + def test_property_named_ref_valid_passes(self): + # property named $ref valid + RefInAllof._from_openapi_data( + { + "$ref": + "a", + }, + _configuration=self._configuration + ) + + def test_property_named_ref_invalid_fails(self): + # property named $ref invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + RefInAllof._from_openapi_data( + { + "$ref": + 2, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_anyof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_anyof.py new file mode 100644 index 00000000000..33ece563af9 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_anyof.py @@ -0,0 +1,46 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.ref_in_anyof import RefInAnyof +from unit_test_api import configuration + + +class TestRefInAnyof(unittest.TestCase): + """RefInAnyof unit test stubs""" + _configuration = configuration.Configuration() + + def test_property_named_ref_valid_passes(self): + # property named $ref valid + RefInAnyof._from_openapi_data( + { + "$ref": + "a", + }, + _configuration=self._configuration + ) + + def test_property_named_ref_invalid_fails(self): + # property named $ref invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + RefInAnyof._from_openapi_data( + { + "$ref": + 2, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_items.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_items.py new file mode 100644 index 00000000000..1cc69e3556b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_items.py @@ -0,0 +1,50 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.ref_in_items import RefInItems +from unit_test_api import configuration + + +class TestRefInItems(unittest.TestCase): + """RefInItems unit test stubs""" + _configuration = configuration.Configuration() + + def test_property_named_ref_valid_passes(self): + # property named $ref valid + RefInItems._from_openapi_data( + [ + { + "$ref": + "a", + }, + ], + _configuration=self._configuration + ) + + def test_property_named_ref_invalid_fails(self): + # property named $ref invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + RefInItems._from_openapi_data( + [ + { + "$ref": + 2, + }, + ], + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_oneof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_oneof.py new file mode 100644 index 00000000000..f063204479f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_oneof.py @@ -0,0 +1,46 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.ref_in_oneof import RefInOneof +from unit_test_api import configuration + + +class TestRefInOneof(unittest.TestCase): + """RefInOneof unit test stubs""" + _configuration = configuration.Configuration() + + def test_property_named_ref_valid_passes(self): + # property named $ref valid + RefInOneof._from_openapi_data( + { + "$ref": + "a", + }, + _configuration=self._configuration + ) + + def test_property_named_ref_invalid_fails(self): + # property named $ref invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + RefInOneof._from_openapi_data( + { + "$ref": + 2, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_property.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_property.py new file mode 100644 index 00000000000..da213d35ed1 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_ref_in_property.py @@ -0,0 +1,52 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.ref_in_property import RefInProperty +from unit_test_api import configuration + + +class TestRefInProperty(unittest.TestCase): + """RefInProperty unit test stubs""" + _configuration = configuration.Configuration() + + def test_property_named_ref_valid_passes(self): + # property named $ref valid + RefInProperty._from_openapi_data( + { + "a": + { + "$ref": + "a", + }, + }, + _configuration=self._configuration + ) + + def test_property_named_ref_invalid_fails(self): + # property named $ref invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + RefInProperty._from_openapi_data( + { + "a": + { + "$ref": + 2, + }, + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ref_in_additionalproperties.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ref_in_additionalproperties.py new file mode 100644 index 00000000000..e9a1d9100a4 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ref_in_additionalproperties.py @@ -0,0 +1,97 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class RefInAdditionalproperties( + DictSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + def _additional_properties(cls) -> typing.Type['PropertyNamedRefThatIsNotAReference']: + return PropertyNamedRefThatIsNotAReference + + + def __new__( + cls, + *args: typing.Union[dict, frozendict, ], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'RefInAdditionalproperties': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) + +from unit_test_api.model.property_named_ref_that_is_not_a_reference import PropertyNamedRefThatIsNotAReference diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ref_in_allof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ref_in_allof.py new file mode 100644 index 00000000000..927d0c2530b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ref_in_allof.py @@ -0,0 +1,114 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class RefInAllof( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 { + 'allOf': [ + PropertyNamedRefThatIsNotAReference, + ], + 'oneOf': [ + ], + 'anyOf': [ + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'RefInAllof': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) + +from unit_test_api.model.property_named_ref_that_is_not_a_reference import PropertyNamedRefThatIsNotAReference diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ref_in_anyof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ref_in_anyof.py new file mode 100644 index 00000000000..989ff30c91b --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ref_in_anyof.py @@ -0,0 +1,114 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class RefInAnyof( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 { + 'allOf': [ + ], + 'oneOf': [ + ], + 'anyOf': [ + PropertyNamedRefThatIsNotAReference, + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'RefInAnyof': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) + +from unit_test_api.model.property_named_ref_that_is_not_a_reference import PropertyNamedRefThatIsNotAReference diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ref_in_items.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ref_in_items.py new file mode 100644 index 00000000000..9253eeeacc6 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ref_in_items.py @@ -0,0 +1,83 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class RefInItems( + ListSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + def _items(cls) -> typing.Type['PropertyNamedRefThatIsNotAReference']: + return PropertyNamedRefThatIsNotAReference + +from unit_test_api.model.property_named_ref_that_is_not_a_reference import PropertyNamedRefThatIsNotAReference diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ref_in_oneof.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ref_in_oneof.py new file mode 100644 index 00000000000..43ea96899ba --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ref_in_oneof.py @@ -0,0 +1,114 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class RefInOneof( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # 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 because 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 { + 'allOf': [ + ], + 'oneOf': [ + PropertyNamedRefThatIsNotAReference, + ], + 'anyOf': [ + ], + 'not': + None + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'RefInOneof': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) + +from unit_test_api.model.property_named_ref_that_is_not_a_reference import PropertyNamedRefThatIsNotAReference diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ref_in_property.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ref_in_property.py new file mode 100644 index 00000000000..e0f43592bbb --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ref_in_property.py @@ -0,0 +1,98 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class RefInProperty( + AnyTypeSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + def a(cls) -> typing.Type['PropertyNamedRefThatIsNotAReference']: + return PropertyNamedRefThatIsNotAReference + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + a: typing.Union['PropertyNamedRefThatIsNotAReference', Unset] = unset, + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'RefInProperty': + return super().__new__( + cls, + *args, + a=a, + _configuration=_configuration, + **kwargs, + ) + +from unit_test_api.model.property_named_ref_that_is_not_a_reference import PropertyNamedRefThatIsNotAReference diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py index 7f40cc8e240..a45a5dacf32 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py @@ -58,6 +58,12 @@ from unit_test_api.model.pattern_is_not_anchored import PatternIsNotAnchored from unit_test_api.model.pattern_validation import PatternValidation from unit_test_api.model.properties_with_escaped_characters import PropertiesWithEscapedCharacters from unit_test_api.model.property_named_ref_that_is_not_a_reference import PropertyNamedRefThatIsNotAReference +from unit_test_api.model.ref_in_additionalproperties import RefInAdditionalproperties +from unit_test_api.model.ref_in_allof import RefInAllof +from unit_test_api.model.ref_in_anyof import RefInAnyof +from unit_test_api.model.ref_in_items import RefInItems +from unit_test_api.model.ref_in_oneof import RefInOneof +from unit_test_api.model.ref_in_property import RefInProperty from unit_test_api.model.required_default_validation import RequiredDefaultValidation from unit_test_api.model.required_validation import RequiredValidation from unit_test_api.model.required_with_empty_array import RequiredWithEmptyArray -- GitLab