

# 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 扩展示例定义了一个 [GatewayResponses](https://docs.aws.amazon.com/apigateway/latest/api/API_GetGatewayResponses.html) 映射，该映射包含两个 [GatewayResponse](https://docs.aws.amazon.com/apigateway/latest/api/API_GatewayResponse.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 }"
      }
    }
  }
}
```