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" * } */