aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-catalog-db-adapter/pom.xml19
-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
4 files changed, 69 insertions, 28 deletions
diff --git a/adapters/mso-catalog-db-adapter/pom.xml b/adapters/mso-catalog-db-adapter/pom.xml
index 9ec98cf96c..a51aa66afa 100644
--- a/adapters/mso-catalog-db-adapter/pom.xml
+++ b/adapters/mso-catalog-db-adapter/pom.xml
@@ -14,6 +14,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
+ <swagger.version>2.0.8</swagger.version>
</properties>
<build>
<plugins>
@@ -143,10 +144,22 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.dataformat</groupId>
+ <artifactId>jackson-dataformat-yaml</artifactId>
+ <version>2.9.9</version>
+ </dependency>
+
+ <dependency>
+ <groupId>io.swagger.core.v3</groupId>
+ <artifactId>swagger-annotations</artifactId>
+ <version>${swagger.version}</version>
+ </dependency>
<dependency>
- <groupId>io.swagger</groupId>
- <artifactId>swagger-jersey2-jaxrs</artifactId>
- <version>1.5.16</version>
+ <groupId>io.swagger.core.v3</groupId>
+ <artifactId>swagger-jaxrs2</artifactId>
+ <version>2.0.6</version>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
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