当前位置:网站首页>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
边栏推荐
- 线程(中):线程安全
- mysql cdc (2.1.1)inital snapshot数据库的时候设置了5个并发度,se
- Important transformation and upgrading
- How cursors work in Pulsar
- 【Static proxy】
- Rpc接口压测
- Stacks and Queues | Implementing Queues with Stacks | Implementing Stacks with Queues | Basic Theory and Code Principles
- SQL Server query optimization
- Ask you guys.The FlinkCDC2.2.0 version in the CDC community has a description of the supported sqlserver version, please
- 【无标题】
猜你喜欢

添加路由的2种方式--router

【Static proxy】

干货 | 查资料利器:线上图书馆

EasyGBS connects to mysql database and prompts "can't connect to mysql server", how to solve it?

Depth of carding: prevent model fitting method

线程(上篇):线程的创建

Rpc interface stress test

一文带你搞懂OAuth2.0

Linear Algebra (4)

Stacks and Queues | Valid parentheses, delete all adjacent elements in a string, reverse Polish expression evaluation, maximum sliding window, top K high frequency elements | leecode brush questions
随机推荐
SQL数据库字段追加到主表
文献 | 关于心理活动符号学,你知道多少?
【LeetCode】Day111-字母异位词分组
FPGA engineer interview questions collection 41~50
安芯电子IPO过会:年营收4亿 汪良恩兄弟持股61.6%
You can‘t specify target table ‘kms_report_reportinfo‘ for update in FROM clause
FPGA engineer interview questions collection 31~40
Joomla漏洞复现
咨询cdc 2.0 for mysql不执行flush with read lock.怎么保证bin
线程(下):读写者模型\环形队列\线程池
Shell编程三剑客之awk
Joomla vulnerability reproduced
Stacks and Queues | Implementing Queues with Stacks | Implementing Stacks with Queues | Basic Theory and Code Principles
【Pei Shu Theorem】CF1055C Lucky Days
oracle cdc时,设置并行度2插槽数1,最终任务只有一个tm,是不是因为oracle不支持并发
我用这一招让团队的开发效率提升了 100%!
栈与队列 | 有效的括号、删除字符串中的所有相邻元素、逆波兰表达式求值、滑动窗口的最大值、前K个高频元素 | leecode刷题笔记
Attention candidates for the soft exam! The detailed registration process for the second half of 2022 is coming!
Depth of carding: prevent model fitting method
Flutter开发:报错The following assertion was thrown resolving an image codec:Unable to…的解决方法