

# x-amazon-apigateway-gateway-responses.gatewayResponse 对象
<a name="api-gateway-swagger-extensions-gateway-responses.gatewayResponse"></a>

定义了给定响应类型的网关响应，包括状态代码、任何适用的响应参数或响应模板。


| 属性名称 | 类型 | 说明 | 
| --- | --- | --- | 
| responseParameters | [x-amazon-apigateway-gateway-responses.responseParameters](api-gateway-swagger-extensions-gateway-responses.responseParameters.md) |  指定 [GatewayResponse](https://docs.aws.amazon.com/apigateway/latest/api/API_GatewayResponse.html) 参数，即标头参数。参数值可以采用任何传入[请求参数](rest-api-parameter-mapping.md)值或静态自定义值。  | 
| responseTemplates | [x-amazon-apigateway-gateway-responses.responseTemplates](api-gateway-swagger-extensions-gateway-responses.responseTemplates.md) |  指定网关响应的映射模板。这些模板不由 VTL 引擎处理。  | 
| statusCode | string |  网关响应的 HTTP 状态代码。  | 

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

 以下基于 OpenAPI 的 API Gateway 扩展示例定义了 [GatewayResponse](https://docs.aws.amazon.com/apigateway/latest/api/API_GatewayResponse.html) 来自定义 `INVALID_API_KEY` 响应，以返回状态代码 `456`、传入请求的 `api-key` 标头值以及 `"Bad api-key"` 消息。

```
    "INVALID_API_KEY": {
      "statusCode": "456",
      "responseParameters": {
        "gatewayresponse.header.api-key": "method.request.header.api-key"
      },
      "responseTemplates": {
        "application/json": "{\"message\": \"Bad api-key\" }"
      }
    }
```