我正在使用带有 AWS CDK 的 typescript 为 api 网关生成 cloudFormation 模板。我有一个 Apache Velocity 模板,可以帮助我转换我的响应。当我使用打字稿创建 API 网关时。如何从代码本身传递模板。我需要在需要字符串的 IntegrationOptions 接口中的 responseTemplates 中传递我的模板。我一直无法找到任何合理的方法将其转换为字符串。
{
"sellableQuantity": $inputRoot.quantity),
"reservedQuantity": $inputRoot.reservedQuantity)
"marketplaceInventories": [
#foreach( $marketplaceInventory in $inputRoot.marketplaceInventories) )
{
"sellableQuantity": $marketplaceInventory.sellableQuantity,
"marketplaceAttributes": {
#set( $marketplaceAttributes = $marketplaceInventory.marketplaceAttributes )
"marketplaceName": "$marketplaceAttributes.marketplaceName",
"channelName": "$marketplaceAttributes.channelName"
}
}
#if( $foreach.hasNext ) , #end
#end
]
}