Reputation: 765
I have an AWS lambda that acts on an events of the form:
{"id": "some-id", "stuff": "bla-bla-stuff-here" }
Now I want to attach an API Gateway endpoint with POSTs to an url of the form /stuff/{id} where the actual stuff would go in the body. So, on the integration request of the method there is a mapping template section which seems to allow for something like:
{
"id": $input.params('id'),
"stuff": $input.body
}
Now, how do I specify this template in the SAM file?
Upvotes: 2
Views: 1408
Reputation: 2746
SAM uses the Proxy integration to Lambda which I don't think works with request/response mapping. If it does, you would need to specify this in Swagger as the DefinitionBody
property of the Serverless::Api as SAM doesn't currently have a property for adding Request/Response mapping and generating the Swagger for you. The easiest way to use Swagger is to inspect the generated CloudFormation template of your stack; copy-paste it into your SAM template under DefinitionBody
; and then apply the necessary Swagger additions.
Upvotes: 1