Introduce `serialzeBodyToJson` property on HTTP event files
- Dominant language
- Python
- Stars
- 6.7k
- Forks
- 1.2k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 52
Description
### Describe your idea/feature/enhancement
Normally, when configuring an FunctionUrl for a Lambda function, you would invoke it like below.
```bash
sam local invoke SomeFunction --event some-event.json
```
Where the event file includes a HTTP payload, containing a raw JSON string for the body.
```json
{
"version": "2.0",
"routeKey": "$default",
"rawPath": "/somepath",
"rawQueryString": "",
"headers": {
"Content-Type": "application/json"
},
"requestContext": {
"http": {
"method": "POST",
"path": "/",
"protocol": "HTTP/1.1"
},
"routeKey": "$default",
"stage": "$default"
},
"body": "{\"message\": \"hi\"}",
"isBase64Encoded": false
}
```
When the application grows, I would like the application be easier to test locally. Including JSON objects in the body to send data, with a flag to turn this off or on would therefor be valueable.
### Proposal
Introduce an optional `serialzeBodyToJson` property on the object and default it to `false`. When `true`, it will directly send the body to the lambda function as a dictionary.
Contributor guide
Assessment
This issue has not been assessed yet.