

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# x-amazon-apigateway-gateway-responses 物件
<a name="api-gateway-swagger-extensions-gateway-responses"></a>

將 API 的閘道回應定義為鍵值對之字串對 [GatewayResponse](https://docs.aws.amazon.com/apigateway/latest/api/API_GatewayResponse.html) 的對應。該擴展適用於根層級 OpenAPI 結構。


| 屬性名稱 | 類型 | 描述 | 
| --- | --- | --- | 
| responseType | [x-amazon-apigateway-gateway-responses.gatewayResponse](api-gateway-swagger-extensions-gateway-responses.gatewayResponse.md) |  指定之 *responseType* 的 `GatewayResponse`。  | 

## x-amazon-apigateway-gateway-responses 範例
<a name="api-gateway-swagger-extensions-gateway-responses-example"></a>

 下列 OpenAPI 的 API Gateway 延伸範例會定義包含兩個 [GatewayResponse](https://docs.aws.amazon.com/apigateway/latest/api/API_GatewayResponse.html) 執行個體的 [GatewayResponses](https://docs.aws.amazon.com/apigateway/latest/api/API_GetGatewayResponses.html) 對應，一個為 `DEFAULT_4XX` 類型，另一個為 `INVALID_API_KEY` 類型。

```
{
  "x-amazon-apigateway-gateway-responses": {
    "DEFAULT_4XX": {
      "responseParameters": {
        "gatewayresponse.header.Access-Control-Allow-Origin": "'domain.com'"
      },
      "responseTemplates": {
        "application/json": "{\"message\": test 4xx b }"
      }
    },
    "INVALID_API_KEY": {
      "statusCode": "429",
      "responseTemplates": {
        "application/json": "{\"message\": test forbidden }"
      }
    }
  }
}
```