From ddbffe9b0edc94090b76d1cc734083558facb652 Mon Sep 17 00:00:00 2001 From: Dusan Jakub Date: Wed, 12 Oct 2022 13:08:56 +0200 Subject: [PATCH] fix: Schema for multimaps is wrong Upgraded sundrio and added a test to validate that multimaps (like `class MultiMap implements Map>`) are generated correctly. Fixes fabric8io/kubernetes-client#4487 --- CHANGELOG.md | 1 + .../crd/generator/CRDGeneratorTest.java | 22 ++++++++----------- pom.xml | 2 +- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de05e3a092a..a3e122f3752 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * Fix #4369: Informers will retry with a backoff on list/watch failure as they did in 5.12 and prior. * Fix #4350: SchemaSwap annotation is now repeatable and is applied multiple times if classes are used more than once in the class hierarchy. * Fix #4413: Stack overflow on multi maps (and other non-trivial generic classes) +* Fix #4487: Schema for multi maps is now generated correctly * Fix #3733: The authentication command from the .kube/config won't be discarded if no arguments are specified * Fix #4441: corrected patch base handling for the patch methods available from a Resource - resource(item).patch() will be evaluated as resource(latest).patch(item). Also undeprecated patch(item), which is consistent with leaving patch(context, item) undeprecated as well. For consistency with the other operations (such as edit), patch(item) will use the context item as the base when available, or the server side item when not. This means that patch(item) is only the same as resource(item).patch() when the patch(item) is called when the context item is missing or is the same as the latest. * Fix #4442: TokenRefreshInterceptor doesn't overwrite existing OAuth token with empty string diff --git a/crd-generator/api/src/test/java/io/fabric8/crd/generator/CRDGeneratorTest.java b/crd-generator/api/src/test/java/io/fabric8/crd/generator/CRDGeneratorTest.java index 47868cd3a55..ce2ba9b0185 100644 --- a/crd-generator/api/src/test/java/io/fabric8/crd/generator/CRDGeneratorTest.java +++ b/crd-generator/api/src/test/java/io/fabric8/crd/generator/CRDGeneratorTest.java @@ -277,29 +277,25 @@ void mapPropertyShouldHaveCorrectValueType() { assertEquals(3, specProps.size()); - checkMapProp(specProps, "test", "array"); - String arrayType = specProps.get("test").getAdditionalProperties().getSchema().getItems().getSchema().getType(); - assertEquals("string", arrayType); + JSONSchemaProps testSchema = checkMapProp(specProps, "test", "array"); + assertEquals("string", testSchema.getItems().getSchema().getType()); - checkMapProp(specProps, "test2", "object"); - JSONSchemaProps valueSchema = specProps.get("test2").getAdditionalProperties().getSchema().getAdditionalProperties().getSchema(); + JSONSchemaProps test2Schema = checkMapProp(specProps, "test2", "object"); + JSONSchemaProps valueSchema = test2Schema.getAdditionalProperties().getSchema(); String valueType = valueSchema.getType(); assertEquals("array", valueType); - - // this check is currently failing, because multimaps are incorrectly processed as if they were normal maps - // (class MultiMap implements Map> is treated like just Map) - // checkMapProp(specProps, "test3", "object"); - final JSONSchemaProps props = specProps.get("test3"); - assertEquals("object", props.getType()); - assertEquals("boolean", valueSchema.getItems().getSchema().getType()); + + JSONSchemaProps test3Schema = checkMapProp(specProps, "test", "array"); + assertEquals("string", test3Schema.getItems().getSchema().getType()); }); } - private void checkMapProp(Map specProps, String name, String valueType) { + private JSONSchemaProps checkMapProp(Map specProps, String name, String valueType) { final JSONSchemaProps props = specProps.get(name); assertEquals("object", props.getType()); assertEquals(valueType, props.getAdditionalProperties().getSchema().getType()); + return props.getAdditionalProperties().getSchema(); } @Test diff --git a/pom.xml b/pom.xml index 8dc86621eb2..1e300bd6ab2 100644 --- a/pom.xml +++ b/pom.xml @@ -80,7 +80,7 @@ UTF-8 - 0.94-bugfix-multi-maps3-SNAPSHOT + 0.93-SNAPSHOT 3.12.12 3.12.1_1 1.15.0