ラムダ関数のAPIゲートウェイの統合をServerless Frameworkバージョン0.4.2と設定しています。「無効なマッピング式が指定された:true」を返すrequestParameters
私の問題は、エンドポイントのリクエストパラメータを定義することです。 AWS docs for API gatewayエントリは言う:
requestParameters
をアマゾンAPIゲートウェイによって受け入れ可能なリクエストパラメータを表します。要求パラメータは、キーをソースとし、ブール値を値とするキー/値マップとして表されます。 Booleanフラグは、パラメータが必須かどうかを指定するために使用されます。ソースはmethod.request。{location}。{name}のパターンと一致する必要があります。locationはクエリーストリング、パス、またはヘッダーです。 nameは有効な一意のパラメータ名です。ここで指定されたソースは、統合要求パラメーターまたはテンプレートへのマッピングのために統合で使用できます。
私はそれを理解し、s-function.json
で設定はAWS CLIに直接与えられているので、私は形式でリクエストパラメータに指定しました: "method.request.querystring.startYear": true
を。しかし、私はInvalid mapping expression specified: true
エラーを受け取りました。私は同じ結果を持つ"method.request.querystring.startYear": "true"
として設定を指定しようとしました。
s-function.json
:
{
"name": "myname",
// etc...
"endpoints": [
{
"path": "mypath",
"method": "GET",
"type": "AWS",
"authorizationType": "none",
"apiKeyRequired": false,
"requestParameters": {
"method.request.querystring.startYear": true,
"method.request.querystring.startMonth": true,
"method.request.querystring.startDay": true,
"method.request.querystring.currentYear": true,
"method.request.querystring.currentMonth": true,
"method.request.querystring.currentDay": true,
"method.request.querystring.totalDays": true,
"method.request.querystring.volume": true,
"method.request.querystring.userId": true
},
// etc...
}
],
"events": []
}
任意のアイデア?前もって感謝します!
その他の優れたソリューションhttp://stackoverflow.com/a/33602122/2318357しかしそれはslsを伴わない。 –
http://kennbrodhagen.net/2015/12/06/how-to-create-a-request-object-for-your-lambda-event-from-api-gateway/ –
私は、文法/この質問のための 'requestParameters'の書式ですが、これは良い使い方です – Seafish