From 54f088c9f7cd3dacaea328e518ec68b4e8967118 Mon Sep 17 00:00:00 2001 From: Tyler Southwick Date: Wed, 8 May 2019 10:53:26 -0700 Subject: [PATCH] make DefinitionString and DefinitionBody mutually exclusive, but allow no definition from https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessapi ``` Swagger specification that describes your API. If neither DefinitionUri nor DefinitionBody are specified, SAM will generate a DefinitionBody for you based on your template configuration. ``` --- tests/test_serverless.py | 9 +++++++++ troposphere/serverless.py | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/test_serverless.py b/tests/test_serverless.py index 902beaf5d..f70710e62 100644 --- a/tests/test_serverless.py +++ b/tests/test_serverless.py @@ -151,6 +151,15 @@ def test_required_api_definitionbody(self): t.add_resource(serverless_api) t.to_json() + def test_api_no_definition(self): + serverless_api = Api( + "SomeApi", + StageName='test', + ) + t = Template() + t.add_resource(serverless_api) + t.to_json() + def test_simple_table(self): serverless_table = SimpleTable( "SomeTable" diff --git a/troposphere/serverless.py b/troposphere/serverless.py index 03f0de0a1..c078a1197 100644 --- a/troposphere/serverless.py +++ b/troposphere/serverless.py @@ -10,7 +10,7 @@ from .awslambda import Environment, VPCConfig, validate_memory_size from .dynamodb import ProvisionedThroughput, SSESpecification from .s3 import Filter -from .validators import exactly_one, positive_integer +from .validators import exactly_one, positive_integer, mutually_exclusive try: from awacs.aws import PolicyDocument policytypes = (dict, list, basestring, PolicyDocument) @@ -216,7 +216,7 @@ def validate(self): 'DefinitionBody', 'DefinitionUri', ] - exactly_one(self.__class__.__name__, self.properties, conds) + mutually_exclusive(self.__class__.__name__, self.properties, conds) class PrimaryKey(AWSProperty):