zoukankan      html  css  js  c++  java
  • 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 博客id Int
    title 博客标题 String 10
    author 博客作者 String 10
    content 博客内容 String 500

    返回值

    {'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 博客id Int
    title 博客标题 String 10
    author 博客作者 String 10
    content 博客内容 String 500

    返回值

    {'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 博客id Int

    返回值

    {'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种。

  • 相关阅读:
    vue-cli 3.0 路由懒加载
    vue 路由拦截、axios请求拦截
    vue-cli 3.0 图片路径问题(何时使用 public 文件夹)
    vue 监听页面宽度变化 和 键盘事件
    WGS84、GCJ-02(火星坐标)、百度坐标,Web墨卡托坐标
    Java学习之道:Java项目打包发布
    ora-14550问题解决
    费氏搜寻法之算法分析与实现
    [置顶] woff格式字体怎么打开和编辑?
    C++小知识之Vector排序
  • 原文地址:https://www.cnblogs.com/suim1218/p/11010378.html
Copyright © 2011-2022 走看看