summaryrefslogtreecommitdiffstats
path: root/esr-mgr
diff options
context:
space:
mode:
authorLizi <li.zi30@zte.com.cn>2018-02-06 11:49:01 +0000
committerLizi <li.zi30@zte.com.cn>2018-02-06 11:50:21 +0000
commita1b75c86ea8a32971a8bef5f75167569b69f5fb6 (patch)
tree3d536fd125d8c2cdb67e8f2412fc0f15854bbc85 /esr-mgr
parent9c05d63a363a0b6a161f5f4d94d5cd893f582806 (diff)
Display ESR API with swagger
When ESR registered to MSB. The API of esr-server can be visited from MSB portal through swagger Change-Id: I142b79c00920697839f55eac95b50a6072d19ca4 Issue-ID: AAI-735 Signed-off-by: Lizi <li.zi30@zte.com.cn>
Diffstat (limited to 'esr-mgr')
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/ExtsysApp.java34
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/resource/EmsManager.java2
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/resource/ThirdpartySdncManager.java5
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/resource/VimManager.java2
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/resource/VnfmManager.java2
5 files changed, 36 insertions, 9 deletions
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysApp.java b/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysApp.java
index 358fb07..db44504 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysApp.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysApp.java
@@ -27,7 +27,12 @@ import org.onap.msb.sdk.httpclient.msb.MSBServiceClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.dropwizard.Application;
+import io.dropwizard.server.SimpleServerFactory;
import io.dropwizard.setup.Environment;
+import io.swagger.jaxrs.config.BeanConfig;
+import io.swagger.jaxrs.listing.ApiListingResource;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
public class ExtsysApp extends Application<ExtsysAppConfiguration> {
@@ -53,6 +58,7 @@ public class ExtsysApp extends Application<ExtsysAppConfiguration> {
environment.jersey().register(new VimManager());
environment.jersey().register(new VnfmManager());
environment.jersey().register(new ServiceTest());
+ initSwaggerConfig(environment, configuration);
if ("true".equals(configuration.getRegistByHand())) {
String MSB_IP = configuration.getMsbDiscoveryIp();
Integer MSB_Port = Integer.valueOf(configuration.getMsbDiscoveryPort());
@@ -67,5 +73,33 @@ public class ExtsysApp extends Application<ExtsysAppConfiguration> {
}
LOGGER.info("Initialize extsys finished.");
}
+
+ /**
+ * initialize swagger configuration.
+ *
+ * @param environment environment information
+ * @param configuration catalogue configuration
+ */
+ private void initSwaggerConfig(Environment environment, ExtsysAppConfiguration configuration) {
+ environment.jersey().register(new ApiListingResource());
+ environment.getObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
+ BeanConfig config = new BeanConfig();
+ config.setTitle("ONAP ESR Service rest API");
+ config.setVersion("1.0.0");
+ config.setResourcePackage("org.onap.aai.esr.resource");
+ // set rest api basepath in swagger
+ SimpleServerFactory simpleServerFactory =
+ (SimpleServerFactory) configuration.getServerFactory();
+ String basePath = simpleServerFactory.getApplicationContextPath();
+ String rootPath = simpleServerFactory.getJerseyRootPath().get();
+ rootPath = rootPath.substring(0, rootPath.indexOf("/*"));
+ basePath =
+ basePath.equals("/") ? rootPath : (new StringBuilder()).append(basePath)
+ .append(rootPath).toString();
+ LOGGER.info("getApplicationContextPath: " + basePath);
+ config.setBasePath(basePath);
+ config.setScan(true);
+ }
+
}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/resource/EmsManager.java b/esr-mgr/src/main/java/org/onap/aai/esr/resource/EmsManager.java
index 3c18353..cebc10f 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/resource/EmsManager.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/resource/EmsManager.java
@@ -21,7 +21,6 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
-import io.swagger.annotations.SwaggerDefinition;
import org.eclipse.jetty.http.HttpStatus;
import org.onap.aai.esr.entity.rest.EmsRegisterInfo;
import org.onap.aai.esr.util.ExtsysUtil;
@@ -39,7 +38,6 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-@SwaggerDefinition
@Path("/emses")
@Api(tags = {" ems Management "})
public class EmsManager {
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/resource/ThirdpartySdncManager.java b/esr-mgr/src/main/java/org/onap/aai/esr/resource/ThirdpartySdncManager.java
index b633b8c..89481e8 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/resource/ThirdpartySdncManager.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/resource/ThirdpartySdncManager.java
@@ -21,7 +21,6 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
-import io.swagger.annotations.SwaggerDefinition;
import org.eclipse.jetty.http.HttpStatus;
import org.onap.aai.esr.entity.rest.ThirdpartySdncRegisterInfo;
import org.onap.aai.esr.util.ExtsysUtil;
@@ -39,9 +38,9 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-@SwaggerDefinition
+
@Path("/sdncontrollers")
-@Api(tags = {"ThirdParty sdnc Management "})
+@Api(tags = {"ThirdParty sdnc Management "})
public class ThirdpartySdncManager {
private static final Logger LOGGER = LoggerFactory.getLogger(ThirdpartySdncManager.class);
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/resource/VimManager.java b/esr-mgr/src/main/java/org/onap/aai/esr/resource/VimManager.java
index b408f62..a122c47 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/resource/VimManager.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/resource/VimManager.java
@@ -20,7 +20,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
-import io.swagger.annotations.SwaggerDefinition;
import org.eclipse.jetty.http.HttpStatus;
import org.onap.aai.esr.entity.rest.VimRegisterInfo;
import org.onap.aai.esr.util.ExtsysUtil;
@@ -38,7 +37,6 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-@SwaggerDefinition
@Path("/vims")
@Api(tags = {" vim Management "})
public class VimManager {
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/resource/VnfmManager.java b/esr-mgr/src/main/java/org/onap/aai/esr/resource/VnfmManager.java
index f86fd57..6588f58 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/resource/VnfmManager.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/resource/VnfmManager.java
@@ -21,7 +21,6 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
-import io.swagger.annotations.SwaggerDefinition;
import org.eclipse.jetty.http.HttpStatus;
import org.onap.aai.esr.entity.rest.VnfmRegisterInfo;
import org.onap.aai.esr.util.ExtsysUtil;
@@ -39,7 +38,6 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-@SwaggerDefinition
@Path("/vnfms")
@Api(tags = {" vnfm Management "})
public class VnfmManager {