次のように、応答テンプレートでnull
を指定します。
aws apigateway put-integration-response \
--region "$region" \
--rest-api-id "$api_id" \
--resource-id "$resource_id" \
--http-method GET \
--status-code 200 \
--response-templates '{"application/json":null}'
エラーが発生します:
Parameter validation failed:
Invalid type for parameter responseTemplates.application/json, value: None, type: <type 'NoneType'>, valid types: <type 'basestring'>
null
を"Empty"
に置き換えると、CLIは次のパラメーターを受け入れます。
--response-templates '{"application/json":"Empty"}'
AWSコンソールが同じメソッドを作成し、それをクエリすると、値はnull
として表示されます。 aws-cliを使用して同じ値に設定できるはずです。
aws-cli / v1.9.2
回避策は、 null
の代わりに空の文字列、つまり--response-templates '{"application/json":""}'
を渡すことであり、次のようになります。
{
"statusCode": "200",
"responseTemplates": {
"application/json": null
}
}
ありがとう。
@quiverと@ehammondに感謝します。 「回避策」が実際にそれを行う正しい方法であると私は恐れています。 実際のところ、apigatewayサービスは入力として文字列を期待するようにモデル化されているため、すべてのAWS SDKはこのように機能し、apigatewayは空の文字列を内部でnullとして変換するようです。 おそらく、AWSコンソールでも同じことが起こります。
最も参考になるコメント
回避策は、
null
の代わりに空の文字列、つまり--response-templates '{"application/json":""}'
を渡すことであり、次のようになります。