Skip to content

Commit af23db6

Browse files
authored
Merge pull request #696 from fjtirado/dataOutputSchema
outputDataSchema addition
2 parents 1f9e0d1 + 4c5aed4 commit af23db6

File tree

3 files changed

+68
-53
lines changed

3 files changed

+68
-53
lines changed

roadmap/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ _Status description:_
4545
| ✏️️| Add SDKs for more languages (Python, PHP, Rust, etc) | |
4646
| ✏️️| Add more samples | |
4747
| ✏️️| Enforce SemVer `version` | |
48+
| ✏️️| Add `dataOutputSchema` | |
4849

4950
## <a name="v08"></a> Released version v0.8
5051

schema/workflow.json

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -39,42 +39,10 @@
3939
"additionalItems": false
4040
},
4141
"dataInputSchema": {
42-
"oneOf": [
43-
{
44-
"type": "string",
45-
"description": "URI of the JSON Schema used to validate the workflow data input",
46-
"minLength": 1
47-
},
48-
{
49-
"type": "object",
50-
"description": "Workflow data input schema definition",
51-
"properties": {
52-
"schema": {
53-
"oneof": [
54-
{
55-
"type": "string",
56-
"description": "URI of the JSON Schema used to validate the workflow data input",
57-
"minLength": 1
58-
},
59-
{
60-
"type": "object",
61-
"description": "The JSON Schema object used to validate the workflow data input",
62-
"$schema": "http://json-schema.org/draft-07/schema#"
63-
}
64-
]
65-
},
66-
"failOnValidationErrors": {
67-
"type": "boolean",
68-
"default": true,
69-
"description": "Determines if workflow execution should continue if there are validation errors"
70-
}
71-
},
72-
"additionalProperties": false,
73-
"required": [
74-
"schema"
75-
]
76-
}
77-
]
42+
"$ref": "#/definitions/validationSchema"
43+
},
44+
"dataOutputSchema": {
45+
"$ref": "#/definitions/validationSchema"
7846
},
7947
"secrets": {
8048
"$ref": "secrets.json#/secrets"
@@ -1899,6 +1867,44 @@
18991867
},
19001868
"additionalProperties": false,
19011869
"required": []
1870+
},
1871+
"validationSchema" : {
1872+
"oneOf": [
1873+
{
1874+
"type": "string",
1875+
"description": "URI of the JSON Schema used to validate the workflow",
1876+
"minLength": 1
1877+
},
1878+
{
1879+
"type": "object",
1880+
"description": "Workflow data input schema definition",
1881+
"properties": {
1882+
"schema": {
1883+
"oneof":[
1884+
{
1885+
"type": "string",
1886+
"description": "URI of the JSON Schema used to validate the workflow",
1887+
"minLength": 1
1888+
},
1889+
{
1890+
"type": "object",
1891+
"description": "The JSON Schema object used to validate the workflow",
1892+
"$schema": "http://json-schema.org/draft-07/schema#"
1893+
}
1894+
]
1895+
},
1896+
"failOnValidationErrors": {
1897+
"type": "boolean",
1898+
"default": true,
1899+
"description": "Determines if error should be thrown if there are validation errors"
1900+
}
1901+
},
1902+
"additionalProperties": false,
1903+
"required": [
1904+
"schema"
1905+
]
1906+
}
1907+
]
19021908
}
19031909
}
19041910
}

specification.md

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,6 +1769,7 @@ definition "id" must be a constant value.
17691769
| version | Workflow version. MUST respect the [semantic versioning](https://semver.org/) format | string | no |
17701770
| annotations | List of helpful terms describing the workflows intended purpose, subject areas, or other important qualities | array | no |
17711771
| dataInputSchema | Used to validate the workflow data input against a defined JSON Schema| string or object | no |
1772+
| dataOutputSchema | Used to validate the workflow data output against a defined JSON Schema| string or object | no |
17721773
| [constants](#Workflow-Constants) | Workflow constants | string or object | no |
17731774
| [secrets](#Workflow-Secrets) | Workflow secrets | string or array | no |
17741775
| [start](#Start-Definition) | Workflow start definition | string or object | no |
@@ -1859,22 +1860,33 @@ The `version` property can be used to provide a specific workflow version. It mu
18591860
The `annotations` property defines a list of helpful terms describing the workflows intended purpose, subject areas, or other important qualities,
18601861
for example "machine learning", "monitoring", "networking", etc
18611862

1862-
The `dataInputSchema` property can be used to validate the workflow data input against a defined JSON Schema.
1863-
This check should be done before any states are executed. `dataInputSchema` can have two different types.
1864-
If it is an object type it has the following definition:
1863+
The `dataInputSchema` and `dataOutputSchema` properties can be used to validate input and output data against a defined JSON Schema.
1864+
1865+
The `dataInputSchema` property validates the [workflow data input](#Workflow-Data-Input). Validation should be performed before any states are executed. In case of
1866+
a start [Event state](#Event-state) the input schema is ignored, if present. The `failOnValidationErrors` property determines if workflow execution should continue in case of validation errors.
1867+
1868+
The `dataOutputSchema` property validates the [Workflow data output](#workflow-data-output). Validation is performed on the output of the workflow execution.
1869+
The `failOnValidationErrors` property determines what should be done when the workflow output does not match the provided schema.
1870+
If `failOnValidationErrors` is true, an error should be thrown. If executed within a subprocess, that error can be be handled by the parent workflow.
1871+
If `failOnValidationErrors` is false, the error should not be propagated. It is up to the implementor to warn the user about that fact. For example, printing a log.
1872+
1873+
Both properties can be expressed as object or string type.
1874+
1875+
If using object type, their `schema` property might be an URI, which points to the JSON schema used to validate the workflow data input, or it might be the JSON schema object. `failOnValidationErrors` is optional, default value is `true`.
1876+
1877+
Example for Json schema reference
18651878

18661879
```json
18671880
"dataInputSchema": {
1868-
"schema": "URL_to_json_schema",
1881+
"schema": "URI to json schema",
18691882
"failOnValidationErrors": false
18701883
}
18711884
```
18721885

1873-
It's `schema` property can be an URI, which points to the JSON schema used to validate the workflow data input, or it can be the JSON schema object.
1874-
If it's a JSON schema object, it has the following definition:
1886+
Example for Json schema included in the workflow file
18751887

18761888
```json
1877-
"dataInputSchema": {
1889+
"dataOutputSchema": {
18781890
"schema": {
18791891
"title": "MyJSONSchema",
18801892
"properties":{
@@ -1886,22 +1898,18 @@ If it's a JSON schema object, it has the following definition:
18861898
}
18871899
}
18881900
},
1889-
"failOnValidationErrors": false
1901+
"failOnValidationErrors": true
18901902
}
18911903
18921904
```
1893-
It' `failOnValidationErrors` property determines if workflow execution should continue in case of validation
1894-
errors. The default value of `failOnValidationErrors` is `true`.
1895-
If `dataInputSchema` has the string type, it has the following definition:
18961905

1897-
```json
1898-
"dataInputSchema": "URL_to_json_schema"
1899-
```
1906+
If using string type, then the string value is the external schema URI and `failOnValidationErrors` default value of `true` is assumed.
19001907

1901-
In this case the `failOnValidationErrors` default value of `true` is assumed.
1908+
Example using string type
19021909

1903-
The `dataInputSchema` property validates the [workflow data input](#Workflow-Data-Input). In case of
1904-
a starting [Event state](#Event-state), it is not used to validate its event payloads.
1910+
```json
1911+
"dataInputSchema": "URI_to_json_schema"
1912+
```
19051913

19061914
The `secrets` property allows you to use sensitive information such as passwords, OAuth tokens, ssh keys, etc. inside your
19071915
Workflow expressions.

0 commit comments

Comments
 (0)