Skip to content
Closed
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
8 changes: 7 additions & 1 deletion lib/utils/serverless-utils/cloudformation-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
25 changes: 25 additions & 0 deletions test/unit/lib/configuration/read.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down