From beb67aa74d40f332596d757ddd4ff66a54be969e Mon Sep 17 00:00:00 2001 From: Robbert van Waveren Date: Wed, 27 Sep 2023 11:50:39 +0200 Subject: [PATCH] [JAVA] Prioritize mapped discriminators over generated (relates to issue #12777) (#15284) * prioritize mapped discriminators over generated * update samples with new ordering * explain reason behind discriminator prioritization * add new samples * prioritize explicit mapping over any generated mappings * update examples to reflect new logic * update tests to reflect explicit mappings --- .../codegen/CodegenDiscriminator.java | 18 +- .../openapitools/codegen/DefaultCodegen.java | 6 +- .../codegen/DefaultCodegenTest.java | 16 +- .../codegen/ruby/RubyClientCodegenTest.java | 8 +- .../client/petstore/python-nextgen/.coverage | Bin 0 -> 77824 bytes .../python-nextgen/dev-requirements.txt.log | 115 ++++++ .../petstore_api.egg-info/PKG-INFO | 13 + .../petstore_api.egg-info/SOURCES.txt | 176 +++++++++ .../dependency_links.txt | 1 + .../petstore_api.egg-info/requires.txt | 6 + .../petstore_api.egg-info/top_level.txt | 1 + .../python-prior/petstore_api/model/mammal.py | 349 ++++++++++++++++++ .../java/org/openapitools/model/Fruit.java | 2 +- 13 files changed, 693 insertions(+), 18 deletions(-) create mode 100644 samples/openapi3/client/petstore/python-nextgen/.coverage create mode 100644 samples/openapi3/client/petstore/python-nextgen/dev-requirements.txt.log create mode 100644 samples/openapi3/client/petstore/python-nextgen/petstore_api.egg-info/PKG-INFO create mode 100644 samples/openapi3/client/petstore/python-nextgen/petstore_api.egg-info/SOURCES.txt create mode 100644 samples/openapi3/client/petstore/python-nextgen/petstore_api.egg-info/dependency_links.txt create mode 100644 samples/openapi3/client/petstore/python-nextgen/petstore_api.egg-info/requires.txt create mode 100644 samples/openapi3/client/petstore/python-nextgen/petstore_api.egg-info/top_level.txt create mode 100644 samples/openapi3/client/petstore/python-prior/petstore_api/model/mammal.py diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenDiscriminator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenDiscriminator.java index 6c2b91caa932..cabdf4d911de 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenDiscriminator.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenDiscriminator.java @@ -123,9 +123,16 @@ public static class MappedModel implements Comparable{ private CodegenModel model; - public MappedModel(String mappingName, String modelName) { + private final boolean explicitMapping; + + public MappedModel(String mappingName, String modelName, boolean explicitMapping) { this.mappingName = mappingName; this.modelName = modelName; + this.explicitMapping = explicitMapping; + } + + public MappedModel(String mappingName, String modelName) { + this(mappingName, modelName, false); } @Override @@ -137,7 +144,14 @@ public int compareTo(MappedModel other) { } else if (other.getMappingName() == null) { return -1; } - return getMappingName().compareTo(other.getMappingName()); + + // prioritize mappings based on mappings in the spec before any auto-generated + // so that during serialization the proper values are used in the json + if (explicitMapping != other.explicitMapping) { + return explicitMapping ? -1 : 1; + } else { + return getMappingName().compareTo(other.getMappingName()); + } } public String getMappingName() { 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 7ffb35f8ebe0..8b032e60e550 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 @@ -3492,7 +3492,7 @@ protected List getOneOfAnyOfDescendants(String composedSchemaName, Map vendorExtensions = cs.getExtensions(); if (vendorExtensions != null && !vendorExtensions.isEmpty() && vendorExtensions.containsKey("x-discriminator-value")) { String xDiscriminatorValue = (String) vendorExtensions.get("x-discriminator-value"); - mm = new MappedModel(xDiscriminatorValue, toModelName(modelName)); + mm = new MappedModel(xDiscriminatorValue, toModelName(modelName), true); descendentSchemas.add(mm); } } @@ -3550,7 +3550,7 @@ protected List getAllOfDescendants(String thisSchemaName) { .map(ve -> ve.get("x-discriminator-value")) .map(discriminatorValue -> (String) discriminatorValue) .orElse(currentSchemaName); - MappedModel mm = new MappedModel(mappingName, toModelName(currentSchemaName)); + MappedModel mm = new MappedModel(mappingName, toModelName(currentSchemaName), mappingName != currentSchemaName); descendentSchemas.add(mm); } return descendentSchemas; @@ -3604,7 +3604,7 @@ protected CodegenDiscriminator createDiscriminator(String schemaName, Schema sch } else { name = e.getValue(); } - uniqueDescendants.add(new MappedModel(e.getKey(), toModelName(name))); + uniqueDescendants.add(new MappedModel(e.getKey(), toModelName(name), true)); } } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java index c5c960b62d5c..9fae04d8c15b 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java @@ -1164,7 +1164,7 @@ public void testComposedSchemaAllOfDiscriminatorMap() { sc = openAPI.getComponents().getSchemas().get(modelName); cm = codegen.fromModel(modelName, sc); hs.clear(); - hs.add(new CodegenDiscriminator.MappedModel("b", codegen.toModelName("B"))); + hs.add(new CodegenDiscriminator.MappedModel("b", codegen.toModelName("B"), true)); hs.add(new CodegenDiscriminator.MappedModel("C", codegen.toModelName("C"))); Assert.assertEquals(cm.getHasDiscriminatorWithNonEmptyMapping(), true); Assert.assertEquals(cm.discriminator.getMappedModels(), hs); @@ -1174,7 +1174,7 @@ public void testComposedSchemaAllOfDiscriminatorMap() { sc = openAPI.getComponents().getSchemas().get(modelName); cm = codegen.fromModel(modelName, sc); hs.clear(); - hs.add(new CodegenDiscriminator.MappedModel("b", codegen.toModelName("B"))); + hs.add(new CodegenDiscriminator.MappedModel("b", codegen.toModelName("B"), true)); hs.add(new CodegenDiscriminator.MappedModel("C", codegen.toModelName("C"))); Assert.assertEquals(cm.getHasDiscriminatorWithNonEmptyMapping(), true); Assert.assertEquals(cm.discriminator.getMappedModels(), hs); @@ -1184,7 +1184,7 @@ public void testComposedSchemaAllOfDiscriminatorMap() { sc = openAPI.getComponents().getSchemas().get(modelName); cm = codegen.fromModel(modelName, sc); hs.clear(); - hs.add(new CodegenDiscriminator.MappedModel("b", codegen.toModelName("B"))); + hs.add(new CodegenDiscriminator.MappedModel("b", codegen.toModelName("B"), true)); Assert.assertEquals(cm.getHasDiscriminatorWithNonEmptyMapping(), true); Assert.assertEquals(cm.discriminator.getMappedModels(), hs); } @@ -1265,7 +1265,7 @@ public void testComposedSchemaAllOfDiscriminatorMapLegacy() { sc = openAPI.getComponents().getSchemas().get(modelName); cm = codegen.fromModel(modelName, sc); hs.clear(); - hs.add(new CodegenDiscriminator.MappedModel("b", codegen.toModelName("B"))); + hs.add(new CodegenDiscriminator.MappedModel("b", codegen.toModelName("B"), true)); Assert.assertEquals(cm.discriminator.getMappedModels(), hs); // the mapping in b is in B @@ -1654,8 +1654,8 @@ public void verifyXDiscriminatorValue() { discriminator.setPropertyBaseName(prop); discriminator.setMapping(null); discriminator.setMappedModels(new HashSet() {{ - add(new CodegenDiscriminator.MappedModel("daily", "DailySubObj")); - add(new CodegenDiscriminator.MappedModel("sub-obj", "SubObj")); + add(new CodegenDiscriminator.MappedModel("daily", "DailySubObj", true)); + add(new CodegenDiscriminator.MappedModel("sub-obj", "SubObj", true)); }}); assertEquals(cm.discriminator, discriminator); } @@ -2049,8 +2049,8 @@ private void verifyPersonDiscriminator(CodegenDiscriminator discriminator) { test.setMapping(new HashMap<>()); test.getMapping().put("a", "#/components/schemas/Adult"); test.getMapping().put("c", "Child"); - test.getMappedModels().add(new CodegenDiscriminator.MappedModel("a", "Adult")); - test.getMappedModels().add(new CodegenDiscriminator.MappedModel("c", "Child")); + test.getMappedModels().add(new CodegenDiscriminator.MappedModel("a", "Adult", true)); + test.getMappedModels().add(new CodegenDiscriminator.MappedModel("c", "Child", true)); Assert.assertEquals(discriminator, test); } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java index 195f533ef26e..2d54a75582a5 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java @@ -386,8 +386,8 @@ public void allOfTest() { CodegenDiscriminator codegenDiscriminator = person.getDiscriminator(); Set mappedModels = new LinkedHashSet(); - mappedModels.add(new CodegenDiscriminator.MappedModel("a", "Adult")); - mappedModels.add(new CodegenDiscriminator.MappedModel("c", "Child")); + mappedModels.add(new CodegenDiscriminator.MappedModel("a", "Adult", true)); + mappedModels.add(new CodegenDiscriminator.MappedModel("c", "Child", true)); Assert.assertEquals(codegenDiscriminator.getMappedModels(), mappedModels); } @@ -405,8 +405,8 @@ public void allOfTestLegacy() { CodegenDiscriminator codegenDiscriminator = person.getDiscriminator(); Set mappedModels = new LinkedHashSet(); - mappedModels.add(new CodegenDiscriminator.MappedModel("a", "Adult")); - mappedModels.add(new CodegenDiscriminator.MappedModel("c", "Child")); + mappedModels.add(new CodegenDiscriminator.MappedModel("a", "Adult", true)); + mappedModels.add(new CodegenDiscriminator.MappedModel("c", "Child", true)); Assert.assertEquals(codegenDiscriminator.getMappedModels(), mappedModels); } diff --git a/samples/openapi3/client/petstore/python-nextgen/.coverage b/samples/openapi3/client/petstore/python-nextgen/.coverage new file mode 100644 index 0000000000000000000000000000000000000000..fbc2acd5d9715afed613d5bd99961fef02cf8884 GIT binary patch literal 77824 zcmeHQ33MFAneLhCxu?5EmTgIvEsbT_mTXBQ`L<Z`lDy87atZY3oL2Gm4UN(B~ke$Hay+5-WO6(ns#p$$S%(3_$)`R5_XVA-|fOY@6UZv_YK~!I3;%&eqa}4fHA-r zU<~|iGmz==Im;?4EaL}LQeQ+)C8V&N(4?^bqRx&>Is=z{lp2UA zF`CR+Qb{RlEFh1_;dDywKW_pXkTm@Q@(NP}VfA8ydNrR}tO9oOp3mbm>pbgu03sJt zbz1Wt5gI(xILFe_KA?P0IvU5!0UsK0N}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ZV)xhP6FmYs@&ZNZ(bM z-R800j7-!qwe22Rt?$dt!&ZO%{DVgKKI?D z5;Ll-wqtayDNuA9=jsf{kJ}7u)U#8~3+>}=5.1 + Downloading chardet-5.1.0-py3-none-any.whl (199 kB) + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 199.1/199.1 KB 8.7 MB/s eta 0:00:00 +Collecting tomli>=2.0.1 + Downloading tomli-2.0.1-py3-none-any.whl (12 kB) +Collecting filelock>=3.11 + Downloading filelock-3.12.0-py3-none-any.whl (10 kB) +Collecting platformdirs>=3.2 + Downloading platformdirs-3.2.0-py3-none-any.whl (14 kB) +Collecting pyproject-api>=1.5.1 + Downloading pyproject_api-1.5.1-py3-none-any.whl (12 kB) +Collecting packaging>=23 + Downloading packaging-23.1-py3-none-any.whl (48 kB) + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.9/48.9 KB 6.8 MB/s eta 0:00:00 +Collecting pluggy>=1 + Downloading pluggy-1.0.0-py2.py3-none-any.whl (13 kB) +Collecting virtualenv>=20.21 + Downloading virtualenv-20.22.0-py3-none-any.whl (3.2 MB) + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.2/3.2 MB 14.5 MB/s eta 0:00:00 +Collecting colorama>=0.4.6 + Downloading colorama-0.4.6-py2.py3-none-any.whl (25 kB) +Collecting cachetools>=5.3 + Downloading cachetools-5.3.0-py3-none-any.whl (9.3 kB) +Collecting mccabe<0.8.0,>=0.7.0 + Downloading mccabe-0.7.0-py2.py3-none-any.whl (7.3 kB) +Collecting pycodestyle<2.11.0,>=2.10.0 + Downloading pycodestyle-2.10.0-py2.py3-none-any.whl (41 kB) + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 41.3/41.3 KB 5.0 MB/s eta 0:00:00 +Collecting pyflakes<3.1.0,>=3.0.0 + Downloading pyflakes-3.0.1-py2.py3-none-any.whl (62 kB) + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.8/62.8 KB 14.3 MB/s eta 0:00:00 +Requirement already satisfied: distlib<1,>=0.3.6 in /home/robbert/.local/lib/python3.10/site-packages (from virtualenv>=20.21->tox->-r dev-requirements.txt (line 1)) (0.3.6) +Installing collected packages: tomli, pyflakes, pycodestyle, pluggy, platformdirs, packaging, mccabe, filelock, colorama, chardet, cachetools, virtualenv, pyproject-api, flake8, tox + Attempting uninstall: filelock + Found existing installation: filelock 3.10.4 + Uninstalling filelock-3.10.4: + Successfully uninstalled filelock-3.10.4 + Attempting uninstall: virtualenv + Found existing installation: virtualenv 20.4.2 + Uninstalling virtualenv-20.4.2: + Successfully uninstalled virtualenv-20.4.2 +Successfully installed cachetools-5.3.0 chardet-5.1.0 colorama-0.4.6 filelock-3.12.0 flake8-6.0.0 mccabe-0.7.0 packaging-23.1 platformdirs-3.2.0 pluggy-1.0.0 pycodestyle-2.10.0 pyflakes-3.0.1 pyproject-api-1.5.1 tomli-2.0.1 tox-4.4.12 virtualenv-20.22.0 +Collecting tox (from -r dev-requirements.txt (line 1)) + Using cached tox-4.4.12-py3-none-any.whl (148 kB) +Collecting flake8 (from -r dev-requirements.txt (line 2)) + Using cached flake8-6.0.0-py2.py3-none-any.whl (57 kB) +Collecting cachetools>=5.3 (from tox->-r dev-requirements.txt (line 1)) + Using cached cachetools-5.3.0-py3-none-any.whl (9.3 kB) +Collecting chardet>=5.1 (from tox->-r dev-requirements.txt (line 1)) + Using cached chardet-5.1.0-py3-none-any.whl (199 kB) +Collecting colorama>=0.4.6 (from tox->-r dev-requirements.txt (line 1)) + Using cached colorama-0.4.6-py2.py3-none-any.whl (25 kB) +Collecting filelock>=3.11 (from tox->-r dev-requirements.txt (line 1)) + Using cached filelock-3.12.0-py3-none-any.whl (10 kB) +Collecting packaging>=23 (from tox->-r dev-requirements.txt (line 1)) + Using cached packaging-23.1-py3-none-any.whl (48 kB) +Collecting platformdirs>=3.2 (from tox->-r dev-requirements.txt (line 1)) + Using cached platformdirs-3.2.0-py3-none-any.whl (14 kB) +Collecting pluggy>=1 (from tox->-r dev-requirements.txt (line 1)) + Using cached pluggy-1.0.0-py2.py3-none-any.whl (13 kB) +Collecting pyproject-api>=1.5.1 (from tox->-r dev-requirements.txt (line 1)) + Using cached pyproject_api-1.5.1-py3-none-any.whl (12 kB) +Collecting tomli>=2.0.1 (from tox->-r dev-requirements.txt (line 1)) + Using cached tomli-2.0.1-py3-none-any.whl (12 kB) +Collecting virtualenv>=20.21 (from tox->-r dev-requirements.txt (line 1)) + Using cached virtualenv-20.22.0-py3-none-any.whl (3.2 MB) +Collecting mccabe<0.8.0,>=0.7.0 (from flake8->-r dev-requirements.txt (line 2)) + Using cached mccabe-0.7.0-py2.py3-none-any.whl (7.3 kB) +Collecting pycodestyle<2.11.0,>=2.10.0 (from flake8->-r dev-requirements.txt (line 2)) + Using cached pycodestyle-2.10.0-py2.py3-none-any.whl (41 kB) +Collecting pyflakes<3.1.0,>=3.0.0 (from flake8->-r dev-requirements.txt (line 2)) + Using cached pyflakes-3.0.1-py2.py3-none-any.whl (62 kB) +Collecting distlib<1,>=0.3.6 (from virtualenv>=20.21->tox->-r dev-requirements.txt (line 1)) + Using cached distlib-0.3.6-py2.py3-none-any.whl (468 kB) +Installing collected packages: distlib, tomli, pyflakes, pycodestyle, pluggy, platformdirs, packaging, mccabe, filelock, colorama, chardet, cachetools, virtualenv, pyproject-api, flake8, tox +Successfully installed cachetools-5.3.0 chardet-5.1.0 colorama-0.4.6 distlib-0.3.6 filelock-3.12.0 flake8-6.0.0 mccabe-0.7.0 packaging-23.1 platformdirs-3.2.0 pluggy-1.0.0 pycodestyle-2.10.0 pyflakes-3.0.1 pyproject-api-1.5.1 tomli-2.0.1 tox-4.4.12 virtualenv-20.22.0 +Requirement already satisfied: tox in ./venv/lib/python3.10/site-packages (from -r dev-requirements.txt (line 1)) (4.4.12) +Requirement already satisfied: flake8 in ./venv/lib/python3.10/site-packages (from -r dev-requirements.txt (line 2)) (6.0.0) +Requirement already satisfied: cachetools>=5.3 in ./venv/lib/python3.10/site-packages (from tox->-r dev-requirements.txt (line 1)) (5.3.0) +Requirement already satisfied: chardet>=5.1 in ./venv/lib/python3.10/site-packages (from tox->-r dev-requirements.txt (line 1)) (5.1.0) +Requirement already satisfied: colorama>=0.4.6 in ./venv/lib/python3.10/site-packages (from tox->-r dev-requirements.txt (line 1)) (0.4.6) +Requirement already satisfied: filelock>=3.11 in ./venv/lib/python3.10/site-packages (from tox->-r dev-requirements.txt (line 1)) (3.12.0) +Requirement already satisfied: packaging>=23 in ./venv/lib/python3.10/site-packages (from tox->-r dev-requirements.txt (line 1)) (23.1) +Requirement already satisfied: platformdirs>=3.2 in ./venv/lib/python3.10/site-packages (from tox->-r dev-requirements.txt (line 1)) (3.2.0) +Requirement already satisfied: pluggy>=1 in ./venv/lib/python3.10/site-packages (from tox->-r dev-requirements.txt (line 1)) (1.0.0) +Requirement already satisfied: pyproject-api>=1.5.1 in ./venv/lib/python3.10/site-packages (from tox->-r dev-requirements.txt (line 1)) (1.5.1) +Requirement already satisfied: tomli>=2.0.1 in ./venv/lib/python3.10/site-packages (from tox->-r dev-requirements.txt (line 1)) (2.0.1) +Requirement already satisfied: virtualenv>=20.21 in ./venv/lib/python3.10/site-packages (from tox->-r dev-requirements.txt (line 1)) (20.22.0) +Requirement already satisfied: mccabe<0.8.0,>=0.7.0 in ./venv/lib/python3.10/site-packages (from flake8->-r dev-requirements.txt (line 2)) (0.7.0) +Requirement already satisfied: pycodestyle<2.11.0,>=2.10.0 in ./venv/lib/python3.10/site-packages (from flake8->-r dev-requirements.txt (line 2)) (2.10.0) +Requirement already satisfied: pyflakes<3.1.0,>=3.0.0 in ./venv/lib/python3.10/site-packages (from flake8->-r dev-requirements.txt (line 2)) (3.0.1) +Requirement already satisfied: distlib<1,>=0.3.6 in ./venv/lib/python3.10/site-packages (from virtualenv>=20.21->tox->-r dev-requirements.txt (line 1)) (0.3.6) +Requirement already satisfied: tox in ./venv/lib/python3.10/site-packages (from -r dev-requirements.txt (line 1)) (4.4.12) +Requirement already satisfied: flake8 in ./venv/lib/python3.10/site-packages (from -r dev-requirements.txt (line 2)) (6.0.0) +Requirement already satisfied: cachetools>=5.3 in ./venv/lib/python3.10/site-packages (from tox->-r dev-requirements.txt (line 1)) (5.3.0) +Requirement already satisfied: chardet>=5.1 in ./venv/lib/python3.10/site-packages (from tox->-r dev-requirements.txt (line 1)) (5.1.0) +Requirement already satisfied: colorama>=0.4.6 in ./venv/lib/python3.10/site-packages (from tox->-r dev-requirements.txt (line 1)) (0.4.6) +Requirement already satisfied: filelock>=3.11 in ./venv/lib/python3.10/site-packages (from tox->-r dev-requirements.txt (line 1)) (3.12.0) +Requirement already satisfied: packaging>=23 in ./venv/lib/python3.10/site-packages (from tox->-r dev-requirements.txt (line 1)) (23.1) +Requirement already satisfied: platformdirs>=3.2 in ./venv/lib/python3.10/site-packages (from tox->-r dev-requirements.txt (line 1)) (3.2.0) +Requirement already satisfied: pluggy>=1 in ./venv/lib/python3.10/site-packages (from tox->-r dev-requirements.txt (line 1)) (1.0.0) +Requirement already satisfied: pyproject-api>=1.5.1 in ./venv/lib/python3.10/site-packages (from tox->-r dev-requirements.txt (line 1)) (1.5.1) +Requirement already satisfied: tomli>=2.0.1 in ./venv/lib/python3.10/site-packages (from tox->-r dev-requirements.txt (line 1)) (2.0.1) +Requirement already satisfied: virtualenv>=20.21 in ./venv/lib/python3.10/site-packages (from tox->-r dev-requirements.txt (line 1)) (20.22.0) +Requirement already satisfied: mccabe<0.8.0,>=0.7.0 in ./venv/lib/python3.10/site-packages (from flake8->-r dev-requirements.txt (line 2)) (0.7.0) +Requirement already satisfied: pycodestyle<2.11.0,>=2.10.0 in ./venv/lib/python3.10/site-packages (from flake8->-r dev-requirements.txt (line 2)) (2.10.0) +Requirement already satisfied: pyflakes<3.1.0,>=3.0.0 in ./venv/lib/python3.10/site-packages (from flake8->-r dev-requirements.txt (line 2)) (3.0.1) +Requirement already satisfied: distlib<1,>=0.3.6 in ./venv/lib/python3.10/site-packages (from virtualenv>=20.21->tox->-r dev-requirements.txt (line 1)) (0.3.6) diff --git a/samples/openapi3/client/petstore/python-nextgen/petstore_api.egg-info/PKG-INFO b/samples/openapi3/client/petstore/python-nextgen/petstore_api.egg-info/PKG-INFO new file mode 100644 index 000000000000..e196af9440dc --- /dev/null +++ b/samples/openapi3/client/petstore/python-nextgen/petstore_api.egg-info/PKG-INFO @@ -0,0 +1,13 @@ +Metadata-Version: 2.1 +Name: petstore-api +Version: 1.0.0 +Summary: OpenAPI Petstore +Home-page: +Author: OpenAPI Generator community +Author-email: team@openapitools.org +License: Apache-2.0 +Keywords: OpenAPI,OpenAPI-Generator,OpenAPI Petstore +Description-Content-Type: text/markdown + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \ # noqa: E501 + diff --git a/samples/openapi3/client/petstore/python-nextgen/petstore_api.egg-info/SOURCES.txt b/samples/openapi3/client/petstore/python-nextgen/petstore_api.egg-info/SOURCES.txt new file mode 100644 index 000000000000..9a144d3d954f --- /dev/null +++ b/samples/openapi3/client/petstore/python-nextgen/petstore_api.egg-info/SOURCES.txt @@ -0,0 +1,176 @@ +README.md +pyproject.toml +setup.cfg +setup.py +petstore_api/__init__.py +petstore_api/api_client.py +petstore_api/configuration.py +petstore_api/exceptions.py +petstore_api/rest.py +petstore_api/signing.py +petstore_api.egg-info/PKG-INFO +petstore_api.egg-info/SOURCES.txt +petstore_api.egg-info/dependency_links.txt +petstore_api.egg-info/requires.txt +petstore_api.egg-info/top_level.txt +petstore_api/api/__init__.py +petstore_api/api/another_fake_api.py +petstore_api/api/default_api.py +petstore_api/api/fake_api.py +petstore_api/api/fake_classname_tags123_api.py +petstore_api/api/fake_classname_tags_123_api.py +petstore_api/api/pet_api.py +petstore_api/api/store_api.py +petstore_api/api/user_api.py +petstore_api/models/__init__.py +petstore_api/models/additional_properties_class.py +petstore_api/models/all_of_with_single_ref.py +petstore_api/models/animal.py +petstore_api/models/any_of_color.py +petstore_api/models/any_of_pig.py +petstore_api/models/api_response.py +petstore_api/models/array_of_array_of_number_only.py +petstore_api/models/array_of_number_only.py +petstore_api/models/array_test.py +petstore_api/models/basque_pig.py +petstore_api/models/capitalization.py +petstore_api/models/cat.py +petstore_api/models/cat_all_of.py +petstore_api/models/category.py +petstore_api/models/circular_reference_model.py +petstore_api/models/class_model.py +petstore_api/models/client.py +petstore_api/models/color.py +petstore_api/models/danish_pig.py +petstore_api/models/deprecated_object.py +petstore_api/models/dog.py +petstore_api/models/dog_all_of.py +petstore_api/models/dummy_model.py +petstore_api/models/enum_arrays.py +petstore_api/models/enum_class.py +petstore_api/models/enum_test.py +petstore_api/models/file.py +petstore_api/models/file_schema_test_class.py +petstore_api/models/first_ref.py +petstore_api/models/foo.py +petstore_api/models/foo_get_default_response.py +petstore_api/models/format_test.py +petstore_api/models/has_only_read_only.py +petstore_api/models/health_check_result.py +petstore_api/models/inner_dict_with_property.py +petstore_api/models/list.py +petstore_api/models/map_test.py +petstore_api/models/mixed_properties_and_additional_properties_class.py +petstore_api/models/model200_response.py +petstore_api/models/model_return.py +petstore_api/models/name.py +petstore_api/models/nullable_class.py +petstore_api/models/number_only.py +petstore_api/models/object_with_deprecated_fields.py +petstore_api/models/order.py +petstore_api/models/outer_composite.py +petstore_api/models/outer_enum.py +petstore_api/models/outer_enum_default_value.py +petstore_api/models/outer_enum_integer.py +petstore_api/models/outer_enum_integer_default_value.py +petstore_api/models/outer_object_with_enum_property.py +petstore_api/models/parent.py +petstore_api/models/parent_with_optional_dict.py +petstore_api/models/pet.py +petstore_api/models/pig.py +petstore_api/models/read_only_first.py +petstore_api/models/second_ref.py +petstore_api/models/self_reference_model.py +petstore_api/models/single_ref_type.py +petstore_api/models/special_character_enum.py +petstore_api/models/special_model_name.py +petstore_api/models/special_name.py +petstore_api/models/tag.py +petstore_api/models/user.py +petstore_api/models/with_nested_one_of.py +test/test_additional_properties_class.py +test/test_all_of_with_single_ref.py +test/test_animal.py +test/test_another_fake_api.py +test/test_any_of_color.py +test/test_any_of_pig.py +test/test_api_response.py +test/test_array_of_array_of_number_only.py +test/test_array_of_number_only.py +test/test_array_test.py +test/test_basque_pig.py +test/test_capitalization.py +test/test_cat.py +test/test_cat_all_of.py +test/test_category.py +test/test_circular_reference_model.py +test/test_class_model.py +test/test_client.py +test/test_color.py +test/test_configuration.py +test/test_danish_pig.py +test/test_default_api.py +test/test_deprecated_object.py +test/test_dog.py +test/test_dog_all_of.py +test/test_dummy_model.py +test/test_enum_arrays.py +test/test_enum_class.py +test/test_enum_test.py +test/test_fake_api.py +test/test_fake_classname_tags123_api.py +test/test_fake_classname_tags_123_api.py +test/test_file.py +test/test_file_schema_test_class.py +test/test_first_ref.py +test/test_foo.py +test/test_foo_get_default_response.py +test/test_format_test.py +test/test_has_only_read_only.py +test/test_health_check_result.py +test/test_inner_dict_with_property.py +test/test_list.py +test/test_map_test.py +test/test_mixed_properties_and_additional_properties_class.py +test/test_model200_response.py +test/test_model_return.py +test/test_name.py +test/test_nullable_class.py +test/test_number_only.py +test/test_object_with_deprecated_fields.py +test/test_order.py +test/test_outer_composite.py +test/test_outer_enum.py +test/test_outer_enum_default_value.py +test/test_outer_enum_integer.py +test/test_outer_enum_integer_default_value.py +test/test_outer_object_with_enum_property.py +test/test_parent.py +test/test_parent_with_optional_dict.py +test/test_pet.py +test/test_pet_api.py +test/test_pig.py +test/test_read_only_first.py +test/test_second_ref.py +test/test_self_reference_model.py +test/test_single_ref_type.py +test/test_special_character_enum.py +test/test_special_model_name.py +test/test_special_name.py +test/test_store_api.py +test/test_tag.py +test/test_user.py +test/test_user_api.py +test/test_with_nested_one_of.py +tests/test_api_client.py +tests/test_api_exception.py +tests/test_api_validation.py +tests/test_configuration.py +tests/test_deserialization.py +tests/test_http_signature.py +tests/test_map_test.py +tests/test_model.py +tests/test_order_model.py +tests/test_pet_api.py +tests/test_pet_model.py +tests/test_store_api.py \ No newline at end of file diff --git a/samples/openapi3/client/petstore/python-nextgen/petstore_api.egg-info/dependency_links.txt b/samples/openapi3/client/petstore/python-nextgen/petstore_api.egg-info/dependency_links.txt new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/samples/openapi3/client/petstore/python-nextgen/petstore_api.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/samples/openapi3/client/petstore/python-nextgen/petstore_api.egg-info/requires.txt b/samples/openapi3/client/petstore/python-nextgen/petstore_api.egg-info/requires.txt new file mode 100644 index 000000000000..89b3b11d6a4d --- /dev/null +++ b/samples/openapi3/client/petstore/python-nextgen/petstore_api.egg-info/requires.txt @@ -0,0 +1,6 @@ +urllib3>=1.25.3 +python-dateutil +pem>=19.3.0 +pycryptodome>=3.9.0 +pydantic<2,>=1.10.5 +aenum diff --git a/samples/openapi3/client/petstore/python-nextgen/petstore_api.egg-info/top_level.txt b/samples/openapi3/client/petstore/python-nextgen/petstore_api.egg-info/top_level.txt new file mode 100644 index 000000000000..81e243dca697 --- /dev/null +++ b/samples/openapi3/client/petstore/python-nextgen/petstore_api.egg-info/top_level.txt @@ -0,0 +1 @@ +petstore_api diff --git a/samples/openapi3/client/petstore/python-prior/petstore_api/model/mammal.py b/samples/openapi3/client/petstore/python-prior/petstore_api/model/mammal.py new file mode 100644 index 000000000000..c5c62b7b8310 --- /dev/null +++ b/samples/openapi3/client/petstore/python-prior/petstore_api/model/mammal.py @@ -0,0 +1,349 @@ +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, + OpenApiModel +) +from petstore_api.exceptions import ApiAttributeError + + +def lazy_import(): + from petstore_api.model.pig import Pig + from petstore_api.model.whale import Whale + from petstore_api.model.zebra import Zebra + globals()['Pig'] = Pig + globals()['Whale'] = Whale + globals()['Zebra'] = Zebra + + +class Mammal(ModelComposed): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + ('type',): { + 'PLAINS': "plains", + 'MOUNTAIN': "mountain", + 'GREVYS': "grevys", + }, + } + + validations = { + } + + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + 'class_name': (str,), # noqa: E501 + 'has_baleen': (bool,), # noqa: E501 + 'has_teeth': (bool,), # noqa: E501 + 'type': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + lazy_import() + val = { + 'whale': Whale, + 'zebra': Zebra, + 'Pig': Pig, + } + if not val: + return None + return {'class_name': val} + + attribute_map = { + 'class_name': 'className', # noqa: E501 + 'has_baleen': 'hasBaleen', # noqa: E501 + 'has_teeth': 'hasTeeth', # noqa: E501 + 'type': 'type', # noqa: E501 + } + + read_only_vars = { + } + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """Mammal - a model defined in OpenAPI + + Keyword Args: + class_name (str): + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + has_baleen (bool): [optional] # noqa: E501 + has_teeth (bool): [optional] # noqa: E501 + type (str): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + for arg in args: + if isinstance(arg, dict): + kwargs.update(arg) + else: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_spec_property_naming': _spec_property_naming, + '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, + } + composed_info = validate_get_composed_info( + constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + for var_name, var_value in kwargs.items(): + if var_name in discarded_args and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self._additional_properties_model_instances: + # discard variable. + continue + setattr(self, var_name, var_value) + + return self + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """Mammal - a model defined in OpenAPI + + Keyword Args: + class_name (str): + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + has_baleen (bool): [optional] # noqa: E501 + has_teeth (bool): [optional] # noqa: E501 + type (str): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + for arg in args: + if isinstance(arg, dict): + kwargs.update(arg) + else: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_spec_property_naming': _spec_property_naming, + '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, + } + composed_info = validate_get_composed_info( + constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + for var_name, var_value in kwargs.items(): + if var_name in discarded_args and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self._additional_properties_model_instances: + # discard variable. + continue + setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") + + @cached_property + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error 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 + lazy_import() + return { + 'anyOf': [ + ], + 'allOf': [ + ], + 'oneOf': [ + Pig, + Whale, + Zebra, + ], + } diff --git a/samples/openapi3/server/petstore/spring-boot-oneof/src/main/java/org/openapitools/model/Fruit.java b/samples/openapi3/server/petstore/spring-boot-oneof/src/main/java/org/openapitools/model/Fruit.java index bd1beceb21b8..a5fd792bd0c8 100644 --- a/samples/openapi3/server/petstore/spring-boot-oneof/src/main/java/org/openapitools/model/Fruit.java +++ b/samples/openapi3/server/petstore/spring-boot-oneof/src/main/java/org/openapitools/model/Fruit.java @@ -29,8 +29,8 @@ @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "fruitType", visible = true) @JsonSubTypes({ @JsonSubTypes.Type(value = Apple.class, name = "APPLE"), - @JsonSubTypes.Type(value = Apple.class, name = "Apple"), @JsonSubTypes.Type(value = Banana.class, name = "BANANA"), + @JsonSubTypes.Type(value = Apple.class, name = "Apple"), @JsonSubTypes.Type(value = Banana.class, name = "Banana") })