summaryrefslogtreecommitdiffstats
path: root/integration
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2021-07-15 14:59:06 +0100
committerLiam Fallon <liam.fallon@est.tech>2021-07-19 13:13:59 +0000
commit123321473628cbacd35963f4f30bf2ab621fd3b7 (patch)
tree1c78e59e063afc9f8cffc96d6b71bc550c55975f /integration
parent5762c5765d4921b4f26de3da3eba0500095d731f (diff)
Add profile for generating Swagger documents
This commit adds a profile for generating Swagger documents and creating a tarball containing the swagger.json, swagger.html, and swagger.pdf files. The profile is triggered in any module when tsts are enabled (In other words when the skipTests flag is off), and when the following proerty is set: <swagger.generation.phase>post-integration-test</swagger.generation.phase> This profile assumes that a unit test exists that creates the following file: target/swagger/swagger.json If this file does not exist, the build will fail if the profile is invoked. Therefore, to generate the Swagger documentation tarball, a module must set the swagger.generation.phase propety AND have a unit test that generates the swagger.json file. Issue-ID: POLICY-3424 Change-Id: I8ff769e7a28bf0e00969d1bc677fee6908951d8a Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'integration')
-rw-r--r--integration/pom.xml164
1 files changed, 164 insertions, 0 deletions
diff --git a/integration/pom.xml b/integration/pom.xml
index 92840093..db055556 100644
--- a/integration/pom.xml
+++ b/integration/pom.xml
@@ -36,6 +36,8 @@
<properties>
<java.version>11</java.version>
+ <!-- NOTE: For RELEASE/SNAPSHOT always set to the project version -->
+ <version.parent.resources>3.4.0-SNAPSHOT</version.parent.resources>
<version.logback>1.2.3</version.logback>
<version.dmaap>1.1.12</version.dmaap>
<version.powermock>2.0.9</version.powermock>
@@ -70,6 +72,12 @@
<dependencyManagement>
<dependencies>
<dependency>
+ <groupId>org.onap.policy.parent</groupId>
+ <artifactId>policy-parent-resources</artifactId>
+ <version>${version.parent.resources}</version>
+ </dependency>
+
+ <dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>${version.jakarta-api}</version>
@@ -855,6 +863,162 @@
</pluginManagement>
</build>
</profile>
+ <profile>
+ <id>generateSwaggerDocs</id>
+ <activation>
+ <property>
+ <name>!skipTests</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <!-- Read the swagger.json file and the definition from SwaggerConfig.java; generate
+ a list of .adoc files containing the APIs info in more structured way -->
+ <plugin>
+ <groupId>io.github.swagger2markup</groupId>
+ <artifactId>swagger2markup-maven-plugin</artifactId>
+ <version>1.3.3</version>
+ <dependencies>
+ <dependency>
+ <groupId>io.github.swagger2markup</groupId>
+ <artifactId>swagger2markup-import-files-ext</artifactId>
+ <version>1.3.3</version>
+ </dependency>
+ <dependency>
+ <groupId>io.github.swagger2markup</groupId>
+ <artifactId>swagger2markup-spring-restdocs-ext</artifactId>
+ <version>1.3.3</version>
+ </dependency>
+ </dependencies>
+ <configuration>
+ <swaggerInput>${project.build.directory}/swagger/swagger.json</swaggerInput>
+ <outputDir>${project.build.directory}/asciidoc/generated</outputDir>
+ <config>
+ <swagger2markup.markupLanguage>ASCIIDOC</swagger2markup.markupLanguage>
+ </config>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>${swagger.generation.phase}</phase>
+ <goals>
+ <goal>convertSwagger2markup</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>unpack-swagger-asciidoc</id>
+ <phase>${swagger.generation.phase}</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.onap.policy.parent</groupId>
+ <artifactId>policy-parent-resources</artifactId>
+ <type>jar</type>
+ <overWrite>true</overWrite>
+ <outputDirectory>${project.build.directory}</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ <includes>asciidoc/**</includes>
+ <outputDirectory>${project.build.directory}</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- Run the generated asciidoc through Asciidoctor to generate other documentation
+ types, such as PDFs or HTML5 -->
+ <plugin>
+ <groupId>org.asciidoctor</groupId>
+ <artifactId>asciidoctor-maven-plugin</artifactId>
+ <version>1.5.7.1</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.asciidoctor</groupId>
+ <artifactId>asciidoctorj-pdf</artifactId>
+ <version>1.5.0-alpha.10.1</version>
+ </dependency>
+ </dependencies>
+ <configuration>
+ <sourceDirectory>${project.build.directory}/asciidoc</sourceDirectory>
+ <sourceDocumentName>swagger.adoc</sourceDocumentName>
+ <attributes>
+ <doctype>book</doctype>
+ <toc>left</toc>
+ <toclevels>3</toclevels>
+ <numbered />
+ <hardbreaks />
+ <sectlinks />
+ <sectanchors />
+ <generated>${project.build.directory}/asciidoc/generated</generated>
+ </attributes>
+ </configuration>
+
+ <executions>
+ <execution>
+ <id>output-html</id>
+ <phase>${swagger.generation.phase}</phase>
+ <goals>
+ <goal>process-asciidoc</goal>
+ </goals>
+ <configuration>
+ <backend>html5</backend>
+ <outputDirectory>${project.build.directory}/swagger</outputDirectory>
+ </configuration>
+ </execution>
+ <execution>
+ <id>output-pdf</id>
+ <phase>${swagger.generation.phase}</phase>
+ <goals>
+ <goal>process-asciidoc</goal>
+ </goals>
+ <configuration>
+ <backend>pdf</backend>
+ <outputDirectory>${project.build.directory}/swagger</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- Create a tarball for Swagger documents -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.policy.parent</groupId>
+ <artifactId>policy-parent-resources</artifactId>
+ <version>${version.parent.resources}</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>generate-swagger-tar</id>
+ <phase>${swagger.generation.phase}</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <descriptorRefs>
+ <descriptorRef>swagger-docs</descriptorRef>
+ </descriptorRefs>
+ <finalName>${project.artifactId}</finalName>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+ </profile>
</profiles>
<build>