aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-catalog-db-adapter/src/main
diff options
context:
space:
mode:
authorArindam Mondal <arind.mondal@samsung.com>2019-09-11 15:13:04 +0900
committerarindamm <arind.mondal@samsung.com>2019-09-16 08:30:40 +0900
commitba997d7d6400f00fad424053df794e4ea9debb31 (patch)
tree7eb60100bb7025adda9d81178ac8ddfe637d6d8f /adapters/mso-catalog-db-adapter/src/main
parent80d6f2f06e538dbb212f968514f0943bb7dd41ba (diff)
Upgrade swagger in mso-catalog-db-adapter
Issue-ID: SO-2305 Change-Id: I25ac20a96cf44a7c8abaa3b78f3b256cb2002d3f Signed-off-by: arindamm <arind.mondal@samsung.com>
Diffstat (limited to 'adapters/mso-catalog-db-adapter/src/main')
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java37
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceRestImpl.java23
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/VnfRestImpl.java18
3 files changed, 53 insertions, 25 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java
index 699347015b..359c8cd46e 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java
@@ -20,6 +20,8 @@
package org.onap.so.adapters.catalogdb;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import javax.annotation.PostConstruct;
import javax.ws.rs.ApplicationPath;
import org.glassfish.jersey.server.ResourceConfig;
@@ -30,9 +32,13 @@ import org.onap.so.adapters.catalogdb.rest.ServiceRestImpl;
import org.onap.so.adapters.catalogdb.rest.VnfRestImpl;
import org.onap.so.logging.jaxrs.filter.SOAuditLogContainerFilter;
import org.springframework.context.annotation.Configuration;
-import io.swagger.jaxrs.config.BeanConfig;
-import io.swagger.jaxrs.listing.ApiListingResource;
-import io.swagger.jaxrs.listing.SwaggerSerializers;
+import io.swagger.v3.jaxrs2.integration.JaxrsOpenApiContextBuilder;
+import io.swagger.v3.jaxrs2.integration.resources.AcceptHeaderOpenApiResource;
+import io.swagger.v3.jaxrs2.integration.resources.OpenApiResource;
+import io.swagger.v3.oas.integration.OpenApiConfigurationException;
+import io.swagger.v3.oas.integration.SwaggerConfiguration;
+import io.swagger.v3.oas.models.OpenAPI;
+import io.swagger.v3.oas.models.info.Info;
@Configuration
@ApplicationPath("/ecomp/mso/catalog")
@@ -42,18 +48,25 @@ public class JerseyConfiguration extends ResourceConfig {
public void setUp() {
System.setProperty(Constants.Property.PARTNER_NAME, ONAPComponents.CATALOG_DB.toString());
register(CatalogDbAdapterRest.class);
- register(ApiListingResource.class);
- register(SwaggerSerializers.class);
register(SOAuditLogContainerFilter.class);
+ register(OpenApiResource.class);
+ register(AcceptHeaderOpenApiResource.class);
register(ServiceRestImpl.class);
register(VnfRestImpl.class);
- BeanConfig beanConfig = new BeanConfig();
- beanConfig.setVersion("1.0.2");
- beanConfig.setSchemes(new String[] {"https"});
- beanConfig.setBasePath("/ecomp/mso/catalog");
- beanConfig.setResourcePackage("org.onap.so.adapters.catalogdb.rest");
- beanConfig.setPrettyPrint(true);
- beanConfig.setScan(true);
+
+ OpenAPI oas = new OpenAPI();
+ Info info = new Info();
+ info.title("Swagger catalog-db-adapter bootstrap code");
+ info.setVersion("1.0.2");
+
+ SwaggerConfiguration oasConfig = new SwaggerConfiguration().openAPI(oas).prettyPrint(true)
+ .resourcePackages(Stream.of("org.onap.so.adapters.catalogdb.rest").collect(Collectors.toSet()));
+
+ try {
+ new JaxrsOpenApiContextBuilder().application(this).openApiConfiguration(oasConfig).buildContext(true);
+ } catch (OpenApiConfigurationException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
}
}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceRestImpl.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceRestImpl.java
index 6f556edfa1..bc4d0064d0 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceRestImpl.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceRestImpl.java
@@ -34,11 +34,17 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.google.common.base.Strings;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
+import io.swagger.v3.oas.annotations.OpenAPIDefinition;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.info.Info;
+import io.swagger.v3.oas.annotations.media.ArraySchema;
+import io.swagger.v3.oas.annotations.media.Content;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
-@Api(value = "/v1", tags = "model")
+
+@OpenAPIDefinition(info = @Info(title = "/v1", description = "model"))
@Path("/v1/services")
@Component
public class ServiceRestImpl {
@@ -63,14 +69,15 @@ public class ServiceRestImpl {
}
@GET
- @ApiOperation(value = "Find Service Models", response = Service.class, responseContainer = "List")
+ @Operation(description = "Find Service Models", responses = @ApiResponse(
+ content = @Content(array = @ArraySchema(schema = @Schema(implementation = Service.class)))))
@Produces({MediaType.APPLICATION_JSON})
@Transactional(readOnly = true)
public List<Service> queryServices(
- @ApiParam(value = "modelName", required = false) @QueryParam("modelName") String modelName,
- @ApiParam(value = "distributionStatus",
+ @Parameter(description = "modelName", required = false) @QueryParam("modelName") String modelName,
+ @Parameter(description = "distributionStatus",
required = false) @QueryParam("distributionStatus") String distributionStatus,
- @ApiParam(value = "depth", required = false) @QueryParam("depth") int depth) {
+ @Parameter(description = "depth", required = false) @QueryParam("depth") int depth) {
List<Service> services = new ArrayList<>();
List<org.onap.so.db.catalog.beans.Service> serviceFromDB = new ArrayList<>();
if (!Strings.isNullOrEmpty(modelName) && !Strings.isNullOrEmpty(distributionStatus)) {
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/VnfRestImpl.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/VnfRestImpl.java
index a3e3a8ee53..9202fd21d4 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/VnfRestImpl.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/VnfRestImpl.java
@@ -34,14 +34,20 @@ import javax.ws.rs.core.Response;
import org.onap.so.db.catalog.beans.VnfResourceCustomization;
import org.onap.so.db.catalog.data.repository.ServiceRepository;
import org.onap.so.db.catalog.data.repository.VnfCustomizationRepository;
+import org.onap.so.rest.catalog.beans.Service;
import org.onap.so.rest.catalog.beans.Vnf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
+import io.swagger.v3.oas.annotations.OpenAPIDefinition;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.info.Info;
+import io.swagger.v3.oas.annotations.media.ArraySchema;
+import io.swagger.v3.oas.annotations.media.Content;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
-@Api(value = "/v1/services/{modelUUID}/vnfs", tags = "model")
+@OpenAPIDefinition(info = @Info(title = "/v1/services/{modelUUID}/vnfs", description = "model"))
@Path("/v1/services/{modelUUID}/vnfs")
@Component
public class VnfRestImpl {
@@ -59,7 +65,8 @@ public class VnfRestImpl {
private VnfCustomizationRepository vnfCustRepo;
@GET
- @ApiOperation(value = "Find a VNF model contained within a service", response = Vnf.class)
+ @Operation(description = "Find a VNF model contained within a service", responses = @ApiResponse(
+ content = @Content(array = @ArraySchema(schema = @Schema(implementation = Vnf.class)))))
@Path("/{modelCustomizationUUID}")
@Produces({MediaType.APPLICATION_JSON})
@Transactional(readOnly = true)
@@ -82,7 +89,8 @@ public class VnfRestImpl {
}
@PUT
- @ApiOperation(value = "Update a VNF model contained within a service", response = Vnf.class)
+ @Operation(description = "Update a VNF model contained within a service", responses = @ApiResponse(
+ content = @Content(array = @ArraySchema(schema = @Schema(implementation = Vnf.class)))))
@Path("/{modelCustomizationUUID}")
@Produces({MediaType.APPLICATION_JSON})
@Transactional