json - 养蜂场:是否可以记录什么是JSON响应字段?

标签 json apiblueprint apiary

我想记录一下实际的JSON字段本身代表什么。

我已经记录了GET语句和参数,但这并未提供完整的文档给用户。

因此,在下面的示例中,我将如何添加有关“OtherFields”的注释。支持这个吗?还是我需要在其他地方制作配套文档。

## View Applications [/cat{?sort}{&order}{&page}]
### List all Applications 
### Get List of Applications [GET]
+ Parameters
    + sort (optional, string) ... `sort` parameter is used to specify which criteria to use for sorting. One of the following strings may be used: 
    `"NAME", 
    "RATING", "QUALITY" ,
    "RISKLEVEL", `

    + order (optional, string) ... `order` parameter is used to specify which order to use if sorting is used. One of the following strings may be used: 
    `"ASC", 
    "DESC"`

    + page (optional, int ) ... `page` parameter is used to request subsequent catalog pages.


+ Response 200 (application/json)

                {
            "Catalog" : {
                "Page" : 0,
                "Count" : 6,
                "Applications" : [{
                        "UID" : "6882e96a-5da1-11e3-1111-3f24f45df3ad"
                        "OtherFields: ""
               }]
               }}

最佳答案

更新:我们刚刚使用MSON syntax推出了一个描述属性的beta版本。

然后可以将原始有效负载描述为

### Get List of Applications [GET]

+ Response 200 (application/json)

    + Attributes
        + Catalog (object)
            + Page: 0 (number) - Number of the page
            + Count: 6 (number) - Count of *Lorem Ipsum*
            + Applications (array) - Some array of something
                + (object)
                    + UID: `6882e96a-5da1-11e3-1111-3f24f45df3ad`
                    + OtherFields

    + Body 

            {
                "Catalog" : {
                    "Page" : 0,
                    "Count" : 6,
                    "Applications" : [{
                        "UID" : "6882e96a-5da1-11e3-1111-3f24f45df3ad"
                        "OtherFields": ""
                    }]
                }
            }

请注意,主体中的显式JSON是多余的,您可以完全跳过它。有关其他详细信息,请参见API蓝图规范– Attributes

关于json - 养蜂场:是否可以记录什么是JSON响应字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21043514/

相关文章:

apiblueprint - 在 API Blueprint/MSON 中使用模式

apiblueprint - 如何在Apiary.io中显示嵌套的属性定义

json - 如何在 Go 的 POST 请求中发送 JSON 字符串

apiblueprint - 如何在 API 蓝图中为每个端点指定多个请求类型?

swagger - 如何为内容类型为 : text/html in Swagger (to test with dredd) 的响应正文提供示例值

jsonschema - api-blueprint 未正确显示嵌套 "One of"属性

javascript - 将 View Web 表单 View 引擎格式中的字符串数组转换为 javaScript 对象

javascript - 在 node.js 中读写一个 json 文件

python - ProgrammingError : (psycopg2. ProgrammingError) 无法适配类型 'dict'

javascript - 将 PHP JSON 编码的数组打印到 JavaScript 并对其进行解码,会产生错误