Skip to content

Commit 73e1bcb

Browse files
committed
undo unnecessary changes, fix tests
1 parent 330dfc4 commit 73e1bcb

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

localstack/services/apigateway/templates.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from localstack.constants import APPLICATION_JSON
1111
from localstack.services.apigateway.context import ApiInvocationContext
1212
from localstack.utils.aws.templating import VelocityUtil, VtlTemplate
13-
from localstack.utils.functions import run_safe
1413
from localstack.utils.json import extract_jsonpath, json_safe
1514
from localstack.utils.strings import to_str
1615

@@ -178,13 +177,6 @@ def render_vtl(self, template, variables):
178177

179178
@staticmethod
180179
def build_variables_mapping(api_context: ApiInvocationContext):
181-
# prepare request body
182-
request_body = api_context.data
183-
if isinstance(request_body, bytes):
184-
request_body = to_str(request_body)
185-
if isinstance(request_body, str):
186-
request_body = run_safe(lambda: json.loads(request_body), _default=request_body)
187-
188180
# TODO: make this (dict) an object so usages of "render_vtl" variables are defined
189181
return {
190182
"context": api_context.context or {},
@@ -200,12 +192,6 @@ def build_variables_mapping(api_context: ApiInvocationContext):
200192
"header": dict(api_context.headers),
201193
},
202194
},
203-
"request": {
204-
"header": dict(api_context.headers),
205-
"querystring": api_context.query_params(),
206-
"path": api_context.invocation_path,
207-
"body": request_body,
208-
},
209195
}
210196

211197

tests/integration/test_apigateway.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,7 +1325,10 @@ def test_put_integration_dynamodb_proxy_validation_with_request_template(self):
13251325
"application/json": json.dumps(
13261326
{
13271327
"TableName": "MusicCollection",
1328-
"Item": {"id": {"S": "$request.body.id"}, "data": {"S": "$request.body.data"}},
1328+
"Item": {
1329+
"id": {"S": "$input.path('id')"},
1330+
"data": {"S": "$input.path('data')"},
1331+
},
13291332
}
13301333
)
13311334
}
@@ -1349,7 +1352,10 @@ def test_api_key_required_for_methods(self):
13491352
"application/json": json.dumps(
13501353
{
13511354
"TableName": "MusicCollection",
1352-
"Item": {"id": {"S": "$request.body.id"}, "data": {"S": "$request.body.data"}},
1355+
"Item": {
1356+
"id": {"S": "$input.path('id')"},
1357+
"data": {"S": "$input.path('data')"},
1358+
},
13531359
}
13541360
)
13551361
}
@@ -1402,7 +1408,10 @@ def test_multiple_api_keys_validate(self, apigateway_client):
14021408
"application/json": json.dumps(
14031409
{
14041410
"TableName": "MusicCollection",
1405-
"Item": {"id": {"S": "$request.body.id"}, "data": {"S": "$request.body.data"}},
1411+
"Item": {
1412+
"id": {"S": "$input.path('id')"},
1413+
"data": {"S": "$input.path('data')"},
1414+
},
14061415
}
14071416
)
14081417
}

0 commit comments

Comments
 (0)