diff options
author | Murali-P <murali.p@huawei.com> | 2018-04-25 11:23:07 +0530 |
---|---|---|
committer | Murali-P <murali.p@huawei.com> | 2018-04-25 11:55:01 +0530 |
commit | e9ff86cbd26db4a699a17d7d60727334e219b6d0 (patch) | |
tree | f1426c055855e65ddfa96b6638d67596fc52c024 | |
parent | 5ef837efbf16ed70e38cdeb75a8761e0c5f42326 (diff) |
Enable swagger documentation for API
Swagger UI and Swagger docs
Issue-ID: VNFSDK-157
Change-Id: I9aeda5c364741c975a8d0d8b788a22c9d3f5f39f
Signed-off-by: Murali-P <murali.p@huawei.com>
4 files changed, 303 insertions, 196 deletions
diff --git a/vnfmarket-be/deployment/zip/pom.xml b/vnfmarket-be/deployment/zip/pom.xml index e0b4e7e9..d2f562f7 100644 --- a/vnfmarket-be/deployment/zip/pom.xml +++ b/vnfmarket-be/deployment/zip/pom.xml @@ -69,6 +69,7 @@ ant.mkdir(dir: "${deployUnzip}/webapps/ROOT") ant.mkdir(dir: "${deployUnzip}/webapps/onapui") + ant.mkdir(dir: "${deployUnzip}/webapps/apidocs") ant.copy(todir: "${deployUnzip}") { fileset(dir: "${basedir}/src/main/release"){ @@ -83,6 +84,13 @@ ant.copy(todir: "${deployUnzip}/webapps/onapui") { fileset(dir: "${project.build.directory}/../../../../vnfmarket/src/main/webapp") } + + ant.copy(todir: "${deployUnzip}/webapps/apidocs") { + fileset(dir: "${project.build.directory}/../../../vnf-sdk-marketplace/target/swagger-ui-master/dist") { + exclude(name: "index.html") + } + fileset(dir: "${project.build.directory}/../../../vnf-sdk-marketplace/src/main/webapp/apidocs") + } ant.zip(destfile: "${deployFolder}/${outfileName}") { fileset(dir: "${deployUnzip}") diff --git a/vnfmarket-be/vnf-sdk-marketplace/pom.xml b/vnfmarket-be/vnf-sdk-marketplace/pom.xml index f78b00b8..eddf022c 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/pom.xml +++ b/vnfmarket-be/vnf-sdk-marketplace/pom.xml @@ -1,206 +1,227 @@ <?xml version="1.0"?> <!-- Copyright 2017 Huawei Technologies Co., Ltd. Licensed under the Apache - License, Version 2.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed - under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - OR CONDITIONS OF ANY KIND, either express or implied. See the License for - the specific language governing permissions and limitations under the License. --> + License, Version 2.0 (the "License"); you may not use this file except in + compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed + under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + OR CONDITIONS OF ANY KIND, either express or implied. See the License for + the specific language governing permissions and limitations under the License. --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <parent> - <groupId>org.onap.vnfsdk.refrepo</groupId> - <artifactId>vnf-sdk-marketplace-core-parent</artifactId> - <version>1.1.0</version> - </parent> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.onap.vnfsdk.refrepo</groupId> + <artifactId>vnf-sdk-marketplace-core-parent</artifactId> + <version>1.1.0</version> + </parent> - <modelVersion>4.0.0</modelVersion> - <artifactId>vnf-sdk-marketplace</artifactId> - <version>1.1.0</version> - <name>vnf-sdk-marketplace/vnf-sdk-marketplace</name> - <packaging>war</packaging> + <modelVersion>4.0.0</modelVersion> + <artifactId>vnf-sdk-marketplace</artifactId> + <version>1.1.0</version> + <name>vnf-sdk-marketplace/vnf-sdk-marketplace</name> + <packaging>war</packaging> - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <cxf.version>3.2.3</cxf.version> - <!-- slf4j.version>1.6.1</slf4j.version> --> - <maven.test.skip>false</maven.test.skip> - <maven.test.failure.ignore>false</maven.test.failure.ignore> - </properties> + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <cxf.version>3.2.3</cxf.version> + <!-- slf4j.version>1.6.1</slf4j.version> --> + <maven.test.skip>false</maven.test.skip> + <maven.test.failure.ignore>false</maven.test.failure.ignore> + <swagger-ui.version>3.12.0</swagger-ui.version> + </properties> - <dependencies> - <dependency> - <groupId>org.apache.cxf</groupId> - <artifactId>cxf-rt-frontend-jaxrs</artifactId> - <version>${cxf.version}</version> - </dependency> - <dependency> - <groupId>org.apache.cxf</groupId> - <artifactId>cxf-rt-rs-client</artifactId> - <version>${cxf.version}</version> - </dependency> - <dependency> - <groupId>org.apache.cxf</groupId> - <artifactId>cxf-rt-transports-http-hc</artifactId> - <version>${cxf.version}</version> - </dependency> - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - <version>1.2.16</version> - </dependency> - <dependency> - <groupId>io.dropwizard</groupId> - <artifactId>dropwizard-assets</artifactId> - <version>1.2.4</version> - </dependency> - <dependency> - <groupId>org.eclipse.persistence</groupId> - <artifactId>javax.persistence</artifactId> - <version>2.1.0</version> - </dependency> + <dependencies> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxrs</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-rs-client</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-transports-http-hc</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <version>1.2.16</version> + </dependency> - <dependency> - <groupId>io.swagger</groupId> - <artifactId>swagger-jersey2-jaxrs</artifactId> - <version>1.5.18</version> - </dependency> - <!-- jersey --> + <dependency> + <groupId>org.eclipse.persistence</groupId> + <artifactId>javax.persistence</artifactId> + <version>2.1.0</version> + </dependency> + + <dependency> + <groupId>io.swagger</groupId> + <artifactId>swagger-jersey2-jaxrs</artifactId> + <version>1.5.19</version> + </dependency> + <!-- jersey --> + + <dependency> + <groupId>org.glassfish.jersey.media</groupId> + <artifactId>jersey-media-multipart</artifactId> + <version>2.25.1</version> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.containers</groupId> + <artifactId>jersey-container-jetty-servlet</artifactId> + <version>2.25.1</version> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.bundles.repackaged</groupId> + <artifactId>jersey-guava</artifactId> + <version>2.25.1</version> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpmime</artifactId> + <version>4.5.3</version> + </dependency> + <!-- consumer --> + <dependency> + <groupId>com.eclipsesource.jaxrs</groupId> + <artifactId>consumer</artifactId> + <exclusions> + <exclusion> + <groupId>com.eclipsesource.jaxrs</groupId> + <artifactId>jersey-all</artifactId> + </exclusion> + </exclusions> + <version>5.0</version> + </dependency> + <!-- gson --> + <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + <version>2.8.2</version> + </dependency> + <dependency> + <groupId>org.postgresql</groupId> + <artifactId>postgresql</artifactId> + <version>42.1.1</version> + </dependency> + <dependency> + <groupId>org.mybatis</groupId> + <artifactId>mybatis</artifactId> + <version>3.2.7</version> + </dependency> + <!-- UT --> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.12</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.powermock</groupId> + <artifactId>powermock-module-junit4</artifactId> + <version>1.4.10</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.powermock</groupId> + <artifactId>powermock-api-mockito</artifactId> + <version>1.4.10</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.jmockit</groupId> + <artifactId>jmockit</artifactId> + <version>1.19</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.jmockit</groupId> + <artifactId>jmockit-coverage</artifactId> + <version>1.19</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.ant</groupId> + <artifactId>ant</artifactId> + <version>1.8.2</version> + <scope>test</scope> + </dependency> - <dependency> - <groupId>org.glassfish.jersey.media</groupId> - <artifactId>jersey-media-multipart</artifactId> - <version>2.25.1</version> - </dependency> - <dependency> - <groupId>org.glassfish.jersey.containers</groupId> - <artifactId>jersey-container-jetty-servlet</artifactId> - <version>2.25.1</version> - </dependency> - <dependency> - <groupId>org.apache.httpcomponents</groupId> - <artifactId>httpmime</artifactId> - <version>4.5.3</version> - </dependency> - <!-- consumer --> - <dependency> - <groupId>com.eclipsesource.jaxrs</groupId> - <artifactId>consumer</artifactId> - <exclusions> - <exclusion> - <groupId>com.eclipsesource.jaxrs</groupId> - <artifactId>jersey-all</artifactId> - </exclusion> - </exclusions> - <version>5.0</version> - </dependency> - <!-- gson --> - <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> - <version>2.3.1</version> - </dependency> - <dependency> - <groupId>org.postgresql</groupId> - <artifactId>postgresql</artifactId> - <version>42.1.1</version> - </dependency> - <dependency> - <groupId>org.mybatis</groupId> - <artifactId>mybatis</artifactId> - <version>3.2.7</version> - </dependency> - <!-- UT --> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.12</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.powermock</groupId> - <artifactId>powermock-module-junit4</artifactId> - <version>1.4.10</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.powermock</groupId> - <artifactId>powermock-api-mockito</artifactId> - <version>1.4.10</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.jmockit</groupId> - <artifactId>jmockit</artifactId> - <version>1.19</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.jmockit</groupId> - <artifactId>jmockit-coverage</artifactId> - <version>1.19</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.ant</groupId> - <artifactId>ant</artifactId> - <version>1.8.2</version> - <scope>test</scope> - </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-io</artifactId> + <version>1.3.2</version> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>2.4</version> + </dependency> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + <version>20.0</version> + </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-io</artifactId> - <version>1.3.2</version> - </dependency> - <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - <version>2.4</version> - </dependency> - <dependency> - <groupId>org.glassfish.jersey.bundles.repackaged</groupId> - <artifactId>jersey-guava</artifactId> - <version>2.6</version> - </dependency> - <!-- UT end --> - <dependency> - <groupId>org.onap.vnfsdk.validation</groupId> - <artifactId>validation-csar</artifactId> - <version>1.1.1</version> - </dependency> - </dependencies> - <profiles> - <profile> - <id>all-tests</id> - <properties> - <build.profile.id>all-tests</build.profile.id> - <skip.unit.tests>false</skip.unit.tests> - </properties> - </profile> - </profiles> - <build> - <finalName>ROOT</finalName> - <plugins> - <!-- Used for unit tests --> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <version>2.20</version> - <configuration> - <forkMode>always</forkMode> - <argLine>${surefireArgLine}</argLine> - <skip>${maven.test.skip}</skip> - <testFailureIgnore>${maven.test.failure.ignore}</testFailureIgnore> - <!-- Excludes integration tests when unit tests are run. --> - <excludes> - <exclude>**/IT*.java</exclude> - </excludes> - </configuration> - </plugin> - </plugins> - </build> + <!-- UT end --> + <dependency> + <groupId>org.onap.vnfsdk.validation</groupId> + <artifactId>validation-csar</artifactId> + <version>1.1.1</version> + </dependency> + </dependencies> + <profiles> + <profile> + <id>all-tests</id> + <properties> + <build.profile.id>all-tests</build.profile.id> + <skip.unit.tests>false</skip.unit.tests> + </properties> + </profile> + </profiles> + <build> + <finalName>ROOT</finalName> + <plugins> + <!-- Used for unit tests --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.20</version> + <configuration> + <forkMode>always</forkMode> + <argLine>${surefireArgLine}</argLine> + <skip>${maven.test.skip}</skip> + <testFailureIgnore>${maven.test.failure.ignore}</testFailureIgnore> + <!-- Excludes integration tests when unit tests are run. --> + <excludes> + <exclude>**/IT*.java</exclude> + </excludes> + </configuration> + </plugin> + <plugin> + <groupId>com.googlecode.maven-download-plugin</groupId> + <artifactId>download-maven-plugin</artifactId> + <version>1.2.1</version> + <executions> + <execution> + <id>swagger-ui</id> + <goals> + <goal>wget</goal> + </goals> + <configuration> + <url>https://github.com/swagger-api/swagger-ui/archive/master.tar.gz</url> + <unpack>true</unpack> + <outputDirectory>${project.build.directory}</outputDirectory> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> </project> diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/webapp/WEB-INF/web.xml b/vnfmarket-be/vnf-sdk-marketplace/src/main/webapp/WEB-INF/web.xml index 8dc5575c..cf229269 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/webapp/WEB-INF/web.xml +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/webapp/WEB-INF/web.xml @@ -9,17 +9,34 @@ <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class> <init-param> <param-name>jersey.config.server.provider.packages</param-name> - <param-value>org.onap.vnfsdk.marketplace.resource</param-value> + <param-value>io.swagger.jaxrs.listing, + org.onap.vnfsdk.marketplace.resource + </param-value> </init-param> <init-param> <param-name>jersey.config.server.provider.classnames</param-name> <param-value>org.glassfish.jersey.media.multipart.MultiPartFeature</param-value> - </init-param> + </init-param> + <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Jersey RESTful Application</servlet-name> <url-pattern>/onapapi/vnfsdk-marketplace/v1/*</url-pattern> - </servlet-mapping> + </servlet-mapping> + + <servlet> + <servlet-name>Jersey2Config</servlet-name> + <servlet-class>io.swagger.jersey.config.JerseyJaxrsConfig</servlet-class> + <init-param> + <param-name>api.version</param-name> + <param-value>1.0.0</param-value> + </init-param> + <init-param> + <param-name>swagger.api.basepath</param-name> + <param-value>http://localhost:8702//onapapi/vnfsdk-marketplace/v1</param-value> + </init-param> + <load-on-startup>2</load-on-startup> + </servlet> <filter> <filter-name>CorsFilter</filter-name> diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/webapp/apidocs/index.html b/vnfmarket-be/vnf-sdk-marketplace/src/main/webapp/apidocs/index.html new file mode 100644 index 00000000..47f9c8ac --- /dev/null +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/webapp/apidocs/index.html @@ -0,0 +1,61 @@ +<!-- HTML for static distribution bundle build --> +<!DOCTYPE html> +<html lang="en"> + <head> + <meta charset="UTF-8"> + <title>Swagger UI</title> + <link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Source+Code+Pro:300,600|Titillium+Web:400,600,700" rel="stylesheet"> + <link rel="stylesheet" type="text/css" href="./swagger-ui.css" > + <link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" /> + <link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" /> + <style> + html + { + box-sizing: border-box; + overflow: -moz-scrollbars-vertical; + overflow-y: scroll; + } + + *, + *:before, + *:after + { + box-sizing: inherit; + } + + body + { + margin:0; + background: #fafafa; + } + </style> + </head> + + <body> + <div id="swagger-ui"></div> + + <script src="./swagger-ui-bundle.js"> </script> + <script src="./swagger-ui-standalone-preset.js"> </script> + <script> + window.onload = function() { + + // Build a system + const ui = SwaggerUIBundle({ + url: "http://localhost:8702/onapapi/vnfsdk-marketplace/v1/swagger.json", + dom_id: '#swagger-ui', + deepLinking: true, + presets: [ + SwaggerUIBundle.presets.apis, + SwaggerUIStandalonePreset + ], + plugins: [ + SwaggerUIBundle.plugins.DownloadUrl + ], + layout: "StandaloneLayout" + }) + + window.ui = ui + } + </script> + </body> +</html> |