5.11. Swagger ドキュメントの有効化

Red Hat Process Automation Manager ビジネスアプリケーションのサービスプロジェクトで利用可能なすべてのエンドポイントに関する Swagger ベースのドキュメントを有効にできます。

前提条件

  • business applications の Web サイトを使用して作成した Spring Boot アプリケーションの ZIP ファイルがある。

手順

  1. <BUSINESS-APPLICATION>.zip ファイルを展開して、<BUSINESS-APPLICATION>/<BUSINESS-APPLICATION>-service ディレクトリーに移動します。<BUSINESS-APPLICATION> は Spring Boot プロジェクトの名前に置き換えます。
  2. テキストエディターでサービスプロジェクト pom.xml ファイルを開きます。
  3. サービスプロジェクトの pom.xml ファイルに以下の依存関係を追加して、このファイルを保存します。

    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-rs-service-description-swagger</artifactId>
      <version>3.2.6</version>
    </dependency>
    <dependency>
      <groupId>io.swagger</groupId>
      <artifactId>swagger-jaxrs</artifactId>
      <version>1.5.15</version>
      <exclusions>
        <exclusion>
          <groupId>javax.ws.rs</groupId>
          <artifactId>jsr311-api</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
  4. Swagger UI を有効にするには (任意)、以下の依存関係を pom.xml ファイルに追加して、このファイルを保存します。

    <dependency>
      <groupId>org.webjars</groupId>
      <artifactId>swagger-ui</artifactId>
      <version>2.2.10</version>
    </dependency>
  5. テキストエディターで <BUSINESS-APPLICATION>/<BUSINESS-APPLICATION>-service/src/main/resources/application.properties ファイルを開きます。
  6. Swagger サポートを有効にするには、以下の行を application.properties ファイルに追加します。

    kieserver.swagger.enabled=true

ビジネスアプリケーションの起動後に、http://localhost:8090/rest/swagger.json で Swagger ドキュメントを表示できます。全エンドポイントについては、http://localhost:8090/rest/api-docs?url=http://localhost:8090/rest/swagger.json で入手できます。