Describe workflow's input JSON
Introduction
As explained in the article about workflow's and blocks' input, there can be special needs that can be addressed by explicitly describing to EI-Flow the structure of the input JSON that is submitted to the workflow when it is executed.
In this way, both at design and execution time, a virtual block named $nlflow_input is defined, ideally located upstream of any workflow block, whose output keys are those indicated as component parts of the workflow input JSON with the procedure described below.
The virtual block can then be referenced as a source of data when setting the input properties of blocks.
To explicitly describe the workflow's input JSON, in the workflow editor, select Input format definition
on the canvas toolbar. The Input format definition window appears.
The workflow input is described by a JSON schema. The schema can be created with three different tools, and what you do with one tool is automatically reflected in the others:
- Designer: compose the schema visually.
- By example: provide a JSON example and the system infers the schema from it.
- JSON Schema: manually edit the schema definition.
The latter allows you to write the schema with all the expressiveness allowed by the standard. The designer also offers many options, while the definition by example necessarily doesn't directly allow you to establish the mandatory nature of certain fields, the use of subschemas and so on, but it's good for drafting the schema that can then be enriched with other tools if necessary.
- To switch from one tool to another simply select the corresponding tab.
- To reset the schema, select Reset JSON Schema
on the toolbar. - To save changes to the schema select Save.
Use the designer
Use the designer as described in the article about editing labels.
Define the schema by example
To define the JSON schema by example select the By example tab.
If the schema was already defined with the the other tools, you'll see an auto-generated sample JSON conforming to the schema.
Warning
In case of subschemas or multiple types, the auto-generated JSON sample represent only one of the possibilities.
Edit the JSON as you like.
When finished, select Change to make the system to infer the schema from the sample JSON or Discard to undo any unsaved changes.
Edit the schema source code
To edit the source code of the JSON schema select the JSON Schema tab. Every change is reflected in the tabs of the other tools.
Use blocks' input variables
You can build the schema using the input variables of the workflow blocks by choosing the block from the first drop-down menu
.
If the selected block has defined input variables, the drop-down menu
gets enabled, allowing you to choose any input variable. If the schema is empty, it is defined based on the name, type, and attributes of the selected variable. Otherwise, if the root field is of type object, a subfield is added with the name, type, and attributes of the selected variable.
If instead of an input variable, you choose the first item in the list, the entire root field is set to an object, in which a subfield is inserted for each of the input variables, with their name, type, and attributes.
-
Exclusive means the specified value is excluded. If it is a "minimum" constraint, the property's value in the actual JSON must be greater than the specified value, it cannot be equal. ↩