aws / aws/aws-sam-cli

Introduce `serialzeBodyToJson` property on HTTP event files

Open
#7,836 1 comment 0 reactions 0 assignees View on GitHub
stage/needs-feedback type/feature
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.