Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Raise Invalid Resource When DisableExecuteApiEndpoint: False And Has No DefinitionBody #2285

Merged
merged 7 commits into from
Jan 21, 2022
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
4 changes: 3 additions & 1 deletion bin/sam-translate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python2
CoshUS marked this conversation as resolved.
Show resolved Hide resolved
#!/usr/bin/env python

"""Convert SAM templates to CloudFormation templates.

Expand Down Expand Up @@ -26,7 +26,9 @@
import sys

import boto3

from docopt import docopt
from functools import reduce

my_path = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, my_path + "/..")
Expand Down
2 changes: 1 addition & 1 deletion samtranslator/model/api/api_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def _add_endpoint_extension(self):
https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-api.html#sam-api-definitionbody
For this reason, we always put DisableExecuteApiEndpoint into openapi object irrespective of origin of DefinitionBody.
"""
if self.disable_execute_api_endpoint and not self.definition_body:
if self.disable_execute_api_endpoint is not None and not self.definition_body:
raise InvalidResourceException(
self.logical_id, "DisableExecuteApiEndpoint works only within 'DefinitionBody' property."
)
Expand Down
2 changes: 1 addition & 1 deletion samtranslator/model/api/http_api_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def _add_endpoint_configuration(self):
For this reason, we always put DisableExecuteApiEndpoint into openapi object.

"""
if self.disable_execute_api_endpoint and not self.definition_body:
if self.disable_execute_api_endpoint is not None and not self.definition_body:
raise InvalidResourceException(
self.logical_id, "DisableExecuteApiEndpoint works only within 'DefinitionBody' property."
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Resources:
ApiGatewayApi:
Type: AWS::Serverless::Api
Properties:
StageName: prod
DisableExecuteApiEndpoint: False
DefinitionUri: s3://sam-demo-bucket/webpage_swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Resources:
ApiGatewayApi:
Type: AWS::Serverless::HttpApi
Properties:
StageName: prod
DisableExecuteApiEndpoint: False
DefinitionUri: s3://sam-demo-bucket/webpage_swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"errorMessage": "Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [ApiGatewayApi] is invalid. DisableExecuteApiEndpoint works only within 'DefinitionBody' property."
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"errorMessage": "Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [ApiGatewayApi] is invalid. DisableExecuteApiEndpoint works only within 'DefinitionBody' property."
}