

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

# Amazon EventBridge でイベント JSON からスキーマを作成する
<a name="eb-schemas-infer-from-json"></a>

イベントの JSON がある場合は、そのタイプのイベントのスキーマを自動的に作成できます。

**イベントの JSON に基づいてスキーマを作成するには**

1. Amazon EventBridge コンソールの [https://console.aws.amazon.com/events/](https://console.aws.amazon.com/events/) を開いてください。

1. ナビゲーションペインで、[**Schemas**] (スキーマ)、[**Create schema**] (スキーマの作成) の順に選択します。

1. (オプション) スキーマレジストリを選択または作成します。

1. [**Schema details (スキーマの詳細)**] に、スキーマの名前を入力します。

1. (オプション) 作成したスキーマの説明を入力します。

1. [**Schema type**] (スキーマタイプ) で [**OpenAPI 3.0**] を選択します。

   イベントの JSON からスキーマを作成する場合、JSONSchema は使用できません。

1. [**Discover from JSON**] (JSON から検出) を選択します。

1. [**JSON**] の下のテキストボックスで、イベントの JSON ソースを貼り付けるかドラッグします。

   たとえば、実行に失敗した場合は、この AWS Step Functions イベントのソースに貼り付けることができます。

   ```
   {
       "version": "0",
       "id": "315c1398-40ff-a850-213b-158f73e60175",
       "detail-type": "Step Functions Execution Status Change",
       "source": "aws.states",
       "account": "012345678912",
       "time": "2019-02-26T19:42:21Z",
       "region": "us-east-1",
       "resources": [
         "arn:aws:states:us-east-1:012345678912:execution:state-machine-name:execution-name"
       ],
       "detail": {
           "executionArn": "arn:aws:states:us-east-1:012345678912:execution:state-machine-name:execution-name",
           "stateMachineArn": "arn:aws:states:us-east-1:012345678912:stateMachine:state-machine",
           "name": "execution-name",
           "status": "FAILED",
           "startDate": 1551225146847,
           "stopDate": 1551225151881,
           "input": "{}",
           "output": null
       }
   }
   ```

1. [**Discover schema**] (スキーマの検出) を選択します。

1. Eventbridge はイベントの OpenAPI スキーマを生成します。例えば、上のステップ関数イベントに対して以下のスキーマが生成されます。

   ```
   {
     "openapi": "3.0.0",
     "info": {
       "version": "1.0.0",
       "title": "StepFunctionsExecutionStatusChange"
     },
     "paths": {},
     "components": {
       "schemas": {
         "AWSEvent": {
           "type": "object",
           "required": ["detail-type", "resources", "detail", "id", "source", "time", "region", "version", "account"],
           "x-amazon-events-detail-type": "Step Functions Execution Status Change",
           "x-amazon-events-source": "aws.states",
           "properties": {
             "detail": {
               "$ref": "#/components/schemas/StepFunctionsExecutionStatusChange"
             },
             "account": {
               "type": "string"
             },
             "detail-type": {
               "type": "string"
             },
             "id": {
               "type": "string"
             },
             "region": {
               "type": "string"
             },
             "resources": {
               "type": "array",
               "items": {
                 "type": "string"
               }
             },
             "source": {
               "type": "string"
             },
             "time": {
               "type": "string",
               "format": "date-time"
             },
             "version": {
               "type": "string"
             }
           }
         },
         "StepFunctionsExecutionStatusChange": {
           "type": "object",
           "required": ["output", "input", "executionArn", "name", "stateMachineArn", "startDate", "stopDate", "status"],
           "properties": {
             "executionArn": {
               "type": "string"
             },
             "input": {
               "type": "string"
             },
             "name": {
               "type": "string"
             },
             "output": {},
             "startDate": {
               "type": "integer",
               "format": "int64"
             },
             "stateMachineArn": {
               "type": "string"
             },
             "status": {
               "type": "string"
             },
             "stopDate": {
               "type": "integer",
               "format": "int64"
             }
           }
         }
       }
     }
   }
   ```

1. スキーマが生成されたら、[**Create**] (作成) を選択します。