Skip to content

Commit dae289b

Browse files
committed
Merge branch 'dev-1.3.0'
2 parents d80d2eb + a9338ab commit dae289b

124 files changed

Lines changed: 3478 additions & 2858 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
### v1.3.22
2+
3+
* json schema number和integer支持枚举
4+
* 服务端测试增加下载功能
5+
* 增加 mock 接口请求字段参数验证
6+
* 增加返回数据验证
7+
8+
### Bug Fixed
9+
10+
* 命令行导入成员信息为 undefined
11+
* 修复form 参数为空时 接口无法保存的问题
12+
113
### v1.3.21
214

315
* 请求配置增加 context.utils.CryptoJS

a.markdown

Lines changed: 0 additions & 60 deletions
This file was deleted.

client/components/AceEditor/AceEditor.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ class AceEditor extends React.PureComponent {
4242
readOnly: this.props.readOnly,
4343
fullScreen: this.props.fullScreen
4444
});
45-
4645
let mode = this.props.mode || 'javascript';
47-
4846
this.editor.editor.getSession().setMode(getMode(mode));
4947
if (typeof this.props.callback === 'function') {
5048
this.props.callback(this.editor.editor);

client/components/Header/Header.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,6 @@ const MenuUser = props => (
5555
</Menu.Item>
5656
);
5757
})}
58-
{/*<Menu.Item key="0">*/}
59-
{/*<Link to={`/user/profile/${props.uid}`} onClick={props.relieveLink}><Icon type="user"/>个人中心</Link>*/}
60-
{/*</Menu.Item>*/}
61-
{/*<Menu.Item key="1">*/}
62-
{/*<Link to={`/follow`} onClick={props.relieveLink}><Icon type="star-o"/>我的关注</Link>*/}
63-
{/*</Menu.Item>*/}
64-
{/*{*/}
65-
{/*props.role === "admin" ? <Menu.Item key="2">*/}
66-
{/*<Link to={`/user/list`}><Icon type="solution"/>用户管理</Link>*/}
67-
{/*</Menu.Item> : ""*/}
68-
{/*}*/}
69-
7058
<Menu.Item key="9">
7159
<a onClick={props.logout}>
7260
<Icon type="logout" />退出

client/components/Postman/Postman.js

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,20 @@ import {
1313
Tabs,
1414
Switch,
1515
Row,
16-
Col
16+
Col,
17+
Alert
1718
} from 'antd';
1819
import constants from '../../constants/variable.js';
1920
import AceEditor from 'client/components/AceEditor/AceEditor';
2021
import _ from 'underscore';
21-
import { isJson, deepCopyJson } from '../../common.js';
22+
import { isJson, deepCopyJson, json5_parse } from '../../common.js';
2223
import axios from 'axios';
2324
import ModalPostman from '../ModalPostman/index.js';
2425
import CheckCrossInstall, { initCrossRequest } from './CheckCrossInstall.js';
2526
import './Postman.scss';
2627
import ProjectEnv from '../../containers/Project/Setting/ProjectEnv/index.js';
2728
import json5 from 'json5';
28-
const { handleParamsValue, ArrayToObject } = require('common/utils.js');
29+
const { handleParamsValue, ArrayToObject, schemaValidator } = require('common/utils.js');
2930
const {
3031
handleParams,
3132
checkRequestBodyIsRaw,
@@ -116,6 +117,7 @@ export default class Run extends Component {
116117
this.state = {
117118
loading: false,
118119
resStatusCode: null,
120+
test_valid_msg: null,
119121
resStatusText: null,
120122
case_env: '',
121123
mock_verify: false,
@@ -208,6 +210,7 @@ export default class Run extends Component {
208210
...data,
209211
req_body_other: body,
210212
resStatusCode: null,
213+
test_valid_msg: null,
211214
resStatusText: null
212215
},
213216
() => this.props.type === 'inter' && this.initEnvState(data.case_env, data.env)
@@ -260,11 +263,9 @@ export default class Run extends Component {
260263
}
261264

262265
handleValue(val, global) {
263-
// console.log('val',val);
264-
// console.log('global',global);
265266
let globalValue = ArrayToObject(global);
266267
return handleParamsValue(val, {
267-
global:globalValue
268+
global: globalValue
268269
});
269270
}
270271

@@ -295,7 +296,6 @@ export default class Run extends Component {
295296
loading: true
296297
});
297298

298-
299299
let options = handleParams(this.state, this.handleValue),
300300
result;
301301

@@ -335,6 +335,15 @@ export default class Run extends Component {
335335
res_body_type: 'json'
336336
});
337337
}
338+
339+
// 对 返回值数据结构 和定义的 返回数据结构 进行 格式校验
340+
let validResult = this.resBodyValidator(this.props.data, result.body);
341+
if (!validResult.valid) {
342+
this.setState({ test_valid_msg: `返回参数 ${validResult.message}` });
343+
} else {
344+
this.setState({ test_valid_msg: '' });
345+
}
346+
338347
this.setState({
339348
resStatusCode: result.status,
340349
resStatusText: result.statusText,
@@ -343,6 +352,20 @@ export default class Run extends Component {
343352
});
344353
};
345354

355+
// 返回数据与定义数据的比较判断
356+
resBodyValidator = (interfaceData, test_res_body) => {
357+
const { res_body_type, res_body_is_json_schema, res_body } = interfaceData;
358+
let validResult = { valid: true };
359+
360+
if (res_body_type === 'json' && res_body_is_json_schema) {
361+
const schema = json5_parse(res_body);
362+
const params = json5_parse(test_res_body);
363+
validResult = schemaValidator(schema, params);
364+
}
365+
366+
return validResult;
367+
};
368+
346369
changeParam = (name, v, index, key) => {
347370
key = key || 'value';
348371
const pathParam = deepCopyJson(this.state[name]);
@@ -848,6 +871,21 @@ export default class Run extends Component {
848871
>
849872
{this.state.resStatusCode + ' ' + this.state.resStatusText}
850873
</h2>
874+
{this.state.test_valid_msg && (
875+
<Alert
876+
message={
877+
<span>
878+
Warning &nbsp;
879+
<Tooltip title="针对定义为 json schema 的返回数据进行格式校验">
880+
<Icon type="question-circle-o" />
881+
</Tooltip>
882+
</span>
883+
}
884+
type="warning"
885+
showIcon
886+
description={this.state.test_valid_msg}
887+
/>
888+
)}
851889

852890
<div className="container-header-body">
853891
<div className="header">
@@ -861,7 +899,7 @@ export default class Run extends Component {
861899
readOnly={true}
862900
className="pretty-editor-header"
863901
data={this.state.test_res_header}
864-
mode="json"
902+
mode="json"
865903
/>
866904
</div>
867905
<div className="resizer">

client/components/TimeLine/TimeLine.js

Lines changed: 9 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,18 @@ const formattersHtml = jsondiffpatch.formatters.html;
1414
import 'jsondiffpatch/dist/formatters-styles/annotated.css';
1515
import 'jsondiffpatch/dist/formatters-styles/html.css';
1616
import './TimeLine.scss';
17+
import { timeago } from '../../../common/utils.js';
1718

1819
// const Option = AutoComplete.Option;
19-
const {Option, OptGroup} = AutoComplete;
20+
const { Option, OptGroup } = AutoComplete;
2021

2122
const AddDiffView = props => {
2223
const { title, content, className } = props;
23-
24+
2425
if (!content) {
2526
return null;
2627
}
27-
28+
2829
return (
2930
<div className={className}>
3031
<h3 className="title">{title}</h3>
@@ -39,51 +40,6 @@ AddDiffView.propTypes = {
3940
className: PropTypes.string
4041
};
4142

42-
function timeago(timestamp) {
43-
let minutes, hours, days, seconds, mouth, year;
44-
const timeNow = parseInt(new Date().getTime() / 1000);
45-
seconds = timeNow - timestamp;
46-
if (seconds > 86400 * 30 * 12) {
47-
year = parseInt(seconds / (86400 * 30 * 12));
48-
} else {
49-
year = 0;
50-
}
51-
if (seconds > 86400 * 30) {
52-
mouth = parseInt(seconds / (86400 * 30));
53-
} else {
54-
mouth = 0;
55-
}
56-
if (seconds > 86400) {
57-
days = parseInt(seconds / 86400);
58-
} else {
59-
days = 0;
60-
}
61-
if (seconds > 3600) {
62-
hours = parseInt(seconds / 3600);
63-
} else {
64-
hours = 0;
65-
}
66-
minutes = parseInt(seconds / 60);
67-
if (year > 0) {
68-
return year + '年前';
69-
} else if (mouth > 0 && year <= 0) {
70-
return mouth + '月前';
71-
} else if (days > 0 && mouth <= 0) {
72-
return days + '天前';
73-
} else if (days <= 0 && hours > 0) {
74-
return hours + '小时前';
75-
} else if (hours <= 0 && minutes > 0) {
76-
return minutes + '分钟前';
77-
} else if (minutes <= 0 && seconds > 0) {
78-
if (seconds < 30) {
79-
return '刚刚';
80-
} else {
81-
return seconds + '秒前';
82-
}
83-
} else {
84-
return '刚刚';
85-
}
86-
}
8743
// timeago(new Date().getTime() - 40);
8844

8945
@connect(
@@ -260,8 +216,7 @@ class TimeTree extends Component {
260216
pending = <Spin />;
261217
}
262218
let diffView = showDiffMsg(jsondiffpatch, formattersHtml, curDiffData);
263-
264-
219+
265220
return (
266221
<section className="news-timeline">
267222
<Modal
@@ -308,12 +263,11 @@ class TimeTree extends Component {
308263
>
309264
{/* {children} */}
310265
<OptGroup label="other">
311-
<Option value="wiki" path="" title="wiki">wiki</Option>
312-
</OptGroup>
313-
<OptGroup label="api">
314-
{children}
266+
<Option value="wiki" path="" title="wiki">
267+
wiki
268+
</Option>
315269
</OptGroup>
316-
270+
<OptGroup label="api">{children}</OptGroup>
317271
</AutoComplete>
318272
</Col>
319273
</Row>

client/containers/AddProject/AddProject.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ class ProjectList extends Component {
169169
rules: [
170170
{
171171
required: false,
172-
message: '描述不超过50字!',
173-
max: 50
172+
message: '描述不超过144字!',
173+
max: 144
174174
}
175175
]
176176
})(<TextArea rows={4} />)}

0 commit comments

Comments
 (0)