diff options
Diffstat (limited to 'asdc-controller')
3 files changed, 35 insertions, 25 deletions
diff --git a/asdc-controller/pom.xml b/asdc-controller/pom.xml index 4d17f5510a..0eef01d0cc 100644 --- a/asdc-controller/pom.xml +++ b/asdc-controller/pom.xml @@ -190,8 +190,8 @@ </build> <dependencies> <dependency> - <groupId>io.swagger</groupId> - <artifactId>swagger-jersey2-jaxrs</artifactId> + <groupId>io.swagger.core.v3</groupId> + <artifactId>swagger-jaxrs2</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/JerseyConfiguration.java b/asdc-controller/src/main/java/org/onap/so/asdc/JerseyConfiguration.java index 22265a0cc6..9929262dbc 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/JerseyConfiguration.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/JerseyConfiguration.java @@ -20,41 +20,51 @@ package org.onap.so.asdc; +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; import org.onap.so.asdc.client.test.rest.ASDCRestInterface; -import org.springframework.beans.factory.annotation.Autowired; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Configuration; -import org.springframework.core.env.Environment; -import io.swagger.jaxrs.config.BeanConfig; -import io.swagger.jaxrs.listing.ApiListingResource; -import io.swagger.jaxrs.listing.SwaggerSerializers; +import io.swagger.v3.jaxrs2.SwaggerSerializers; +import io.swagger.v3.jaxrs2.integration.JaxrsOpenApiContextBuilder; +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("/test") public class JerseyConfiguration extends ResourceConfig { - private Environment environment; - - @Autowired - public JerseyConfiguration(final Environment environment) { - this.environment = environment; - } + private static final Logger logger = LoggerFactory.getLogger(JerseyConfiguration.class); @PostConstruct public void setUp() { register(ASDCRestInterface.class); - register(ApiListingResource.class); + register(OpenApiResource.class); register(SwaggerSerializers.class); - final BeanConfig beanConfig = new BeanConfig(); - beanConfig.setVersion("1.0.2"); - beanConfig.setSchemes(new String[] {"http"}); - beanConfig.setHost("localhost:" + environment.getProperty("server.port")); - beanConfig.setBasePath("/mso"); - beanConfig.setResourcePackage("org.onap.so.apihandlerinfra"); - beanConfig.setPrettyPrint(true); - beanConfig.setScan(true); + final OpenAPI openApi = new OpenAPI(); + Info info = new Info(); + info.setVersion("1.0.2"); + info.setTitle("Swagger asdc-controller code"); + openApi.setInfo(info); + + SwaggerConfiguration swaggerConfig = new SwaggerConfiguration().openAPI(openApi).prettyPrint(true) + .resourcePackages(Stream.of("org.onap.so.asdc").collect(Collectors.toSet())); + + try { + JaxrsOpenApiContextBuilder jaxrsConfig = new JaxrsOpenApiContextBuilder(); + jaxrsConfig.application(this).openApiConfiguration(swaggerConfig).buildContext(true); + } catch (OpenApiConfigurationException e) { + logger.error("Error during jersey configuration", e); + throw new RuntimeException(e.getMessage(), e); + } + } } diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java index bf2b8ad7bc..556e5b910f 100644 --- a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java +++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java @@ -262,7 +262,7 @@ public class ASDCControllerITTest extends BaseTest { pnfCustomization.getBlueprintName()); assertEquals("cds blueprint version(sdnc_model_version property)", "v1.4.0", pnfCustomization.getBlueprintVersion()); - assertTrue("skip post instantiation configuration", pnfCustomization.isSkipPostInstConf()); + assertTrue("skip post instantiation configuration", pnfCustomization.getSkipPostInstConf()); assertEquals("controller actor", "SO-REF-DATA", pnfCustomization.getControllerActor()); /** @@ -533,7 +533,7 @@ public class ASDCControllerITTest extends BaseTest { assertEquals("cds blueprint version(sdnc_model_version property)", "1.0.0", pnfCustomization.getBlueprintVersion()); assertEquals("default software version", "4.0.0", pnfCustomization.getDefaultSoftwareVersion()); - assertTrue("skip post instantiation configuration", pnfCustomization.isSkipPostInstConf()); + assertTrue("skip post instantiation configuration", pnfCustomization.getSkipPostInstConf()); assertEquals("controller actor", "SO-REF-DATA", pnfCustomization.getControllerActor()); /** @@ -643,7 +643,7 @@ public class ASDCControllerITTest extends BaseTest { assertEquals("cds blueprint version(sdnc_model_version property)", "1.0.0", pnfCustomization.getBlueprintVersion()); assertEquals("default software version", "foo-123", pnfCustomization.getDefaultSoftwareVersion()); - assertTrue("skip post instantiation configuration", pnfCustomization.isSkipPostInstConf()); + assertTrue("skip post instantiation configuration", pnfCustomization.getSkipPostInstConf()); assertEquals("controller actor", "SO-REF-DATA", pnfCustomization.getControllerActor()); /** |