diff --git a/kubernetes-model-generator/openapi/maven-plugin/src/main/java/io/fabric8/kubernetes/schema/generator/GeneratorSettings.java b/kubernetes-model-generator/openapi/maven-plugin/src/main/java/io/fabric8/kubernetes/schema/generator/GeneratorSettings.java index 151a7daffc4..8db2311aab8 100644 --- a/kubernetes-model-generator/openapi/maven-plugin/src/main/java/io/fabric8/kubernetes/schema/generator/GeneratorSettings.java +++ b/kubernetes-model-generator/openapi/maven-plugin/src/main/java/io/fabric8/kubernetes/schema/generator/GeneratorSettings.java @@ -185,7 +185,9 @@ private static Map computeApiVersions(OpenAPI openAPI) { for (Operation operation : new Operation[] { apiPath.getValue().getGet(), apiPath.getValue().getPost() }) { if (operation == null || operation.getResponses().get("200") == null - || operation.getResponses().get("200").getContent().get(APPLICATION_JSON) == null) { + || operation.getResponses().get("200").getContent().get(APPLICATION_JSON) == null + || operation.getExtensions() == null + || operation.getExtensions().get("x-kubernetes-group-version-kind") == null) { continue; } final ApiVersion.ApiVersionBuilder apiVersionBuilder = ApiVersion.builder(); @@ -196,9 +198,6 @@ private static Map computeApiVersions(OpenAPI openAPI) { // } else { // apiVersionBuilder.group("").version("v1"); // } - if (operation.getExtensions() == null || operation.getExtensions().get("x-kubernetes-group-version-kind") == null) { - continue; - } final Map groupVersionKind = (Map) operation.getExtensions() .get("x-kubernetes-group-version-kind"); apiVersionBuilder.group(groupVersionKind.get("group")); diff --git a/kubernetes-model-generator/openapi/maven-plugin/src/main/java/io/fabric8/kubernetes/schema/generator/model/ModelGenerator.java b/kubernetes-model-generator/openapi/maven-plugin/src/main/java/io/fabric8/kubernetes/schema/generator/model/ModelGenerator.java index f55a4d1a602..cbc662f19ba 100644 --- a/kubernetes-model-generator/openapi/maven-plugin/src/main/java/io/fabric8/kubernetes/schema/generator/model/ModelGenerator.java +++ b/kubernetes-model-generator/openapi/maven-plugin/src/main/java/io/fabric8/kubernetes/schema/generator/model/ModelGenerator.java @@ -266,7 +266,7 @@ private String resolveImplementedInterfaces(TemplateContext templateContext) { private Map> buildableReferences(TemplateContext templateContext, List> fields) { final List references = new ArrayList<>(settings.getBuildableReferences()); references.add(0, settings.getObjectMetaClass()); - if (fields.stream().map(f -> f.get("type")).map(Object::toString) + if (fields.stream().map(f -> f.get("type")).filter(Objects::nonNull).map(Object::toString) .anyMatch(r -> r.contains("KubernetesResource") || r.contains("HasMetadata") || r.contains("RawExtension"))) { references.add(settings.getGenericKubernetesResourceClass()); references.add(settings.getRawExtensionClass());