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 5f77ee775bb..b1463c32b2c 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 @@ -416,20 +416,7 @@ private T internalFromImpl(String name, TypeRef typeRef, Set visited) { .toArray(JsonNode[]::new); return enumProperty(enumValues); } else { - if (!resolving) { - visited.clear(); - resolving = true; - } else { - String visitedName = name + ":" + classRef; - if (!def.getFullyQualifiedName().startsWith("java") && visited.contains(visitedName)) { - throw new IllegalArgumentException("Found a cyclic reference involving the field " + name + " of type " + classRef.getFullyQualifiedName()); - } - visited.add(visitedName); - } - - T res = internalFromImpl(def, visited); - resolving = false; - return res; + return resolveNestedClass(name, def, visited); } } @@ -441,6 +428,23 @@ private T internalFromImpl(String name, TypeRef typeRef, Set visited) { // Flag to detect cycles private boolean resolving = false; + private T resolveNestedClass(String name, TypeDef def, Set visited) { + if (!resolving) { + visited.clear(); + resolving = true; + } else { + String visitedName = name + ":" + def.getFullyQualifiedName(); + if (!def.getFullyQualifiedName().startsWith("java") && visited.contains(visitedName)) { + throw new IllegalArgumentException("Found a cyclic reference involving the field " + name + " of type " + def.getFullyQualifiedName()); + } + visited.add(visitedName); + } + + T res = internalFromImpl(def, visited); + resolving = false; + return res; + } + /** * Builds the schema for specifically handled property types (e.g. intOrString properties) *