c语言api接口文档模板,apiDoc生成接口文档,不费吹灰之力

e2d340d62c86159e7fdd0b27906d1045.png

背景

之前做前端的时候,后端同学仗着自己是老同志,不给我接口文档

苦逼如我,需要拿着笔坐在他的旁边,听他口述

写下需要的api接口url和参数等等

现在自己做后端了,那不能这样子胡作非为了

自己吃的苦,怎能给其他同学吃呢?

这时候,apiDoc你值得拥有,稳稳的输出一篇优质的接口文档

安装apidoc

官网上是全局安装,我是喜欢安装到项目中,这样可以在另一个环境下, npm install 就可以下载有所有依赖包

npm install apidoc --save-dev/-D

复制代码

写注释

注册接口的注释

/**

* @api {post} /v1/auth/register User Register

* @apiName UserRegister

* @apiGroup userAuthentication

*

* @apiParam {String} username New user's username.

* @apiParam {String} password New user's password.

*

* @apiSuccess {String} username The username of the register user.

* @apiSuccess {string} message The registering success info.

*

* @apiSuccessExample Success-Response:

* HTTP/1.1 200 OK

* {

* "username": "username",

* "message": "User registered successful"

* }

*

* @apiError REGISTER_FAILURE The register failure.

*

* @apiErrorExample Error-Response:

* HTTP/1.1 500 Internal Server Error

* {

* "err": "REGISTER_FAILURE",

* "message": "User register failure!"

* }

*/

复制代码

删除接口的注释

/**

* @api {delete} /v1/auth/user/ User delete

* @apiName UserDelete

* @apiGroup userAuthentication

*

* @apiParam {String} username User's username.

* @apiParam {String} executor Executor of this operation.

*

* @apiSuccess {String} username The username of the deleted user.

* @apiSuccess {string} message The message if deleting successful.

*

* @apiSuccessExample Success-Response:

* HTTP/1.1 200 OK

* {

* "username": "username",

* "message": "Delete User Successful"

* }

*

* @apiError NOT_LOGIN The register failure.

*

* @apiErrorExample Error-Response:

* HTTP/1.1 401 Unauthorized

*

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值