diff --git a/crd-generator/api/src/main/java/io/fabric8/crd/generator/AbstractJsonSchema.java b/crd-generator/api/src/main/java/io/fabric8/crd/generator/AbstractJsonSchema.java index 92a61ec8d36..8a00b7db6d0 100644 --- a/crd-generator/api/src/main/java/io/fabric8/crd/generator/AbstractJsonSchema.java +++ b/crd-generator/api/src/main/java/io/fabric8/crd/generator/AbstractJsonSchema.java @@ -325,7 +325,7 @@ private T internalFromImpl(TypeDef definition, Set visited, List spec = specSchema.getProperties(); - assertEquals(2, spec.size()); + assertEquals(3, spec.size()); // check typed SchemaFrom JSONSchemaProps foo = spec.get("foo"); @@ -222,6 +222,13 @@ void shouldExtractPropertiesSchemaFromExtractValueAnnotation() { // you can exclude fields assertNull(barProps.get("baz")); + + // verify that x-kubernetes-preserve-unknown-fields isn't on parent object when + // nested object is annotated with @PreserveUnknownFields + JSONSchemaProps qux = spec.get("qux"); + Map quxProps = qux.getProperties(); + assertTrue(quxProps.get("foo").getXKubernetesPreserveUnknownFields()); + assertNull(qux.getXKubernetesPreserveUnknownFields()); } @Test