This is an automated email from the ASF dual-hosted git repository.
xuba pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/amoro.git
The following commit(s) were added to refs/heads/master by this push:
new 74099273b [AMORO-3880] Make amoro-openapi-sdk standalone (#3881)
74099273b is described below
commit 74099273b12f001851ba4976c26987b877c115a3
Author: Fei Wang <[email protected]>
AuthorDate: Tue Nov 4 08:02:07 2025 -0800
[AMORO-3880] Make amoro-openapi-sdk standalone (#3881)
* [AMORO-3880] Make amoro-openapi-sdk standalone
* save
---
.github/workflows/openapi-sdk-ci.yml | 2 +-
amoro-ams/pom.xml | 95 -------
amoro-openapi-sdk/pom.xml | 285 +++++++++++++++++++++
.../java/org/apache/amoro/openapi/OpenAPITest.java | 71 +++++
dev/reformat | 2 +-
pom.xml | 6 +
6 files changed, 364 insertions(+), 97 deletions(-)
diff --git a/.github/workflows/openapi-sdk-ci.yml
b/.github/workflows/openapi-sdk-ci.yml
index 8ff0cef1c..0f594712c 100644
--- a/.github/workflows/openapi-sdk-ci.yml
+++ b/.github/workflows/openapi-sdk-ci.yml
@@ -54,4 +54,4 @@ jobs:
check-latest: false
- name: Build OpenAPI SDK
- run: ./mvnw clean package -DskipTests -Pgenerate-sdk -pl amoro-ams -am
+ run: ./mvnw clean package -pl amoro-openapi-sdk -am -Popenapi-sdk
diff --git a/amoro-ams/pom.xml b/amoro-ams/pom.xml
index 51aaac70f..db602e945 100644
--- a/amoro-ams/pom.xml
+++ b/amoro-ams/pom.xml
@@ -35,10 +35,7 @@
<url>https://amoro.apache.org</url>
<properties>
- <httpmime.version>4.5.13</httpmime.version>
-
<openapi-generator-maven-plugin.version>6.0.0</openapi-generator-maven-plugin.version>
<swagger-ui.version>5.17.14</swagger-ui.version>
- <swagger-annorations.version>1.6.16</swagger-annorations.version>
<git-commit-id-plugin.fail-on-no-git-dir>false</git-commit-id-plugin.fail-on-no-git-dir>
</properties>
@@ -427,12 +424,6 @@
<version>${swagger-ui.version}</version>
</dependency>
- <dependency>
- <groupId>io.swagger</groupId>
- <artifactId>swagger-annotations</artifactId>
- <version>${swagger-annorations.version}</version>
- </dependency>
-
<!-- testcontainers dependencies -->
<dependency>
<groupId>org.testcontainers</groupId>
@@ -582,91 +573,5 @@
<git-commit-id-plugin.fail-on-no-git-dir>true</git-commit-id-plugin.fail-on-no-git-dir>
</properties>
</profile>
- <profile>
- <id>generate-sdk</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.openapitools</groupId>
- <artifactId>openapi-generator-maven-plugin</artifactId>
-
<version>${openapi-generator-maven-plugin.version}</version>
- <executions>
- <execution>
- <id>generate-sdk</id>
- <goals>
- <goal>generate</goal>
- </goals>
- <phase>generate-sources</phase>
- <configuration>
-
<inputSpec>${project.basedir}/src/main/resources/openapi/openapi.yaml</inputSpec>
- <generatorName>java</generatorName>
-
<output>${project.build.directory}/generated-sources/openapi</output>
-
<apiPackage>org.apache.amoro.openapi.api</apiPackage>
-
<modelPackage>org.apache.amoro.openapi.model</modelPackage>
-
<invokerPackage>org.apache.amoro.openapi.invoker</invokerPackage>
- <configOptions>
- <library>apache-httpclient</library>
- </configOptions>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <id>package-sdk</id>
- <goals>
- <goal>jar</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <classifier>sdk</classifier>
- <classesDirectory>
-
${project.build.directory}/generated-sources/openapi/src/main/java
- </classesDirectory>
-
<outputDirectory>${project.build.directory}</outputDirectory>
-
<finalName>amoro-openapi-${project.version}</finalName>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpmime</artifactId>
- <version>${httpmime.version}</version>
- </dependency>
- </dependencies>
- </profile>
- <profile>
- <id>generate-doc</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.openapitools</groupId>
- <artifactId>openapi-generator-maven-plugin</artifactId>
-
<version>${openapi-generator-maven-plugin.version}</version>
- <executions>
- <execution>
- <id>generate-doc</id>
- <goals>
- <goal>generate</goal>
- </goals>
- <phase>generate-sources</phase>
- <configuration>
-
<inputSpec>${project.basedir}/src/main/resources/openapi/openapi.yaml</inputSpec>
- <generatorName>html2</generatorName>
-
<output>${project.build.directory}/generated-docs/openapi</output>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
</profiles>
</project>
diff --git a/amoro-openapi-sdk/pom.xml b/amoro-openapi-sdk/pom.xml
new file mode 100644
index 000000000..02d31848a
--- /dev/null
+++ b/amoro-openapi-sdk/pom.xml
@@ -0,0 +1,285 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you 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:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ 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>org.apache.amoro</groupId>
+ <artifactId>amoro-parent</artifactId>
+ <version>0.9-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>amoro-openapi-sdk</artifactId>
+ <packaging>jar</packaging>
+ <name>Amoro Project OpenAPI SDK</name>
+ <url>https://amoro.apache.org</url>
+
+ <properties>
+
<openapi-generator-maven-plugin.version>6.0.0</openapi-generator-maven-plugin.version>
+ <swagger-annorations.version>1.6.16</swagger-annorations.version>
+ <commons-logging.version>1.3.5</commons-logging.version>
+ <google.jsr305.version>3.0.2</google.jsr305.version>
+ <httpclient.version>4.5.14</httpclient.version>
+ <httpcore.version>4.4.16</httpcore.version>
+ <jackson.version>2.13.5</jackson.version>
+ <jakarta.annotation-api.version>1.3.5</jakarta.annotation-api.version>
+ <wiremock.version>2.35.2</wiremock.version>
+ <shading.prefix>org.apache.amoro.shade</shading.prefix>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-annotations</artifactId>
+ <version>${swagger-annorations.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>${commons-logging.version}</version>
+ </dependency>
+
+ <!-- @Nullable annotation -->
+ <dependency>
+ <groupId>com.google.code.findbugs</groupId>
+ <artifactId>jsr305</artifactId>
+ <version>${google.jsr305.version}</version>
+ </dependency>
+
+ <!-- HTTP client: apache client -->
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>${httpclient.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpmime</artifactId>
+ <version>${httpclient.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore</artifactId>
+ <version>${httpcore.version}</version>
+ </dependency>
+
+ <!-- JSON processing: jackson -->
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ <version>${jackson.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ <version>${jackson.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>${jackson.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.datatype</groupId>
+ <artifactId>jackson-datatype-jsr310</artifactId>
+ <version>${jackson.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.jaxrs</groupId>
+ <artifactId>jackson-jaxrs-json-provider</artifactId>
+ <version>${jackson.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>jakarta.annotation</groupId>
+ <artifactId>jakarta.annotation-api</artifactId>
+ <version>${jakarta.annotation-api.version}</version>
+ </dependency>
+
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.github.tomakehurst</groupId>
+ <artifactId>wiremock-jre8</artifactId>
+ <version>${wiremock.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.openapitools</groupId>
+ <artifactId>openapi-generator-maven-plugin</artifactId>
+ <version>${openapi-generator-maven-plugin.version}</version>
+ <executions>
+ <execution>
+ <id>generate-sdk</id>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <phase>generate-sources</phase>
+ <configuration>
+
<inputSpec>${project.basedir}/../amoro-ams/src/main/resources/openapi/openapi.yaml</inputSpec>
+ <generatorName>java</generatorName>
+
<output>${project.build.directory}/generated-sources/openapi</output>
+
<apiPackage>org.apache.amoro.openapi.api</apiPackage>
+
<modelPackage>org.apache.amoro.openapi.model</modelPackage>
+
<invokerPackage>org.apache.amoro.openapi.invoker</invokerPackage>
+ <generateApiTests>false</generateApiTests>
+ <generateModelTests>false</generateModelTests>
+ <configOptions>
+ <library>apache-httpclient</library>
+ </configOptions>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.openapitools</groupId>
+ <artifactId>openapi-generator-maven-plugin</artifactId>
+ <version>${openapi-generator-maven-plugin.version}</version>
+ <executions>
+ <execution>
+ <id>generate-doc</id>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <phase>generate-sources</phase>
+ <configuration>
+
<inputSpec>${project.basedir}/../amoro-ams/src/main/resources/openapi/openapi.yaml</inputSpec>
+ <generatorName>html2</generatorName>
+
<output>${project.build.directory}/generated-docs/openapi</output>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>${maven-build-helper-plugin.version}</version>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+
<source>${project.build.directory}/generated-sources/openapi/src/main/java</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>gradle/**</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>shade-sdk</id>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <relocations>
+ <relocation>
+ <pattern>io.swagger</pattern>
+
<shadedPattern>${shading.prefix}.io.swagger</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>com.fasterxml.jackson</pattern>
+
<shadedPattern>${shading.prefix}.com.fasterxml.jackson</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>javax.annotation</pattern>
+
<shadedPattern>${shading.prefix}.javax.annotation</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>org.apache.commons</pattern>
+
<shadedPattern>${shading.prefix}.org.apache.commons</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>org.apache.http</pattern>
+
<shadedPattern>${shading.prefix}.org.apache.http</shadedPattern>
+ </relocation>
+ </relocations>
+ <artifactSet>
+ <includes>
+
<include>io.swagger:swagger-annotations</include>
+
<include>commons-logging:commons-logging</include>
+
<include>com.google.code.findbugs:jsr305</include>
+
<include>org.apache.httpcomponents:httpclient</include>
+
<include>org.apache.httpcomponents:httpcore</include>
+
<include>org.apache.httpcomponents:httpmime</include>
+
<include>com.fasterxml.jackson.core:jackson-annotations</include>
+
<include>com.fasterxml.jackson.core:jackson-core</include>
+
<include>com.fasterxml.jackson.core:jackson-databind</include>
+
<include>com.fasterxml.jackson.datatype:jackson-datatype-jsr310</include>
+
<include>com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider</include>
+
<include>jakarta.annotation:jakarta.annotation-api</include>
+ </includes>
+ </artifactSet>
+ <filters>
+ <filter>
+ <artifact>*:*</artifact>
+ <excludes>
+ <exclude>META-INF/*.SF</exclude>
+ <exclude>META-INF/*.DSA</exclude>
+ <exclude>META-INF/*.RSA</exclude>
+ <exclude>**/log4j.properties</exclude>
+
<exclude>META-INF/DEPENDENCIES</exclude>
+ <exclude>META-INF/*LICENSE*</exclude>
+ <exclude>META-INF/MANIFEST.MF</exclude>
+ <exclude>META-INF/*NOTICE*</exclude>
+
<exclude>META-INF/**/module-info.class</exclude>
+ <exclude>LICENSE.txt</exclude>
+ <exclude>NOTICE.txt</exclude>
+ <exclude>mozilla/*.txt</exclude>
+ </excludes>
+ </filter>
+ </filters>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git
a/amoro-openapi-sdk/src/test/java/org/apache/amoro/openapi/OpenAPITest.java
b/amoro-openapi-sdk/src/test/java/org/apache/amoro/openapi/OpenAPITest.java
new file mode 100644
index 000000000..1dd7cef16
--- /dev/null
+++ b/amoro-openapi-sdk/src/test/java/org/apache/amoro/openapi/OpenAPITest.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.amoro.openapi;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.configureFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+
+import com.github.tomakehurst.wiremock.WireMockServer;
+import org.apache.amoro.openapi.api.HealthApi;
+import org.apache.amoro.openapi.invoker.ApiClient;
+import org.apache.amoro.openapi.model.Response;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class OpenAPITest {
+ private WireMockServer wireMockServer;
+ private String basePath;
+
+ @Before
+ public void setup() {
+ wireMockServer = new WireMockServer(0);
+ wireMockServer.start();
+ int port = wireMockServer.port();
+ configureFor("localhost", port);
+ basePath = "http://localhost:" + port;
+ }
+
+ @After
+ public void teardown() {
+ wireMockServer.stop();
+ }
+
+ @Test
+ public void testSdkCall() throws Exception {
+ String json = "{\"message\":\"string\",\"code\":0,\"result\":{}}";
+ stubFor(
+ get(urlEqualTo("/api/ams/v1/health/status"))
+ .willReturn(
+ aResponse()
+ .withStatus(200)
+ .withBody("{\"message\":\"\",\"code\":0,\"result\":{}}")));
+
+ ApiClient apiClient = new ApiClient().setBasePath(basePath);
+ HealthApi api = new HealthApi(apiClient);
+ Response healthResponse = api.apiAmsV1HealthStatusGet();
+ assert healthResponse.getCode() == 0;
+ assert healthResponse.getMessage().equals("");
+ assert healthResponse.getResult() instanceof java.util.Map;
+ assert ((java.util.Map<?, ?>) healthResponse.getResult()).isEmpty();
+ }
+}
diff --git a/dev/reformat b/dev/reformat
index 3dffc2ad9..061f8f88c 100755
--- a/dev/reformat
+++ b/dev/reformat
@@ -20,5 +20,5 @@ set -x
PROJECT_HOME="$(cd "`dirname "$0"`/.."; pwd)"
-$PROJECT_HOME/mvnw spotless:apply "-Psupport-all-formats,spark-3.5"
+$PROJECT_HOME/mvnw spotless:apply "-Psupport-all-formats,openapi-sdk,spark-3.5"
$PROJECT_HOME/mvnw spotless:apply "-Pspark-3.3"
diff --git a/pom.xml b/pom.xml
index 443e49cbf..5d8f16f25 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1468,5 +1468,11 @@
<spark.major.version>3.5</spark.major.version>
</properties>
</profile>
+ <profile>
+ <id>openapi-sdk</id>
+ <modules>
+ <module>amoro-openapi-sdk</module>
+ </modules>
+ </profile>
</profiles>
</project>