当前位置:网站首页>How to use Apifox's Smart Mock function?
How to use Apifox's Smart Mock function?
2022-08-10 05:16: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') | Digital type date |
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
边栏推荐
- Guys, is it normal that the oracle archive log grows by 3G in 20 minutes after running cdc?
- 通过一个案例轻松入门OAuth协议
- 深度学习之-01
- 栈与队列 | 有效的括号、删除字符串中的所有相邻元素、逆波兰表达式求值、滑动窗口的最大值、前K个高频元素 | leecode刷题笔记
- 如何模拟后台API调用场景,很细!
- leetcode每天5题-Day11
- SQLSERVER 2008 parses data in Json format
- 一篇文章掌握整个JVM,JVM超详细解析!!!
- tensorflow分词深度学习——影评预测
- SQL database field to append to main table
猜你喜欢
告诉你如何从keil工程知道使用了多少RAM和ROM空间
How to choose the right oscilloscope probe in different scenarios
Zhongang Mining: Strong downstream demand for fluorite
Matlab simulation of multi-factor house price prediction based on BP neural network
Pulsar中游标的工作原理
EasyGBS connects to mysql database and prompts "can't connect to mysql server", how to solve it?
Shell编程三剑客之awk
万字总结:分布式系统的38个知识点
Flutter development: error The following assertion was thrown resolving an image codec: Solution for Unable to...
RadiAnt DICOM Viewer 2022.1 Crack
随机推荐
leetcode每天5题-Day12
Order table delete, insert and search operations
Arduino框架下合宙ESP32C3 +1.8“tft 网络时钟
2022 security officer C certificate test and simulation test in shandong province
栈与队列 | 有效的括号、删除字符串中的所有相邻元素、逆波兰表达式求值、滑动窗口的最大值、前K个高频元素 | leecode刷题笔记
Flutter development: error The following assertion was thrown resolving an image codec: Solution for Unable to...
一篇文章带你搞懂什么是幂等性问题?如何解决幂等性问题?
Thread.sleep, Thread.yield role explanation
元宇宙 | 你能通过图灵测试吗?
oracle rac 11g安装执行root.sh时报错
【无标题】
FPGA工程师面试试题集锦21~30
2022 T Elevator Repair Exam Questions and Mock Exams
单页面应用
SQLSERVER 2008 parses data in Json format
Transforming into a product, is it reliable to take the NPDP test?
栈与队列 | 用栈实现队列 | 用队列实现栈 | 基础理论与代码原理
应用在智能触摸遥控器中的触摸芯片
flex related
安芯电子IPO过会:年营收4亿 汪良恩兄弟持股61.6%