From 8b98eb93f7b0c4dc1885a70db3ea8dd7bb84cc77 Mon Sep 17 00:00:00 2001 From: "BOSLET, CORY" Date: Mon, 15 Mar 2021 11:25:54 -0400 Subject: update swagger to v3 open api version Upgraded all projects and services to use the new v3 swagger, discontinued use of old swagger. Updated unit test to account for swagger change and removed apis Issue-ID: SO-3587 Signed-off-by: AT&T Open Source Change-Id: Iddcfe92f8ab240691f92ce2bf23e1ab2ad159780 --- .../so/adapters/cloudregion/CloudRegionRestV1.java | 48 +++++++++++----------- .../so/adapters/openstack/CXFConfiguration.java | 26 ++++++------ 2 files changed, 38 insertions(+), 36 deletions(-) (limited to 'adapters/mso-openstack-adapters/src/main/java') diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/cloudregion/CloudRegionRestV1.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/cloudregion/CloudRegionRestV1.java index 6cf42e1433..49cc0190db 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/cloudregion/CloudRegionRestV1.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/cloudregion/CloudRegionRestV1.java @@ -39,15 +39,18 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; +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.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; @Path("/v1/cloud-region") -@Api(value = "/v1/cloud-region", description = "root of cloud region adapter") +@OpenAPIDefinition(info = @Info(title = "/v1/cloud-region", description = "root of cloud region adapter")) @Component public class CloudRegionRestV1 { private static Logger logger = LoggerFactory.getLogger(CloudRegionRestV1.class); @@ -58,13 +61,12 @@ public class CloudRegionRestV1 { @POST @Consumes({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "CreateCloudRegion", response = Response.class, - notes = "Create a cloud site in MSO and Region In AAI") - @ApiResponses({@ApiResponse(code = 201, message = "Cloud Region has been created"), - @ApiResponse(code = 500, message = "Create Cloud Region has failed")}) + @Operation(description = "CreateCloudRegion", summary = "Create a cloud site in MSO and Region In AAI") + @ApiResponses({@ApiResponse(responseCode = "201", description = "Cloud Region has been created"), + @ApiResponse(responseCode = "500", description = "Create Cloud Region has failed")}) public Response createCloudRegion( - @ApiParam(value = "cloud-region-id", required = true) @PathParam("cloud-region-id") String cloudRegionId, - @ApiParam(value = "CloudSite", required = true) final CloudSite cloudSite) { + @Parameter(name = "cloud-region-id", required = true) @PathParam("cloud-region-id") String cloudRegionId, + @Parameter(name = "CloudSite", required = true) final CloudSite cloudSite) { cloudRestImpl.createCloudRegion(cloudSite); return Response.status(HttpStatus.SC_CREATED).build(); } @@ -73,12 +75,12 @@ public class CloudRegionRestV1 { @Path("{cloud-region-id}/{cloud-owner}") @Consumes({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "CreateCloudRegion", response = Response.class, notes = "Delete an cloud Region in SO") - @ApiResponses({@ApiResponse(code = 204, message = "cloud Region has been deleted"), - @ApiResponse(code = 500, message = "Cloud Region delete has failed")}) + @Operation(description = "CreateCloudRegion", summary = "Delete an cloud Region in SO") + @ApiResponses({@ApiResponse(responseCode = "204", description = "cloud Region has been deleted"), + @ApiResponse(responseCode = "500", description = "Cloud Region delete has failed")}) public Response deleteCloudRegion( - @ApiParam(value = "cloud-region-id", required = true) @PathParam("cloud-region-id") String cloudRegionId, - @ApiParam(value = "cloud-owner", required = true) @PathParam("cloud-owner") String cloudOwner) { + @Parameter(name = "cloud-region-id", required = true) @PathParam("cloud-region-id") String cloudRegionId, + @Parameter(name = "cloud-owner", required = true) @PathParam("cloud-owner") String cloudOwner) { cloudRestImpl.deleteCloudRegion(cloudRegionId); return Response.status(HttpStatus.SC_NO_CONTENT).build(); } @@ -87,13 +89,13 @@ public class CloudRegionRestV1 { @Path("{cloud-region-id}/{cloud-owner}") @Consumes({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "CreateCloudRegion", response = Response.class, notes = "Update an existing Cloud Region") - @ApiResponses({@ApiResponse(code = 200, message = "Cloud Region has been updated"), - @ApiResponse(code = 500, message = "Update Cloud Region has failed examine entity object for details")}) + @Operation(description = "CreateCloudRegion", summary = "Update an existing Cloud Region") + @ApiResponses({@ApiResponse(responseCode = "200", description = "Cloud Region has been updated"), @ApiResponse( + responseCode = "500", description = "Update Cloud Region has failed examine entity object for details")}) public Response updateCloudRegion( - @ApiParam(value = "cloud-region-id", required = true) @PathParam("cloud-region-id") String cloudRegionId, - @ApiParam(value = "cloud-owner", required = true) @PathParam("cloud-owner") String cloudOwner, - @ApiParam(value = "CloudSite", required = true) final CloudSite cloudSite) { + @Parameter(name = "cloud-region-id", required = true) @PathParam("cloud-region-id") String cloudRegionId, + @Parameter(name = "cloud-owner", required = true) @PathParam("cloud-owner") String cloudOwner, + @Parameter(name = "CloudSite", required = true) final CloudSite cloudSite) { cloudRestImpl.updateCloudRegion(cloudSite); return Response.status(HttpStatus.SC_OK).build(); } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/CXFConfiguration.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/CXFConfiguration.java index 1446047ebd..942da2937b 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/CXFConfiguration.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/CXFConfiguration.java @@ -23,13 +23,14 @@ package org.onap.so.adapters.openstack; import java.util.Arrays; +import java.util.HashSet; import javax.xml.ws.Endpoint; import org.apache.cxf.Bus; import org.apache.cxf.bus.spring.SpringBus; import org.apache.cxf.endpoint.Server; import org.apache.cxf.feature.LoggingFeature; import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; -import org.apache.cxf.jaxrs.swagger.Swagger2Feature; +import org.apache.cxf.jaxrs.openapi.OpenApiFeature; import org.apache.cxf.jaxws.EndpointImpl; import org.apache.cxf.transport.servlet.CXFServlet; import org.onap.so.adapters.cloudregion.CloudRegionRestV1; @@ -101,18 +102,17 @@ public class CXFConfiguration { return endpoint.create(); } - @Bean - public Swagger2Feature createSwaggerFeature() { - Swagger2Feature swagger2Feature = new Swagger2Feature(); - swagger2Feature.setPrettyPrint(true); - swagger2Feature.setTitle("SO Orchestration Application"); - swagger2Feature.setContact("The ONAP SO team"); - swagger2Feature.setDescription("This project is the SO Orchestration Engine"); - swagger2Feature.setVersion("1.0.0"); - swagger2Feature.setResourcePackage( - "org.onap.so.adapters.network,org.onap.so.adapters.tenant,org.onap.so.adapters.vnf"); - swagger2Feature.setScan(true); - return swagger2Feature; + public OpenApiFeature createSwaggerFeature() { + OpenApiFeature openApiFeature = new OpenApiFeature(); + openApiFeature.setPrettyPrint(true); + openApiFeature.setTitle("SO Orchestration Application"); + openApiFeature.setContactName("The ONAP SO team"); + openApiFeature.setDescription("This project is the SO Orchestration Engine"); + openApiFeature.setVersion("1.0.0"); + openApiFeature.setResourcePackages( + new HashSet(Arrays.asList("org.onap.so.adapters.network,org.onap.so.adapters.vnf"))); + openApiFeature.setScan(true); + return openApiFeature; } } -- cgit 1.2.3-korg