summaryrefslogtreecommitdiffstats
path: root/asdc-controller/src
diff options
context:
space:
mode:
authorBOSLET, CORY <cory.boslet@att.com>2021-03-15 11:25:54 -0400
committerAT&T Open Source <g22940@att.com>2021-03-15 11:25:54 -0400
commit8b98eb93f7b0c4dc1885a70db3ea8dd7bb84cc77 (patch)
tree9aabba6929b28e0dc31d2e8e46b08c2ed0dafdbf /asdc-controller/src
parent42218d946ea8a87ae4dccac3fd6b8dbeafd22c37 (diff)
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 <g22940@att.com> Change-Id: Iddcfe92f8ab240691f92ce2bf23e1ab2ad159780
Diffstat (limited to 'asdc-controller/src')
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/JerseyConfiguration.java50
1 files changed, 30 insertions, 20 deletions
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);
+ }
+
}
}