Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion samtranslator/swagger/swagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -1144,4 +1144,5 @@ def safe_compare_regex_with_string(regex, data):

@staticmethod
def get_path_without_trailing_slash(path):
return re.sub(r"{([a-zA-Z0-9._-]+|proxy\+)}", "*", path)
# convert greedy paths to such as {greedy+}, {proxy+} to "*"
return re.sub(r"{([a-zA-Z0-9._-]+|[a-zA-Z0-9._-]+\+|proxy\+)}", "*", path)
17 changes: 17 additions & 0 deletions tests/model/eventsources/test_api_event_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,23 @@ def test_get_permission_with_trailing_slash(self):

self.assertEqual(arn, "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/GET/foo")

@patch("boto3.session.Session.region_name", "eu-west-2")
def test_get_permission_with_path_parameter_to_any_path(self):
self.api_event_source.Path = "/foo/{userId+}"
cfn = self.api_event_source.to_cloudformation(function=self.func, explicit_api={})

perm = cfn[0]
self.assertIsInstance(perm, LambdaPermission)

try:
arn = self._extract_path_from_arn("{}PermissionProd".format(self.logical_id), perm)
except AttributeError:
self.fail("Permission class isn't valid")

self.assertEqual(
arn, "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/${__Stage__}/GET/foo/*"
)

@patch("boto3.session.Session.region_name", "eu-west-2")
def test_get_permission_with_path_parameter(self):
self.api_event_source.Path = "/foo/{userId}/bar"
Expand Down