---
schema_version: "1"
id: 654285011d2eb6686024e445410f2c14131e1959fa9774dca6a204fe9056edfc
title: AsyncAPI 仕様の作成およびインポート
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/anypoint-code-builder/des-create-asyncapi-api-specs.md
canonical_url: https://docs.mulesoft.com/jp/anypoint-code-builder/des-create-asyncapi-api-specs
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 4f66dca56ffd172a407c0572827fc469c1d90ce8d84c7c76bb3a570e2e181862
description: MuleSoft Documentation Site
latest: true
---
# AsyncAPI 仕様の作成およびインポート

**進行中のベータリリース**​: **クラウド IDE は進行中のベータリリースです**​。ベータ状態での Anypoint Code Builder の使用には、IDE で入手できる、該当するベータサービス契約条件が適用されます。

Anypoint Exchange にパブリッシュする前に Anypoint Code Builder を使用して AsyncAPI 仕様の設計、インポート、管理、テストを行います。

1. IDE から Anypoint Code Builder で AsyncAPI 仕様プロジェクトを作成および設計するか、MuleSoft VCS から仕様をインポートして AsyncAPI 仕様プロジェクトを作成します。
    
    - [IDE から AsyncAPI 仕様プロジェクトを作成および設計する](#design-new-api-spec)
    - [MuleSoft VCS から AsyncAPI 仕様をインポートする](#import-spec)
2. [出力パネルで進行状況を追跡します](#open-output-panel)​。
3. [API Console で仕様を確認します](#review-spec-console)​。

Anypoint Code Builder の機能を調べるには、​[`asyncapi-example`](#example-asyncapi-api-spec)​ API 仕様を使用してください。

## [](#始める前に)始める前に

- [Web またはデスクトップ IDE をセットアップしてアクセスします](https://docs.mulesoft.com/jp/anypoint-code-builder/start-acb)​。
- AsyncAPI 仕様の設計の基礎を理解します。
- [ビジネスグループ](https://docs.mulesoft.com/jp/access-management/business-groups)​に精通します。
    
    API 仕様を Anypoint Code Builder から Exchange にパブリッシュすると、IDE でビジネスグループの名前が要求されます。[ビジネスグループ](https://docs.mulesoft.com/jp/access-management/business-groups)を参照してください。

## [](#design-new-api-spec)新しい AsyncAPI 仕様プロジェクトを作成および設計する

Anypoint Code Builder で AsyncAPI 仕様プロジェクトを作成および設計する手順は、次のとおりです。

1. IDE のアクティビティバーで、​![](/mulesoft/current/ja-jp/anypoint-code-builder/_images/icon-ms-logo.png)​ (​**Anypoint Code Builder**​) アイコンをクリックします。
    
    ![アクティビティバー内で強調表示されている「Anypoint Code Builder」アイコン](/mulesoft/current/ja-jp/anypoint-code-builder/_images/anypoint-code-builder-view.png)
2. **\[Quick Actions (クイックアクション)\]**​ から ​**\[Design an API (API を設計)\]**​ をクリックします。
    
    ![\*\[Quick Actions (クイックアクション)\]\* セクション内の強調表示された \*\[Design an API (API を設計)\]\* リンク](_images/design-api-1.png)
3. **\[API Specification (API 仕様)\]**​ フォームに入力します。
    
    <table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 75%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">項目名</th>
<th class="tableblock halign-left valign-top">項目値</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><strong>Project Name (プロジェクト名)</strong></p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>プロジェクトの一意の名前。</p>
</div>
<div class="paragraph">
<p>この名前は Exchange での AsyncAPI 仕様のタイトル、仕様ファイルの名前、プロジェクトのルートディレクトリの名前として使用されます。
たとえば、プロジェクト名が​<em>「AsyncAPI Example」</em>​ (AsyncAPI 例) の場合、仕様ファイル名は ​<code>asyncapi-example</code>​ になります。</p>
</div>
<div class="paragraph">
<p>既存のプロジェクト名を再利用するには、その名前をすでに使用しているプロジェクトを最初に削除する必要があります。<a href="https://docs.mulesoft.com/jp/anypoint-code-builder/des-delete-api-projects" class="xref page">API 仕様とフラグメントの削除</a>を参照してください。</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><strong>Project Location (プロジェクトの場所)</strong></p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>ホームディレクトリまたは作成する別のディレクトリ。</p>
</div>
<div class="paragraph">
<p><a href="https://docs.mulesoft.com/jp/anypoint-code-builder/start-add-folders" class="xref page">ホームディレクトリへのフォルダーの追加</a>を参照してください。</p>
</div>
<div class="paragraph">
<p>別のプロジェクトディレクトリ内にプロジェクトを作成しないでください。</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><strong>API Type (API 種別)</strong></p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>作成する API 仕様のエンティティの種別。</p>
</div>
<div class="paragraph">
<p>使用可能なオプションは、​<strong>[REST API]</strong>​ と ​<strong>[AsyncAPI]</strong>​ です。</p>
</div>
<div class="paragraph">
<p>この手順で​<a href="#example-asyncapi-api-spec">サンプル</a>​を使用するには、​<strong>[AsyncAPI]</strong>​ を選択します。</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><strong>API Specification Language (API 仕様言語)</strong></p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a href="https://docs.mulesoft.com/jp/anypoint-code-builder/des-designing-api-specs#supported-spec-languages" class="xref page">「サポートされる AsyncAPI バージョン」</a>​を参照してください。</p>
</div>
<div class="paragraph">
<p>この手順で​<a href="#example-asyncapi-api-spec">サンプル</a>​を使用するには、​<strong>[AsyncAPI 2.6 (YAML)]</strong>​ を選択します。</p>
</div></div></td>
</tr>
</tbody>
</table>
4. **\[Create Project (プロジェクトを作成)\]**​ をクリックします。
    
    確認を促されたら、フォルダー内のファイルの作成者を信頼します。
    
    プロジェクトの編集準備が整ったら、API プロジェクトのエディタービューで次の AsyncAPI 2.6 (YAML) 仕様のような仕様が開きます。
    
    ![新しい AsyncAPI 2.6 (YAML) API プロジェクト](/mulesoft/current/ja-jp/anypoint-code-builder/_images/des-asyncapi-create.png)
5. 引き続き API 仕様を設計します。
    
    要素を入力するときに、​[オートコンプリート](https://docs.mulesoft.com/jp/anypoint-code-builder/start-discover-ui#auto-complete)​ (Ctrl+Space) を使用すると、コンテキスト内で使用可能なオプションが表示されます。

## [](#import-spec)MuleSoft VCS から AsyncAPI 仕様をインポートする

MuleSoft VCS から AsyncAPI 仕様をインポートし、デスクトップまたはクラウド IDE で Git または VS Code と互換性のある別のソース管理システムを使用して、プロジェクトの同期を維持します。詳細は、​[API 設計プロジェクトのソース制御](https://docs.mulesoft.com/jp/anypoint-code-builder/des-designing-api-specs#anypoint-scm)​を参照してください。

1. コマンドパレットを開きます。
    
    手順を表示
    
    - キーボードショートカットを使用する。
        
        - Mac: Cmd+Shift+p
        - Windows: Ctrl+Shift+p
    - デスクトップ IDE で、​**\[View (表示)\]**​ > ​**\[Command Palette (コマンドパレット)\]**​ を選択する。
    - クラウド IDE で、​![](/mulesoft/current/ja-jp/anypoint-code-builder/_images/icon-menu.png)​ (メニュー) アイコンをクリックし、​**\[View (表示)\]**​ > ​**\[Command Palette (コマンドパレット)\]**​ を選択する。
2. 次のコマンドを入力します。
    
    ```command
    MuleSoft: Import API Specification from MuleSoft VCS
    ```
3. Anypoint Platform にログインするように促されたら、IDE からログインします。
4. インポートプロセスを完了します。
    
    1. **\[Select a Business Group (ビジネスグループを選択)\]**​ ポップアップからビジネスグループを選択します。
    2. **\[APIs from MuleSoft VCS (MuleSoft VCS から API)\]**​ 項目で API 仕様を検索します。
    3. 仕様のフォルダーに移動するか、そのフォルダーを作成して、​**\[Select target folder (対象フォルダーを選択)\]**​ をクリックします。
        
        インポートが失敗したといったエラー (​**「Importing project _a\_project\_name_ has failed (プロジェクト _a\_project\_name_ のインポートに失敗しました)」**​) を受け取ったら、同じ名前のプロジェクトの対象フォルダーを確認します。インポートする前に重複する名前の問題に対処するには、設計プロジェクトを別の対象フォルダーにインポートするか、プロジェクトを IDE から削除することができます ([API 仕様とフラグメントの削除](https://docs.mulesoft.com/jp/anypoint-code-builder/des-delete-api-projects)を参照)。
5. 必要に応じて、仕様を編集するか、引き続き仕様を設計します。
    
    要素を入力するときに、​[オートコンプリート](https://docs.mulesoft.com/jp/anypoint-code-builder/start-discover-ui#auto-complete)​ (Ctrl+Space) を使用すると、コンテキスト内で使用可能なオプションが表示されます。
6. 必要に応じて、MuleSoft VCS を使用して変更内容を同期します。
    
    この機能は、MuleSoft VCS からインポートした API プロジェクトでのみ使用できます。作業内容を別の SCM に保存することもできます。SCM オプションについては、[ソースファイルの制御](https://docs.mulesoft.com/jp/anypoint-code-builder/start-scm)を参照してください。

## [](#open-output-panel)出力パネルで進行状況を追跡する

API を設計しているときに内部処理の進行状況を追跡する手順は、次のとおりです。

1. 出力パネルを開きます。
    
    手順を表示
    
    - キーボードショートカットを使用する。
        
        - Mac: Cmd+Shift+u
        - Windows: Ctrl+Shift+u
    - デスクトップ IDE で、​**\[View (表示)\]**​ > ​**\[Output (出力)\]**​ を選択する。
    - クラウド IDE で、​![](/mulesoft/current/ja-jp/anypoint-code-builder/_images/icon-menu.png)​ (メニュー) アイコンをクリックし、​**\[View (表示)\]**​ > ​**\[Output (出力)\]**​ を選択する。
2. ドロップダウンから ​**\[Mule DX Server (Mule DX サーバー)\]**​ を選択します:
    
    ![出力ペイン内の \[Mule DX Server (Mule DX サーバー)\]](_images/des-output-panel.png)

## [](#review-spec-console)API Console で仕様を確認する

コンソールに仕様を表示する手順は、次のとおりです。

1. エディターで仕様ファイルをクリックします。
2. ![](/mulesoft/current/ja-jp/anypoint-code-builder/_images/icon-api-console.png)​ (​**API Console**​) アイコンをクリックします。
    
    または、​[コマンドパレット](https://docs.mulesoft.com/jp/anypoint-code-builder/start-use-command-palette)​でコマンド ​`MuleSoft: API Console`​ を入力することができます。
3. API Console にチャネルが表示されるまで待機します。
    
    API Console に仕様のチャネルが表示されます。次に例を示します。
    
    ![API Console 内の AsyncAPI 仕様](/mulesoft/current/ja-jp/anypoint-code-builder/_images/des-asyncapi-api-console.png)
    
    <table><tbody><tr><td><i class="conum" data-value="1"></i><b>1</b></td><td>チャネルをクリックして詳細を表示します。</td></tr><tr><td><i class="conum" data-value="2"></i><b>2</b></td><td>コンソールメニューを表示します。</td></tr></tbody></table>
4. コンソールでチャネルをクリックするか、メニューから項目を選択して、仕様のさまざまな部分を表示します。 たとえば、​**\[PUBLISH\]**​ をクリックすると、次のように表示されます。
    
    ![PUBLISH の詳細を含む API Console](/mulesoft/current/ja-jp/anypoint-code-builder/_images/des-asyncapi-api-console-detail.png)

## [](#example-asyncapi-api-spec)AsyncAPI (YAML) API 仕様の例

AsyncAPI 2.6 (YAML) プロジェクトを作成したら、初期仕様を次のコード例で置き換えることができます。

AsyncAPI 2.6 (YAML) 仕様の例

```YAML
asyncapi: '2.6.0' (1)
info:
  title: Orders AsyncAPI
  version: '1.0.0'
  description: Orders API
  license:
    name: Anypoint MQ
    url: https://license.com
  contact:
    name: Max Muley
    email: max@salesforce.com
    url: http://salesforce.com
defaultContentType: application/json
tags:
  - name: Orders API
    description: API for orders
servers: (2)
  AMQ-prod:
    url: https:://your_MQ_server_URL_here
    protocol: anypointmq
    protocolVersion: v1
    description: Anypoint MQ broker
  kafka-prod:
    url: your_kafka_URL_here
    protocol: kafka
    description: kafka broker
  sfpubsub-prod:
      protocol: salesforcepubsub
      protocolVersion: v1
      url: api.pubsub.salesforce.com
      description: Salesforce pub sub for Platform events production
  solace-server:
    protocol: solace
    variables:
      port:
        enum:
        - '1000'
    bindings:
      solace:
        msgVpn: your_solace_vpn_here
        bindingVersion: 0.4.0
    protocolVersion: 1.0.0
    url: mySolaceURL
channels: (3)
  order-placed:
    description: new orders channel
    servers:
      - AMQ-prod
    publish:
      operationId: listen-order-placed
      description: listen for new order events
      summary: Order Placed Event
      message:
        $ref: '#/components/messages/OrderPlaced'
    subscribe:
      operationId: publish-order-placed
      description: publish new order events
      summary: Order Placed Event
      message:
        $ref: '#/components/messages/OrderPlaced'
  order-updated:
    description: updated orders channel
    servers:
      - solace-server
    publish:
      operationId: listen-order-updated
      description: listen for updated order events
      summary: Order updated Event
      bindings:
        solace:
          bindingVersion: 0.3.0
          destinations:
          - destinationType: queue
            queue:
              name: listen-order-updated
              topicSubscriptions:
              - acmeretail/onlineservices/order/updated/v1/*/*
              - acmeretail/onlineservices/order/updated/v2/*/*
      message:
        $ref: '#/components/messages/OrderUpdated'
    subscribe:
      operationId: publish-order-updated
      description: publish updated order events
      summary: Order updated Event
      bindings:
        solace:
          bindingVersion: 0.3.0
          destinations:
          - destinationType: queue
            queue:
              name: C360.CUSTOMERS
              topicSubscriptions:
              - acmeretail/onlineservices/order/updated/v1/*/*
              - acmeretail/onlineservices/order/updated/v2/*/*
      message:
        $ref: '#/components/messages/OrderUpdated'
  order-cancelled:
    description: orders cancelled channel
    servers:
      - AMQ-prod
    publish:
      operationId: listen-order-cancellations
      description: listen for order cancellation events
      summary: Order Cancelled Event
      message:
        $ref: '#/components/messages/OrderCancelled'
    subscribe:
      operationId: publish-order-cancellations
      description: publish order cancellation events
      summary: Order Cancelled Event
      message:
        $ref: '#/components/messages/OrderCancelled'
  order-confirmed:
    description: orders confirmed channel
    servers:
      - sfpubsub-prod
    publish:
      operationId: listen-order-confirmations
      description: listen for order confirmation events
      summary: Order Confirmed Event
      message:
        $ref: '#/components/messages/OrderConfirmedSub'
    subscribe:
      operationId: publish-order-confirmations
      description: publish order confirmation events
      summary: Order Confirmed Event
      message:
        $ref: '#/components/messages/OrderConfirmedPub'
  order-backordered:
    servers:
      - kafka-prod
    description: orders backordered channel
    publish:
      operationId: listen-order-backordered
      description: listen for backorder events
      summary: Backorder Event
      message:
        $ref: '#/components/messages/BackOrder'
    subscribe:
      operationId: publish-order-backordered
      description: publish backorder events
      summary: Backorder Event
      message:
        $ref: '#/components/messages/BackOrder'
components: (4)
  messages:
    OrderPlaced:
      payload:
        type: object
        properties:
          orderId:
            type: string
          customerName:
            type: string
          email:
            type: string
          items:
            type: array
            items:
              type: object
              properties:
                productId:
                  type: string
                productName:
                  type: string
                quantity:
                  type: integer
                price:
                  type: number
              required: [productId, productName, quantity, price]
              additionalProperties: false
        required: [orderId, customerName, email, items]
        additionalProperties: false
    OrderConfirmedPub:
      summary: order message pub
      contentType: application/json
      payload:
        type: array
        orderconfirmation:
          type: object
          properties:
            orderId__c:
              type: string
            email__c:
              type: string
            required: [orderId, email]
            additionalProperties: false
    OrderConfirmedSub:
      summary: order message sub
      contentType: application/json
      payload:
        type: object
        properties:
          event:
            type: object
            properties:
              orderId__c:
                type: string
              email__c:
                type: string
        required: [orderId, email]
        additionalProperties: false
    OrderCancelled:
      payload:
        type: object
        properties:
          orderId:
            type: string
          email:
            type: string
          reason:
            type: string
        required: [orderId, email, reason]
        additionalProperties: false
    BackOrder:
      payload:
        type: object
        properties:
          orderId:
            type: string
          email:
            type: string
        required: [orderId, email]
        additionalProperties: false
    OrderUpdated:
      contentType: application/json
      description: Shows changes to customer information including name, address and
        loyalty status
      payload:
        "$ref": "#/components/schemas/Order_JSON"
      schemaFormat: application/vnd.aai.asyncapi+json;version=2.0.0
      x-ep-application-domain-id: p4oo2ehrcpf
      x-ep-application-domain-name: OnlineServices
      x-ep-custom-attr-confidential: 'true'
      x-ep-event-id: 66gdcid5pht
      x-ep-event-name: Customer Created
      x-ep-event-state-id: '2'
      x-ep-event-state-name: RELEASED
      x-ep-event-version: 2.0.2
      x-ep-event-version-displayname: ''
      x-ep-event-version-id: 29btjydowi0
      x-ep-shared: 'true'
  schemas:
    Order_JSON:
      "$schema": http://json-schema.org/draft-07/schema#
      properties:
        customer_id:
          description: The unique identifier of the customer
          type: string
        insight_description:
          description: A brief description of the insight
          type: string
        insight_type:
          description: The type of insight (e.g., demographic, behavioral, transactional)
          type: string
        insight_value:
          description: The value or result of the insight
          type: string
        timestamp:
          description: The timestamp when the insight was generated
          format: date-time
          type: string
      required:
      - customer_id
      - insight_type
      - insight_description
      - insight_value
      - timestamp
      title: CustomerInsight
      type: object
      x-ep-application-domain-id: a3hbbd7unz2
      x-ep-application-domain-name: Customer360
      x-ep-schema-id: 6dqkacw0k70
      x-ep-schema-name: Customer Insight
      x-ep-schema-state-id: '1'
      x-ep-schema-state-name: DRAFT
      x-ep-schema-version: 0.1.0
      x-ep-schema-version-displayname: ''
      x-ep-schema-version-id: u15ylfss2qx
      x-ep-shared: 'false'
```

<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>AsyncAPI
<div class="paragraph">
<p>API モデルを AsyncAPI として識別し、API 仕様のタイトルとバージョンを指定します。</p>
</div></td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>サーバー
<div class="paragraph">
<p>AsyncAPI モジュールの操作を介してイベントをパブリッシュまたはサブスクライブするときに (間接的に) 使用するコネクタを決定するメッセージブローカーを定義します。</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>AMQ-prod</code>​ では、Anypoint MQ ブローカーを設定します</p>
</li>
<li>
<p><code>Kafka-prod</code>​ では、ローカルでホストされた Kafka ブローカーを設定します</p>
</li>
<li>
<p><code>sfpubsub-prod</code>​ では、Salesforce Pub/Sub ブローカーを設定します</p>
</li>
<li>
<p><code>solace-server</code>​ では Solace PubSub+ ブローカーを設定します</p>
</li>
</ul>
</div></td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>Channels (チャネル)
<div class="paragraph">
<p>バインドを定義します。</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>order-placed</code>​ では、新しい注文をパブリッシュおよびサブスクライブするための Anypoint MQ チャネルを設定します。</p>
</li>
<li>
<p><code>order-updated</code>​ では、注文の更新をパブリッシュおよびサブスクライブするための Solace PubSub+ チャネルを設定します</p>
</li>
<li>
<p><code>order-cancelled</code>​ では、キャンセル済み注文をパブリッシュおよびサブスクライブするための Anypoint MQ チャネルを設定します</p>
</li>
<li>
<p><code>order-confirmed</code>​ では、注文確認イベントをパブリッシュおよびサブスクライブするための Salesforce Pub/Sub チャネルを設定します</p>
</li>
<li>
<p><code>order-backordered</code>​ では、取り寄せ注文をパブリッシュおよびサブスクライブするための Kafka チャネルを設定します</p>
</li>
</ul>
</div></td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>コンポーネント
<div class="paragraph">
<p><code>OrderPlaced</code>​、​<code>OrderConfirmedPub</code>​、​<code>OrderConfirmedSub</code>​、​<code>OrderCancelled</code>​、​<code>BackOrder</code>​、​<code>OrderUpdated</code>​ を含むさまざまな注文種別のメッセージの構造を定義します</p>
</div></td>
</tr>
</tbody></table>

## [](#関連情報)関連情報

- [Anypoint Code Builder 入門](https://docs.mulesoft.com/jp/anypoint-code-builder/start-acb)
- [チュートリアル](https://docs.mulesoft.com/jp/anypoint-code-builder/tutorials)
- [ビジネスグループ](https://docs.mulesoft.com/jp/access-management/business-groups)
- [IntelliSense を使用してエディターでオートコンプリートを実行する](https://docs.mulesoft.com/jp/anypoint-code-builder/start-discover-ui#use-autocomplete)
- [ガバナンスルールセットに対する API 仕様の検証](https://docs.mulesoft.com/jp/anypoint-code-builder/des-govern-api)
- [API 仕様とフラグメントの削除](https://docs.mulesoft.com/jp/anypoint-code-builder/des-delete-api-projects)