本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
x-amazon-apigateway-gateway-responses.responseTemp
将给定网关响应的GatewayResponse string-to-string 映射模板定义为键值对的映射。对于每个键/值对,“键”指内容类型。例如“application/json”,而“值”指简单变量替换的字符串化映射模板。GatewayResponse
映射模板不由 Velocity 模板语言 (VTL)
属性 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
属性名称 | 类型 | 说明 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
string |
|
x-amazon-apigateway-gateway-响应.响应模板示例
以下 OpenAPI 扩展示例显示了一个GatewayResponse映射模板,用于将 API 网关生成的错误响应自定义为特定于应用程序的格式。
"responseTemplates": { "application/json": "{ \"message\": $context.error.messageString, \"type\":$context.error.responseType, \"statusCode\": '488' }" }
以下 OpenAPI 扩展示例显示了一个GatewayResponse映射模板,用于使用静态错误消息覆盖 API 网关生成的错误响应。
"responseTemplates": { "application/json": "{ \"message\": 'API-specific errors' }" }