From a1f340a07e0ba4f21b8655da2c4d608849278901 Mon Sep 17 00:00:00 2001 From: Graham Jenson Date: Sat, 30 Nov 2019 10:59:17 -0800 Subject: [PATCH] fix(schema): AWS::Serverless::Api.MethodSettings should be a list Fixes a mistake in the SAM schema. AWS::Serverless::Api.MethodSettings should be a list of MethodSetting objects, not a single object. fixes #242 --- cloudformation/serverless/aws-serverless-api.go | 2 +- generate/sam-2016-10-31.json | 3 ++- schema/sam.go | 5 ++++- schema/sam.schema.json | 5 ++++- test/yaml/aws-serverless-api.yaml | 14 +++++++------- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/cloudformation/serverless/aws-serverless-api.go b/cloudformation/serverless/aws-serverless-api.go index ebff6da31b..6e2bd885a7 100644 --- a/cloudformation/serverless/aws-serverless-api.go +++ b/cloudformation/serverless/aws-serverless-api.go @@ -60,7 +60,7 @@ type Api struct { // MethodSettings AWS CloudFormation Property // Required: false // See: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessapi - MethodSettings interface{} `json:"MethodSettings,omitempty"` + MethodSettings []interface{} `json:"MethodSettings,omitempty"` // Name AWS CloudFormation Property // Required: false diff --git a/generate/sam-2016-10-31.json b/generate/sam-2016-10-31.json index a8c1fbc2ee..91b807ffa5 100644 --- a/generate/sam-2016-10-31.json +++ b/generate/sam-2016-10-31.json @@ -207,7 +207,8 @@ "MethodSettings": { "Documentation": "https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessapi", "Required": false, - "PrimitiveType": "Json", + "PrimitiveItemType": "Json", + "Type": "List", "UpdateType": "Immutable" }, "EndpointConfiguration": { diff --git a/schema/sam.go b/schema/sam.go index 679b0a74d5..bf61c2138d 100644 --- a/schema/sam.go +++ b/schema/sam.go @@ -52120,7 +52120,10 @@ var SamSchema = `{ "type": "string" }, "MethodSettings": { - "type": "object" + "items": { + "type": "object" + }, + "type": "array" }, "Name": { "type": "string" diff --git a/schema/sam.schema.json b/schema/sam.schema.json index 6e44b3d073..ad100df5e0 100644 --- a/schema/sam.schema.json +++ b/schema/sam.schema.json @@ -52117,7 +52117,10 @@ "type": "string" }, "MethodSettings": { - "type": "object" + "items": { + "type": "object" + }, + "type": "array" }, "Name": { "type": "string" diff --git a/test/yaml/aws-serverless-api.yaml b/test/yaml/aws-serverless-api.yaml index a57d8c3354..9574294e7a 100644 --- a/test/yaml/aws-serverless-api.yaml +++ b/test/yaml/aws-serverless-api.yaml @@ -12,21 +12,21 @@ Resources: CacheClusterEnabled: true CacheClusterSize: test-cache-cluster-size Variables: - NAME: VALUE + NAME: VALUE ServerlessApiWithDefinitionUriAsS3Location: Type: AWS::Serverless::Api Properties: Name: test-name StageName: test-stage-name - DefinitionUri: + DefinitionUri: Bucket: test-bucket Key: test-key Version: 1 CacheClusterEnabled: true CacheClusterSize: test-cache-cluster-size Variables: - NAME: VALUE + NAME: VALUE ServerlessApiWithDefinitionBodyAsJSON: Type: AWS::Serverless::Api @@ -40,19 +40,19 @@ Resources: CacheClusterEnabled: true CacheClusterSize: test-cache-cluster-size Variables: - NAME: VALUE + NAME: VALUE ServerlessApiWithDefinitionBodyAsYAML: Type: AWS::Serverless::Api Properties: Name: test-name StageName: test-stage-name - DefinitionBody: + DefinitionBody: DefinitionKey: test-definition-value CacheClusterEnabled: true CacheClusterSize: test-cache-cluster-size Variables: - NAME: VALUE + NAME: VALUE ServerlessApiWithMethodSettingsAsYAML: Type: AWS::Serverless::Api @@ -60,7 +60,7 @@ Resources: Name: test-name StageName: test-stage-name MethodSettings: - LoggingLevel: ERROR + - LoggingLevel: ERROR MetricsEnabled: true CacheClusterEnabled: true CacheClusterSize: test-cache-cluster-size