I have encountered a fascinating feature while using the Django REST Framework. When I navigate to the browsable API and click on the OPTIONS
button, detailed definitions of fields and permitted actions for the specific resource are beautifully displayed. One such example is the user resource described below:
HTTP 200 OK
Content-Type: application/json
Vary: Accept
Allow: GET, PUT, PATCH, DELETE, HEAD, OPTIONS
{
"name": "XSpot User Detail",
"description": "",
"renders": [
"application/json",
"text/html"
],
"parses": [
"application/json",
"application/x-www-form-urlencoded",
"multipart/form-data"
],
"actions": {
"PUT": {
"url": {
"type": "field",
"required": false,
"read_only": true
},
"mail_sent": {
"type": "boolean",
"required": false,
"read_only": false,
"label": "mail sent"
},
"email": {
"type": "email",
"required": true,
"read_only": false,
"label": "email address",
"max_length": 255
}
}
}
}
CURIOUS: I wonder if there are any JavaScript frameworks capable of leveraging this metadata to automatically generate forms?