Skip to content
This repository has been archived by the owner on Apr 16, 2022. It is now read-only.

Commit

Permalink
Fixing AWS::Serverless::Api.MethodSettings (#222)
Browse files Browse the repository at this point in the history
* - Fixing wrong type in the specification file
- Updating `js-yaml` Typescript module
- Removing the definition overloading now patched fixed thanks to the previous update

* - Adding test cases and fixing previous according to the standard
- Fixing missing `ItemType` in the new schema
- Adding required properties in `MethodSetting`

* - Adding test templates in the test case
- Moving typing module in the devDep
- Generating `sam_20161031_cfn.json`

* Fix whitespace and IDE changes

* Add to changelog
  • Loading branch information
acolombier authored and martysweet committed Feb 5, 2019
1 parent c2690b1 commit 9f08c3f
Show file tree
Hide file tree
Showing 9 changed files with 190 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,8 @@ and this project adheres to [Semantic
Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
- Merge PR #222, fixing AWS::Serverless::Api.MethodSettings

## [1.9.4] - 2018-12-09
### Changed
Expand Down
2 changes: 1 addition & 1 deletion data/sam_20161031_cfn.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions data/sam_20161031_custom_specification.json
Expand Up @@ -113,7 +113,7 @@
"HttpMethod": {
"Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apitgateway-stage-methodsetting.html#cfn-apigateway-stage-methodsetting-httpmethod",
"PrimitiveType": "String",
"Required": false,
"Required": true,
"UpdateType": "Mutable"
},
"LoggingLevel": {
Expand All @@ -131,7 +131,7 @@
"ResourcePath": {
"Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apitgateway-stage-methodsetting.html#cfn-apigateway-stage-methodsetting-resourcepath",
"PrimitiveType": "String",
"Required": false,
"Required": true,
"UpdateType": "Mutable"
},
"ThrottlingBurstLimit": {
Expand Down Expand Up @@ -220,7 +220,8 @@
"Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigateway-deployment-stagedescription.html#cfn-apigateway-deployment-stagedescription-methodsettings",
"DuplicatesAllowed": false,
"Required": false,
"Type": "MethodSetting",
"Type": "List",
"ItemType": "MethodSetting",
"UpdateType": "Mutable"
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -32,7 +32,7 @@
"@types/clone": "^0.1.30",
"@types/colors": "~1.1.3",
"@types/commander": "^2.11.0",
"@types/js-yaml": "^3.9.1",
"@types/js-yaml": "^3.12.0",
"@types/mocha": "^2.2.44",
"@types/node": "^8.0.50",
"@types/opn": "^3.0.28",
Expand Down
7 changes: 0 additions & 7 deletions src/fixes.d.ts

This file was deleted.

14 changes: 14 additions & 0 deletions src/test/validatorTest.ts
Expand Up @@ -1910,5 +1910,19 @@ describe('validator', () => {
expect(result).to.have.deep.property('templateValid', true);
expect(result['errors']['crit']).to.have.lengthOf(0);
});

it('a invalid APIGateway::Stage.MethodSettings type (sam_20161031_api_methodsettings_not_a_list.yaml) should invalidate successfully', () => {
const input = 'testData/invalid/yaml/sam_20161031_api_methodsettings_not_a_list.yaml';
let result = validator.validateFile(input);
expect(result).to.have.deep.property('templateValid', false);
expect(result['errors']['crit']).to.have.lengthOf(1);
});

it('a valid APIGateway::Stage.MethodSettings containing incomplete APIGateway::Stage.MethodSetting (sam_20161031_api_methodsettings_missing_required.yaml) should invalidate successfully', () => {
const input = 'testData/invalid/yaml/sam_20161031_api_methodsettings_missing_required.yaml';
let result = validator.validateFile(input);
expect(result).to.have.deep.property('templateValid', false);
expect(result['errors']['crit']).to.have.lengthOf(2);
});
});
});
@@ -0,0 +1,81 @@
AWSTemplateFormatVersion : '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: A hello world application.

Globals:
Function:
Handler: index.handler
Runtime: nodejs6.10
CodeUri: src/
DeadLetterQueue:
Type: SNS
TargetArn: arn:aws:sns:us-east-1:84969EXAMPLE:DeadLetterQueue
Description: somethingCool
MemorySize: 512
Timeout: 10
VpcConfig:
SecurityGroupIds:
- SGID0
SubnetIds:
- SID0
Environment:
Variables:
VAR0: 0
Tags:
TAG0: tag0
Tracing: PassThrough
KmsKeyArn: arn:aws:sns:us-east-1:84969EXAMPLE:KmsKeyArn
AutoPublishAlias: live
DeploymentPreference:
Type: Linear10PercentEvery10Minutes

Api:
Name: ServerlessRestApi
DefinitionUri: s3://s3-eu-west-1.amazonaws.com/s3test.example.com
CacheClusterEnabled: True
CacheClusterSize: 1024M
Variables:
VAR1: 1
EndpointConfiguration: EDGE
MethodSettings:
- CacheDataEncrypted: True
BinaryMediaTypes:
- image~1gif
- image~1png
Cors: example.com

SimpleTable:
SSESpecification:
SSEEnabled: True


Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
VpcConfig:
SecurityGroupIds:
- SGID1
SubnetIds:
- SID1
Tags:
TAG1: tag1
Environment:
Variables:
VAR2: shouldBe2

HelloWorldAPI:
Type: AWS::Serverless::Api
Properties:
StageName: Prod
EndpointConfiguration: REGIONAL
BinaryMediaTypes:
- image~1exe
Variables:
VAR2: 2
VAR3: 3

HelloWorldTable:
Type: AWS::Serverless::SimpleTable
Properties:
TableName: example-table
@@ -0,0 +1,83 @@
AWSTemplateFormatVersion : '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: A hello world application.

Globals:
Function:
Handler: index.handler
Runtime: nodejs6.10
CodeUri: src/
DeadLetterQueue:
Type: SNS
TargetArn: arn:aws:sns:us-east-1:84969EXAMPLE:DeadLetterQueue
Description: somethingCool
MemorySize: 512
Timeout: 10
VpcConfig:
SecurityGroupIds:
- SGID0
SubnetIds:
- SID0
Environment:
Variables:
VAR0: 0
Tags:
TAG0: tag0
Tracing: PassThrough
KmsKeyArn: arn:aws:sns:us-east-1:84969EXAMPLE:KmsKeyArn
AutoPublishAlias: live
DeploymentPreference:
Type: Linear10PercentEvery10Minutes

Api:
Name: ServerlessRestApi
DefinitionUri: s3://s3-eu-west-1.amazonaws.com/s3test.example.com
CacheClusterEnabled: True
CacheClusterSize: 1024M
Variables:
VAR1: 1
EndpointConfiguration: EDGE
MethodSettings:
HttpMethod: GET
ResourcePath: /*
CacheDataEncrypted: True
BinaryMediaTypes:
- image~1gif
- image~1png
Cors: example.com

SimpleTable:
SSESpecification:
SSEEnabled: True


Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
VpcConfig:
SecurityGroupIds:
- SGID1
SubnetIds:
- SID1
Tags:
TAG1: tag1
Environment:
Variables:
VAR2: shouldBe2

HelloWorldAPI:
Type: AWS::Serverless::Api
Properties:
StageName: Prod
EndpointConfiguration: REGIONAL
BinaryMediaTypes:
- image~1exe
Variables:
VAR2: 2
VAR3: 3

HelloWorldTable:
Type: AWS::Serverless::SimpleTable
Properties:
TableName: example-table
5 changes: 4 additions & 1 deletion testData/valid/yaml/sam_20161031_globals.yaml
Expand Up @@ -39,7 +39,10 @@ Globals:
VAR1: 1
EndpointConfiguration: EDGE
MethodSettings:
CacheDataEncrypted: True
- HttpMethod: GET
ResourcePath: /*
MetricsEnabled: 'true'
DataTraceEnabled: 'true'
BinaryMediaTypes:
- image~1gif
- image~1png
Expand Down

0 comments on commit 9f08c3f

Please sign in to comment.