From 9d4c7c9f3daff343d03fe865e10c476ad1cf27e5 Mon Sep 17 00:00:00 2001 From: Malte Brunnlieb Date: Mon, 14 Sep 2020 17:09:35 +0200 Subject: [PATCH 1/4] #1235 Set next development version --- .../cobigen-openapiplugin-model/pom.xml | 2 +- .../cobigen-openapiplugin-parent/cobigen-openapiplugin/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cobigen/cobigen-openapiplugin-parent/cobigen-openapiplugin-model/pom.xml b/cobigen/cobigen-openapiplugin-parent/cobigen-openapiplugin-model/pom.xml index cf08999cd2..d271e323d0 100644 --- a/cobigen/cobigen-openapiplugin-parent/cobigen-openapiplugin-model/pom.xml +++ b/cobigen/cobigen-openapiplugin-parent/cobigen-openapiplugin-model/pom.xml @@ -1,7 +1,7 @@ 4.0.0 openapiplugin-model - 7.0.0 + 7.1.0-SNAPSHOT CobiGen Openapiplugin Model jar CobiGen - OpenAPI Plug-in Model diff --git a/cobigen/cobigen-openapiplugin-parent/cobigen-openapiplugin/pom.xml b/cobigen/cobigen-openapiplugin-parent/cobigen-openapiplugin/pom.xml index 688ed34951..1c75dd689a 100644 --- a/cobigen/cobigen-openapiplugin-parent/cobigen-openapiplugin/pom.xml +++ b/cobigen/cobigen-openapiplugin-parent/cobigen-openapiplugin/pom.xml @@ -2,7 +2,7 @@ 4.0.0 openapiplugin CobiGen - Open API Plug-in - 7.0.0 + 7.1.0-SNAPSHOT jar CobiGen - OpenAPI Plug-in From 3e03a1fd16210dc3fd7a0ae2bf979301233c0729 Mon Sep 17 00:00:00 2001 From: jan-vcapgemini <59438728+jan-vcapgemini@users.noreply.github.com> Date: Thu, 29 Oct 2020 11:00:06 +0100 Subject: [PATCH 2/4] #1244 fixed openapiplugin not being able to handle nullable enums (#1258) added testNullableEnum unit test --- .../inputreader/OpenAPIInputReader.java | 6 +++- .../inputreader/OpenAPIInputReaderTest.java | 33 +++++++++++++++++ .../OpenAPIInputReaderTest/nullableEnum.yaml | 36 +++++++++++++++++++ 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 cobigen/cobigen-openapiplugin-parent/cobigen-openapiplugin/src/test/resources/testdata/unittest/OpenAPIInputReaderTest/nullableEnum.yaml diff --git a/cobigen/cobigen-openapiplugin-parent/cobigen-openapiplugin/src/main/java/com/devonfw/cobigen/openapiplugin/inputreader/OpenAPIInputReader.java b/cobigen/cobigen-openapiplugin-parent/cobigen-openapiplugin/src/main/java/com/devonfw/cobigen/openapiplugin/inputreader/OpenAPIInputReader.java index c9f3922f21..ce29c8a2e8 100644 --- a/cobigen/cobigen-openapiplugin-parent/cobigen-openapiplugin/src/main/java/com/devonfw/cobigen/openapiplugin/inputreader/OpenAPIInputReader.java +++ b/cobigen/cobigen-openapiplugin-parent/cobigen-openapiplugin/src/main/java/com/devonfw/cobigen/openapiplugin/inputreader/OpenAPIInputReader.java @@ -401,7 +401,11 @@ private List extractProperties(OpenApi3 openApi, String componentNa List enumElements = new ArrayList<>(); for (Object element : enums) { - enumElements.add(element.toString()); + if (element != null) { + enumElements.add(element.toString()); + } else { + enumElements.add("null"); + } } propModel.setEnumElements(enumElements); } diff --git a/cobigen/cobigen-openapiplugin-parent/cobigen-openapiplugin/src/test/java/com/devonfw/cobigen/openapiplugin/unittest/inputreader/OpenAPIInputReaderTest.java b/cobigen/cobigen-openapiplugin-parent/cobigen-openapiplugin/src/test/java/com/devonfw/cobigen/openapiplugin/unittest/inputreader/OpenAPIInputReaderTest.java index e6bd24c18c..532a21e8d2 100644 --- a/cobigen/cobigen-openapiplugin-parent/cobigen-openapiplugin/src/test/java/com/devonfw/cobigen/openapiplugin/unittest/inputreader/OpenAPIInputReaderTest.java +++ b/cobigen/cobigen-openapiplugin-parent/cobigen-openapiplugin/src/test/java/com/devonfw/cobigen/openapiplugin/unittest/inputreader/OpenAPIInputReaderTest.java @@ -279,6 +279,29 @@ public void testInvalidPath() throws Exception { List inputObjects = getInputs("invalidPath.yaml"); } + /** + * Tests if the input reader can handle nullable enums. See: + * https://github.com/devonfw/cobigen/issues/1244 + * + * @throws Exception + */ + @Test + public void testNullableEnum() throws Exception { + List inputObjects = getInputs("nullableEnum.yaml"); + + for (Object o : inputObjects) { + if (isEntityDef(o)) { + EntityDef entity = (EntityDef) o; + List properties = entity.getProperties(); + for (PropertyDef p : properties) { + List enums = p.getEnumElements(); + assertThat(enums.get(0)).isEqualTo("enum1"); + assertThat(enums.get(1)).isEqualTo("null"); + } + } + } + } + @Test(expected = InvalidConfigurationException.class) public void testInvalidXComponent() throws Exception { List inputObjects = getInputs("invalidXComponent.yaml"); @@ -414,4 +437,14 @@ private boolean isComponentDef(Object o) { return o.getClass() == ComponentDef.class; } + /** + * Checks whether the object is an {@link EntityDef} + * @param o + * object to check whether it is an EntityDef + * @return true if it is an EntityDef + */ + private boolean isPropertyDef(Object o) { + return o.getClass() == PropertyDef.class; + } + } diff --git a/cobigen/cobigen-openapiplugin-parent/cobigen-openapiplugin/src/test/resources/testdata/unittest/OpenAPIInputReaderTest/nullableEnum.yaml b/cobigen/cobigen-openapiplugin-parent/cobigen-openapiplugin/src/test/resources/testdata/unittest/OpenAPIInputReaderTest/nullableEnum.yaml new file mode 100644 index 0000000000..2df91b9b91 --- /dev/null +++ b/cobigen/cobigen-openapiplugin-parent/cobigen-openapiplugin/src/test/resources/testdata/unittest/OpenAPIInputReaderTest/nullableEnum.yaml @@ -0,0 +1,36 @@ +openapi: 3.0.0 +servers: + - url: 'https://localhost:8081/server/services/rest' +info: + title: Devon Example + description: Example of a API definition + version: 1.0.0 +paths: + /tablemanagement/v1/table/{id}: + get: + operationId: findTable + parameters: + - name: id + in: path + required: true + schema: + type: integer + format: int64 + minimum: 0 + maximum: 50 + responses: + '200': + description: Any +components: + schemas: + Table: + x-component: tablemanagament + description: Entity definiton of Table + type: object + properties: + myenum: + type: string + nullable: true + enum: + - enum1 + - null \ No newline at end of file From 8d249dcff846ea26eb1ca3702837a2ca49012f44 Mon Sep 17 00:00:00 2001 From: MikeSchumacher Date: Fri, 4 Dec 2020 10:50:49 +0100 Subject: [PATCH 3/4] #1285 update wiki docs --- documentation/master-cobigen.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/master-cobigen.asciidoc b/documentation/master-cobigen.asciidoc index 2a9cbd616b..16076feaee 100644 --- a/documentation/master-cobigen.asciidoc +++ b/documentation/master-cobigen.asciidoc @@ -25,7 +25,7 @@ DISCLAIMER: All Cobigen plugins are compatible with the latest release of Devonf * CobiGen - Text Merger v2.1.0 * CobiGen - JSON Plug-in v2.1.0 * CobiGen - HTML Plug-in v2.1.0 -* CobiGen - Open API Plug-in v7.0.0 +* CobiGen - Open API Plug-in v7.1.0 * CobiGen - FreeMaker Template Engine v2.1.0 * CobiGen - Velocity Template Engine v2.0.1 From 7d789c689f0dd1bf6e223d8496ab61a33563f0e6 Mon Sep 17 00:00:00 2001 From: MikeSchumacher Date: Fri, 4 Dec 2020 10:50:52 +0100 Subject: [PATCH 4/4] #1285 Set release version --- .../cobigen-openapiplugin-model/pom.xml | 2 +- .../cobigen-openapiplugin-parent/cobigen-openapiplugin/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cobigen/cobigen-openapiplugin-parent/cobigen-openapiplugin-model/pom.xml b/cobigen/cobigen-openapiplugin-parent/cobigen-openapiplugin-model/pom.xml index d271e323d0..e4a2d20ed3 100644 --- a/cobigen/cobigen-openapiplugin-parent/cobigen-openapiplugin-model/pom.xml +++ b/cobigen/cobigen-openapiplugin-parent/cobigen-openapiplugin-model/pom.xml @@ -1,7 +1,7 @@ 4.0.0 openapiplugin-model - 7.1.0-SNAPSHOT + 7.1.0 CobiGen Openapiplugin Model jar CobiGen - OpenAPI Plug-in Model diff --git a/cobigen/cobigen-openapiplugin-parent/cobigen-openapiplugin/pom.xml b/cobigen/cobigen-openapiplugin-parent/cobigen-openapiplugin/pom.xml index 1c75dd689a..33c6289569 100644 --- a/cobigen/cobigen-openapiplugin-parent/cobigen-openapiplugin/pom.xml +++ b/cobigen/cobigen-openapiplugin-parent/cobigen-openapiplugin/pom.xml @@ -2,7 +2,7 @@ 4.0.0 openapiplugin CobiGen - Open API Plug-in - 7.1.0-SNAPSHOT + 7.1.0 jar CobiGen - OpenAPI Plug-in