x-amazon-apigateway-gateway-responses 对象 - Amazon API Gateway
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

x-amazon-apigateway-gateway-responses 对象

将 API 的网关响应定义为键/值对的字符串到 GatewayResponse 映射。扩展适用于根级 OpenAPI 结构。

属性
属性名称 类型 说明
responseType x-amazon-apigateway-gateway-responses.gatewayResponse

指定 responseTypeGatewayResponse

x-amazon-apigateway-gateway-responses 示例

以下基于 OpenAPI 的 API Gateway 扩展示例定义了一个 GatewayResponses 映射,该映射包含两个 GatewayResponse 实例,其中一个为 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 }" } } } }