有没有办法在Apiary中重用RESPONSE?我认为Data Structures不是正确的方法,但我找不到任何其他的东西......
答案 0 :(得分:0)
数据结构 - 正如您可能已经注意到的那样,首先看一下有点矫枉过正,但这是您正在寻找的确切答案。如果您对如何在“高级模式”中使用它们更感兴趣,请查看https://github.com/apiaryio/api-blueprint/blob/master/Advanced%20Tutorial.md#data-structures上的教程
另一种选择是使用资源模型:
## My Message [/message]
+ Model (application/vnd.siren+json)
This is the `application/vnd.siren+json` message resource representation.
+ Headers
Location: http://api.acme.com/message
+ Body
{
"class": [ "message" ],
"properties": {
"message": "Hello World!"
},
"links": [
{ "rel": "self" , "href": "/message" }
]
}
另一种选择我们使用普通属性(https://github.com/apiaryio/api-blueprint/blob/master/API%20Blueprint%20Specification.md#resource-attributes-description)
# Blog Post [/posts/{id}]
Resource representing **ACME Blog** posts.
+ Attributes
+ id (number)
+ message (string) - The blog post article
+ author: john@appleseed.com (string) - Author of the blog post
后来参考^^^“资产”,如下所示:
+ Attributes (Blog Post)