Skip to content

Commit

Permalink
feat(cloud): add cloud JSON Schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Niklas Kiefer authored and merge-me[bot] committed Feb 14, 2022
1 parent 73ef400 commit 1a9d15c
Show file tree
Hide file tree
Showing 16 changed files with 1,780 additions and 0 deletions.
535 changes: 535 additions & 0 deletions resources/cloud.json

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions src/cloud.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "http://camunda.org/schema/cloud-element-templates/1.0",
"title": "Cloud Element Template Schema",
"description": "A single element template configuration or an array of element template configurations",
"definitions": {
"properties": {
"allOf": [
{
"$ref": "src/defs/base-properties.json"
},
{
"$ref": "src/defs/cloud-properties.json"
}
]
},
"template": {
"type": "object",
"allOf": [
{
"$ref": "src/defs/base.json"
}
],
"properties": {
"properties": {
"$ref": "#/definitions/properties",
"$id": "#/properties"
}
}
}
},
"oneOf": [
{
"$ref": "#/definitions/template"
},
{
"type": "array",
"items": {
"$ref": "#/definitions/template"
}
}
]
}
233 changes: 233 additions & 0 deletions src/defs/cloud-properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"type": "array",
"title": "element template properties",
"description": "The properties of the element template",
"default": [],
"items": {
"type": "object",
"title": "element template property",
"description": "A property defined for the element template",
"default": {},
"required": [
"binding"
],
"errorMessage": {
"required": {
"binding": "missing binding for property \"${0#}\""
}
},
"allOf": [
{
"if": {
"properties": {
"binding": {
"properties": {
"type": {
"const": "property"
}
},
"required": [
"type"
]
}
},
"required": [
"binding"
]
},
"then": {
"properties": {
"type": {
"enum": [
"String",
"Text",
"Hidden",
"Dropdown",
"Boolean"
],
"errorMessage": "invalid property type ${0} for binding type \"property\"; must be any of { String, Text, Hidden, Dropdown, Boolean }"
}
}
}
},
{
"if": {
"properties": {
"binding": {
"properties": {
"type": {
"enum": [
"zeebe:input",
"zeebe:output",
"zeebe:taskHeader",
"zeebe:taskDefinition:type"
]
}
},
"required": [
"type"
]
}
},
"required": [
"binding"
]
},
"then": {
"properties": {
"type": {
"enum": [
"String",
"Text",
"Hidden",
"Dropdown"
],
"errorMessage": "invalid property type ${0} for binding type ${1/binding/type}; must be any of { String, Text, Hidden, Dropdown }"
}
}
}
},
{
"if": {
"properties": {
"optional": {
"const": true
}
},
"required": [
"optional"
]
},
"then": {
"properties": {
"binding": {
"properties": {
"type": {
"enum": [
"zeebe:input",
"zeebe:output"
],
"errorMessage": "optional is not supported for binding type ${0}; must be any of { zeebe:input, zeebe:output }"
}
},
"required": [
"type"
]
}
}
}
}
],
"properties": {
"binding": {
"$id": "#/properties/property/binding",
"type": "object",
"title": "property binding",
"description": "A binding to a BPMN 2.0 property",
"required": [
"type"
],
"allOf": [
{
"if": {
"properties": {
"type": {
"enum": [
"property",
"zeebe:input"
]
}
},
"required": [
"type"
]
},
"then": {
"required": [
"name"
],
"errorMessage": "property.binding ${0/type} requires name"
}
},
{
"if": {
"properties": {
"type": {
"const": "zeebe:output"
}
},
"required": [
"type"
]
},
"then": {
"required": [
"source"
],
"errorMessage": "property.binding ${0/type} requires source"
}
},
{
"if": {
"properties": {
"type": {
"const": "zeebe:taskHeader"
}
},
"required": [
"type"
]
},
"then": {
"required": [
"key"
],
"errorMessage": "property.binding ${0/type} requires key"
}
}
],
"properties": {
"type": {
"$id": "#/properties/property/binding/type",
"type": "string",
"title": "property binding type",
"enum": [
"property",
"zeebe:taskDefinition:type",
"zeebe:input",
"zeebe:output",
"zeebe:taskHeader"
],
"errorMessage": "invalid property.binding type ${0}; must be any of { property, zeebe:taskDefinition:type, zeebe:input, zeebe:output, zeebe:taskHeader }",
"description": "The type of the property binding"
},
"name": {
"$id": "#/properties/property/binding/name",
"type": "string",
"title": "property binding name",
"description": "The name of binding xml property"
},
"source": {
"$id": "#/properties/property/binding/source",
"type": "string",
"title": "property binding source",
"description": "The source value of a property binding (zeebe:output)"
},
"key": {
"$id": "#/properties/property/binding/key",
"type": "string",
"title": "property binding key",
"description": "The key value of a property binding (zeebe:taskHeader)"
}
}
},
"optional": {
"$id": "#/optional",
"type": "boolean",
"title": "element template optional",
"description": "Indicates whether a property is optional"
}
}
}
}
30 changes: 30 additions & 0 deletions test/fixtures/cloud-optional-inputs-outputs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export const template = {
'name': 'REST Connector',
'id': 'io.camunda.connectors.RestConnector-s1',
'description': 'A generic REST service.',
'appliesTo': [
'bpmn:ServiceTask'
],
'properties': [
{
'label': 'Request Body',
'type': 'String',
'optional': true,
'binding': {
'type': 'zeebe:input',
'name': 'body'
}
},
{
'label': 'Result Variable',
'type': 'String',
'optional': true,
'binding': {
'type': 'zeebe:output',
'source': '= body'
}
}
]
};

export const errors = null;
70 changes: 70 additions & 0 deletions test/fixtures/cloud-optional-invalid-type.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
export const template = {
'name': 'REST Connector',
'id': 'io.camunda.connectors.RestConnector-s1',
'description': 'A generic REST service.',
'appliesTo': [
'bpmn:ServiceTask'
],
'properties': [
{
'label': 'Request Body',
'type': 'String',
'optional': true,
'binding': {
'type': 'zeebe:input',
'name': 'body'
}
},
{
'label': 'Result Variable',
'type': 'String',
'optional': true,
'binding': {
'type': 'zeebe:taskHeader',
'key': 'key'
}
}
]
};

export const errors = [
{
keyword: 'errorMessage',
dataPath: '/properties/1/binding/type',
schemaPath: '#/definitions/properties/allOf/1/items/allOf/2/then/properties/binding/properties/type/errorMessage',
params: {
errors: [
{
keyword: 'enum',
dataPath: '/properties/1/binding/type',
schemaPath: '#/definitions/properties/allOf/1/items/allOf/2/then/properties/binding/properties/type/enum',
params: { allowedValues: [ 'zeebe:input', 'zeebe:output' ] },
message: 'should be equal to one of the allowed values',
emUsed: true
}
]
},
message: 'optional is not supported for binding type "zeebe:taskHeader"; must be any of { zeebe:input, zeebe:output }'
},
{
keyword: 'if',
dataPath: '/properties/1',
schemaPath: '#/definitions/properties/allOf/1/items/allOf/2/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'
}
];
Loading

0 comments on commit 1a9d15c

Please sign in to comment.