Add Swagger Related Configurations 89/13889/1
authorGuangrong Fu <fu.guangrong@zte.com.cn>
Wed, 20 Sep 2017 13:18:36 +0000 (21:18 +0800)
committerGuangrong Fu <fu.guangrong@zte.com.cn>
Wed, 20 Sep 2017 13:18:36 +0000 (21:18 +0800)
Change-Id: I54ec08d909a2b37b9296d1dd4e581a12d021bec1
Issue-ID: HOLMES-54
Signed-off-by: Guangrong Fu <fu.guangrong@zte.com.cn>
engine-d-standalone/pom.xml
engine-d/pom.xml
engine-d/src/main/java/org/onap/holmes/engine/resources/EngineResources.java
engine-d/src/main/java/org/onap/holmes/engine/resources/HealthCheck.java
engine-d/src/main/resources/swagger.json [new file with mode: 0644]

index 791dc8f..58dcb79 100644 (file)
                                     <excludes>
                                         <exclude>**/*.bat</exclude>
                                     </excludes>
+                                </resource>
+                                                               <resource>
+                                    <directory>../engine-d/src/main/resources</directory>
+                                    <filtering>false</filtering>
                                 </resource>
                             </resources>
                             <overwrite>true</overwrite>
                                     <excludes>
                                         <exclude>**/*.sh</exclude>
                                     </excludes>
+                                </resource>
+                                                               <resource>
+                                    <directory>../engine-d/src/main/resources</directory>
+                                    <filtering>false</filtering>
                                 </resource>
                             </resources>
                             <overwrite>true</overwrite>
index a5f85dc..4cbe04c 100644 (file)
@@ -34,6 +34,7 @@
     </properties>
 
     <dependencies>
+
         <dependency>
             <groupId>org.onap.msb.java-sdk</groupId>
             <artifactId>msb-java-sdk</artifactId>
                     </execution>
                 </executions>
             </plugin>
-
         </plugins>
         <resources>
             <resource>
             </resource>
         </resources>
     </build>
+
+    <profiles>
+        <profile>
+            <id>swagger</id>
+            <dependencies>
+                <dependency>
+                    <groupId>io.swagger</groupId>
+                    <artifactId>swagger-jersey2-jaxrs</artifactId>
+                    <version>1.5.0</version>
+                </dependency>
+            </dependencies>
+
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>com.github.kongchen</groupId>
+                        <artifactId>swagger-maven-plugin</artifactId>
+                        <version>3.1.1</version>
+                        <configuration>
+                            <apiSources>
+                                <apiSource>
+                                    <springmvc>false</springmvc>
+                                    <locations>org.onap.holmes.engine.resources</locations>
+                                    <basePath>/api/holmes-engine-mgmt/v1/</basePath>
+                                    <info>
+                                        <title>API Descriptions for Holmes Engine Management</title>
+                                        <version>v1</version>
+                                        <description>
+                                            This page shows all the APIs available in the Holmes engine management module.
+                                        </description>
+                                        <termsOfService>
+                                            http://www.github.com/kongchen/swagger-maven-plugin
+                                        </termsOfService>
+                                        <contact>
+                                            <email>fu.guangrong@zte.com.cn</email>
+                                            <name>Guangrong Fu</name>
+                                        </contact>
+                                        <license>
+                                            <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
+                                            <name>Apache 2.0</name>
+                                        </license>
+                                    </info>
+                                    <securityDefinitions>
+                                    </securityDefinitions>
+                                    <swaggerDirectory>${basedir}/src/main/resources</swaggerDirectory>
+                                </apiSource>
+                            </apiSources>
+                        </configuration>
+                        <executions>
+                            <execution>
+                                <phase>compile</phase>
+                                <goals>
+                                    <goal>generate</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                        <dependencies>
+                            <dependency>
+                                <groupId>io.swagger</groupId>
+                                <artifactId>swagger-hibernate-validations</artifactId>
+                                <version>1.5.6</version>
+                            </dependency>
+                        </dependencies>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
 </project>
index 3480dbb..8f9a271 100644 (file)
@@ -19,6 +19,7 @@ package org.onap.holmes.engine.resources;
 import com.codahale.metrics.annotation.Timed;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
 import java.util.Locale;
 import javax.inject.Inject;
 import javax.servlet.http.HttpServletRequest;
@@ -42,7 +43,7 @@ import org.onap.holmes.engine.response.CorrelationRuleResponse;
 
 @Service
 @Path("/rule")
-@Api(tags = {"Engine Manager"})
+@Api(tags = {"Holmes Engine Management"})
 @Produces(MediaType.APPLICATION_JSON)
 @Slf4j
 public class EngineResources {
@@ -51,10 +52,14 @@ public class EngineResources {
     DroolsEngine droolsEngine;
 
     @PUT
-    @ApiOperation(value = "Add rule to Engine and Cache", response = CorrelationRuleResponse.class)
+    @ApiOperation(value = "Deploy a rule into the Drools engine.", response = CorrelationRuleResponse.class)
     @Produces(MediaType.APPLICATION_JSON)
     @Timed
-    public CorrelationRuleResponse deployRule(DeployRuleRequest deployRuleRequest,
+    public CorrelationRuleResponse deployRule(
+            @ApiParam(value = "The request entity of the HTTP call, which comprises two "
+                    + "fields: \"content\" and \"engineid\". "
+                    + "The \"content\" should be a valid Drools rule string and the \"engineid\" "
+                    + "has to be \"engine-d\" in the Amsterdam release.", required = true) DeployRuleRequest deployRuleRequest,
             @Context HttpServletRequest httpRequest) {
 
         CorrelationRuleResponse crResponse = new CorrelationRuleResponse();
@@ -74,7 +79,7 @@ public class EngineResources {
     }
 
     @DELETE
-    @ApiOperation(value = "delete rule")
+    @ApiOperation(value = "Undeploy a rule from the Drools engine.")
     @Produces(MediaType.APPLICATION_JSON)
     @Timed
     @Path("/{packageName}")
@@ -96,7 +101,7 @@ public class EngineResources {
 
 
     @POST
-    @ApiOperation(value = "compile rule")
+    @ApiOperation(value = "Check the validity of a rule.")
     @Produces(MediaType.APPLICATION_JSON)
     @Timed
     public boolean compileRule(CompileRuleRequest compileRuleRequest,
index da2bf1b..c86bf06 100644 (file)
@@ -29,7 +29,7 @@ import org.jvnet.hk2.annotations.Service;
 @Service
 @SwaggerDefinition
 @Path("/healthcheck")
-@Api(tags = {"HealthCheck"})
+@Api(tags = {"Health Check"})
 @Produces(MediaType.TEXT_PLAIN)
 @Slf4j
 public class HealthCheck {
diff --git a/engine-d/src/main/resources/swagger.json b/engine-d/src/main/resources/swagger.json
new file mode 100644 (file)
index 0000000..4dd3f6d
--- /dev/null
@@ -0,0 +1,128 @@
+{
+  "swagger" : "2.0",
+  "info" : {
+    "description" : "This page shows all the APIs available in the Holmes engine management module.",
+    "version" : "v1",
+    "title" : "API Descriptions for Holmes Engine Management",
+    "termsOfService" : "http://www.github.com/kongchen/swagger-maven-plugin",
+    "contact" : {
+      "name" : "Guangrong Fu",
+      "email" : "fu.guangrong@zte.com.cn"
+    },
+    "license" : {
+      "name" : "Apache 2.0",
+      "url" : "http://www.apache.org/licenses/LICENSE-2.0.html"
+    }
+  },
+  "basePath" : "/api/holmes-engine-mgmt/v1/",
+  "tags" : [ {
+    "name" : "Health Check"
+  }, {
+    "name" : "Holmes Engine Management"
+  } ],
+  "paths" : {
+    "/healthcheck" : {
+      "get" : {
+        "tags" : [ "Health Check" ],
+        "summary" : "Interface for the health check of the engine management module for Holmes",
+        "description" : "",
+        "operationId" : "healthCheck",
+        "produces" : [ "text/plain" ],
+        "responses" : {
+          "200" : {
+            "description" : "successful operation",
+            "schema" : {
+              "type" : "boolean"
+            }
+          }
+        }
+      }
+    },
+    "/rule" : {
+      "post" : {
+        "tags" : [ "Holmes Engine Management" ],
+        "summary" : "Check the validity of a rule.",
+        "description" : "",
+        "operationId" : "compileRule",
+        "produces" : [ "application/json" ],
+        "responses" : {
+          "200" : {
+            "description" : "successful operation",
+            "schema" : {
+              "type" : "boolean"
+            }
+          }
+        }
+      },
+      "put" : {
+        "tags" : [ "Holmes Engine Management" ],
+        "summary" : "Deploy a rule into the Drools engine.",
+        "description" : "",
+        "operationId" : "deployRule",
+        "produces" : [ "application/json" ],
+        "parameters" : [ {
+          "in" : "body",
+          "name" : "body",
+          "description" : "The request entity of the HTTP call, which comprises two fields: \"content\" and \"engineid\". The \"content\" should be a valid Drools rule string and the \"engineid\" has to be \"engine-d\" in the Amsterdam release.",
+          "required" : true,
+          "schema" : {
+            "$ref" : "#/definitions/DeployRuleRequest"
+          }
+        } ],
+        "responses" : {
+          "200" : {
+            "description" : "successful operation",
+            "schema" : {
+              "$ref" : "#/definitions/CorrelationRuleResponse"
+            }
+          }
+        }
+      }
+    },
+    "/rule/{packageName}" : {
+      "delete" : {
+        "tags" : [ "Holmes Engine Management" ],
+        "summary" : "Undeploy a rule from the Drools engine.",
+        "description" : "",
+        "operationId" : "undeployRule",
+        "produces" : [ "application/json" ],
+        "parameters" : [ {
+          "name" : "packageName",
+          "in" : "path",
+          "required" : true,
+          "type" : "string"
+        } ],
+        "responses" : {
+          "200" : {
+            "description" : "successful operation",
+            "schema" : {
+              "type" : "boolean"
+            }
+          }
+        }
+      }
+    }
+  },
+  "definitions" : {
+    "CorrelationRuleResponse" : {
+      "type" : "object",
+      "properties" : {
+        "package" : {
+          "type" : "string"
+        }
+      }
+    },
+    "DeployRuleRequest" : {
+      "type" : "object",
+      "required" : [ "content" ],
+      "properties" : {
+        "content" : {
+          "type" : "string"
+        },
+        "engineid" : {
+          "type" : "string"
+        }
+      }
+    }
+  }
+}
\ No newline at end of file