在起草API蓝图文档时,如何注释响应?

时间:2013-12-24 21:34:48

标签: apiblueprint

我想注释一些错误响应,如下所示:

* Response 412
If the Etag supplied in `If-Match` didn’t match.

* Response 428
If the request didn’t include the header `If-Match`.

但解析器(snowcrash)似乎将注释解释为响应主体。

如何对这些回复进行注释并让snowcrash明白它们是注释?

1 个答案:

答案 0 :(得分:5)

我明白了:我需要在响应中添加一个空的Body部分,如下所示:

* Response 204

    The request succeeded; there’s no need to transfer a representation of the new state of the resource, as the resource no longer exists.

    * Body

* Response 412

    If the Etag supplied in `If-Match` didn’t match.

    * Body

然后根据需要对其进行解析:

responses:
- name: 204
  description: "The request succeeded; there’s no need to transfer a representation of the new state of the resource, as the resource no longer exists.\n"
  headers:
  body:
  schema:
- name: 412
  description: "If the Etag supplied in `If-Match` didn’t match.\n"
  headers:
  body:
  schema:
- name: 428
  description: "If the request didn’t include the header `If-Match`.\n"
  headers:
  body:
  schema: