mirror of
https://github.com/YMFE/yapi.git
synced 2025-01-18 13:04:46 +08:00
feat: 增加严格模式使用说明
This commit is contained in:
parent
54235afb32
commit
083d29f173
@ -361,8 +361,6 @@ export default class Run extends Component {
|
||||
const params = json5_parse(test_res_body);
|
||||
validResult = schemaValidator(schema, params);
|
||||
}
|
||||
|
||||
console.log(validResult);
|
||||
return validResult;
|
||||
};
|
||||
|
||||
@ -873,7 +871,12 @@ export default class Run extends Component {
|
||||
</h2>
|
||||
{this.state.test_valid_msg && (
|
||||
<Alert
|
||||
message="Warning"
|
||||
message={<span>
|
||||
Warning
|
||||
<Tooltip title="针对定义为 json schema 的返回数据进行格式校验">
|
||||
<Icon type="question-circle-o" />
|
||||
</Tooltip>
|
||||
</span>}
|
||||
type="warning"
|
||||
showIcon
|
||||
description={this.state.test_valid_msg}
|
||||
|
@ -986,7 +986,9 @@ class InterfaceEditForm extends Component {
|
||||
{getFieldDecorator('req_body_is_json_schema', {
|
||||
valuePropName: 'checked',
|
||||
initialValue: this.state.req_body_is_json_schema || projectMsg.is_json5
|
||||
})(<Switch checkedChildren="开" unCheckedChildren="关" disabled={projectMsg.is_json5}/>)}
|
||||
})(
|
||||
<Switch checkedChildren="开" unCheckedChildren="关" disabled={projectMsg.is_json5} />
|
||||
)}
|
||||
|
||||
<Col style={{ marginTop: '5px' }} className="interface-edit-json-info">
|
||||
{!this.props.form.getFieldValue('req_body_is_json_schema') ? (
|
||||
@ -1053,7 +1055,13 @@ class InterfaceEditForm extends Component {
|
||||
{getFieldDecorator('res_body_is_json_schema', {
|
||||
valuePropName: 'checked',
|
||||
initialValue: this.state.res_body_is_json_schema || projectMsg.is_json5
|
||||
})(<Switch checkedChildren="json-schema" unCheckedChildren="json" disabled={ projectMsg.is_json5}/>)}
|
||||
})(
|
||||
<Switch
|
||||
checkedChildren="json-schema"
|
||||
unCheckedChildren="json"
|
||||
disabled={projectMsg.is_json5}
|
||||
/>
|
||||
)}
|
||||
</h2>
|
||||
<div className="container-radiogroup">
|
||||
{getFieldDecorator('res_body_type', {
|
||||
|
@ -363,7 +363,7 @@ class ProjectMessage extends Component {
|
||||
label={
|
||||
<span>
|
||||
mock严格模式
|
||||
<Tooltip title="开启mock严格模式后会对query,body form 的必须字段和json schema 进行校验">
|
||||
<Tooltip title="开启后 mock 请求会对 query,body form 的必须字段和 json schema 进行校验">
|
||||
<Icon type="question-circle-o" />
|
||||
</Tooltip>
|
||||
</span>
|
||||
|
@ -23,6 +23,7 @@
|
||||
* [方式1. mockjs](mock.md#方式1. mockjs)
|
||||
* [方式2. json-schema](mock.md#方式2. json-schema)
|
||||
* [如何使用](mock.md#如何使用 Mock)
|
||||
* [严格模式](mock.md#mock请求严格模式)
|
||||
* [高级Mock](adv_mock.md)
|
||||
* [Mock 期望](adv_mock.md#Mock 期望)
|
||||
* [自定义脚本](adv_mock.md#自定义 Mock 脚本)
|
||||
|
BIN
docs/documents/images/mock-strice.png
Normal file
BIN
docs/documents/images/mock-strice.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 92 KiB |
BIN
docs/documents/images/mock-strice2.png
Normal file
BIN
docs/documents/images/mock-strice2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 92 KiB |
BIN
docs/documents/images/mock-strice3.png
Normal file
BIN
docs/documents/images/mock-strice3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
@ -148,3 +148,16 @@ proxy_pass http://yapi.xxx.com/mock/2817/baseapi; #baseapi后面没有"/"
|
||||
|
||||
<img src="./images/charles.png" width="60%" />
|
||||
|
||||
## mock请求严格模式
|
||||
|
||||
版本 v1.3.22 新增 mock 接口请求字段参数验证功能,具体使用方法如下:
|
||||
|
||||
1. 打开 项目 -> 设置 开启 mock 严格模式
|
||||
2. 针对 query form 中设置的必须字段会进行必填校验
|
||||
<img src="./images/mock-strice.png"/>
|
||||
|
||||
3. 针对 req_body_type 是json schema 格式的数据进行校验
|
||||
|
||||
<img src="./images/mock-strice3.png"/>
|
||||
<img src="./images/mock-strice2.png"/>
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
BIN
static/doc/documents/images/mock-strice.png
Normal file
BIN
static/doc/documents/images/mock-strice.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 92 KiB |
BIN
static/doc/documents/images/mock-strice2.png
Normal file
BIN
static/doc/documents/images/mock-strice2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 92 KiB |
BIN
static/doc/documents/images/mock-strice3.png
Normal file
BIN
static/doc/documents/images/mock-strice3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -454,6 +454,11 @@ window.ydoc_plugin_search_json = {
|
||||
"title": "2 \b基于本地服务器反向代理",
|
||||
"url": "/documents/mock.html#如何使用-mock-2-\b基于本地服务器反向代理",
|
||||
"content": "2 \b基于本地服务器反向代理优点:不用修改项目代码2.1 基于 nginx 反向代理location /baseapi{\nproxy_pass http://yapi.xxx.com/mock/2817/baseapi; #baseapi后面没有\"/\"\n}\n2.2 基于 ykit mock功能{ pattern: /\\/api\\/(.*)/,\n responder: 'http://yapi.xxx.com/mock/58/api/$1'\n}\n上面通过正则匹配,将所有接口转到 http://yapi.xxx.com 上,比如 http://localhost/api/user/status 会成为 http://yapi.xxx.com/mock/58/api/user/status详细使用指南: ykit-config-mock2.3 基于 ykit Jerry 代理假设您本地服务器访问地址是: http://xxx.com具体用法如下:清除本地配置的 hosts\n下载 Chrome 插件 SwitchyOmega 点击“选项” => 新建情景模式 设置代理服务器 127.0.0.1 代理端口 999\n启动 sudo ykit s -x 浏览器访问 http://127.0.0.1:1334/jerry\n在 jerry 中重新配置 hosts\n在 Jerry 中点击 URL MAP 并添加配置\n详细使用指南: 代理工具2.4 基于 Charles 代理点击 Charles 工具栏下的 tools >> Rewrite Settings 填写如下信息:"
|
||||
},
|
||||
{
|
||||
"title": "mock请求严格模式",
|
||||
"url": "/documents/mock.html#mock请求严格模式",
|
||||
"content": "mock请求严格模式版本 v1.3.22 新增 mock 接口请求字段参数验证功能,具体使用方法如下:\n打开 项目 -> 设置 开启 mock 严格模式\n\n\n针对 query form 中设置的必须字段会进行必填校验\n\n\n\n针对 req_body_type 是json schema 格式的数据进行校验\n\n"
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -501,6 +506,11 @@ window.ydoc_plugin_search_json = {
|
||||
"title": "2 \b基于本地服务器反向代理",
|
||||
"url": "/documents/mock.html#如何使用-mock-2-\b基于本地服务器反向代理",
|
||||
"content": "2 \b基于本地服务器反向代理优点:不用修改项目代码2.1 基于 nginx 反向代理location /baseapi{\nproxy_pass http://yapi.xxx.com/mock/2817/baseapi; #baseapi后面没有\"/\"\n}\n2.2 基于 ykit mock功能{ pattern: /\\/api\\/(.*)/,\n responder: 'http://yapi.xxx.com/mock/58/api/$1'\n}\n上面通过正则匹配,将所有接口转到 http://yapi.xxx.com 上,比如 http://localhost/api/user/status 会成为 http://yapi.xxx.com/mock/58/api/user/status详细使用指南: ykit-config-mock2.3 基于 ykit Jerry 代理假设您本地服务器访问地址是: http://xxx.com具体用法如下:清除本地配置的 hosts\n下载 Chrome 插件 SwitchyOmega 点击“选项” => 新建情景模式 设置代理服务器 127.0.0.1 代理端口 999\n启动 sudo ykit s -x 浏览器访问 http://127.0.0.1:1334/jerry\n在 jerry 中重新配置 hosts\n在 Jerry 中点击 URL MAP 并添加配置\n详细使用指南: 代理工具2.4 基于 Charles 代理点击 Charles 工具栏下的 tools >> Rewrite Settings 填写如下信息:"
|
||||
},
|
||||
{
|
||||
"title": "mock请求严格模式",
|
||||
"url": "/documents/mock.html#mock请求严格模式",
|
||||
"content": "mock请求严格模式版本 v1.3.22 新增 mock 接口请求字段参数验证功能,具体使用方法如下:\n打开 项目 -> 设置 开启 mock 严格模式\n\n\n针对 query form 中设置的必须字段会进行必填校验\n\n\n\n针对 req_body_type 是json schema 格式的数据进行校验\n\n"
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -1172,7 +1182,7 @@ window.ydoc_plugin_search_json = {
|
||||
{
|
||||
"title": "v1.3.22",
|
||||
"url": "/documents/CHANGELOG.html#v1.3.22",
|
||||
"content": "v1.3.22json schema number和integer支持枚举\n服务端测试增加下载功能\n"
|
||||
"content": "v1.3.22json schema number和integer支持枚举\n服务端测试增加下载功能\n增加 mock 接口请求字段参数验证\n增加返回数据验证\n"
|
||||
},
|
||||
{
|
||||
"title": "Bug Fixed",
|
||||
@ -1354,7 +1364,7 @@ window.ydoc_plugin_search_json = {
|
||||
{
|
||||
"title": "v1.3.22",
|
||||
"url": "/documents/CHANGELOG.html#v1.3.22",
|
||||
"content": "v1.3.22json schema number和integer支持枚举\n服务端测试增加下载功能\n"
|
||||
"content": "v1.3.22json schema number和integer支持枚举\n服务端测试增加下载功能\n增加 mock 接口请求字段参数验证\n增加返回数据验证\n"
|
||||
},
|
||||
{
|
||||
"title": "Bug Fixed",
|
||||
|
Loading…
Reference in New Issue
Block a user