2017-08-16 7 views
0

Spring REST Docsの新機能で、最新の1.2.1を使用しています。私はRESTfulコントローラを使っていますが、私は一連の作業テストをしています。今では、新しい開発者向けにドキュメント化されたドキュメントを入手するために、ドキュメントの側面を紹介しています。Spring REST Docsで空のインデックスファイルが生成される

私はこのように構成さのpom.xmlを持っている:

<properties> 
    <snippetsDirectory>${project.build.directory}/generated-snippets</snippetsDirectory> 
</properties> 

<build> 

    <outputDirectory>target/${project.artifactId}-${project.version}/WEB-INF/classes</outputDirectory> 
    <plugins> 

     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>buildnumber-maven-plugin</artifactId> 
      <version>1.4</version> 
      <executions> 
       <execution> 
        <phase>validate</phase> 
        <goals> 
         <goal>create</goal> 
        </goals> 
       </execution> 
      </executions> 
      <configuration> 
       <doCheck>false</doCheck> 
       <doUpdate>false</doUpdate> 
      </configuration> 
     </plugin> 

     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <configuration> 
       <source>1.8</source> 
       <target>1.8</target> 
      </configuration> 
     </plugin> 

     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>3.1.0</version> 
      <configuration> 
       <archive> 
        <manifest> 
         <addDefaultImplementationEntries>true</addDefaultImplementationEntries> 
        </manifest> 
        <manifestEntries> 
         <Git-Revision>${buildNumber}</Git-Revision> 
        </manifestEntries> 
       </archive> 
       <archiveClasses>true</archiveClasses> 
       <webResources> 
        <!-- in order to interpolate version from pom into appengine-web.xml --> 
        <resource> 
         <directory>${basedir}/src/main/webapp/WEB-INF</directory> 
         <filtering>true</filtering> 
         <targetPath>WEB-INF</targetPath> 
        </resource> 
       </webResources> 
       <failOnMissingWebXml>false</failOnMissingWebXml> 
      </configuration> 
     </plugin> 

     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <version>2.20</version> 
      <configuration> 
       <includes> 
        <include>**/*Documentation.java</include> 
       </includes> 
      </configuration> 
     </plugin> 

     <plugin> 
      <groupId>org.asciidoctor</groupId> 
      <artifactId>asciidoctor-maven-plugin</artifactId> 
      <version>1.5.5</version> 
      <executions> 
       <execution> 
        <id>generate-docs</id> 
        <phase>prepare-package</phase> 
        <goals> 
         <goal>process-asciidoc</goal> 
        </goals> 
        <configuration> 
         <backend>html</backend> 
         <doctype>book</doctype> 
         <sourceDocumentName>index.adoc</sourceDocumentName> 
         <attributes> 
          <snippets>${snippetsDirectory}</snippets> 
         </attributes> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

     <plugin> 
      <artifactId>maven-resources-plugin</artifactId> 
      <version>3.0.2</version> 
      <executions> 
       <execution> 
        <id>copy-resources</id> 
        <phase>prepare-package</phase> 
        <goals> 
         <goal>copy-resources</goal> 
        </goals> 
        <configuration> 
         <outputDirectory> ${project.build.outputDirectory}/static/docs 
         </outputDirectory> 
         <resources> 
          <resource> 
           <directory> ${project.build.directory}/generated-docs 
           </directory> 
          </resource> 
         </resources> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

    </plugins> 
</build> 

そして、私は仕事のテストを持っており、下/ターゲット私がいた:ビルドのプラグインがどこにあるか

<dependency> 
     <groupId>org.springframework.restdocs</groupId> 
     <artifactId>spring-restdocs-mockmvc</artifactId> 
     <version>1.2.1.RELEASE</version> 
     <scope>test</scope> 
    </dependency> 

、ここでは、いくつかの* .adocファイルで作成されたディレクトリがあります。それは素晴らしいです。

私は/src/main/asciidoc/index.adocを作成していますが、ビルドを行うと成功します。 index.adocファイルには何もありません。 ので、ビルドが成功した後、私は下の "ADOC" ファイルの多くを得る:/ myappの:
/myappのプラットフォーム-WS /ターゲット/生成-スニペット

私も下のファイル "index.htmlを" を取得それは何もありません....

私はいくつかの方法をいくつか書いていますが、それぞれのコントローラがあります。これは大丈夫です。しかし、私は、作成されたさまざまなadocファイルに対して複数のhtmlファイルを持つことができるいくつかの方法を見つけたいと思います。

Spring RESTのドキュメントは本当に新しく、私は多くの新しいことを試していますので、私はチームに公開することができます。

ご協力いただければ幸いです。ありがとう!

は=============== UPDATE 1.0 =================ので

、私は前にこのプラグインを追加しました'asciidoctor'プラグイン。

 <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <version>2.20</version> 
      <configuration> 
       <includes> 
        <include>**/*Documentation.java</include> 
       </includes> 
      </configuration> 
     </plugin> 

はそして、はい、私はそうでない場合、私はそれがなかったというエラーになるだろうので、バージョンを含める必要がありましたが、それはまだ成功し、ビルドしました。しかし、今では私のテストは実行されません。

[[overview-headers]] 
== Headers 
Every response has the following header(s): 
<h>Organizations</h> 
include::{snippets}/orgs/response-headers.adoc[] 
include::{snippets}/orgs/portal/response-headers.adoc[] 

そして、テストが実行されていないので、そう、それはこれらのファイルを追加していません。

私はまた、次の含めるように私のindex.adocを変更しました。 「response-headers.adoc」も生成されていないと思われます。 テストが実行されているときに、スニペットを取得していました。

私はテストをもう一度実行することができたら私は正しい軌道に乗ると思う。私はすべてのテストをスキップしているわけではありません。

=============== UPDATE 2.0 =================

私は実際に動作するように確実なプラグインを変更私が持っているテストで:だから/*Test.java
内のすべての私のテスト以来

 <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <version>2.20</version> 
      <configuration> 
       <includes> 
        <include>**/*Test.java</include> 
       </includes> 
      </configuration> 
     </plugin> 

、終わり、これはすべて私のテストを実行しました。

私は* .adocファイルが欠落していたというメッセージが出ていたので、私は

<properties> 
    <snippetsDirectory>${project.build.directory}/generated-snippets</snippetsDirectory> 
</properties> 

が正しいセットアップでしたが、私はこれが削除されていた気づいていなかったので、私は、再追加す​​ることをダブルチェックエラーメッセージが表示されなくなりました。

私はそれを言及しても思い出せませんが、私はindex.adocに詳細を追加しました。そして、最終的にその中にコンテンツを含むindex.htmlを生成することができました。

私は今、AsciiDoctorについてもっと学ぶ必要があります。私は、POSTSとPUTのすべてとGETのためにindex.adocを更新できます。

答えて

0

上記のような実験の後、私はついにこれを動作させました。私はちょうど正しい設定をしなければなりませんでした、そして、それは最終的に動作します。 index.adocファイルを作成し、index.htmlファイルをコンテンツとともに作成しました。

私は今、AsciiDoctorについてもっと学ぶ必要があります。私は、POSTSとPUTのすべてとGETのためにindex.adocを更新できます。

関連する問題