C/C++教程

apidoc配置

本文主要是介绍apidoc配置,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

安装

npm install apidoc -g

运行

apidoc -i (项目路径) -o (注释存储路径) 

apidoc.json

项目根目录中的可选内容包括有关项目的常见信息,例如标题,简短描述,版本和配置选项

{
  "name": "example",               //项目名称
  "version": "0.1.0",                //项目版本
  "description": "apiDoc basic example",   //项目简介
  "title": "Custom apiDoc browser title",   /浏览器标题文本
  "url" : "https://api.github.com/v1"       //api路径的前缀
}

注释模板

/**
 * @api {get} /user/:id Request User information
 * @apiName GetUser
 * @apiGroup User
 *
 * @apiParam {Number} id Users unique ID.
 *
 * @apiSuccess {String} firstname Firstname of the User.
 * @apiSuccess {String} lastname  Lastname of the User.
 *
 * @apiSuccessExample Success-Response:
 *     HTTP/1.1 200 OK
 *     {
 *       "firstname": "John",
 *       "lastname": "Doe"
 *     }
 *
 * @apiError UserNotFound The id of the User was not found.
 *
 * @apiErrorExample Error-Response:
 *     HTTP/1.1 404 Not Found
 *     {
 *       "error": "UserNotFound"
 *     }
 */
这篇关于apidoc配置的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!