22. 如何编写接口文档

登录

接口描述

用户登录接口

接口地址

接口地址localhost:8000/login
请求方式POST

请求参数

参数名描述参数类型是否必填
username用户名String
password密码String

返回值

{'status': 1, 'message': 'login success'}
{'status': 0, 'message': 'username or password null'}
{'status': 0, 'message': 'username or password error'}
{'status': 0, 'message': 'request type error'}

创建博客

接口描述

创建博客接口

接口地址

接口地址localhost:8000/add_article
请求方式POST

请求参数

参数名描述参数类型是否必填最大长度限制
id博客idInt
title博客标题String10
author博客作者String10
content博客内容String500

返回值

{'status': 0, 'message': 'id or title or author or content null'}
{'status': 0, 'message': "参数类型错误"}
{'status': 0, 'message': 'article id already exists'}
{'status': 0, 'message': "创建博客失败"}
{'status': 1, 'data': data, 'message': 'add article success'}
{'status': 0, 'message': 'request type error'}

修改博客

接口描述

用户修改博客接口

接口地址

接口地址localhost:8000/modify_article
请求方式POST

请求参数

参数名描述参数类型是否必填最大长度限制
id博客idInt
title博客标题String10
author博客作者String10
content博客内容String500

返回值

{'status': 0, 'message': 'id or title or author or content null'}
{'status': 0, 'message': "参数类型错误"}
{'status': 0, 'message': 'article not exist'}
{'status': 0, 'message': "修改博客失败"}
{'status': 1, 'data': data, 'message': 'modify article success'}
{'status': 0, 'message': 'request type error'}

查询博客

接口描述

用户根据标题查询博客接口

接口地址

接口地址localhost:8000/get_article
请求方式GET

请求参数

参数名描述参数类型是否必填
title博客标题String

返回值

{'status': 1, 'message': 'login success'}
{'status': 0, 'message': 'username or password null'}
{'status': 0, 'message': 'username or password error'}
{'status': 0, 'message': 'request type error'}

删除博客

接口描述

用户删除博客接口

接口地址

接口地址localhost:8000/delete_article
请求方式POST

请求参数

参数名描述参数类型是否必填
id博客idInt

返回值

{'status': 0, 'message': 'id null'}
{'status': 0, 'message': "参数类型错误"}
{'status': 0, 'message': 'id not exist'}
{'status': 0, 'message': '删除博客失败'}
{'status': 1, 'message': 'delete article success'}
{'status': 0, 'message': 'request type error'}

之前已经提到过,我们测试接口的时候,一般是增删改查以及登录是这五种,所以这里简单写了一个demo,涵盖了以上5种。

转载于:https://www.cnblogs.com/suim1218/p/11010378.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值