Creating a JSON Schema Manually
You need to have two input and output JSON Schema files for a Data Mapping configuration as shown in the example below.
Therefore, you can use the WSO2 Data Mapper Diagram Editor to create a JSON Schema manually by adding elements to the Data Mapper tree view as explained below.
Components of a JSON Schema
There are the following four types of components in a JSON Schema:
- Arrays
- Objects
- Fields
- Attributes
Adding the root element
When creating the tree you need to first add the root element. The root element can be either an object or an array. Right-click on the Input or Output box and then click Add new Root Element as shown below, to add the root element.
Add the following details to create the root element.
- Name: name of the root element
- Schema Type: type of the element (i.e. array or object)
- ID: ID of the root element to uniquely identify it
- isNullable: whether the element can be a nullable (i.e. not available in the payload (optional)
Namespaces: prefix and URL of the namespace (optional) - Required: child elements required to be there in the payload (optional)
- Schema Value: custom URI of the Schema
You view the root element added to the Input box as shown below.
Adding a child element
You can add Arrays, Objects, Fields and Attributes as child elements as explained below.
Setting a nullable element
You can set an element as a nullable element, so that it is not required to have that element in the payload. Right-click on the parent element and click Enable Nullable, to enable an element to make it nullable as shown below.
Right-click on the parent element and click Disable Nullable, to make it required in the payload as shown below.
Editing an element
Right-click on any element and click Edit Object, to edit and update the field values as required as shown below.
Deleting an element
Right-click on any element and click Delete from Model, to delete it as shown below.
This deletes the element with its child nodes.