This is an automated email from the ASF dual-hosted git repository.

hxd pushed a commit to branch openapi
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/openapi by this push:
     new 0e951cd  finish java rest framework
0e951cd is described below

commit 0e951cde6dd7c7f06fbc808b1790a53004e24104
Author: xiangdong huang <[email protected]>
AuthorDate: Thu Jan 14 21:08:52 2021 +0800

    finish java rest framework
---
 openapi/java-rest/pom.xml                          |  67 +++++++------
 .../iotdb/openapi/gen/handler/Bootstrap.java       |   4 -
 .../handler/factories/PingApiServiceFactory.java   |  32 +++++++
 .../gen/handler/impl/PingApiServiceImpl.java       |  35 +++++++
 .../openapi/gen/handler/impl/V1ApiServiceImpl.java |   6 --
 openapi/java-rest/src/main/webapp/WEB-INF/web.xml  |  21 +---
 openapi/pom.xml                                    | 106 +--------------------
 openapi/src/main/openapi3/iotdb-rest.yaml          |  20 +++-
 8 files changed, 127 insertions(+), 164 deletions(-)

diff --git a/openapi/java-rest/pom.xml b/openapi/java-rest/pom.xml
index 68a513d..5adad96 100644
--- a/openapi/java-rest/pom.xml
+++ b/openapi/java-rest/pom.xml
@@ -27,34 +27,34 @@
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <artifactId>java-rest</artifactId>
+    <packaging>war</packaging>
     <properties>
         <maven.compiler.source>8</maven.compiler.source>
         <maven.compiler.target>8</maven.compiler.target>
     </properties>
-<!--    <build>-->
-<!--        <plugins>-->
-<!--            <plugin>-->
-<!--                <groupId>org.codehaus.mojo</groupId>-->
-<!--                <artifactId>build-helper-maven-plugin</artifactId>-->
-<!--                <version>1.4</version>-->
-<!--                <executions>-->
-<!--                    <execution>-->
-<!--                        <id>add-java-rest-source</id>-->
-<!--                        <phase>generate-sources</phase>-->
-<!--                        <goals>-->
-<!--                            <goal>add-source</goal>-->
-<!--                        </goals>-->
-<!--                        <configuration>-->
-<!--                            <sources>-->
-<!--                                
<source>${project.basedir}/../target/generated-sources/java/src/gen/java</source>-->
-<!--                            </sources>-->
-<!--                        </configuration>-->
-<!--                    </execution>-->
-<!--                </executions>-->
-<!--            </plugin>-->
-<!--        </plugins>-->
-<!--    </build>-->
-
+    <!--    <build>-->
+    <!--        <plugins>-->
+    <!--            <plugin>-->
+    <!--                <groupId>org.codehaus.mojo</groupId>-->
+    <!--                <artifactId>build-helper-maven-plugin</artifactId>-->
+    <!--                <version>1.4</version>-->
+    <!--                <executions>-->
+    <!--                    <execution>-->
+    <!--                        <id>add-java-rest-source</id>-->
+    <!--                        <phase>generate-sources</phase>-->
+    <!--                        <goals>-->
+    <!--                            <goal>add-source</goal>-->
+    <!--                        </goals>-->
+    <!--                        <configuration>-->
+    <!--                            <sources>-->
+    <!--                                
<source>${project.basedir}/../target/generated-sources/java/src/gen/java</source>-->
+    <!--                            </sources>-->
+    <!--                        </configuration>-->
+    <!--                    </execution>-->
+    <!--                </executions>-->
+    <!--            </plugin>-->
+    <!--        </plugins>-->
+    <!--    </build>-->
     <profiles>
         <profile>
             <id>java-rest-pom-by-openapi</id>
@@ -67,7 +67,7 @@
             <properties>
                 <swagger-core-version>1.5.18</swagger-core-version>
                 <beanvalidation-version>1.1.0.Final</beanvalidation-version>
-                <jetty-version>9.2.9.v20150224</jetty-version>
+                <jetty-version>${jetty.version}</jetty-version>
                 <jersey2-version>2.22.2</jersey2-version>
                 <jackson-version>${jackson.version}</jackson-version>
                 <junit-version>${junit.version}</junit-version>
@@ -206,8 +206,6 @@
                     <artifactId>migbase64</artifactId>
                     <version>2.2</version>
                 </dependency>
-
-
                 <!-- Bean Validation API support -->
                 <dependency>
                     <groupId>javax.validation</groupId>
@@ -215,11 +213,18 @@
                     <version>${beanvalidation-version}</version>
                     <scope>provided</scope>
                 </dependency>
-
+                <!-- -->
+                <!--                <dependency>-->
+                <!--                    
<groupId>org.glassfish.jersey.containers</groupId>-->
+                <!--                    
<artifactId>jersey-container-servlet-core</artifactId>-->
+                <!--                    
<version>${jersey2-version}</version>-->
+                <!--                </dependency>-->
+                <!--                <dependency>-->
+                <!--                    
<groupId>org.glassfish.jersey.media</groupId>-->
+                <!--                    
<artifactId>jersey-media-multipart</artifactId>-->
+                <!--                    
<version>${jersey2-version}</version>-->
+                <!--                </dependency>-->
             </dependencies>
-
-
         </profile>
     </profiles>
-
 </project>
diff --git 
a/openapi/java-rest/src/main/java/org/apache/iotdb/openapi/gen/handler/Bootstrap.java
 
b/openapi/java-rest/src/main/java/org/apache/iotdb/openapi/gen/handler/Bootstrap.java
index e619fe2..7342505 100644
--- 
a/openapi/java-rest/src/main/java/org/apache/iotdb/openapi/gen/handler/Bootstrap.java
+++ 
b/openapi/java-rest/src/main/java/org/apache/iotdb/openapi/gen/handler/Bootstrap.java
@@ -22,10 +22,7 @@ package org.apache.iotdb.openapi.gen.handler;
 import io.swagger.jaxrs.config.SwaggerContextService;
 import io.swagger.models.*;
 
-import io.swagger.models.auth.*;
-
 import javax.servlet.http.HttpServlet;
-import javax.servlet.ServletContext;
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
 
@@ -42,7 +39,6 @@ public class Bootstrap extends HttpServlet {
         .name("Apache 2.0")
         .url("http://unlicense.org";));
 
-    ServletContext context = config.getServletContext();
     Swagger swagger = new Swagger().info(info);
 
     new 
SwaggerContextService().withServletConfig(config).updateSwagger(swagger);
diff --git 
a/openapi/java-rest/src/main/java/org/apache/iotdb/openapi/gen/handler/factories/PingApiServiceFactory.java
 
b/openapi/java-rest/src/main/java/org/apache/iotdb/openapi/gen/handler/factories/PingApiServiceFactory.java
new file mode 100644
index 0000000..d676657
--- /dev/null
+++ 
b/openapi/java-rest/src/main/java/org/apache/iotdb/openapi/gen/handler/factories/PingApiServiceFactory.java
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+
+// this file is generated by openapi generator
+
+package org.apache.iotdb.openapi.gen.handler.factories;
+
+import org.apache.iotdb.openapi.gen.handler.PingApiService;
+import org.apache.iotdb.openapi.gen.handler.impl.PingApiServiceImpl;
+
[email protected](value = 
"org.openapitools.codegen.languages.JavaJerseyServerCodegen", date = 
"2021-01-14T20:28:23.313+08:00[Asia/Shanghai]")
+public class PingApiServiceFactory {
+    private static final PingApiService service = new PingApiServiceImpl();
+
+    public static PingApiService getPingApi() {
+        return service;
+    }
+}
diff --git 
a/openapi/java-rest/src/main/java/org/apache/iotdb/openapi/gen/handler/impl/PingApiServiceImpl.java
 
b/openapi/java-rest/src/main/java/org/apache/iotdb/openapi/gen/handler/impl/PingApiServiceImpl.java
new file mode 100644
index 0000000..79ff2ac
--- /dev/null
+++ 
b/openapi/java-rest/src/main/java/org/apache/iotdb/openapi/gen/handler/impl/PingApiServiceImpl.java
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+// this file is generated by openapi generator
+
+package org.apache.iotdb.openapi.gen.handler.impl;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.SecurityContext;
+import org.apache.iotdb.openapi.gen.handler.ApiResponseMessage;
+import org.apache.iotdb.openapi.gen.handler.NotFoundException;
+import org.apache.iotdb.openapi.gen.handler.PingApiService;
+
[email protected](value = 
"org.openapitools.codegen.languages.JavaJerseyServerCodegen", date = 
"2021-01-14T20:28:23.313+08:00[Asia/Shanghai]")
+public class PingApiServiceImpl extends PingApiService {
+    @Override
+    public Response tryPing(SecurityContext securityContext) throws 
NotFoundException {
+        // do some magic!
+        return Response.ok().entity(new 
ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
+    }
+}
diff --git 
a/openapi/java-rest/src/main/java/org/apache/iotdb/openapi/gen/handler/impl/V1ApiServiceImpl.java
 
b/openapi/java-rest/src/main/java/org/apache/iotdb/openapi/gen/handler/impl/V1ApiServiceImpl.java
index 7b476f5..e6f9865 100644
--- 
a/openapi/java-rest/src/main/java/org/apache/iotdb/openapi/gen/handler/impl/V1ApiServiceImpl.java
+++ 
b/openapi/java-rest/src/main/java/org/apache/iotdb/openapi/gen/handler/impl/V1ApiServiceImpl.java
@@ -28,14 +28,8 @@ import org.apache.iotdb.openapi.gen.model.GroupByFillPlan;
 import org.apache.iotdb.openapi.gen.model.InlineResponse200;
 import org.apache.iotdb.openapi.gen.model.InlineResponse2001;
 import java.util.List;
-import java.util.Set;
-
-import java.util.List;
 import org.apache.iotdb.openapi.gen.handler.NotFoundException;
 
-import java.io.InputStream;
-
-import org.glassfish.jersey.media.multipart.FormDataBodyPart;
 
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.SecurityContext;
diff --git a/openapi/java-rest/src/main/webapp/WEB-INF/web.xml 
b/openapi/java-rest/src/main/webapp/WEB-INF/web.xml
index 24e86f8..09a5651 100644
--- a/openapi/java-rest/src/main/webapp/WEB-INF/web.xml
+++ b/openapi/java-rest/src/main/webapp/WEB-INF/web.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <!--
 
     Licensed to the Apache Software Foundation (ASF) under one
@@ -19,23 +19,14 @@
     under the License.
 
 -->
-
 <!-- This file is generated by openapi generator tool.-->
-
-<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee";
-  xmlns:j2ee="http://java.sun.com/xml/ns/j2ee"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee    
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";>
-
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"; 
xmlns:j2ee="http://java.sun.com/xml/ns/j2ee"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; version="2.4" 
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee    
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";>
     <servlet>
         <servlet-name>jersey</servlet-name>
         
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
         <init-param>
             <param-name>jersey.config.server.provider.packages</param-name>
-            <param-value>
-                io.swagger.jaxrs.listing,
-                io.swagger.sample.resource,
-                org.apache.iotdb.openapi.gen.handler
-            </param-value>
+            <param-value>io.swagger.jaxrs.listing, io.swagger.sample.resource, 
org.apache.iotdb.openapi.gen.handler</param-value>
         </init-param>
         <init-param>
             <param-name>jersey.config.server.provider.classnames</param-name>
@@ -47,7 +38,6 @@
         </init-param>
         <load-on-startup>1</load-on-startup>
     </servlet>
-
     <servlet>
         <servlet-name>Jersey2Config</servlet-name>
         
<servlet-class>io.swagger.jersey.config.JerseyJaxrsConfig</servlet-class>
@@ -61,9 +51,8 @@
         </init-param>
         <init-param>
             <param-name>swagger.api.basepath</param-name>
-            
<param-value>https://virtserver.swaggerhub.com/jixuan1989/iotdb/1.0.0</param-value>
+            <param-value>http://localhost:5667</param-value>
         </init-param>
-
         <load-on-startup>2</load-on-startup>
     </servlet>
     <servlet>
@@ -73,7 +62,7 @@
     </servlet>
     <servlet-mapping>
         <servlet-name>jersey</servlet-name>
-        <url-pattern>/jixuan1989/iotdb/1.0.0/*</url-pattern>
+        <url-pattern>/*</url-pattern>
     </servlet-mapping>
     <filter>
         <filter-name>ApiOriginFilter</filter-name>
diff --git a/openapi/pom.xml b/openapi/pom.xml
index 12bcb17..1b3a6c4 100644
--- a/openapi/pom.xml
+++ b/openapi/pom.xml
@@ -41,111 +41,7 @@
 
         </plugins>
     </build>
-    <!--  <properties>-->
-    <!--    
<swagger-codegen-maven-plugin-version>3.0.24</swagger-codegen-maven-plugin-version>-->
-    <!--    <resteasy-version>3.1.3.Final</resteasy-version>-->
-    <!--    <swagger-core-version>2.0.0</swagger-core-version>-->
-    <!--  </properties>-->
-    <!--  <build>-->
-    <!--    <plugins>-->
-    <!--      <plugin>-->
-    <!--        <groupId>io.swagger.codegen.v3</groupId>-->
-    <!--        <artifactId>swagger-codegen-maven-plugin</artifactId>-->
-    <!--        <version>${swagger-codegen-maven-plugin-version}</version>-->
-    <!--        <executions>-->
-    <!--          <execution>-->
-    <!--            <goals>-->
-    <!--              <goal>generate</goal>-->
-    <!--            </goals>-->
-    <!--            <configuration>-->
-    <!--              &lt;!&ndash; use `java -jar 
swagger-codegen-cli-3.0.24.jar config-help -l java`-->
-    <!--              to see configuration options&ndash;&gt;-->
-    <!--              
<inputSpec>${project.basedir}/src/main/openapi3/iotdb-rest.yaml</inputSpec>-->
-    <!--              <language>java</language>-->
-    <!--              
<output>${project.build.directory}/generated-sources/java</output>-->
-    <!--              
<apiPackage>org.apache.iotdb.openapi.gen.handler</apiPackage>-->
-    <!--              
<modelPackage>org.apache.iotdb.openapi.gen.model</modelPackage>-->
-    <!--              
<invokerPackage>org.apache.iotdb.openapi.gen.invoker</invokerPackage>-->
-    <!--              <addCompileSourceRoot>false</addCompileSourceRoot>-->
-    <!--              <configOptions>-->
-    <!--                <licenseName>Apache License 2.0</licenseName>-->
-    <!--                <groupId>org.apache.iotdb</groupId>-->
-    <!--                <artifactId>iotdb-rest-service</artifactId>-->
-    <!--                
<artifactVersion>${project.version}</artifactVersion>-->
-    <!--                <serverPort>5667</serverPort>-->
-    <!--                <dateLibrary>java8</dateLibrary>-->
-    <!--                <useGzipFeature>true</useGzipFeature>-->
-    <!--&lt;!&ndash;                <library>resteasy</library>&ndash;&gt;-->
-    <!--              </configOptions>-->
-    <!--            </configuration>-->
-    <!--          </execution>-->
-    <!--        </executions>-->
-    <!--      </plugin>-->
-    <!--    </plugins>-->
-    <!--  </build>-->
-    <!--
-  <dependencies>
-    <dependency>
-      <groupId>io.swagger.core.v3</groupId>
-      <artifactId>swagger-annotations</artifactId>
-      <version>${swagger-core-version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.jboss.resteasy</groupId>
-      <artifactId>resteasy-client</artifactId>
-      <version>${resteasy-version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.jboss.resteasy</groupId>
-      <artifactId>resteasy-multipart-provider</artifactId>
-      <version>${resteasy-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-annotations</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>org.jboss.resteasy</groupId>
-      <artifactId>resteasy-jackson-provider</artifactId>
-      <version>3.1.3.Final</version>
-    </dependency>
-    <dependency>
-      <groupId>com.github.joschi.jackson</groupId>
-      <artifactId>jackson-datatype-threetenbp</artifactId>
-      <version>${jackson.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>${junit.version}</version>
-      <scope>test</scope>
-    </dependency>
-  </dependencies>
--->
-<!--    <profiles>-->
-<!--        <profile>-->
-<!--            <id>java-rest</id>-->
-<!--            <modules>-->
-<!--                <module>target/generated-sources/java</module>-->
-<!--            </modules>-->
-<!--        </profile>-->
-<!--    </profiles>-->
+
     <profiles>
         <profile>
             <id>openapi-generation</id>
diff --git a/openapi/src/main/openapi3/iotdb-rest.yaml 
b/openapi/src/main/openapi3/iotdb-rest.yaml
index 8b8831b..dfd09a9 100644
--- a/openapi/src/main/openapi3/iotdb-rest.yaml
+++ b/openapi/src/main/openapi3/iotdb-rest.yaml
@@ -7,13 +7,29 @@ info:
     name: Apache 2.0
   version: 1.0.0
 servers:
-- url: https://virtserver.swaggerhub.com/jixuan1989/iotdb/1.0.0
-  description: SwaggerHub API Auto Mocking
 - url: http://localhost:5667
   description: api
 security:
 - basic: []
 paths:
+  /ping:
+    get:
+      summary: Your GET endpoint
+      tags: []
+      security:
+        - basic: []
+      responses:
+        '200':
+          description: OK
+          content:
+            application/json:
+              schema:
+                type: string
+              examples:
+                example-1:
+                  value: OK
+      operationId: tryPing
+      description: Just for checking whether the server works
   /v1/grafana/query/frame:
     post:
       summary: Serve for queries from Grafana

Reply via email to