
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
mock-convert
Advanced tools
将idoc上的接口数据转换为mock数据
npm i mock-convert --save-dev
写好配置文件,然后执行,配置文件参考下一节
mock-convert -c config/config.js;
config.js
module.exports = {
projectJsonUrl: "http://api.demo", // 项目文档接口地址,必须
outOpt: {
outPath: "mock/data.js", // 生成mock文件输出的路径,必须
singleFile: true, // 生成单个文件,默认为false
fileNames: {
'登录': 'login',
'行情': 'market',
} // 文件名
}
parseOpt: [ // 可选配置
{
dataType: "string", // 参数类型,支持多个参数类型,类型之间用,分隔开
identifier: "price", // 参数变量名
ignoreCase: true, // 匹配时候是否忽略大小写,匹配内容为identifier的值
fullMatch: false, // 全字匹配,匹配内容为identifier的值
target: '\"$identifier$\|3000-5000.1-2\": 3000', // 生成目标,identifier为占位符,在转换过程中会替换为identifier的值
},
{
dataType: "int,string",
identifier: "retcode",
ignoreCase: true,
fullMatch: true,
target: 'retcode: 200'
},
]
}
在可选配置中,可以对转换做定制化操作:
{
dataType: "string",
id: 49384,
identifier: "buyPrice",
isNecessary: 1,
mock: "",
name: "买入价",
parameterList: [ ],
remark: "精确到小数点2位 没有有效行情下是0",
validator: ""
},
// 匹配到第一个规则,配置中$identifier$为占位符,实际使用中会替换为identifier的值,这里最终转换的结果为:"buyPrice|3000-5000.1-2": 3000
{
dataType: "string",
id: 49024,
identifier: "retcode",
isNecessary: 1,
mock: "",
name: "返回码",
parameterList: [ ],
remark: "200为成功,错误对应相应的错误代码 9011(交易密码错误,登录失败) 9018(账号或密码错误,无密码剩余次数记录)",
validator: ""
}
// dataType支持多种数据类型,这里匹配到第二个规则,会转换为: retcode: 200
mock规则可参考 http://mockjs.com/
FAQs
convert interface data to mock data
We found that mock-convert demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.