当前位置:网站首页>如何用Apifox 的智能Mock功能?
如何用Apifox 的智能Mock功能?
2022-08-10 05:09:00 【Liamhong】
大家好。继上一章节我们学习了Apifox的前置操作和后置操作,我们基本上学会了如何使用Apifox 去测试一个接口了。现在我们开始学习Apifox的强大的Mock功能。
今天我们学习下最简单的智能Mock 功能。
首先我们学习下添加一个接口后,如何添加响应返回数据。
- 添加新分组,添加一个接口。
- 添加接口URL 以及接口名称
- 添加响应数据。滚动到最下面的返回响应位置,点击根节点的最右边对的【添加子节点】。就可以添加返回数据了。然后继续添加正在编辑节点的【添加相邻节点】
- 如果返回字段还有子节点,就把当前字段类型 设置成 object。然后最后面的+ ,数据hover 上去,就会出现2个子菜单,选择【添加子节点】 即可。
- 添加完成后,点击【保存】按钮。
- 点击【运行】。
是不是很强大,自动Mock 了这些属性?
我们学习下 Apifox都 内置了哪些数据类型。【项目设置】---【功能设置】---【智能Mock 设置】
由上面2张图片,我们可以看出,常见数据类型基本都是内置好的。
数据类型 | 匹配方式 | 匹配规则 | Mock 规则 | 备注 |
---|---|---|---|---|
string | 正则表达式 | avatar | icon | @image('100x100') |
string | 正则表达式 | image | img | photo |
string | 通配符 | *url | @url('http') | URL |
string | 正则表达式 | nick | user_?name | @cname |
string | 正则表达式 | title | name | @ctitle |
stringintegernumber | 正则表达式 | id | num | code |
stringintegernumber | 正则表达式 | phone | mobile | tel$ |
string | 通配符 | *date | @date('yyyy-MM-dd') | 字符串日期 |
integernumber | 通配符 | *date | @date('yyyyMMdd') | 数字型日期 |
string | 正则表达式 | created?_?at | updated?_?at | deleted?_?at |
integernumber | 正则表达式 | created?_?at | updated?_?at | deleted?_?at |
string | 正则表达式 | e?mail* | @email('qq.com') | 邮箱 |
string | 通配符 | province | @province | 省份 |
string | 通配符 | city | @city | 城市 |
string | 通配符 | *address | @address | 地址 |
string | 通配符 | *district | @county | 区 |
string | 通配符 | *ip | @ip | IP 地址 |
integernumber | 通配符 | * | @natural(1, 100) | 通用数字类型 |
\
看完是不是觉得很强大。你学会了吗?
官网地址:www.apifox.cn
边栏推荐
- 暑期学前作业
- summer preschool assignments
- 十年架构五年生活-06 离职的冲动
- aliases节点分析
- Hezhou ESP32C3 +1.8"tft network clock under Arduino framework
- Shield Alt hotkey in vscode
- ctf-pikachu-file_inclusion
- [Web3 Series Development Tutorial - Create Your First NFT (7)] Create an NFT DApp and assign attributes to your NFT, such as pictures
- 通过一个案例轻松入门OAuth协议
- 十年架构五年生活-07 年轻气盛的蜕变
猜你喜欢
tensorflow分词深度学习——影评预测
Flutter开发:报错The following assertion was thrown resolving an image codec:Unable to…的解决方法
【论文笔记】Prototypical Contrast Adaptation for Domain Adaptive Semantic Segmentation
【无标题】
awk of the Three Musketeers of Shell Programming
顺序表的删除,插入和查找操作
Depth of carding: prevent model fitting method
ORA-16018 异常处理记录
EasyGBS connects to mysql database and prompts "can't connect to mysql server", how to solve it?
线性代数(四)
随机推荐
万字总结:分布式系统的38个知识点
如何从代码层提高产品质量
Nexus_Warehouse Type
重要转型升级
JavsSE => 多态
Ueditor editor arbitrary file upload vulnerability
ORA-16018 异常处理记录
元宇宙 | 你能通过图灵测试吗?
LeetCode 301. Remove Invalid Parentheses BFS
Hezhou ESP32C3 +1.8"tft network clock under Arduino framework
Rpc interface stress test
JS gets the year, month, day, time, etc. of the simple current time
FPGA engineer interview questions collection 41~50
【无标题】
pytorch learning
解决“#231-D declaration is not visible outside of function”告警方法
Nexus_仓库类型
【心理学·人物】第二期(学术X综艺)
Advanced Feature Selection Techniques in Linear Models - Based on R
Using the DatePicker date control, Prop being mutated: "placement" error occurs