From 5bfe939a68c114dce86ee13a23b939128af33504 Mon Sep 17 00:00:00 2001 From: Mariusz Nowak Date: Fri, 9 Oct 2020 13:23:46 +0200 Subject: [PATCH] fix(Config Schema): Revert invalid "oneOf" based validation --- .../compile/events/cloudWatchEvent/index.js | 16 ++++++++------ .../compile/events/eventBridge/index.js | 21 +++++++++---------- lib/plugins/aws/provider/awsProvider.js | 5 ----- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/lib/plugins/aws/package/compile/events/cloudWatchEvent/index.js b/lib/plugins/aws/package/compile/events/cloudWatchEvent/index.js index bba42f5e032..3d440515bd4 100644 --- a/lib/plugins/aws/package/compile/events/cloudWatchEvent/index.js +++ b/lib/plugins/aws/package/compile/events/cloudWatchEvent/index.js @@ -35,12 +35,6 @@ class AwsCompileCloudWatchEventEvents { name: { type: 'string', pattern: '[a-zA-Z0-9-_.]+', minLength: 1, maxLength: 64 }, enabled: { type: 'boolean' }, }, - oneOf: [ - { required: ['input'] }, - { required: ['inputPath'] }, - { required: ['inputTransformer'] }, - { required: [] }, - ], additionalProperties: false, }); } @@ -69,6 +63,16 @@ class AwsCompileCloudWatchEventEvents { Input = event.cloudwatchEvent.input; InputTransformer = event.cloudwatchEvent.inputTransformer; + if ([Input, InputPath, InputTransformer].filter(Boolean).length > 1) { + throw new this.serverless.classes.Error( + [ + 'You can only set one of input, inputPath, or inputTransformer ', + 'properties at the same time for cloudwatch events. ', + 'Please check the AWS docs for more info', + ].join('') + ); + } + if (Input && typeof Input === 'object') { Input = JSON.stringify(Input); } diff --git a/lib/plugins/aws/package/compile/events/eventBridge/index.js b/lib/plugins/aws/package/compile/events/eventBridge/index.js index 0d85b866347..389b5c91034 100644 --- a/lib/plugins/aws/package/compile/events/eventBridge/index.js +++ b/lib/plugins/aws/package/compile/events/eventBridge/index.js @@ -49,17 +49,7 @@ class AwsCompileEventBridgeEvents { additionalProperties: false, }, }, - allOf: [ - { anyOf: [{ required: ['pattern'] }, { required: ['schedule'] }] }, - { - oneOf: [ - { required: [] }, - { required: ['input'] }, - { required: ['inputPath'] }, - { required: ['inputTransformer'] }, - ], - }, - ], + anyOf: [{ required: ['pattern'] }, { required: ['schedule'] }], }); } @@ -105,6 +95,15 @@ class AwsCompileEventBridgeEvents { idx ); + if ([Input, InputPath, InputTransformer].filter(Boolean).length > 1) { + throw new this.serverless.classes.Error( + [ + 'You can only set one of input, inputPath, or inputTransformer ', + 'properties for eventBridge events.', + ].join('') + ); + } + if (InputTransformer) { InputTransformer = _.mapKeys( InputTransformer, diff --git a/lib/plugins/aws/provider/awsProvider.js b/lib/plugins/aws/provider/awsProvider.js index bb89468c0e9..6d62067ba3e 100644 --- a/lib/plugins/aws/provider/awsProvider.js +++ b/lib/plugins/aws/provider/awsProvider.js @@ -555,11 +555,6 @@ class AwsProvider { role: { $ref: '#/definitions/awsArn' }, roleManagedExternally: { type: 'boolean' }, }, - oneOf: [ - { required: [] }, - { required: ['role'] }, - { required: ['roleManagedExternally'] }, - ], additionalProperties: false, }, ],