

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# Infrastructure Composer でOpenAPI仕様の外部ファイルを参照する
<a name="using-composer-external-files-examples-example1"></a>

この例では、コンソールの Infrastructure Composer を使用して、API Gateway を定義する外部OpenAPI仕様ファイルを参照しますREST API。

まず、Infrastructure Composer **ホームページ**から新しいプロジェクトを作成します。

次に、**メニューから****ローカル同期**をアクティブ化を選択して**、ローカル同期をアクティブ化**します。という名前の新しいフォルダを作成し`demo`、プロンプトにファイルの表示を許可して、**アクティブ化**を選択します。プロンプトが表示されたら、**変更の保存**を選択します。

![Infrastructure Composer Activate local sync window with a demo project folder selected and the Activate button is ready to be selected。](http://docs.aws.amazon.com/ja_jp/infrastructure-composer/latest/dg/images/aac_use_ex_11.png)


次に、Amazon API Gateway カードをキャンバスにドラッグします。**詳細**を選択して、**リソースプロパティ**パネルを表示します。

![リソースプロパティパネルが開いたキャンバス上の API Gateway リソース。](http://docs.aws.amazon.com/ja_jp/infrastructure-composer/latest/dg/images/aac_use_ex_12.png)


**リソースプロパティ**パネルから、以下を設定して**保存します**。
+ **API 定義に外部ファイルを使用する**オプションを選択します。
+ **外部ファイルへの相対パス**`./api-spec.yaml`として入力する

![「API 定義に外部ファイルを使用する」とマークされたチェックボックスと、定義された外部ファイルへの相対パスを示すウィンドウ。](http://docs.aws.amazon.com/ja_jp/infrastructure-composer/latest/dg/images/aac_use_ex_13.png)


これにより、ローカルマシンに次のディレクトリが作成されます。

```
demo
└── api-spec.yaml
```

これで、ローカルマシンで外部ファイルを設定できます。IDE を使用して、プロジェクトフォルダ`api-spec.yaml`にある を開きます。その内容を以下に置き換えます。

```
openapi: '3.0'
info: {}
paths:
  /:
    get:
      responses: {}
    post:
      x-amazon-apigateway-integration:
        credentials:
          Fn::GetAtt:
            - ApiQueuesendmessageRole
            - Arn
        httpMethod: POST
        type: aws
        uri:
          Fn::Sub: arn:${AWS::Partition}:apigateway:${AWS::Region}:sqs:path/${AWS::AccountId}/${Queue.QueueName}
        requestParameters:
          integration.request.header.Content-Type: '''application/x-www-form-urlencoded'''
        requestTemplates:
          application/json: Action=SendMessage&MessageBody={"data":$input.body}
        responses:
          default:
            statusCode: 200
      responses:
        '200':
          description: 200 response
```

Infrastructure Composer **Template** ビューでは、Infrastructure Composer が外部ファイルを参照するようにテンプレートを自動的に更新したことを確認できます。

![外部ファイルを参照するように設定されたインフラストラクチャコードを示す Infrastructure Composer テンプレートビュー。](http://docs.aws.amazon.com/ja_jp/infrastructure-composer/latest/dg/images/aac_use_ex_07.png)
