summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cps/cps-rest/pom.xml11
-rw-r--r--cps/cps-rest/src/main/java/org/onap/cps/rest/config/JerseyConfig.java24
-rw-r--r--cps/cps-rest/src/main/resources/openapi-configuration.json28
-rw-r--r--cps/cps-service/pom.xml12
-rw-r--r--cps/pom.xml13
5 files changed, 73 insertions, 15 deletions
diff --git a/cps/cps-rest/pom.xml b/cps/cps-rest/pom.xml
index bd9be8dfde..2b4cbb8940 100644
--- a/cps/cps-rest/pom.xml
+++ b/cps/cps-rest/pom.xml
@@ -44,6 +44,17 @@
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
+ <dependency>
+ <groupId>io.swagger.core.v3</groupId>
+ <artifactId>swagger-annotations</artifactId>
+ <version>${swagger.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>io.swagger.core.v3</groupId>
+ <artifactId>swagger-jaxrs2</artifactId>
+ <version>${swagger.version}</version>
+ </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
diff --git a/cps/cps-rest/src/main/java/org/onap/cps/rest/config/JerseyConfig.java b/cps/cps-rest/src/main/java/org/onap/cps/rest/config/JerseyConfig.java
index 44487fe068..ea273986c8 100644
--- a/cps/cps-rest/src/main/java/org/onap/cps/rest/config/JerseyConfig.java
+++ b/cps/cps-rest/src/main/java/org/onap/cps/rest/config/JerseyConfig.java
@@ -20,20 +20,38 @@
package org.onap.cps.rest.config;
+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 javax.annotation.PostConstruct;
import javax.ws.rs.ApplicationPath;
import org.glassfish.jersey.media.multipart.MultiPartFeature;
import org.glassfish.jersey.server.ResourceConfig;
-import org.onap.cps.rest.controller.RestController;
import org.springframework.context.annotation.Configuration;
@Configuration
@ApplicationPath("/api/v1")
public class JerseyConfig extends ResourceConfig {
+ /**
+ * This method is used to setup Jersey related configuration.
+ */
@PostConstruct
public void init() {
- register(RestController.class);
register(MultiPartFeature.class);
+ register(OpenApiResource.class);
+ register(AcceptHeaderOpenApiResource.class);
+
+ packages("org.onap.cps.rest.controller");
+ configureSwagger();
+ }
+
+ private void configureSwagger() {
+ try {
+ new JaxrsOpenApiContextBuilder<>().buildContext(true).read();
+ } catch (final OpenApiConfigurationException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
}
-} \ No newline at end of file
+}
diff --git a/cps/cps-rest/src/main/resources/openapi-configuration.json b/cps/cps-rest/src/main/resources/openapi-configuration.json
new file mode 100644
index 0000000000..ad5998feb7
--- /dev/null
+++ b/cps/cps-rest/src/main/resources/openapi-configuration.json
@@ -0,0 +1,28 @@
+{
+ "resourcePackages": [
+ "org.onap.cps.rest.controller"
+ ],
+ "prettyPrint": true,
+ "cacheTTL": 0,
+ "openAPI": {
+ "info": {
+ "title": "ONAP Open API v3 CPS Spec",
+ "description": "The API Description may be multiline, and GitHub Flavored Markdown, GFM syntax, can be used for rich text representation.",
+ "x-logo": {
+ "url": "logo.png"
+ },
+ "contact": {
+ "name": "ONAP",
+ "url": "https://onap.readthedocs.io",
+ "email": "onap-discuss@lists.onap.org"
+ },
+ "license": {
+ "name": "Apache 2.0",
+ "url": "http://www.apache.org/licenses/LICENSE-2.0"
+ },
+ "version": "1.2.34",
+ "x-planned-retirement-date": "202207",
+ "x-component": "Modeling"
+ }
+ }
+}
diff --git a/cps/cps-service/pom.xml b/cps/cps-service/pom.xml
index a59376c20f..731873420c 100644
--- a/cps/cps-service/pom.xml
+++ b/cps/cps-service/pom.xml
@@ -14,26 +14,26 @@
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-parser-api</artifactId>
- <version>${org.opendaylight.yangtools.version}</version>
+ <version>${yangtools.version}</version>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-parser-impl</artifactId>
- <version>${org.opendaylight.yangtools.version}</version>
+ <version>${yangtools.version}</version>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-model-util</artifactId>
- <version>${org.opendaylight.yangtools.version}</version>
+ <version>${yangtools.version}</version>
</dependency>
<dependency>
<!-- required for processing yang data in json format -->
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-data-codec-gson</artifactId>
- <version>${org.opendaylight.yangtools.version}</version>
+ <version>${yangtools.version}</version>
</dependency>
<dependency>
@@ -64,13 +64,13 @@
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
- <version>${version.groovy}</version>
+ <version>${groovy.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
- <version>${version.spock-core}</version>
+ <version>${spock-core.version}</version>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/cps/pom.xml b/cps/pom.xml
index 5435c4a4a6..d81ee9e08e 100644
--- a/cps/pom.xml
+++ b/cps/pom.xml
@@ -19,12 +19,13 @@
</organization>
<properties>
- <version.java.compiler>11</version.java.compiler>
+ <java.version>11</java.version>
<springboot.version>2.3.3.RELEASE</springboot.version>
<oparent.version>3.1.0</oparent.version>
- <org.opendaylight.yangtools.version>5.0.5</org.opendaylight.yangtools.version>
- <version.groovy>3.0.6</version.groovy>
- <version.spock-core>2.0-M2-groovy-3.0</version.spock-core>
+ <yangtools.version>5.0.6</yangtools.version>
+ <swagger.version>2.1.4</swagger.version>
+ <groovy.version>3.0.6</groovy.version>
+ <spock-core.version>2.0-M2-groovy-3.0</spock-core.version>
</properties>
<dependencyManagement>
@@ -67,8 +68,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
- <source>${version.java.compiler}</source>
- <target>${version.java.compiler}</target>
+ <source>${java.version}</source>
+ <target>${java.version}</target>
</configuration>
</plugin>