For simplicity's sake, let's say we are storing users' personal informations like so (JSON here, but that's not the point):
{
"name": "John"
"age": 35
"sex": "M"
}
We want to have the UI client to create a form in order to display these infos and also for creating new users or updating existing ones.
So, my question is:
How can this be achieved in a RESTful manner? Does REST even provide for such type of interactions, that is, hinting clients on how to display the resources provided?
We would like to give clients maximum freedom on how to represent resources but also to help them send us back the correct data without too much coupling between backend and frontend.
For example, we could have a template for user
like so:
{
"self": "/template/user"
"method": "GET"
"data": {
"fields": [
{
"name": "name"
"value": {
"data_type": "string"
}
},
{
"name": "age"
"value": {
"data_type": "number"
}
},
{
"name": "sex"
"value": {
"data_type": "string"
"options": [
"M",
"F"
]
}
}
]
}
}
Thank you for any input you might be able to provide.