Skip to content

Commit bb8af11

Browse files
authored
fix(apigateway): update Response class to require status_code only (#1560)
1 parent 04cc5b9 commit bb8af11

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

aws_lambda_powertools/event_handler/api_gateway.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ class Response:
143143
def __init__(
144144
self,
145145
status_code: int,
146-
content_type: Optional[str],
147-
body: Union[str, bytes, None],
146+
content_type: Optional[str] = None,
147+
body: Union[str, bytes, None] = None,
148148
headers: Optional[Dict] = None,
149149
):
150150
"""

tests/functional/event_handler/test_api_gateway.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,3 +1289,10 @@ def handler(event: APIGatewayProxyEventV2, context):
12891289
# THEN
12901290
result = handler(load_event("apiGatewayProxyV2Event.json"), None)
12911291
assert result["statusCode"] == 200
1292+
1293+
1294+
def test_response_with_status_code_only():
1295+
ret = Response(status_code=204)
1296+
assert ret.status_code == 204
1297+
assert ret.body is None
1298+
assert ret.headers == {}

0 commit comments

Comments
 (0)