Skip to content

Commit

Permalink
fix(parser): set APIGatewayProxyEventSchema body and query string key…
Browse files Browse the repository at this point in the history
…s to be nullable (#2465)

Co-authored-by: 1482568 <austin.blythe@hyatt.com>
  • Loading branch information
blytheaw and 1482568 authored May 2, 2024
1 parent 1f6cc41 commit 7ce5b3c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions packages/parser/src/schemas/apigw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ const APIGatewayProxyEventSchema = z.object({
'OPTIONS',
]),
headers: z.record(z.string()).optional(),
queryStringParameters: z.record(z.string()).optional(),
queryStringParameters: z.record(z.string()).nullable(),
multiValueHeaders: z.record(z.array(z.string())).optional(),
multiValueQueryStringParameters: z.record(z.array(z.string())).optional(),
multiValueQueryStringParameters: z.record(z.array(z.string())).nullable(),
requestContext: APIGatewayEventRequestContext,
pathParameters: z.record(z.string()).optional().nullish(),
stageVariables: z.record(z.string()).optional().nullish(),
isBase64Encoded: z.boolean().optional(),
body: z.string().optional(),
body: z.string().nullable(),
});

export { APIGatewayProxyEventSchema, APIGatewayCert };
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
"queryStringParameters": {
"QueryString1": "queryValue1"
},
"multiValueQueryStringParameters": {
"QueryString1": ["queryValue1"]
},
"pathParameters": {},
"stageVariables": {
"StageVar1": "stageValue1"
Expand Down Expand Up @@ -64,5 +67,6 @@
"resourceId": "ANY /request",
"resourcePath": "/request",
"stage": "test"
}
},
"body": null
}
4 changes: 2 additions & 2 deletions packages/parser/tests/unit/envelopes/apigwt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('ApigwEnvelope ', () => {

it('should throw no body provided', () => {
const testEvent = TestEvents.apiGatewayProxyEvent as APIGatewayProxyEvent;
testEvent.body = undefined;
testEvent.body = null;

expect(() => ApiGatewayEnvelope.parse(testEvent, TestSchema)).toThrow(
ParseError
Expand Down Expand Up @@ -56,7 +56,7 @@ describe('ApigwEnvelope ', () => {

it('should return success false with original body if no body provided', () => {
const testEvent = TestEvents.apiGatewayProxyEvent as APIGatewayProxyEvent;
testEvent.body = undefined;
testEvent.body = null;

const resp = ApiGatewayEnvelope.safeParse(testEvent, TestSchema);
expect(resp).toEqual({
Expand Down

0 comments on commit 7ce5b3c

Please sign in to comment.