diff --git a/lib/utils/serverless-utils/cloudformation-schema.js b/lib/utils/serverless-utils/cloudformation-schema.js index ac02b47dd8..48c6e459ae 100644 --- a/lib/utils/serverless-utils/cloudformation-schema.js +++ b/lib/utils/serverless-utils/cloudformation-schema.js @@ -43,7 +43,13 @@ const createSchema = () => { const types = functionNames.flatMap((functionName) => ['mapping', 'scalar', 'sequence'].map((kind) => yamlType(functionName, kind)) ); - return yaml.DEFAULT_SCHEMA.extend(types); + const implicitTypes = yaml.DEFAULT_SCHEMA.implicit.filter( + (type) => type.tag !== 'tag:yaml.org,2002:timestamp' + ); + return new yaml.Schema({ + implicit: implicitTypes, + explicit: yaml.DEFAULT_SCHEMA.explicit, + }).extend(types); }; module.exports = createSchema(); diff --git a/test/unit/lib/configuration/read.test.js b/test/unit/lib/configuration/read.test.js index 8c72450a74..503fd19667 100644 --- a/test/unit/lib/configuration/read.test.js +++ b/test/unit/lib/configuration/read.test.js @@ -46,6 +46,31 @@ describe('test/unit/lib/configuration/read.test.js', () => { }); }); + it('should preserve date-shaped YAML values as strings', async () => { + configurationPath = 'serverless.yml'; + await fsp.writeFile( + configurationPath, + [ + 'service: test-date-strings', + 'provider:', + ' name: aws', + ' unquotedDate: 2020-12-12', + " quotedDate: '2020-12-12'", + ' explicitlyTaggedDate: !!str 2020-12-12', + '', + ].join('\n') + ); + expect(await readConfiguration(configurationPath)).to.deep.equal({ + service: 'test-date-strings', + provider: { + name: 'aws', + unquotedDate: '2020-12-12', + quotedDate: '2020-12-12', + explicitlyTaggedDate: '2020-12-12', + }, + }); + }); + it('should read "serverless.json"', async () => { configurationPath = 'serverless.json'; const configuration = {