在pom.xml中添加以下配置:
<plugin>
<groupId>io.github.swagger2markup</groupId>
<artifactId>swagger2markup-maven-plugin</artifactId>
<version>1.3.3</version>
<configuration>
<!--swagger頁面可以看到-->
<swaggerInput>項目訪問根路徑/v2/api-docs</swaggerInput>
<!--生成多個文件-->
<!--<outputDir>./docs/asciidoc/generated/all</outputDir>-->
<!--生成單個文件-->
<outputFile>./docs/asciidoc/generated/xxx-api</outputFile>
<config>
<!-- 除了ASCIIDOC之外,還有MARKDOWN和CONFLUENCE_MARKUP可選 -->
<swagger2markup.markupLanguage>ASCIIDOC</swagger2markup.markupLanguage>
</config>
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>convertSwagger2markup</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
<version>1.5.6</version>
<dependencies>
<dependency>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctorj-pdf</artifactId>
<version>1.5.0-alpha.16</version>
</dependency>
<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby-complete</artifactId>
<version>9.2.8.0</version>
</dependency>
</dependencies>
<configuration>
<!--asciidoc文件所在路徑-->
<sourceDirectory>./docs/asciidoc/generated</sourceDirectory>
<headerFooter>true</headerFooter>
<doctype>book</doctype>
<sourceHighlighter>coderay</sourceHighlighter>
<attributes>
<!--菜單欄在左邊-->
<toc>left</toc>
<!--多標(biāo)題排列-->
<toclevels>3</toclevels>
<!--自動打數(shù)字序號-->
<sectnums>true</sectnums>
</attributes>
</configuration>
<executions>
<execution>
<id>output-html</id>
<phase>generate-resources</phase>
<goals>
<goal>process-asciidoc</goal>
</goals>
<configuration>
<backend>html5</backend>
<outputDirectory>./docs/asciidoc/html</outputDirectory>
</configuration>
</execution>
<execution>
<id>output-pdf</id>
<phase>generate-resources</phase>
<goals>
<goal>process-asciidoc</goal>
</goals>
<configuration>
<backend>pdf</backend>
<outputDirectory>./docs/asciidoc/pdf</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
執(zhí)行 maven compile即可漫雷。