View Templates Configuration
Sunbird RC provides a functionality to transform the entity response body with different transformation templates
{
"id": "personDefaultView1",
"subject": "Person",
"fields": [
{
"name": "firstName",
"title": "NAME"
},
{
"name": "lastName",
"display": true
},
{
"name": "nationalIdentifier",
"title": "OS number",
"display": false,
"$comment": "This field is not displayable, but needed for internal referencing"
},
{
"title": "Name in passport",
"function": "#/functionDefinitions/concat($lastName, $firstName)",
"$comment": "This is a virtual field not defined in the schema"
},
{
"title": "Name as in DL",
"function": "#/functionDefinitions/userDefinedConcat($firstName, $lastName)",
"$comment": "This is a virtual field not defined in the schema"
}
],
"functionDefinitions": [
{
"name" : "concat",
"result": "arg1 + \", \" + arg2",
"$comment": "arg1 and arg2 will be populated with parameter values at runtime"
},
{
"name" : "userDefinedConcat",
"provider": "dev.sunbirdrc.provider.SampleViewFunctionProvider",
"$comment" : "Complex operations that cannot be expressed easily in an in-line function definition can be implemented as a class. "
}
]
}Last updated