mirror of
https://github.com/YMFE/yapi.git
synced 2024-12-15 05:10:47 +08:00
Merge branch 'dev' of http://gitlab.corp.qunar.com/mfe/yapi into dev
This commit is contained in:
commit
6ff9185fda
@ -72,7 +72,7 @@ export default class Run extends Component {
|
||||
validRes: [],
|
||||
hasPlugin: true,
|
||||
test_status: null,
|
||||
resTest: true,
|
||||
resMockTest: true,
|
||||
resStatusCode: null,
|
||||
resStatusText: ''
|
||||
}
|
||||
@ -138,7 +138,8 @@ export default class Run extends Component {
|
||||
test_status = '',
|
||||
test_res_body = '',
|
||||
test_report = [],
|
||||
test_res_header = ''
|
||||
test_res_header = '',
|
||||
mock_verify = true
|
||||
} = data;
|
||||
|
||||
// case 任意编辑 pathname,不管项目的 basepath
|
||||
@ -175,7 +176,8 @@ export default class Run extends Component {
|
||||
test_status: test_status,
|
||||
validRes: test_report,
|
||||
res: test_res_body,
|
||||
resHeader: test_res_header
|
||||
resHeader: test_res_header,
|
||||
resMockTest: mock_verify
|
||||
}, () => {
|
||||
if (req_body_type && req_body_type !== 'file' && req_body_type !== 'form') {
|
||||
this.loadBodyEditor()
|
||||
@ -218,7 +220,7 @@ export default class Run extends Component {
|
||||
files: bodyType === 'form' ? this.getFiles(bodyForm) : {},
|
||||
file: bodyType === 'file' ? 'single-file' : null,
|
||||
success: (res, header, third) => {
|
||||
console.log('suc',third);
|
||||
console.log('suc', third);
|
||||
this.setState({
|
||||
resStatusCode: third.res.status,
|
||||
resStatusText: third.res.statusText
|
||||
@ -268,7 +270,7 @@ export default class Run extends Component {
|
||||
}
|
||||
},
|
||||
error: (err, header, third) => {
|
||||
console.log('err',third);
|
||||
console.log('err', third);
|
||||
this.setState({
|
||||
resStatusCode: third.res.status,
|
||||
resStatusText: third.res.statusText
|
||||
@ -480,6 +482,8 @@ export default class Run extends Component {
|
||||
readOnly: true,
|
||||
onChange: function () { }
|
||||
})
|
||||
|
||||
|
||||
mockEditor({
|
||||
container: 'res-headers-pretty',
|
||||
data: this.state.resHeader,
|
||||
@ -512,7 +516,7 @@ export default class Run extends Component {
|
||||
@autobind
|
||||
onTestSwitched(checked) {
|
||||
this.setState({
|
||||
resTest: checked
|
||||
resMockTest: checked
|
||||
});
|
||||
}
|
||||
|
||||
@ -537,7 +541,7 @@ export default class Run extends Component {
|
||||
|
||||
return (
|
||||
<div className="interface-test postman">
|
||||
<div className={ hasPlugin? null : 'has-plugin' } >
|
||||
<div className={hasPlugin ? null : 'has-plugin'} >
|
||||
{hasPlugin ? '' : <Alert
|
||||
message={
|
||||
<div>
|
||||
@ -742,58 +746,42 @@ export default class Run extends Component {
|
||||
</Collapse>
|
||||
|
||||
<h2 className="interface-title">返回结果</h2>
|
||||
{this.state.resStatusCode ?
|
||||
<Spin spinning={this.state.loading}>
|
||||
<h2 className={'res-code ' + ((this.state.resStatusCode >= 200 && this.state.resStatusCode < 400 && !this.state.loading) ? 'success' : 'fail')}>{this.state.resStatusCode + ' ' + this.state.resStatusText}</h2>
|
||||
|
||||
<div className="container-header-body">
|
||||
<div className="header">
|
||||
<div className="container-title">
|
||||
<h4>Headers</h4>
|
||||
</div>
|
||||
<div id="res-headers-pretty" className="pretty-editor-header"></div>
|
||||
<Spin spinning={this.state.loading}>
|
||||
<h2 style={{ display: this.state.resStatusCode !== null ? '' : 'none' }} className={'res-code ' + ((this.state.resStatusCode >= 200 && this.state.resStatusCode < 400 && !this.state.loading) ? 'success' : 'fail')}>{this.state.resStatusCode + ' ' + this.state.resStatusText}</h2>
|
||||
|
||||
<div style={{ display: this.state.res ? '' : 'none' }} className="container-header-body">
|
||||
<div className="header">
|
||||
<div className="container-title">
|
||||
<h4>Headers</h4>
|
||||
</div>
|
||||
<div className="resizer">
|
||||
<div className="container-title">
|
||||
<h4 style={{visibility: 'hidden'}}>1</h4>
|
||||
</div>
|
||||
</div>
|
||||
<div className="body">
|
||||
<div className="container-title">
|
||||
<h4>Body</h4>
|
||||
</div>
|
||||
<div id="res-body-pretty" className="pretty-editor-body" style={{ display: isResJson ? '' : 'none' }}></div>
|
||||
<div
|
||||
style={{display: isResJson ? 'none' : ''}}
|
||||
className="res-body-text"
|
||||
>{this.state.res && this.state.res.toString()}</div>
|
||||
<div id="res-headers-pretty" className="pretty-editor-header"></div>
|
||||
</div>
|
||||
<div className="resizer">
|
||||
<div className="container-title">
|
||||
<h4 style={{ visibility: 'hidden' }}>1</h4>
|
||||
</div>
|
||||
</div>
|
||||
</Spin> : <p>发送请求后在这里查看返回结果。</p>}
|
||||
|
||||
{/*<Collapse defaultActiveKey={['0', '1']} bordered={true}>
|
||||
<Panel header="BODY" key="0" >
|
||||
<div id="res-body-pretty" className="pretty-editor-body" style={{ display: isResJson ? '' : 'none' }}></div>*/}
|
||||
{/*<TextArea
|
||||
<div className="body">
|
||||
<div className="container-title">
|
||||
<h4>Body</h4>
|
||||
</div>
|
||||
<div id="res-body-pretty" className="pretty-editor-body" style={{ display: isResJson ? '' : 'none' }}></div>
|
||||
<div
|
||||
style={{ display: isResJson ? 'none' : '' }}
|
||||
value={this.state.res && this.state.res.toString()}
|
||||
autosize={{ minRows: 10, maxRows: 20 }}
|
||||
></TextArea>*/}
|
||||
{/*</Panel>
|
||||
<Panel header="HEADERS" key="1" >*/}
|
||||
{/*<TextArea
|
||||
value={typeof this.state.resHeader === 'object' ? JSON.stringify(this.state.resHeader, null, 2) : this.state.resHeader.toString()}
|
||||
autosize={{ minRows: 2, maxRows: 10 }}
|
||||
></TextArea>*/}
|
||||
{/*<div id="res-headers-pretty" className="pretty-editor-header"></div>
|
||||
</Panel>
|
||||
</Collapse>*/}
|
||||
className="res-body-text"
|
||||
>{this.state.res && this.state.res.toString()}</div>
|
||||
</div>
|
||||
</div>
|
||||
</Spin>
|
||||
|
||||
<p style={{ display: this.state.resStatusCode===null ? '' : 'none' }}>发送请求后在这里查看返回结果。</p>
|
||||
|
||||
<h2 className="interface-title">数据结构验证
|
||||
<Switch style={{verticalAlign: 'text-bottom', marginLeft: '8px'}} checked={this.state.resTest} onChange={this.onTestSwitched} />
|
||||
<Switch style={{ verticalAlign: 'text-bottom', marginLeft: '8px' }} checked={this.state.resMockTest} onChange={this.onTestSwitched} />
|
||||
</h2>
|
||||
<div className={(isResJson && this.state.resTest) ? '' : 'none' }>
|
||||
{(isResJson && this.state.resTest) ? validResView : <div><p>若开启此功能,则发送请求后在这里查看验证结果。</p><p>数据结构验证在接口编辑页面配置,YApi 将根据 Response body 验证请求返回的结果。</p></div>}
|
||||
<div className={(isResJson && this.state.resMockTest) ? '' : 'none'}>
|
||||
{(isResJson && this.state.resMockTest) ? validResView : <div><p>若开启此功能,则发送请求后在这里查看验证结果。</p><p>数据结构验证在接口编辑页面配置,YApi 将根据 Response body 验证请求返回的结果。</p></div>}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
@ -106,7 +106,8 @@ export default class InterfaceCaseContent extends Component {
|
||||
headers: req_headers,
|
||||
bodyType: req_body_type,
|
||||
bodyForm: req_body_form,
|
||||
bodyOther: req_body_other
|
||||
bodyOther: req_body_other,
|
||||
resMockTest: mock_verify
|
||||
} = this.postman.state;
|
||||
|
||||
const {editCasename: casename} = this.state;
|
||||
@ -122,7 +123,8 @@ export default class InterfaceCaseContent extends Component {
|
||||
req_headers,
|
||||
req_body_type,
|
||||
req_body_form,
|
||||
req_body_other
|
||||
req_body_other,
|
||||
mock_verify
|
||||
};
|
||||
if(this.postman.state.test_status !== 'error'){
|
||||
params.test_res_body = this.postman.state.res;
|
||||
|
@ -185,8 +185,11 @@ class InterfaceColContent extends Component {
|
||||
query: interfaceData.req_query,
|
||||
body: interfaceData.req_body_form
|
||||
})
|
||||
let validRes = Mock.valid(tpl, res);
|
||||
|
||||
let validRes = [];
|
||||
if(interfaceData.mock_verify){
|
||||
validRes = Mock.valid(tpl, res);
|
||||
}
|
||||
if (validRes.length === 0) {
|
||||
result.code = 0;
|
||||
result.validRes = [{ message: '验证通过' }];
|
||||
|
@ -57,7 +57,9 @@ export default class Run extends Component {
|
||||
headers: req_headers,
|
||||
bodyType: req_body_type,
|
||||
bodyForm: req_body_form,
|
||||
bodyOther: req_body_other
|
||||
bodyOther: req_body_other,
|
||||
resMockTest: mock_verify
|
||||
|
||||
} = this.postman.state;
|
||||
|
||||
let params = {
|
||||
@ -73,7 +75,8 @@ export default class Run extends Component {
|
||||
req_headers,
|
||||
req_body_type,
|
||||
req_body_form,
|
||||
req_body_other
|
||||
req_body_other,
|
||||
mock_verify
|
||||
};
|
||||
|
||||
if(this.postman.state.test_status !== 'error'){
|
||||
|
@ -263,7 +263,7 @@ class View extends Component {
|
||||
title: '参数值',
|
||||
dataIndex: 'value',
|
||||
key: 'value',
|
||||
width: '100px'
|
||||
width: '300px'
|
||||
}, {
|
||||
title: '是否必须',
|
||||
dataIndex: 'required',
|
||||
|
@ -1 +1 @@
|
||||
module.exports = {}
|
||||
module.exports = {qsso : require('plugins/yapi-plugin-qsso/client.js')}
|
@ -70,22 +70,17 @@ class groupController extends baseController {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '项目分组名不能为空');
|
||||
}
|
||||
|
||||
if (!params.owner_uids || !params.owner_uids.length) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '项目分组必须添加一个组长');
|
||||
}
|
||||
|
||||
let owners = [];
|
||||
for(let i = 0, len = params.owner_uids.length; i < len; i++) {
|
||||
let id = params.owner_uids[i]
|
||||
let groupUserdata = await this.getUserdata(id, 'owner');
|
||||
if (groupUserdata) {
|
||||
owners.push(groupUserdata)
|
||||
if(params.owner_uids){
|
||||
for(let i = 0, len = params.owner_uids.length; i < len; i++) {
|
||||
let id = params.owner_uids[i]
|
||||
let groupUserdata = await this.getUserdata(id, 'owner');
|
||||
if (groupUserdata) {
|
||||
owners.push(groupUserdata)
|
||||
}
|
||||
}
|
||||
}
|
||||
// groupUserdata = await this.getUserdata(params.owner_uid, 'owner');
|
||||
// if (!owners.length) {
|
||||
// return ctx.body = yapi.commons.resReturn(null, 400, '组长uid不存在')
|
||||
// }
|
||||
|
||||
|
||||
let groupInst = yapi.getInst(groupModel);
|
||||
|
||||
|
@ -33,7 +33,8 @@ class interfaceCase extends baseModel {
|
||||
test_res_body: String,
|
||||
test_status: {type: String, enum: ['ok', 'invalid', 'error', '']},
|
||||
test_report: [],
|
||||
test_res_header: Schema.Types.Mixed
|
||||
test_res_header: Schema.Types.Mixed,
|
||||
mock_verify: {type: Boolean, default: true}
|
||||
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user