Skip to content

Commit

Permalink
feat: OpenAPI-based generator and Maven Plugin
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Nuri <[email protected]>
  • Loading branch information
manusa committed Jul 16, 2024
1 parent d73b220 commit 1a2a9a8
Show file tree
Hide file tree
Showing 46 changed files with 402,016 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ clean: clean-java
.PHONY: generate-openapi
generate-openapi:
cd kubernetes-model-generator/openapi/generator && go build
cd kubernetes-model-generator/openapi/generator && ./generator
./kubernetes-model-generator/openapi/generator/generator ./kubernetes-model-generator/openapi/schemas

# Legacy generation of the model: TODO: remove
.PHONY: generate-model
generate-model:
cd kubernetes-model-generator && ./generateModel.sh
Expand Down
110 changes: 110 additions & 0 deletions kubernetes-model-generator/openapi/maven-plugin/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model-generator</artifactId>
<version>7.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<artifactId>openapi-model-generator-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>

<properties>
<maven.compiler.release>11</maven.compiler.release>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.deploy.skip>true</maven.deploy.skip><!-- Keep module private -->
</properties>

<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.samskivert</groupId>
<artifactId>jmustache</artifactId>
<version>1.15</version>
</dependency>
<dependency>
<groupId>io.swagger.parser.v3</groupId>
<artifactId>swagger-parser</artifactId>
<version>2.1.22</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<configuration>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<cloneClean>true</cloneClean>
<settingsFile>src/it/settings.xml</settingsFile>
<postBuildHookScript>verify</postBuildHookScript>
<addTestClassPath>true</addTestClassPath>
<skipInvocation>${skipTests}</skipInvocation>
<streamLogs>true</streamLogs>
<invokerPropertiesFile>invoker.properties</invokerPropertiesFile>
<scriptVariables>
<version>${project.version}</version>
<artifactId>${project.artifactId}</artifactId>
<groupId>${project.groupId}</groupId>
</scriptVariables>
</configuration>
<executions>
<execution>
<id>integration-tests</id>
<goals>
<goal>install</goal>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@

package io.fabric8.kubernetes.api.model;

import java.util.LinkedHashMap;
import java.util.Map;
import javax.annotation.Generated;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.fabric8.kubernetes.api.builder.Editable;
import io.fabric8.kubernetes.model.annotation.Group;
import io.fabric8.kubernetes.model.annotation.Version;
import io.sundr.builder.annotations.Buildable;
import io.sundr.transform.annotations.TemplateTransformation;
import io.sundr.transform.annotations.TemplateTransformations;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;

@JsonDeserialize(using = com.fasterxml.jackson.databind.JsonDeserializer.None.class)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"apiVersion",
"kind",
"metadata",
"spec",
"status"
})
@ToString
@EqualsAndHashCode
@Accessors(prefix = {
"_",
""
})
@Buildable(editableEnabled = false, validationEnabled = false, generateBuilderPackage = false, lazyCollectionInitEnabled = false, builderPackage = "io.fabric8.kubernetes.api.builder")
@TemplateTransformations({
@TemplateTransformation(value = "/manifest.vm", outputPath = "META-INF/services/io.fabric8.kubernetes.api.model.KubernetesResource", gather = true)
})
@Version("v1")
@Group("")
@Generated("jsonschema2pojo")
public class Pod implements Editable<PodBuilder> , HasMetadata, Namespaced
{

/**
*
* (Required)
*
*/
@JsonProperty("apiVersion")
private String apiVersion = "v1";
/**
*
* (Required)
*
*/
@JsonProperty("kind")
private String kind = "Pod";
@JsonProperty("metadata")
private ObjectMeta metadata;
@JsonProperty("spec")
private PodSpec spec;
@JsonProperty("status")
private PodStatus status;
@JsonIgnore
private Map<String, Object> additionalProperties = new LinkedHashMap<String, Object>();

/**
* No args constructor for use in serialization
*
*/
public Pod() {
}

public Pod(String apiVersion, String kind, ObjectMeta metadata, PodSpec spec, PodStatus status) {
super();
this.apiVersion = apiVersion;
this.kind = kind;
this.metadata = metadata;
this.spec = spec;
this.status = status;
}

/**
*
* (Required)
*
*/
@JsonProperty("apiVersion")
public String getApiVersion() {
return apiVersion;
}

/**
*
* (Required)
*
*/
@JsonProperty("apiVersion")
public void setApiVersion(String apiVersion) {
this.apiVersion = apiVersion;
}

/**
*
* (Required)
*
*/
@JsonProperty("kind")
public String getKind() {
return kind;
}

/**
*
* (Required)
*
*/
@JsonProperty("kind")
public void setKind(String kind) {
this.kind = kind;
}

@JsonProperty("metadata")
public ObjectMeta getMetadata() {
return metadata;
}

@JsonProperty("metadata")
public void setMetadata(ObjectMeta metadata) {
this.metadata = metadata;
}

@JsonProperty("spec")
public PodSpec getSpec() {
return spec;
}

@JsonProperty("spec")
public void setSpec(PodSpec spec) {
this.spec = spec;
}

@JsonProperty("status")
public PodStatus getStatus() {
return status;
}

@JsonProperty("status")
public void setStatus(PodStatus status) {
this.status = status;
}

@JsonIgnore
public PodBuilder edit() {
return new PodBuilder(this);
}

@JsonIgnore
public PodBuilder toBuilder() {
return edit();
}

@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}

@JsonAnySetter
public void setAdditionalProperty(String name, Object value) {
this.additionalProperties.put(name, value);
}

public void setAdditionalProperties(Map<String, Object> additionalProperties) {
this.additionalProperties = additionalProperties;
}

}
Loading

0 comments on commit 1a2a9a8

Please sign in to comment.