Adding swagger codegen
[cps.git] / cps / cps-rest / pom.xml
index 253c29c..3cecc5f 100644 (file)
@@ -1,6 +1,6 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0"\r
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">\r
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">\r
     <modelVersion>4.0.0</modelVersion>\r
     <artifactId>cps-rest</artifactId>\r
     <parent>\r
             <artifactId>jersey-media-multipart</artifactId>\r
         </dependency>\r
 \r
+        <dependency>\r
+            <groupId>org.springframework</groupId>\r
+            <artifactId>spring-webmvc</artifactId>\r
+        </dependency>\r
+\r
         <dependency>\r
             <groupId>org.springframework.boot</groupId>\r
             <artifactId>spring-boot-starter-jersey</artifactId>\r
         </dependency>\r
 \r
         <dependency>\r
-            <groupId>org.springframework.boot</groupId>\r
-            <artifactId>spring-boot-starter-web</artifactId>\r
-        </dependency>\r
-\r
-        <dependency>\r
-            <groupId>io.springfox</groupId>\r
-            <artifactId>springfox-swagger2</artifactId>\r
-            <version>2.9.2</version>\r
+            <groupId>io.swagger.core.v3</groupId>\r
+            <artifactId>swagger-annotations</artifactId>\r
+            <version>${swagger.version}</version>\r
         </dependency>\r
 \r
         <dependency>\r
-            <groupId>io.springfox</groupId>\r
-            <artifactId>springfox-swagger-ui</artifactId>\r
-            <version>2.9.2</version>\r
+            <groupId>io.swagger.core.v3</groupId>\r
+            <artifactId>swagger-jaxrs2</artifactId>\r
+            <version>${swagger.version}</version>\r
         </dependency>\r
 \r
         <dependency>\r
                 </exclusion>\r
             </exclusions>\r
         </dependency>\r
+\r
+        <!--   Used by the generated API     -->\r
+        <dependency>\r
+            <groupId>org.apache.cxf</groupId>\r
+            <artifactId>cxf-bundle-jaxrs</artifactId>\r
+            <version>${cxf-bundle-jaxrs.version}</version>\r
+        </dependency>\r
+\r
+        <!--   Used by the generated API     -->\r
+        <dependency>\r
+            <groupId>org.apache.cxf</groupId>\r
+            <artifactId>cxf-rt-rs-service-description</artifactId>\r
+            <version>${cxf-rt-rs-service.version}</version>\r
+        </dependency>\r
+\r
     </dependencies>\r
 \r
     <build>\r
                     </execution>\r
                 </executions>\r
             </plugin>\r
+\r
+            <plugin>\r
+                <groupId>io.swagger.codegen.v3</groupId>\r
+                <artifactId>swagger-codegen-maven-plugin</artifactId>\r
+                <version>${swagger-codegen.version}</version>\r
+                <executions>\r
+                    <execution>\r
+                        <goals>\r
+                            <goal>generate</goal>\r
+                        </goals>\r
+                        <configuration>\r
+                            <inputSpec>${project.basedir}/docs/api/swagger/openapi.yml</inputSpec>\r
+                            <invokerPackage>org.onap.cps.rest.controller</invokerPackage>\r
+                            <modelPackage>org.onap.cps.rest.model</modelPackage>\r
+                            <apiPackage>org.onap.cps.rest.controller</apiPackage>\r
+                            <language>jaxrs-cxf</language>\r
+                            <generateSupportingFiles>true</generateSupportingFiles>\r
+                            <configOptions>\r
+                                <sourceFolder>src/gen/java</sourceFolder>\r
+                                <dateLibrary>java8</dateLibrary>\r
+                                <library>jersey2</library>\r
+                                <interfaceOnly>true</interfaceOnly>\r
+                            </configOptions>\r
+                        </configuration>\r
+                    </execution>\r
+                </executions>\r
+            </plugin>\r
+            <plugin>\r
+                <!-- Download Swagger UI webjar. -->\r
+                <groupId>org.apache.maven.plugins</groupId>\r
+                <artifactId>maven-dependency-plugin</artifactId>\r
+                <version>${maven-dependency-plugin.version}</version>\r
+                <executions>\r
+                    <execution>\r
+                        <phase>prepare-package</phase>\r
+                        <goals>\r
+                            <goal>unpack</goal>\r
+                        </goals>\r
+                        <configuration>\r
+                            <artifactItems>\r
+                                <artifactItem>\r
+                                    <groupId>org.webjars</groupId>\r
+                                    <artifactId>swagger-ui</artifactId>\r
+                                    <version>${swagger-ui.version}</version>\r
+                                </artifactItem>\r
+                            </artifactItems>\r
+                            <outputDirectory>\r
+                                ${project.build.directory}/swagger-ui-${swagger-ui.version}\r
+                            </outputDirectory>\r
+                        </configuration>\r
+                    </execution>\r
+                </executions>\r
+            </plugin>\r
+            <plugin>\r
+                <!-- Copy Swagger UI resources to static resources directory. -->\r
+                <groupId>org.apache.maven.plugins</groupId>\r
+                <artifactId>maven-resources-plugin</artifactId>\r
+                <version>${maven-resources-plugin.version}</version>\r
+                <executions>\r
+                    <execution>\r
+                        <id>copy-resources</id>\r
+                        <phase>prepare-package</phase>\r
+                        <goals>\r
+                            <goal>copy-resources</goal>\r
+                        </goals>\r
+                        <configuration>\r
+                            <outputDirectory>${project.build.outputDirectory}/static/swagger-ui\r
+                            </outputDirectory>\r
+                            <resources>\r
+                                <resource>\r
+                                    <directory>\r
+                                        ${project.build.directory}/swagger-ui-${swagger-ui.version}/META-INF/resources/webjars/swagger-ui/${swagger-ui.version}/\r
+                                    </directory>\r
+                                    <excludes>\r
+                                        <exclude>**/*.gz</exclude>\r
+                                    </excludes>\r
+                                </resource>\r
+                            </resources>\r
+                        </configuration>\r
+                    </execution>\r
+                </executions>\r
+            </plugin>\r
+            <plugin>\r
+                <!-- Replace the OpenAPI specification example URL with the local one. -->\r
+                <groupId>com.google.code.maven-replacer-plugin</groupId>\r
+                <artifactId>replacer</artifactId>\r
+                <version>${maven-replacer-plugin.version}</version>\r
+                <executions>\r
+                    <execution>\r
+                        <phase>prepare-package</phase>\r
+                        <goals>\r
+                            <goal>replace</goal>\r
+                        </goals>\r
+                    </execution>\r
+                </executions>\r
+                <configuration>\r
+                    <file>${project.build.outputDirectory}/static/swagger-ui/index.html</file>\r
+                    <replacements>\r
+                        <replacement>\r
+                            <token>https://petstore.swagger.io/v2/swagger.json</token>\r
+                            <value>/api/cps/openapi.json</value>\r
+                        </replacement>\r
+                    </replacements>\r
+                </configuration>\r
+            </plugin>\r
         </plugins>\r
     </build>\r
 </project>\r