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

 周啸夫_919 发布于 2023-02-08 11:54

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

* 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 个回答
  • 我想通了:我需要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:
    

    2023-02-08 11:57 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有