From 34db75499f89a1a434258a17a99ad2af46c5c079 Mon Sep 17 00:00:00 2001 From: Maciej Barelkowski Date: Fri, 19 Jan 2024 13:45:47 +0100 Subject: [PATCH 1/2] chore: extract all condition-related properties to condition.json --- .../src/base-error-messages.json | 4 +- .../src/defs/base-properties.json | 12 +- .../src/defs/condition.json | 55 ++++---- .../test/fixtures/condition-default-type.js | 20 ++- .../condition-missing-condition-keyword.js | 20 ++- .../fixtures/condition-missing-property.js | 8 +- .../test/fixtures/condition-wrong-type.js | 60 ++++----- .../test/fixtures/condition-wrong-types.js | 42 +++---- .../test/fixtures/condition-default-type.js | 22 ++-- .../test/fixtures/condition-empty-allMatch.js | 118 ++++++++---------- .../condition-missing-condition-keyword.js | 22 ++-- .../fixtures/condition-missing-property.js | 10 +- .../test/fixtures/condition-wrong-type.js | 60 ++++----- .../test/fixtures/condition-wrong-types.js | 46 ++++--- 14 files changed, 224 insertions(+), 275 deletions(-) diff --git a/packages/element-templates-json-schema-shared/src/base-error-messages.json b/packages/element-templates-json-schema-shared/src/base-error-messages.json index d264d6b..0fe58cc 100644 --- a/packages/element-templates-json-schema-shared/src/base-error-messages.json +++ b/packages/element-templates-json-schema-shared/src/base-error-messages.json @@ -139,8 +139,8 @@ "allOf", 0, "items", - "properties", - "condition", + "allOf", + 1, "definitions", "condition" ], diff --git a/packages/element-templates-json-schema-shared/src/defs/base-properties.json b/packages/element-templates-json-schema-shared/src/defs/base-properties.json index 3a4288b..ba5c154 100644 --- a/packages/element-templates-json-schema-shared/src/defs/base-properties.json +++ b/packages/element-templates-json-schema-shared/src/defs/base-properties.json @@ -24,13 +24,12 @@ "choices" ] } + }, + { + "$ref": "condition.json" } ], "properties": { - "id": { - "type": "string", - "description": "Unique identifier of the property." - }, "value": { "$id": "#/properties/property/value", "type": [ @@ -80,7 +79,7 @@ "description": "The value of a choice." }, "condition": { - "$ref": "condition.json" + "$ref": "condition.json#/properties/condition" } }, "required": [ @@ -143,9 +142,6 @@ "$id": "#/properties/property/group", "type": "string", "description": "The custom group of a control field." - }, - "condition": { - "$ref": "condition.json" } } } diff --git a/packages/element-templates-json-schema-shared/src/defs/condition.json b/packages/element-templates-json-schema-shared/src/defs/condition.json index f0b16a6..cd4a579 100644 --- a/packages/element-templates-json-schema-shared/src/defs/condition.json +++ b/packages/element-templates-json-schema-shared/src/defs/condition.json @@ -1,12 +1,4 @@ { - "$id": "#/condition", - "type": "object", - "description": "Condition(s) to activate the binding.", - "allOf": [ - { - "$ref": "examples.json#/condition" - } - ], "definitions": { "condition": { "type": "object", @@ -71,24 +63,39 @@ ] } }, - "oneOf": [ - { - "$ref": "#/definitions/condition" + "properties": { + "id": { + "type": "string", + "description": "Unique identifier of the property." }, - { - "properties": { - "allMatch": { - "$id": "#/allMatch", - "type": "array", - "items": { - "$ref": "#/definitions/condition" + "condition": { + "type": "object", + "description": "Condition(s) to activate the binding.", + "allOf": [ + { + "$ref": "examples.json#/condition" + } + ], + "oneOf": [ + { + "$ref": "#/definitions/condition" + }, + { + "properties": { + "allMatch": { + "$id": "#/allMatch", + "type": "array", + "items": { + "$ref": "#/definitions/condition" + }, + "minItems": 1 + } }, - "minItems": 1 + "required": [ + "allMatch" + ] } - }, - "required": [ - "allMatch" ] } - ] -} \ No newline at end of file + } +} diff --git a/packages/element-templates-json-schema/test/fixtures/condition-default-type.js b/packages/element-templates-json-schema/test/fixtures/condition-default-type.js index 2f1095d..7ad6567 100644 --- a/packages/element-templates-json-schema/test/fixtures/condition-default-type.js +++ b/packages/element-templates-json-schema/test/fixtures/condition-default-type.js @@ -32,44 +32,42 @@ export const errors = [ { keyword: 'required', dataPath: '/properties/1/condition', - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/0/required', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf/0/required', params: { missingProperty: 'equals' }, message: "should have required property 'equals'" }, { keyword: 'required', dataPath: '/properties/1/condition', - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/1/required', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf/1/required', params: { missingProperty: 'oneOf' }, message: "should have required property 'oneOf'" }, { - dataPath: '/properties/1/condition', keyword: 'required', - message: "should have required property 'isActive'", - params: { - missingProperty: 'isActive' - }, - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/2/required' + dataPath: '/properties/1/condition', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf/2/required', + params: { missingProperty: 'isActive' }, + message: "should have required property 'isActive'" }, { keyword: 'oneOf', dataPath: '/properties/1/condition', - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf', params: { passingSchemas: null }, message: 'should match exactly one schema in oneOf' }, { keyword: 'required', dataPath: '/properties/1/condition', - schemaPath: '#/allOf/0/items/properties/condition/oneOf/1/required', + schemaPath: '#/allOf/0/items/allOf/1/properties/condition/oneOf/1/required', params: { missingProperty: 'allMatch' }, message: "should have required property 'allMatch'" }, { keyword: 'oneOf', dataPath: '/properties/1/condition', - schemaPath: '#/allOf/0/items/properties/condition/oneOf', + schemaPath: '#/allOf/0/items/allOf/1/properties/condition/oneOf', params: { passingSchemas: null }, message: 'should match exactly one schema in oneOf' }, diff --git a/packages/element-templates-json-schema/test/fixtures/condition-missing-condition-keyword.js b/packages/element-templates-json-schema/test/fixtures/condition-missing-condition-keyword.js index 1e27c36..7989a23 100644 --- a/packages/element-templates-json-schema/test/fixtures/condition-missing-condition-keyword.js +++ b/packages/element-templates-json-schema/test/fixtures/condition-missing-condition-keyword.js @@ -33,44 +33,42 @@ export const errors = [ { keyword: 'required', dataPath: '/properties/1/condition', - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/0/required', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf/0/required', params: { missingProperty: 'equals' }, message: "should have required property 'equals'" }, { keyword: 'required', dataPath: '/properties/1/condition', - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/1/required', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf/1/required', params: { missingProperty: 'oneOf' }, message: "should have required property 'oneOf'" }, { - dataPath: '/properties/1/condition', keyword: 'required', - message: "should have required property 'isActive'", - params: { - missingProperty: 'isActive' - }, - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/2/required' + dataPath: '/properties/1/condition', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf/2/required', + params: { missingProperty: 'isActive' }, + message: "should have required property 'isActive'" }, { keyword: 'oneOf', dataPath: '/properties/1/condition', - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf', params: { passingSchemas: null }, message: 'should match exactly one schema in oneOf' }, { keyword: 'required', dataPath: '/properties/1/condition', - schemaPath: '#/allOf/0/items/properties/condition/oneOf/1/required', + schemaPath: '#/allOf/0/items/allOf/1/properties/condition/oneOf/1/required', params: { missingProperty: 'allMatch' }, message: "should have required property 'allMatch'" }, { keyword: 'oneOf', dataPath: '/properties/1/condition', - schemaPath: '#/allOf/0/items/properties/condition/oneOf', + schemaPath: '#/allOf/0/items/allOf/1/properties/condition/oneOf', params: { passingSchemas: null }, message: 'should match exactly one schema in oneOf' }, diff --git a/packages/element-templates-json-schema/test/fixtures/condition-missing-property.js b/packages/element-templates-json-schema/test/fixtures/condition-missing-property.js index 9e0b65e..1c40251 100644 --- a/packages/element-templates-json-schema/test/fixtures/condition-missing-property.js +++ b/packages/element-templates-json-schema/test/fixtures/condition-missing-property.js @@ -33,13 +33,13 @@ export const errors = [ { keyword: 'errorMessage', dataPath: '/properties/1/condition', - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/errorMessage', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/errorMessage', params: { errors: [ { keyword: 'required', dataPath: '/properties/1/condition', - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/required', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/required', params: { missingProperty: 'property' }, message: "should have required property 'property'", emUsed: true @@ -51,14 +51,14 @@ export const errors = [ { keyword: 'required', dataPath: '/properties/1/condition', - schemaPath: '#/allOf/0/items/properties/condition/oneOf/1/required', + schemaPath: '#/allOf/0/items/allOf/1/properties/condition/oneOf/1/required', params: { missingProperty: 'allMatch' }, message: "should have required property 'allMatch'" }, { keyword: 'oneOf', dataPath: '/properties/1/condition', - schemaPath: '#/allOf/0/items/properties/condition/oneOf', + schemaPath: '#/allOf/0/items/allOf/1/properties/condition/oneOf', params: { passingSchemas: null }, message: 'should match exactly one schema in oneOf' }, diff --git a/packages/element-templates-json-schema/test/fixtures/condition-wrong-type.js b/packages/element-templates-json-schema/test/fixtures/condition-wrong-type.js index 1221486..dc4760d 100644 --- a/packages/element-templates-json-schema/test/fixtures/condition-wrong-type.js +++ b/packages/element-templates-json-schema/test/fixtures/condition-wrong-type.js @@ -32,48 +32,38 @@ export const template = { export const errors = [ { - 'dataPath': '/properties/1/condition/type', - 'keyword': 'const', - 'message': 'should be equal to constant', - 'params': { - 'allowedValue': 'simple' - }, - 'schemaPath': '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/properties/type/const' + keyword: 'const', + dataPath: '/properties/1/condition/type', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/properties/type/const', + params: { allowedValue: 'simple' }, + message: 'should be equal to constant' }, { - 'keyword': 'required', - 'dataPath': '/properties/1/condition', - 'schemaPath': '#/allOf/0/items/properties/condition/oneOf/1/required', - 'params': { - 'missingProperty': 'allMatch' - }, - 'message': "should have required property 'allMatch'" + keyword: 'required', + dataPath: '/properties/1/condition', + schemaPath: '#/allOf/0/items/allOf/1/properties/condition/oneOf/1/required', + params: { missingProperty: 'allMatch' }, + message: "should have required property 'allMatch'" }, { - 'keyword': 'oneOf', - 'dataPath': '/properties/1/condition', - 'schemaPath': '#/allOf/0/items/properties/condition/oneOf', - 'params': { - 'passingSchemas': null - }, - 'message': 'should match exactly one schema in oneOf' + keyword: 'oneOf', + dataPath: '/properties/1/condition', + schemaPath: '#/allOf/0/items/allOf/1/properties/condition/oneOf', + params: { passingSchemas: null }, + message: 'should match exactly one schema in oneOf' }, { - 'dataPath': '', - 'keyword': 'type', - 'message': 'should be array', - 'params': { - 'type': 'array', - }, - 'schemaPath': '#/oneOf/1/type' + keyword: 'type', + dataPath: '', + schemaPath: '#/oneOf/1/type', + params: { type: 'array' }, + message: 'should be array' }, { - 'dataPath': '', - 'keyword': 'oneOf', - 'message': 'should match exactly one schema in oneOf', - 'params': { - 'passingSchemas': null - }, - 'schemaPath': '#/oneOf' + keyword: 'oneOf', + dataPath: '', + schemaPath: '#/oneOf', + params: { passingSchemas: null }, + message: 'should match exactly one schema in oneOf' } ]; diff --git a/packages/element-templates-json-schema/test/fixtures/condition-wrong-types.js b/packages/element-templates-json-schema/test/fixtures/condition-wrong-types.js index 629c564..584d8d2 100644 --- a/packages/element-templates-json-schema/test/fixtures/condition-wrong-types.js +++ b/packages/element-templates-json-schema/test/fixtures/condition-wrong-types.js @@ -47,95 +47,91 @@ export const errors = [ { keyword: 'type', dataPath: '/properties/1/condition/equals', - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/0/properties/equals/type', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf/0/properties/equals/type', params: { type: [ 'string', 'number', 'boolean' ] }, message: 'should be string,number,boolean' }, { keyword: 'required', dataPath: '/properties/1/condition', - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/1/required', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf/1/required', params: { missingProperty: 'oneOf' }, message: "should have required property 'oneOf'" }, { - dataPath: '/properties/1/condition', keyword: 'required', - message: "should have required property 'isActive'", - params: { - missingProperty: 'isActive' - }, - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/2/required' + dataPath: '/properties/1/condition', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf/2/required', + params: { missingProperty: 'isActive' }, + message: "should have required property 'isActive'" }, { keyword: 'oneOf', dataPath: '/properties/1/condition', - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf', params: { passingSchemas: null }, message: 'should match exactly one schema in oneOf' }, { keyword: 'required', dataPath: '/properties/1/condition', - schemaPath: '#/allOf/0/items/properties/condition/oneOf/1/required', + schemaPath: '#/allOf/0/items/allOf/1/properties/condition/oneOf/1/required', params: { missingProperty: 'allMatch' }, message: "should have required property 'allMatch'" }, { keyword: 'oneOf', dataPath: '/properties/1/condition', - schemaPath: '#/allOf/0/items/properties/condition/oneOf', + schemaPath: '#/allOf/0/items/allOf/1/properties/condition/oneOf', params: { passingSchemas: null }, message: 'should match exactly one schema in oneOf' }, { keyword: 'required', dataPath: '/properties/2/condition', - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/0/required', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf/0/required', params: { missingProperty: 'equals' }, message: "should have required property 'equals'" }, { keyword: 'type', dataPath: '/properties/2/condition/oneOf/0', - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/1/properties/oneOf/items/type', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf/1/properties/oneOf/items/type', params: { type: [ 'string', 'number' ] }, message: 'should be string,number' }, { keyword: 'type', dataPath: '/properties/2/condition/oneOf/1', - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/1/properties/oneOf/items/type', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf/1/properties/oneOf/items/type', params: { type: [ 'string', 'number' ] }, message: 'should be string,number' }, { - dataPath: '/properties/2/condition', keyword: 'required', - message: "should have required property 'isActive'", - params: { - missingProperty: 'isActive' - }, - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/2/required' + dataPath: '/properties/2/condition', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf/2/required', + params: { missingProperty: 'isActive' }, + message: "should have required property 'isActive'" }, { keyword: 'oneOf', dataPath: '/properties/2/condition', - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf', params: { passingSchemas: null }, message: 'should match exactly one schema in oneOf' }, { keyword: 'required', dataPath: '/properties/2/condition', - schemaPath: '#/allOf/0/items/properties/condition/oneOf/1/required', + schemaPath: '#/allOf/0/items/allOf/1/properties/condition/oneOf/1/required', params: { missingProperty: 'allMatch' }, message: "should have required property 'allMatch'" }, { keyword: 'oneOf', dataPath: '/properties/2/condition', - schemaPath: '#/allOf/0/items/properties/condition/oneOf', + schemaPath: '#/allOf/0/items/allOf/1/properties/condition/oneOf', params: { passingSchemas: null }, message: 'should match exactly one schema in oneOf' }, diff --git a/packages/zeebe-element-templates-json-schema/test/fixtures/condition-default-type.js b/packages/zeebe-element-templates-json-schema/test/fixtures/condition-default-type.js index 299908e..7ad6567 100644 --- a/packages/zeebe-element-templates-json-schema/test/fixtures/condition-default-type.js +++ b/packages/zeebe-element-templates-json-schema/test/fixtures/condition-default-type.js @@ -32,44 +32,42 @@ export const errors = [ { keyword: 'required', dataPath: '/properties/1/condition', - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/0/required', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf/0/required', params: { missingProperty: 'equals' }, message: "should have required property 'equals'" }, { keyword: 'required', dataPath: '/properties/1/condition', - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/1/required', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf/1/required', params: { missingProperty: 'oneOf' }, message: "should have required property 'oneOf'" }, { - dataPath: '/properties/1/condition', keyword: 'required', - message: "should have required property 'isActive'", - params: { - missingProperty: 'isActive' - }, - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/2/required' + dataPath: '/properties/1/condition', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf/2/required', + params: { missingProperty: 'isActive' }, + message: "should have required property 'isActive'" }, { keyword: 'oneOf', dataPath: '/properties/1/condition', - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf', params: { passingSchemas: null }, message: 'should match exactly one schema in oneOf' }, { keyword: 'required', dataPath: '/properties/1/condition', - schemaPath: '#/allOf/0/items/properties/condition/oneOf/1/required', - message: "should have required property 'allMatch'", + schemaPath: '#/allOf/0/items/allOf/1/properties/condition/oneOf/1/required', params: { missingProperty: 'allMatch' }, + message: "should have required property 'allMatch'" }, { keyword: 'oneOf', dataPath: '/properties/1/condition', - schemaPath: '#/allOf/0/items/properties/condition/oneOf', + schemaPath: '#/allOf/0/items/allOf/1/properties/condition/oneOf', params: { passingSchemas: null }, message: 'should match exactly one schema in oneOf' }, diff --git a/packages/zeebe-element-templates-json-schema/test/fixtures/condition-empty-allMatch.js b/packages/zeebe-element-templates-json-schema/test/fixtures/condition-empty-allMatch.js index 79125d4..8a4e16b 100644 --- a/packages/zeebe-element-templates-json-schema/test/fixtures/condition-empty-allMatch.js +++ b/packages/zeebe-element-templates-json-schema/test/fixtures/condition-empty-allMatch.js @@ -40,95 +40,77 @@ export const template = { export const errors = [ { - 'dataPath': '/properties/2/condition', 'keyword': 'required', - 'message': "should have required property 'equals'", - 'params': { - 'missingProperty': 'equals' - }, - 'schemaPath': '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/0/required' + 'dataPath': '/properties/2/condition', + 'schemaPath': '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf/0/required', + 'params': { missingProperty: 'equals' }, + 'message': "should have required property 'equals'" }, { - 'dataPath': '/properties/2/condition', 'keyword': 'required', - 'message': "should have required property 'oneOf'", - 'params': { - 'missingProperty': 'oneOf' - }, - 'schemaPath': '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/1/required' + 'dataPath': '/properties/2/condition', + 'schemaPath': '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf/1/required', + 'params': { missingProperty: 'oneOf' }, + 'message': "should have required property 'oneOf'" }, { - 'dataPath': '/properties/2/condition', 'keyword': 'required', - 'message': "should have required property 'isActive'", - 'params': { - 'missingProperty': 'isActive' - }, - 'schemaPath': '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/2/required' + 'dataPath': '/properties/2/condition', + 'schemaPath': '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf/2/required', + 'params': { missingProperty: 'isActive' }, + 'message': "should have required property 'isActive'" }, { - 'dataPath': '/properties/2/condition', - 'keyword': 'oneOf', - 'message': 'should match exactly one schema in oneOf', - 'params': { - 'passingSchemas': null - }, - 'schemaPath': '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf' + keyword: 'oneOf', + dataPath: '/properties/2/condition', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf', + params: { passingSchemas: null }, + message: 'should match exactly one schema in oneOf' }, { - 'dataPath': '/properties/2/condition', - 'keyword': 'errorMessage', - 'message': 'missing property name for condition', - 'params': { - 'errors': [ + keyword: 'errorMessage', + dataPath: '/properties/2/condition', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/errorMessage', + params: { + errors: [ { - 'keyword': 'required', - 'dataPath': '/properties/2/condition', - 'emUsed': true, - 'schemaPath': '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/required', - 'params': { - 'missingProperty': 'property' - }, - 'message': "should have required property 'property'" - }, + keyword: 'required', + dataPath: '/properties/2/condition', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/required', + params: { missingProperty: 'property' }, + message: "should have required property 'property'", + emUsed: true + } ] }, - 'schemaPath': '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/errorMessage' + message: 'missing property name for condition' }, { - 'dataPath': '/properties/2/condition/allMatch', - 'keyword': 'minItems', - 'message': 'should NOT have fewer than 1 items', - 'params': { - 'limit': 1 - }, - 'schemaPath': '#/allOf/0/items/properties/condition/oneOf/1/properties/allMatch/minItems' + keyword: 'minItems', + dataPath: '/properties/2/condition/allMatch', + schemaPath: '#/allOf/0/items/allOf/1/properties/condition/oneOf/1/properties/allMatch/minItems', + params: { limit: 1 }, + message: 'should NOT have fewer than 1 items' }, { - 'dataPath': '/properties/2/condition', - 'keyword': 'oneOf', - 'message': 'should match exactly one schema in oneOf', - 'params': { - 'passingSchemas': null - }, - 'schemaPath': '#/allOf/0/items/properties/condition/oneOf' + keyword: 'oneOf', + dataPath: '/properties/2/condition', + schemaPath: '#/allOf/0/items/allOf/1/properties/condition/oneOf', + params: { passingSchemas: null }, + message: 'should match exactly one schema in oneOf' }, { - 'dataPath': '', - 'keyword': 'type', - 'message': 'should be array', - 'params': { - 'type': 'array' - }, - 'schemaPath': '#/oneOf/1/type' + keyword: 'type', + dataPath: '', + schemaPath: '#/oneOf/1/type', + params: { type: 'array' }, + message: 'should be array' }, { - 'dataPath': '', - 'keyword': 'oneOf', - 'message': 'should match exactly one schema in oneOf', - 'params': { - 'passingSchemas': null - }, - 'schemaPath': '#/oneOf' + keyword: 'oneOf', + dataPath: '', + schemaPath: '#/oneOf', + params: { passingSchemas: null }, + message: 'should match exactly one schema in oneOf' } ]; \ No newline at end of file diff --git a/packages/zeebe-element-templates-json-schema/test/fixtures/condition-missing-condition-keyword.js b/packages/zeebe-element-templates-json-schema/test/fixtures/condition-missing-condition-keyword.js index 30f2120..7989a23 100644 --- a/packages/zeebe-element-templates-json-schema/test/fixtures/condition-missing-condition-keyword.js +++ b/packages/zeebe-element-templates-json-schema/test/fixtures/condition-missing-condition-keyword.js @@ -33,44 +33,42 @@ export const errors = [ { keyword: 'required', dataPath: '/properties/1/condition', - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/0/required', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf/0/required', params: { missingProperty: 'equals' }, message: "should have required property 'equals'" }, { keyword: 'required', dataPath: '/properties/1/condition', - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/1/required', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf/1/required', params: { missingProperty: 'oneOf' }, message: "should have required property 'oneOf'" }, { - dataPath: '/properties/1/condition', keyword: 'required', - message: "should have required property 'isActive'", - params: { - missingProperty: 'isActive' - }, - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/2/required' + dataPath: '/properties/1/condition', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf/2/required', + params: { missingProperty: 'isActive' }, + message: "should have required property 'isActive'" }, { keyword: 'oneOf', dataPath: '/properties/1/condition', - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf', params: { passingSchemas: null }, message: 'should match exactly one schema in oneOf' }, { keyword: 'required', dataPath: '/properties/1/condition', - schemaPath: '#/allOf/0/items/properties/condition/oneOf/1/required', - message: "should have required property 'allMatch'", + schemaPath: '#/allOf/0/items/allOf/1/properties/condition/oneOf/1/required', params: { missingProperty: 'allMatch' }, + message: "should have required property 'allMatch'" }, { keyword: 'oneOf', dataPath: '/properties/1/condition', - schemaPath: '#/allOf/0/items/properties/condition/oneOf', + schemaPath: '#/allOf/0/items/allOf/1/properties/condition/oneOf', params: { passingSchemas: null }, message: 'should match exactly one schema in oneOf' }, diff --git a/packages/zeebe-element-templates-json-schema/test/fixtures/condition-missing-property.js b/packages/zeebe-element-templates-json-schema/test/fixtures/condition-missing-property.js index f1cf426..1c40251 100644 --- a/packages/zeebe-element-templates-json-schema/test/fixtures/condition-missing-property.js +++ b/packages/zeebe-element-templates-json-schema/test/fixtures/condition-missing-property.js @@ -33,13 +33,13 @@ export const errors = [ { keyword: 'errorMessage', dataPath: '/properties/1/condition', - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/errorMessage', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/errorMessage', params: { errors: [ { keyword: 'required', dataPath: '/properties/1/condition', - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/required', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/required', params: { missingProperty: 'property' }, message: "should have required property 'property'", emUsed: true @@ -51,14 +51,14 @@ export const errors = [ { keyword: 'required', dataPath: '/properties/1/condition', - schemaPath: '#/allOf/0/items/properties/condition/oneOf/1/required', - message: "should have required property 'allMatch'", + schemaPath: '#/allOf/0/items/allOf/1/properties/condition/oneOf/1/required', params: { missingProperty: 'allMatch' }, + message: "should have required property 'allMatch'" }, { keyword: 'oneOf', dataPath: '/properties/1/condition', - schemaPath: '#/allOf/0/items/properties/condition/oneOf', + schemaPath: '#/allOf/0/items/allOf/1/properties/condition/oneOf', params: { passingSchemas: null }, message: 'should match exactly one schema in oneOf' }, diff --git a/packages/zeebe-element-templates-json-schema/test/fixtures/condition-wrong-type.js b/packages/zeebe-element-templates-json-schema/test/fixtures/condition-wrong-type.js index 53c4800..dc4760d 100644 --- a/packages/zeebe-element-templates-json-schema/test/fixtures/condition-wrong-type.js +++ b/packages/zeebe-element-templates-json-schema/test/fixtures/condition-wrong-type.js @@ -32,48 +32,38 @@ export const template = { export const errors = [ { - 'dataPath': '/properties/1/condition/type', - 'keyword': 'const', - 'message': 'should be equal to constant', - 'params': { - 'allowedValue': 'simple' - }, - 'schemaPath': '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/properties/type/const' + keyword: 'const', + dataPath: '/properties/1/condition/type', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/properties/type/const', + params: { allowedValue: 'simple' }, + message: 'should be equal to constant' }, { - 'dataPath': '/properties/1/condition', - 'keyword': 'required', - 'message': "should have required property 'allMatch'", - 'params': { - 'missingProperty': 'allMatch' - }, - 'schemaPath': '#/allOf/0/items/properties/condition/oneOf/1/required' + keyword: 'required', + dataPath: '/properties/1/condition', + schemaPath: '#/allOf/0/items/allOf/1/properties/condition/oneOf/1/required', + params: { missingProperty: 'allMatch' }, + message: "should have required property 'allMatch'" }, { - 'dataPath': '/properties/1/condition', - 'keyword': 'oneOf', - 'message': 'should match exactly one schema in oneOf', - 'params': { - 'passingSchemas': null - }, - 'schemaPath': '#/allOf/0/items/properties/condition/oneOf' + keyword: 'oneOf', + dataPath: '/properties/1/condition', + schemaPath: '#/allOf/0/items/allOf/1/properties/condition/oneOf', + params: { passingSchemas: null }, + message: 'should match exactly one schema in oneOf' }, { - 'dataPath': '', - 'keyword': 'type', - 'message': 'should be array', - 'params': { - 'type': 'array', - }, - 'schemaPath': '#/oneOf/1/type' + keyword: 'type', + dataPath: '', + schemaPath: '#/oneOf/1/type', + params: { type: 'array' }, + message: 'should be array' }, { - 'dataPath': '', - 'keyword': 'oneOf', - 'message': 'should match exactly one schema in oneOf', - 'params': { - 'passingSchemas': null - }, - 'schemaPath': '#/oneOf' + keyword: 'oneOf', + dataPath: '', + schemaPath: '#/oneOf', + params: { passingSchemas: null }, + message: 'should match exactly one schema in oneOf' } ]; diff --git a/packages/zeebe-element-templates-json-schema/test/fixtures/condition-wrong-types.js b/packages/zeebe-element-templates-json-schema/test/fixtures/condition-wrong-types.js index 357305c..584d8d2 100644 --- a/packages/zeebe-element-templates-json-schema/test/fixtures/condition-wrong-types.js +++ b/packages/zeebe-element-templates-json-schema/test/fixtures/condition-wrong-types.js @@ -47,95 +47,91 @@ export const errors = [ { keyword: 'type', dataPath: '/properties/1/condition/equals', - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/0/properties/equals/type', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf/0/properties/equals/type', params: { type: [ 'string', 'number', 'boolean' ] }, message: 'should be string,number,boolean' }, { keyword: 'required', dataPath: '/properties/1/condition', - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/1/required', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf/1/required', params: { missingProperty: 'oneOf' }, message: "should have required property 'oneOf'" }, { - dataPath: '/properties/1/condition', keyword: 'required', - message: "should have required property 'isActive'", - params: { - missingProperty: 'isActive' - }, - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/2/required' + dataPath: '/properties/1/condition', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf/2/required', + params: { missingProperty: 'isActive' }, + message: "should have required property 'isActive'" }, { keyword: 'oneOf', dataPath: '/properties/1/condition', - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf', params: { passingSchemas: null }, message: 'should match exactly one schema in oneOf' }, { keyword: 'required', dataPath: '/properties/1/condition', - schemaPath: '#/allOf/0/items/properties/condition/oneOf/1/required', - message: "should have required property 'allMatch'", + schemaPath: '#/allOf/0/items/allOf/1/properties/condition/oneOf/1/required', params: { missingProperty: 'allMatch' }, + message: "should have required property 'allMatch'" }, { keyword: 'oneOf', dataPath: '/properties/1/condition', - schemaPath: '#/allOf/0/items/properties/condition/oneOf', + schemaPath: '#/allOf/0/items/allOf/1/properties/condition/oneOf', params: { passingSchemas: null }, message: 'should match exactly one schema in oneOf' }, { keyword: 'required', dataPath: '/properties/2/condition', - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/0/required', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf/0/required', params: { missingProperty: 'equals' }, message: "should have required property 'equals'" }, { keyword: 'type', dataPath: '/properties/2/condition/oneOf/0', - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/1/properties/oneOf/items/type', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf/1/properties/oneOf/items/type', params: { type: [ 'string', 'number' ] }, message: 'should be string,number' }, { keyword: 'type', dataPath: '/properties/2/condition/oneOf/1', - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/1/properties/oneOf/items/type', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf/1/properties/oneOf/items/type', params: { type: [ 'string', 'number' ] }, message: 'should be string,number' }, { - dataPath: '/properties/2/condition', keyword: 'required', - message: "should have required property 'isActive'", - params: { - missingProperty: 'isActive' - }, - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf/2/required' + dataPath: '/properties/2/condition', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf/2/required', + params: { missingProperty: 'isActive' }, + message: "should have required property 'isActive'" }, { keyword: 'oneOf', dataPath: '/properties/2/condition', - schemaPath: '#/definitions/properties/allOf/0/items/properties/condition/definitions/condition/oneOf', + schemaPath: '#/definitions/properties/allOf/0/items/allOf/1/definitions/condition/oneOf', params: { passingSchemas: null }, message: 'should match exactly one schema in oneOf' }, { keyword: 'required', dataPath: '/properties/2/condition', - schemaPath: '#/allOf/0/items/properties/condition/oneOf/1/required', - message: "should have required property 'allMatch'", + schemaPath: '#/allOf/0/items/allOf/1/properties/condition/oneOf/1/required', params: { missingProperty: 'allMatch' }, + message: "should have required property 'allMatch'" }, { keyword: 'oneOf', dataPath: '/properties/2/condition', - schemaPath: '#/allOf/0/items/properties/condition/oneOf', + schemaPath: '#/allOf/0/items/allOf/1/properties/condition/oneOf', params: { passingSchemas: null }, message: 'should match exactly one schema in oneOf' }, From ff6cc7dfd95da0d837491e13e6c067c5eaf73544 Mon Sep 17 00:00:00 2001 From: Maciej Barelkowski Date: Fri, 19 Jan 2024 13:46:35 +0100 Subject: [PATCH 2/2] feat: disallow condition depending on the containing property Closes #125 --- .../src/base-error-messages.json | 30 +++++++ .../src/defs/condition.json | 78 +++++++++++++++++++ .../test/helpers/index.js | 3 +- .../fixtures/condition-on-itself-allMatch.js | 69 ++++++++++++++++ .../condition-on-itself-dropdown-choices.js | 78 +++++++++++++++++++ .../test/fixtures/condition-on-itself.js | 64 +++++++++++++++ .../test/fixtures/condition.js | 1 + .../test/spec/validationSpec.js | 9 +++ 8 files changed, 331 insertions(+), 1 deletion(-) create mode 100644 packages/zeebe-element-templates-json-schema/test/fixtures/condition-on-itself-allMatch.js create mode 100644 packages/zeebe-element-templates-json-schema/test/fixtures/condition-on-itself-dropdown-choices.js create mode 100644 packages/zeebe-element-templates-json-schema/test/fixtures/condition-on-itself.js diff --git a/packages/element-templates-json-schema-shared/src/base-error-messages.json b/packages/element-templates-json-schema-shared/src/base-error-messages.json index 0fe58cc..fc1d316 100644 --- a/packages/element-templates-json-schema-shared/src/base-error-messages.json +++ b/packages/element-templates-json-schema-shared/src/base-error-messages.json @@ -149,5 +149,35 @@ "property": "missing property name for condition" } } + }, + { + "path": [ + "definitions", + "properties", + "allOf", + 0, + "items", + "allOf", + 1, + "allOf", + 0, + "then" + ], + "errorMessage": "Invalid condition.property, must be different than property.id" + }, + { + "path": [ + "definitions", + "properties", + "allOf", + 0, + "items", + "allOf", + 1, + "allOf", + 1, + "then" + ], + "errorMessage": "Invalid condition.property, must be different than property.id" } ] \ No newline at end of file diff --git a/packages/element-templates-json-schema-shared/src/defs/condition.json b/packages/element-templates-json-schema-shared/src/defs/condition.json index cd4a579..855aeea 100644 --- a/packages/element-templates-json-schema-shared/src/defs/condition.json +++ b/packages/element-templates-json-schema-shared/src/defs/condition.json @@ -61,8 +61,86 @@ ] } ] + }, + "conditionDependingOnId": { + "anyOf": [ + { + "required": [ + "property" + ], + "properties": { + "property": { + "const": { + "$data": "2/id" + } + } + } + }, + { + "required": [ + "allMatch" + ], + "allMatch": { + "contains": { + "properties": { + "property": { + "const": { + "$data": "2/id" + } + } + } + } + } + } + ] } }, + "allOf": [ + { + "$comment": "property#condition should not depend on property#id", + "if": { + "required": [ + "id", + "condition" + ], + "properties": { + "condition": { + "$ref": "#/definitions/conditionDependingOnId" + } + } + }, + "then": { + "not": { + "required": [ "condition" ] + } + } + }, + { + "$comment": "property#condition should not depend on property#id", + "if": { + "required": [ + "id", + "choices" + ], + "properties": { + "choices": { + "contains": { + "properties": { + "condition": { + "$ref": "#/definitions/conditionDependingOnId" + } + } + } + } + } + }, + "then": { + "not": { + "required": [ "choices" ] + } + } + } + ], "properties": { "id": { "type": "string", diff --git a/packages/element-templates-json-schema-shared/test/helpers/index.js b/packages/element-templates-json-schema-shared/test/helpers/index.js index 1a3eb5c..f0f484f 100644 --- a/packages/element-templates-json-schema-shared/test/helpers/index.js +++ b/packages/element-templates-json-schema-shared/test/helpers/index.js @@ -15,7 +15,8 @@ function createValidator(schema, errors) { const ajv = new Ajv({ allErrors: true, - strict: false + strict: false, + $data: true }); AjvErrors(ajv); diff --git a/packages/zeebe-element-templates-json-schema/test/fixtures/condition-on-itself-allMatch.js b/packages/zeebe-element-templates-json-schema/test/fixtures/condition-on-itself-allMatch.js new file mode 100644 index 0000000..58cc35a --- /dev/null +++ b/packages/zeebe-element-templates-json-schema/test/fixtures/condition-on-itself-allMatch.js @@ -0,0 +1,69 @@ +export const template = { + 'name': 'Condition', + 'id': 'example.com.condition', + 'appliesTo': [ + 'bpmn:ServiceTask' + ], + 'properties': [ + { + 'id': 'myId', + 'label': 'input 1', + 'type': 'String', + 'binding': { + 'type': 'property', + 'name': 'input1' + }, + 'condition': { + 'allMatch': [ + { + 'type': 'simple', + property: 'myId', + equals: 'text' + } + ] + } + } + ] +}; + +export const errors = [ + { + keyword: 'errorMessage', + dataPath: '/properties/0', + schemaPath: '#/allOf/0/items/allOf/1/allOf/0/then/errorMessage', + params: { + errors: [ + { + keyword: 'not', + dataPath: '/properties/0', + schemaPath: '#/allOf/0/items/allOf/1/allOf/0/then/not', + params: {}, + message: 'should NOT be valid', + emUsed: true + } + ] + }, + message: 'Invalid condition.property, must be different than property.id' + }, + { + keyword: 'if', + dataPath: '/properties/0', + schemaPath: '#/allOf/0/items/allOf/1/allOf/0/if', + params: { failingKeyword: 'then' }, + message: 'should match "then" schema' + }, + { + keyword: 'type', + dataPath: '', + schemaPath: '#/oneOf/1/type', + params: { type: 'array' }, + message: 'should be array' + }, + { + keyword: 'oneOf', + dataPath: '', + schemaPath: '#/oneOf', + params: { passingSchemas: null }, + message: 'should match exactly one schema in oneOf' + } +]; diff --git a/packages/zeebe-element-templates-json-schema/test/fixtures/condition-on-itself-dropdown-choices.js b/packages/zeebe-element-templates-json-schema/test/fixtures/condition-on-itself-dropdown-choices.js new file mode 100644 index 0000000..dc326bd --- /dev/null +++ b/packages/zeebe-element-templates-json-schema/test/fixtures/condition-on-itself-dropdown-choices.js @@ -0,0 +1,78 @@ +export const template = { + 'name': 'Condition', + 'id': 'example.com.condition', + 'appliesTo': [ + 'bpmn:ServiceTask' + ], + 'properties': [ + { + 'id': 'myId', + 'label': 'Dropdown', + 'type': 'Dropdown', + 'choices': [ + { + 'value': 'opt1', + 'name':'opt1' + }, + { + 'value': 'opt2', + 'name': 'opt2' + }, + { + 'value': 'opt3', + 'name': 'opt3', + 'condition': { + 'property': 'myId', + 'equals': 'text' + } + } + ], + 'binding': { + 'type': 'zeebe:property', + 'name': 'method' + } + } + ] +}; + +export const errors = [ + { + keyword: 'errorMessage', + dataPath: '/properties/0', + schemaPath: '#/allOf/0/items/allOf/1/allOf/1/then/errorMessage', + params: { + errors: [ + { + keyword: 'not', + dataPath: '/properties/0', + schemaPath: '#/allOf/0/items/allOf/1/allOf/1/then/not', + params: {}, + message: 'should NOT be valid', + emUsed: true + } + ] + }, + message: 'Invalid condition.property, must be different than property.id' + }, + { + keyword: 'if', + dataPath: '/properties/0', + schemaPath: '#/allOf/0/items/allOf/1/allOf/1/if', + params: { failingKeyword: 'then' }, + message: 'should match "then" schema' + }, + { + keyword: 'type', + dataPath: '', + schemaPath: '#/oneOf/1/type', + params: { type: 'array' }, + message: 'should be array' + }, + { + keyword: 'oneOf', + dataPath: '', + schemaPath: '#/oneOf', + params: { passingSchemas: null }, + message: 'should match exactly one schema in oneOf' + } +]; \ No newline at end of file diff --git a/packages/zeebe-element-templates-json-schema/test/fixtures/condition-on-itself.js b/packages/zeebe-element-templates-json-schema/test/fixtures/condition-on-itself.js new file mode 100644 index 0000000..4c15a4c --- /dev/null +++ b/packages/zeebe-element-templates-json-schema/test/fixtures/condition-on-itself.js @@ -0,0 +1,64 @@ +export const template = { + 'name': 'Condition', + 'id': 'example.com.condition', + 'appliesTo': [ + 'bpmn:ServiceTask' + ], + 'properties': [ + { + 'id': 'myId', + 'label': 'input 1', + 'type': 'String', + 'binding': { + 'type': 'property', + 'name': 'input1' + }, + 'condition': { + property: 'myId', + equals: 'text' + } + } + ] +}; + +export const errors = [ + { + keyword: 'errorMessage', + dataPath: '/properties/0', + schemaPath: '#/allOf/0/items/allOf/1/allOf/0/then/errorMessage', + params: { + errors: [ + { + keyword: 'not', + dataPath: '/properties/0', + schemaPath: '#/allOf/0/items/allOf/1/allOf/0/then/not', + params: {}, + message: 'should NOT be valid', + emUsed: true + } + ] + }, + message: 'Invalid condition.property, must be different than property.id' + }, + { + keyword: 'if', + dataPath: '/properties/0', + schemaPath: '#/allOf/0/items/allOf/1/allOf/0/if', + params: { failingKeyword: 'then' }, + message: 'should match "then" schema' + }, + { + keyword: 'type', + dataPath: '', + schemaPath: '#/oneOf/1/type', + params: { type: 'array' }, + message: 'should be array' + }, + { + keyword: 'oneOf', + dataPath: '', + schemaPath: '#/oneOf', + params: { passingSchemas: null }, + message: 'should match exactly one schema in oneOf' + } +]; diff --git a/packages/zeebe-element-templates-json-schema/test/fixtures/condition.js b/packages/zeebe-element-templates-json-schema/test/fixtures/condition.js index 0a91480..7cf9101 100644 --- a/packages/zeebe-element-templates-json-schema/test/fixtures/condition.js +++ b/packages/zeebe-element-templates-json-schema/test/fixtures/condition.js @@ -80,6 +80,7 @@ export const template = { } }, { + 'id': 'someId', 'label': 'default condition type', 'type': 'String', 'condition': { diff --git a/packages/zeebe-element-templates-json-schema/test/spec/validationSpec.js b/packages/zeebe-element-templates-json-schema/test/spec/validationSpec.js index 4503863..79db9c7 100644 --- a/packages/zeebe-element-templates-json-schema/test/spec/validationSpec.js +++ b/packages/zeebe-element-templates-json-schema/test/spec/validationSpec.js @@ -289,6 +289,15 @@ describe('validation', function() { testTemplate('condition-dropdown-choices-invalid'); + + + testTemplate('condition-on-itself'); + + + testTemplate('condition-on-itself-allMatch'); + + + testTemplate('condition-on-itself-dropdown-choices'); });