File tree 2 files changed +16
-3
lines changed
aws_lambda_powertools/utilities/parser/models
2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -63,9 +63,9 @@ class APIGatewayProxyEventV2Model(BaseModel):
63
63
rawQueryString : str
64
64
cookies : Optional [List [str ]]
65
65
headers : Dict [str , str ]
66
- queryStringParameters : Dict [str , str ]
66
+ queryStringParameters : Optional [ Dict [str , str ] ]
67
67
pathParameters : Optional [Dict [str , str ]]
68
68
stageVariables : Optional [Dict [str , str ]]
69
69
requestContext : RequestContextV2
70
- body : str
70
+ body : Optional [ str ]
71
71
isBase64Encoded : bool
Original file line number Diff line number Diff line change 1
- from aws_lambda_powertools .utilities .parser import envelopes , event_parser
1
+ from aws_lambda_powertools .utilities .parser import envelopes , event_parser , parse
2
2
from aws_lambda_powertools .utilities .parser .models import (
3
3
APIGatewayProxyEventV2Model ,
4
4
RequestContextV2 ,
@@ -90,3 +90,16 @@ def test_api_gateway_proxy_v2_event_iam_authorizer():
90
90
assert iam .principalOrgId == "AwsOrgId"
91
91
assert iam .userArn == "arn:aws:iam::1234567890:user/Admin"
92
92
assert iam .userId == "AROA2ZJZYVRE7Y3TUXHH6"
93
+
94
+
95
+ def test_apigw_event_empty_body ():
96
+ event = load_event ("apiGatewayProxyV2Event.json" )
97
+ event .pop ("body" ) # API GW v2 removes certain keys when no data is passed
98
+ parse (event = event , model = APIGatewayProxyEventV2Model )
99
+
100
+
101
+ def test_apigw_event_empty_query_strings ():
102
+ event = load_event ("apiGatewayProxyV2Event.json" )
103
+ event ["rawQueryString" ] = ""
104
+ event .pop ("queryStringParameters" ) # API GW v2 removes certain keys when no data is passed
105
+ parse (event = event , model = APIGatewayProxyEventV2Model )
You can’t perform that action at this time.
0 commit comments