Json Schema
We have design schema structure similer to json object send and receive from a API. Near about all properties define as json object type except 'options' & 'optionValue' metadata(sub-proerty), they have json array type.
Example:{
"customer": { // entity name
"firstName": { // property name
"dataType": "string", // required metadata
"inputType": "text", // optional metadata
"dispalyName": "First Name" // optional metadata
},
"lastName": {
"dataType": "string"
},
"address": {
"dataType": "group",
"inputType": "group",
"properties": {
"area": {
"dataType": "string"
},
"city": {
"dataType": "string",
"validation": {
"required": true
}
}
...
}
}
...
},
"product": {
"productName": {
"dataType": "string"
},
productCode: {
"dataType": "string"
},
"category": {
"dataType": "number",
"inputType": "select",
"options": [ // options, optionValues or source any one is requried, if inputType is 'select'
{"desc": "Samsung TV 51", "val": 125},
{"desc": "LG Washing Machine 10kg", "val": 201},
{"desc": "Sony Camera HXV3026" "val": 341}
]
or
// only for string dataType
"optionValues": ["Samsung TV 51", "LG Washing Machine 10kg", "Sony Camera HXV3026"]
or
"source": "http://schematocode.com/api/category" // any valid url
"descField": "name",
"valField": "code",
"parentObject": "cat" // only if expected data[] not at root level.
}
...
}
...
}
Entity
Entities are top level objects that should be unique entity name should be valid json identifier, it should be start with character and can contains characters, numbers and underscore only, it should not contain space or any special characters.
Properties
Properties are second level objects and it should also be unique name within entity and should be valid json identifier, it should be start with character and can contains characters, numbers and underscore only, it should not contains space or any special characters.
Metadata (sub-propertiies)
Metadata are predifined sub-proeprties, that help to generate input control and send data in specific data types. Some metadata are required and some are optional.
Required metadata
"dataType" : This metadata required for every property.
"key" : This metadata only required for primary / unique key property.
"options" or "optionValues" or "source", "descField" & "valField" only for "inputType" select, array->checkbox(checkbox group) and radio.
Optional metadata
"displayName" : It will be use in grid/list component and will use for column name.
"format" : It will only applicable to date inputType.
"inputType" : Which form-control will be use for input data. If it is not provided then, it will be computed on base of dataType and other sub-properties(meta-data).
"label" : It will be use as lable for the form-control in input form. If it is not provided then displayName will be use.
"multiple" : It will store data as array instead of single value, it will be applicable only to select, file & image inputType.
"parentObject" : required only if descFiled and valField data not available at root level.
"position" : It will only applicable to checkbox inputType.
"rows" : It will only applicable to textarea inputType.
"step" : It will only applicable to number inputType.
"validation" & "hint" : It can be applicable to almost all inputTypes.
"value" : It will only applicable to checkbox inputType having string dataType.
Group
'group' inputType can be use to group multiple properties into one object. You need to use 'properties' sub-property(metadata) to define child properties same as top level properties.
You can use 'group' or 'array' as dataType and 'group' as inputType. In case of array it will be stored as array of group and having add/remove functionality.
Array
You can use 'array' dataType to stored data as string array, number array or group/object array.