我正在使用Django REST框架。
使用可浏览的API时,单击OPTIONS
按钮后,我看到了字段的漂亮定义以及该资源的允许操作,例如,下面的此用户资源:
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
}
}
}
}
问题:是否有任何JS框架能够利用此元信息来生成表单?
最佳答案
好吧,我认为这对http://formly-js.github.io/angular-formly有用,它采用JSON并呈现HTML表单。