【发布时间】:2021-02-06 04:13:27
【问题描述】:
我想为我的新 REST API 使用 JSON:API。规范听起来不错,一切都很好。我唯一缺少的是一种询问实体有效属性的方法。
如果还没有实体,我发现没有记录的可能性来查看我需要哪些属性来创建一个新的。有没有人有同样的问题或解决这个差距的好方法?
示例
请求获取文章列表
GET /articles HTTP/1.1
Accept: application/vnd.api+json
响应(零篇文章)
HTTP/1.1 200 OK
Content-Type: application/vnd.api+json
{
"links": {
"self": "http://example.com/articles"
},
"data": []
}
=> 这里我缺少一个调用来检索新文章实体的可用属性
请求创建文章
POST /photos HTTP/1.1
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json
{
"data": {
"type": "articles",
"attributes": {
"title": "New Article" <= i have to know this attribute
}
}
}
【问题讨论】:
标签: json-api