diff --git a/kubernetes-model-generator/openapi/maven-plugin/pom.xml b/kubernetes-model-generator/openapi/maven-plugin/pom.xml
index 39941b7f2e3..14dc4ede69b 100644
--- a/kubernetes-model-generator/openapi/maven-plugin/pom.xml
+++ b/kubernetes-model-generator/openapi/maven-plugin/pom.xml
@@ -32,9 +32,6 @@
maven-plugin
-
-
-
true
diff --git a/kubernetes-model-generator/openapi/maven-plugin/src/main/java/io/fabric8/kubernetes/schema/generator/schema/CrdParser.java b/kubernetes-model-generator/openapi/maven-plugin/src/main/java/io/fabric8/kubernetes/schema/generator/schema/CrdParser.java
index 00214c155b0..ebb52358040 100644
--- a/kubernetes-model-generator/openapi/maven-plugin/src/main/java/io/fabric8/kubernetes/schema/generator/schema/CrdParser.java
+++ b/kubernetes-model-generator/openapi/maven-plugin/src/main/java/io/fabric8/kubernetes/schema/generator/schema/CrdParser.java
@@ -106,6 +106,9 @@ public static OpenAPI crdToOpenApi(URI crdUri) throws IOException {
}
}
final File tempOpenApi = Files.createTempFile("openapi", ".json").toFile();
+ assert tempOpenApi.setReadable(true, true);
+ assert tempOpenApi.setWritable(true, true);
+ assert tempOpenApi.setExecutable(true, true);
tempOpenApi.deleteOnExit();
// Writing to a file and parsing it fixes any issue with the computed OpenAPI values, this step is necessary
Json31.pretty().writeValue(tempOpenApi, openAPI);
diff --git a/kubernetes-model-generator/openapi/maven-plugin/src/test/java/io/fabric8/kubernetes/schema/generator/schema/CrdParserTest.java b/kubernetes-model-generator/openapi/maven-plugin/src/test/java/io/fabric8/kubernetes/schema/generator/schema/CrdParserTest.java
new file mode 100644
index 00000000000..4ee5cbff1b2
--- /dev/null
+++ b/kubernetes-model-generator/openapi/maven-plugin/src/test/java/io/fabric8/kubernetes/schema/generator/schema/CrdParserTest.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2015 Red Hat, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.fabric8.kubernetes.schema.generator.schema;
+
+import io.swagger.v3.oas.models.OpenAPI;
+import io.swagger.v3.oas.models.media.Schema;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Nested;
+import org.junit.jupiter.api.Test;
+
+import java.net.URI;
+import java.util.Objects;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+class CrdParserTest {
+
+ @Nested
+ class SingleDocument {
+
+ private OpenAPI singleDocument;
+
+ @BeforeEach
+ void parse() throws Exception {
+ final URI uri = Objects.requireNonNull(CrdParserTest.class.getResource("/crd-parser/single-document.yaml"))
+ .toURI();
+ singleDocument = CrdParser.crdToOpenApi(uri);
+ }
+
+ @Test
+ void parsesSingleDocument() {
+ assertNotNull(singleDocument);
+ // 1 list and 1 resource
+ assertEquals(2, singleDocument.getComponents().getSchemas().size());
+ }
+
+ @Test
+ void createsResourceNamespacedPath() {
+ assertNotNull(singleDocument.getPaths().get("/apis/example.com/v1/namespaces/{namespace}/resources/{name}"));
+ }
+
+ @Test
+ void createsResourceNamespacedListPath() {
+ assertNotNull(singleDocument.getPaths().get("/apis/example.com/v1/namespaces/{namespace}/resources"));
+ }
+
+ @Test
+ void createsResourceComponent() {
+ assertNotNull(singleDocument.getComponents().getSchemas().get("com.example.resources.v1.Resource"));
+ }
+
+ @Test
+ void createsListComponent() {
+ assertNotNull(singleDocument.getComponents().getSchemas().get("com.example.resources.v1.ResourceList"));
+ }
+
+ @Test
+ void setsReferenceToObjectMeta() {
+ assertEquals("#/components/schemas/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta",
+ ((Schema>) singleDocument.getComponents().getSchemas().get("com.example.resources.v1.Resource")
+ .getProperties().get("metadata")).get$ref());
+ }
+
+ }
+
+ @Nested
+ class MultipleDocuments {
+
+ private OpenAPI multipleDocuments;
+
+ @BeforeEach
+ void parse() throws Exception {
+ final URI uri = Objects.requireNonNull(CrdParserTest.class.getResource("/crd-parser/multiple-documents.yaml"))
+ .toURI();
+ multipleDocuments = CrdParser.crdToOpenApi(uri);
+ }
+
+ @Test
+ void parsesMultipleDocuments() {
+ assertNotNull(multipleDocuments);
+ // 1 list and 1 resource
+ assertEquals(4, multipleDocuments.getComponents().getSchemas().size());
+ }
+
+ @Test
+ void createsResourceNamespacedPaths() {
+ assertNotNull(multipleDocuments.getPaths().get("/apis/example.com/v1/namespaces/{namespace}/resources/{name}"));
+ assertNotNull(multipleDocuments.getPaths().get("/apis/example.com/v1/additional-resources/{name}"));
+ }
+
+ @Test
+ void createsResourceNamespacedListPaths() {
+ assertNotNull(multipleDocuments.getPaths().get("/apis/example.com/v1/namespaces/{namespace}/resources"));
+ assertNotNull(multipleDocuments.getPaths().get("/apis/example.com/v1/additional-resources"));
+ }
+
+ @Test
+ void createsResourceComponents() {
+ assertNotNull(multipleDocuments.getComponents().getSchemas().get("com.example.resources.v1.Resource"));
+ assertNotNull(
+ multipleDocuments.getComponents().getSchemas().get("com.example.additional-resources.v1.AdditionalResource"));
+ }
+
+ @Test
+ void createsListComponents() {
+ assertNotNull(multipleDocuments.getComponents().getSchemas().get("com.example.resources.v1.ResourceList"));
+ assertNotNull(
+ multipleDocuments.getComponents().getSchemas().get("com.example.additional-resources.v1.AdditionalResourceList"));
+ }
+ }
+}
diff --git a/kubernetes-model-generator/openapi/maven-plugin/src/test/resources/crd-parser/multiple-documents.yaml b/kubernetes-model-generator/openapi/maven-plugin/src/test/resources/crd-parser/multiple-documents.yaml
new file mode 100644
index 00000000000..5d442ff87ee
--- /dev/null
+++ b/kubernetes-model-generator/openapi/maven-plugin/src/test/resources/crd-parser/multiple-documents.yaml
@@ -0,0 +1,58 @@
+#
+# Copyright (C) 2015 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+---
+apiVersion: apiextensions.k8s.io/v1
+kind: CustomResourceDefinition
+metadata:
+ name: resources.example.com
+spec:
+ group: example.com
+ names:
+ kind: Resource
+ plural: resources
+ singular: resource
+ scope: Namespaced
+ versions:
+ - name: v1
+ served: true
+ storage: true
+ schema:
+ openAPIV3Schema:
+ properties:
+ metadata:
+ type: object
+---
+apiVersion: apiextensions.k8s.io/v1
+kind: CustomResourceDefinition
+metadata:
+ name: additional-resources.example.com
+spec:
+ group: example.com
+ names:
+ kind: AdditionalResource
+ plural: additional-resources
+ singular: additional-resource
+ scope: Cluster
+ versions:
+ - name: v1
+ served: true
+ storage: true
+ schema:
+ openAPIV3Schema:
+ properties:
+ metadata:
+ type: object
diff --git a/kubernetes-model-generator/openapi/maven-plugin/src/test/resources/crd-parser/single-document.yaml b/kubernetes-model-generator/openapi/maven-plugin/src/test/resources/crd-parser/single-document.yaml
new file mode 100644
index 00000000000..c9c046297e4
--- /dev/null
+++ b/kubernetes-model-generator/openapi/maven-plugin/src/test/resources/crd-parser/single-document.yaml
@@ -0,0 +1,36 @@
+#
+# Copyright (C) 2015 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+apiVersion: apiextensions.k8s.io/v1
+kind: CustomResourceDefinition
+metadata:
+ name: resources.example.com
+spec:
+ group: example.com
+ names:
+ kind: Resource
+ plural: resources
+ singular: resource
+ scope: Namespaced
+ versions:
+ - name: v1
+ served: true
+ storage: true
+ schema:
+ openAPIV3Schema:
+ properties:
+ metadata:
+ type: object
diff --git a/kubernetes-model-generator/openshift-model-autoscaling/pom.xml b/kubernetes-model-generator/openshift-model-autoscaling/pom.xml
index b1c40176719..d4ac516c797 100644
--- a/kubernetes-model-generator/openshift-model-autoscaling/pom.xml
+++ b/kubernetes-model-generator/openshift-model-autoscaling/pom.xml
@@ -55,12 +55,13 @@
openapi-model-generator-maven-plugin
-
- ${openapi.schema.openshift-latest}
-
+
+ https://raw.githubusercontent.com/openshift/cluster-autoscaler-operator/refs/heads/release-${openapi.openshift-version}/install/01_clusterautoscaler.crd.yaml
+ https://raw.githubusercontent.com/openshift/cluster-autoscaler-operator/refs/heads/release-${openapi.openshift-version}/install/02_machineautoscaler.crd.yaml
+
- io.fabric8.kubernetes.api.model
- io.fabric8.openshift.api.model.autoscaling
+ io.fabric8.openshift.api.model.autoscaling
+ io.fabric8.openshift.api.model.autoscaling
^io\.openshift\.autoscaling\..*$
diff --git a/kubernetes-model-generator/pom.xml b/kubernetes-model-generator/pom.xml
index 738fa435957..f116f2610b5 100644
--- a/kubernetes-model-generator/pom.xml
+++ b/kubernetes-model-generator/pom.xml
@@ -82,6 +82,7 @@
${project.parent.basedir}/openapi/schemas/openshift-4.17.0.json
${project.parent.basedir}/openapi/schemas/openshift-generated.json
+ 4.17
osgi.extender;
filter:="(osgi.extender=osgi.serviceloader.registrar)"