apiDoc creates a documentation from API annotations in your source code
apiDoc是一個接口文檔,它的建立方式是基於你的源代碼的接口備註。咱們只須要給接口寫好相應的文檔,而後使用apiDoc生成接口文檔工具生成文檔,便於管理和查看。前端
1.安裝apidoc(npm是啥???本身問前端同窗吧。。)git
npm install apidoc -g
安裝http-servergithub
npm install http-server -g
2.給接口添加文檔(官方示例),添加在Controller入口方法前面。npm
/** * @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. */
3.建立apidoc.json(官方示例)json
{ "name": "example", "version": "0.1.0", "description": "apiDoc basic example", "apidoc": { "title": "Custom apiDoc browser title", "url" : "https://api.github.com/v1" } }
4.生成apiDocapi
apidoc -i app/Http/Controllers -o apidoc/
5.運行app
http-server api/doc