从YAML源生成一个输出文件

时间:2017-07-10 18:45:58

标签: html maven swagger

我使用的是YAML tutorial提供的示例代码。

我使用Maven从此YAML源生成HTML / PDF文件。 POM文件(片段)显示在本文末尾。

我已成功生成输出文件,但有4个HTML(definitions.htmloverview.htmlpaths.htmlsecurity.html)。 只是想知道,是否有可能只生成 一个输出文件?我应该改变POM中的任何内容吗?

POM文件(摘录):

<plugin>
<groupId>io.github.swagger2markup</groupId>
<artifactId>swagger2markup-maven-plugin</artifactId>
<version>${swagger2markup.version}</version>
<dependencies>
  <dependency>
    <groupId>io.github.swagger2markup</groupId>
    <artifactId>swagger2markup-import-files-ext</artifactId>
    <version>${swagger2markup.version}</version>
  </dependency>
  <dependency>
      <groupId>io.github.swagger2markup</groupId>
      <artifactId>swagger2markup-spring-restdocs-ext</artifactId>
      <version>${swagger2markup.version}</version>
  </dependency>
</dependencies>
<configuration>
  <swaggerInput>${swagger.input}</swaggerInput>
  <outputDir>${generated.asciidoc.directory}</outputDir>
  <config>
    <swagger2markup.markupLanguage>ASCIIDOC</swagger2markup.markupLanguage>
    <!--<swagger2markup.basePathPrefixEnabled>true</swagger2markup.basePathPrefixEnabled>-->
    <swagger2markup.listDelimiterEnabled>true</swagger2markup.listDelimiterEnabled>
  </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>${asciidoctor.maven.version}</version>
  <dependencies>
    <dependency>
      <groupId>org.asciidoctor</groupId>
      <artifactId>asciidoctorj-pdf</artifactId>
      <version>${asciidoctorj.pdf.version}</version>
    </dependency>
    <dependency>
      <groupId>org.asciidoctor</groupId>
      <artifactId>asciidoctorj</artifactId>
      <version>${asciidoctorj.version}</version>
    </dependency>
  </dependencies>
  <!-- Configure generic document generation settings -->
  <configuration>
    <sourceDirectory>${asciidoctor.input.directory}</sourceDirectory>
    <attributes>
      <doctype>book</doctype>
      <toc>left</toc>
      <toclevels>3</toclevels>
      <numbered></numbered>
      <hardbreaks></hardbreaks>
      <sectlinks></sectlinks>
      <sectanchors></sectanchors>
      <generated>${generated.asciidoc.directory}</generated>
    </attributes>
  </configuration>
  <executions>
    <execution>
      <id>output-html</id>
      <phase>generate-resources</phase>
      <goals>
        <goal>process-asciidoc</goal>
      </goals>
      <configuration>
        <backend>html5</backend>
        <outputDirectory>${asciidoctor.html.output.directory}</outputDirectory>
      </configuration>
    </execution>
    <execution>
      <id>output-pdf</id>
      <phase>generate-resources</phase>
      <goals>
          <goal>process-asciidoc</goal>
      </goals>
      <configuration>
          <backend>pdf</backend>
          <outputDirectory>${asciidoctor.pdf.output.directory}</outputDirectory>
      </configuration>
    </execution>
  </executions>
</plugin>

1 个答案:

答案 0 :(得分:0)

由于documentation of the Asciidoctor Maven Plugin configuration options留有足够的改进空间,而且:

[ERROR] Could not find goal 'help' in plugin org.asciidoctor:asciidoctor-maven-plugin:1.5.5
among available goals auto-refresh, http, process-asciidoc, zip

您可以使用Maven Shade Plugin with its [Xml]AppendingTransformer

  

...通过将其内容附加到一个文件中来合并它们。