Skip to content

Commit 777fcfc

Browse files
moelasmarqingchm
authored andcommitted
fix the request parameter parsing, the value can contain dots (aws#1975)
* fix the request parameter parsing, the value can contain dots * fix the unit test for python 2.7 * use built in split, instead of concatenating the string
1 parent dc7413d commit 777fcfc

File tree

5 files changed

+31
-11
lines changed

5 files changed

+31
-11
lines changed

samtranslator/swagger/swagger.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,8 @@ def add_request_parameters_to_method(self, path, method_name, request_parameters
11341134

11351135
parameter_name = request_parameter["Name"]
11361136
location_name = parameter_name.replace("method.request.", "")
1137-
location, name = location_name.split(".")
1137+
1138+
location, name = location_name.split(".", 1)
11381139

11391140
if location == "querystring":
11401141
location = "query"

tests/translator/input/function_with_request_parameters.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ Resources:
3838
RequestParameters:
3939
- method.request.querystring.type
4040
- method.request.path.id
41+
- method.request.querystring.full.type

tests/translator/output/aws-cn/function_with_request_parameters.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@
5353
}
5454
}
5555
},
56-
"ServerlessRestApiDeploymentc2741b5220": {
56+
"ServerlessRestApiDeployment32042a0513": {
5757
"Type": "AWS::ApiGateway::Deployment",
5858
"Properties": {
5959
"RestApiId": {
6060
"Ref": "ServerlessRestApi"
6161
},
62-
"Description": "RestApi deployment id: c2741b5220c940a753e3d1e18da6763aaba1c19b",
62+
"Description": "RestApi deployment id: 32042a0513cd1c4e5c14794b306c4de10ca5c4af",
6363
"StageName": "Stage"
6464
}
6565
},
@@ -118,7 +118,7 @@
118118
"Type": "AWS::ApiGateway::Stage",
119119
"Properties": {
120120
"DeploymentId": {
121-
"Ref": "ServerlessRestApiDeploymentc2741b5220"
121+
"Ref": "ServerlessRestApiDeployment32042a0513"
122122
},
123123
"RestApiId": {
124124
"Ref": "ServerlessRestApi"
@@ -247,6 +247,12 @@
247247
"type": "string",
248248
"name": "id",
249249
"in": "path"
250+
},
251+
{
252+
"required": false,
253+
"type": "string",
254+
"name": "full.type",
255+
"in": "query"
250256
}
251257
]
252258
}

tests/translator/output/aws-us-gov/function_with_request_parameters.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@
5353
}
5454
}
5555
},
56-
"ServerlessRestApiDeployment7c706bcd56": {
56+
"ServerlessRestApiDeploymentbe3a929cf9": {
5757
"Type": "AWS::ApiGateway::Deployment",
5858
"Properties": {
5959
"RestApiId": {
6060
"Ref": "ServerlessRestApi"
6161
},
62-
"Description": "RestApi deployment id: 7c706bcd56e685afb5882e0219515c9413bcd13b",
62+
"Description": "RestApi deployment id: be3a929cf90555789f2865fc4a96eb9a11ff7a81",
6363
"StageName": "Stage"
6464
}
6565
},
@@ -128,7 +128,7 @@
128128
"Type": "AWS::ApiGateway::Stage",
129129
"Properties": {
130130
"DeploymentId": {
131-
"Ref": "ServerlessRestApiDeployment7c706bcd56"
131+
"Ref": "ServerlessRestApiDeploymentbe3a929cf9"
132132
},
133133
"RestApiId": {
134134
"Ref": "ServerlessRestApi"
@@ -247,6 +247,12 @@
247247
"type": "string",
248248
"name": "id",
249249
"in": "path"
250+
},
251+
{
252+
"required": false,
253+
"type": "string",
254+
"name": "full.type",
255+
"in": "query"
250256
}
251257
]
252258
}

tests/translator/output/function_with_request_parameters.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@
5353
}
5454
}
5555
},
56-
"ServerlessRestApiDeployment2223b43914": {
56+
"ServerlessRestApiDeployment104b236830": {
5757
"Type": "AWS::ApiGateway::Deployment",
5858
"Properties": {
5959
"RestApiId": {
6060
"Ref": "ServerlessRestApi"
6161
},
62-
"Description": "RestApi deployment id: 2223b439142974b7a3aad1381ddd39027077ce52",
62+
"Description": "RestApi deployment id: 104b236830d26d2515909073d13fa9c58ad6db49",
6363
"StageName": "Stage"
6464
}
6565
},
@@ -118,7 +118,7 @@
118118
"Type": "AWS::ApiGateway::Stage",
119119
"Properties": {
120120
"DeploymentId": {
121-
"Ref": "ServerlessRestApiDeployment2223b43914"
121+
"Ref": "ServerlessRestApiDeployment104b236830"
122122
},
123123
"RestApiId": {
124124
"Ref": "ServerlessRestApi"
@@ -239,6 +239,12 @@
239239
"type": "string",
240240
"name": "id",
241241
"in": "path"
242+
},
243+
{
244+
"required": false,
245+
"type": "string",
246+
"name": "full.type",
247+
"in": "query"
242248
}
243249
]
244250
}
@@ -272,4 +278,4 @@
272278
}
273279
}
274280
}
275-
}
281+
}

0 commit comments

Comments
 (0)