Skip to content

Commit

Permalink
Merge branch 'dev-1.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
gaoxiaomumu committed Aug 9, 2018
2 parents d80d2eb + a9338ab commit dae289b
Show file tree
Hide file tree
Showing 124 changed files with 3,478 additions and 2,858 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
### v1.3.22

* json schema number和integer支持枚举
* 服务端测试增加下载功能
* 增加 mock 接口请求字段参数验证
* 增加返回数据验证

### Bug Fixed

* 命令行导入成员信息为 undefined
* 修复form 参数为空时 接口无法保存的问题

### v1.3.21

* 请求配置增加 context.utils.CryptoJS
Expand Down
60 changes: 0 additions & 60 deletions a.markdown

This file was deleted.

2 changes: 0 additions & 2 deletions client/components/AceEditor/AceEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ class AceEditor extends React.PureComponent {
readOnly: this.props.readOnly,
fullScreen: this.props.fullScreen
});

let mode = this.props.mode || 'javascript';

this.editor.editor.getSession().setMode(getMode(mode));
if (typeof this.props.callback === 'function') {
this.props.callback(this.editor.editor);
Expand Down
12 changes: 0 additions & 12 deletions client/components/Header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,6 @@ const MenuUser = props => (
</Menu.Item>
);
})}
{/*<Menu.Item key="0">*/}
{/*<Link to={`/user/profile/${props.uid}`} onClick={props.relieveLink}><Icon type="user"/>个人中心</Link>*/}
{/*</Menu.Item>*/}
{/*<Menu.Item key="1">*/}
{/*<Link to={`/follow`} onClick={props.relieveLink}><Icon type="star-o"/>我的关注</Link>*/}
{/*</Menu.Item>*/}
{/*{*/}
{/*props.role === "admin" ? <Menu.Item key="2">*/}
{/*<Link to={`/user/list`}><Icon type="solution"/>用户管理</Link>*/}
{/*</Menu.Item> : ""*/}
{/*}*/}

<Menu.Item key="9">
<a onClick={props.logout}>
<Icon type="logout" />退出
Expand Down
54 changes: 46 additions & 8 deletions client/components/Postman/Postman.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ import {
Tabs,
Switch,
Row,
Col
Col,
Alert
} from 'antd';
import constants from '../../constants/variable.js';
import AceEditor from 'client/components/AceEditor/AceEditor';
import _ from 'underscore';
import { isJson, deepCopyJson } from '../../common.js';
import { isJson, deepCopyJson, json5_parse } from '../../common.js';
import axios from 'axios';
import ModalPostman from '../ModalPostman/index.js';
import CheckCrossInstall, { initCrossRequest } from './CheckCrossInstall.js';
import './Postman.scss';
import ProjectEnv from '../../containers/Project/Setting/ProjectEnv/index.js';
import json5 from 'json5';
const { handleParamsValue, ArrayToObject } = require('common/utils.js');
const { handleParamsValue, ArrayToObject, schemaValidator } = require('common/utils.js');
const {
handleParams,
checkRequestBodyIsRaw,
Expand Down Expand Up @@ -116,6 +117,7 @@ export default class Run extends Component {
this.state = {
loading: false,
resStatusCode: null,
test_valid_msg: null,
resStatusText: null,
case_env: '',
mock_verify: false,
Expand Down Expand Up @@ -208,6 +210,7 @@ export default class Run extends Component {
...data,
req_body_other: body,
resStatusCode: null,
test_valid_msg: null,
resStatusText: null
},
() => this.props.type === 'inter' && this.initEnvState(data.case_env, data.env)
Expand Down Expand Up @@ -260,11 +263,9 @@ export default class Run extends Component {
}

handleValue(val, global) {
// console.log('val',val);
// console.log('global',global);
let globalValue = ArrayToObject(global);
return handleParamsValue(val, {
global:globalValue
global: globalValue
});
}

Expand Down Expand Up @@ -295,7 +296,6 @@ export default class Run extends Component {
loading: true
});


let options = handleParams(this.state, this.handleValue),
result;

Expand Down Expand Up @@ -335,6 +335,15 @@ export default class Run extends Component {
res_body_type: 'json'
});
}

// 对 返回值数据结构 和定义的 返回数据结构 进行 格式校验
let validResult = this.resBodyValidator(this.props.data, result.body);
if (!validResult.valid) {
this.setState({ test_valid_msg: `返回参数 ${validResult.message}` });
} else {
this.setState({ test_valid_msg: '' });
}

this.setState({
resStatusCode: result.status,
resStatusText: result.statusText,
Expand All @@ -343,6 +352,20 @@ export default class Run extends Component {
});
};

// 返回数据与定义数据的比较判断
resBodyValidator = (interfaceData, test_res_body) => {
const { res_body_type, res_body_is_json_schema, res_body } = interfaceData;
let validResult = { valid: true };

if (res_body_type === 'json' && res_body_is_json_schema) {
const schema = json5_parse(res_body);
const params = json5_parse(test_res_body);
validResult = schemaValidator(schema, params);
}

return validResult;
};

changeParam = (name, v, index, key) => {
key = key || 'value';
const pathParam = deepCopyJson(this.state[name]);
Expand Down Expand Up @@ -848,6 +871,21 @@ export default class Run extends Component {
>
{this.state.resStatusCode + ' ' + this.state.resStatusText}
</h2>
{this.state.test_valid_msg && (
<Alert
message={
<span>
Warning &nbsp;
<Tooltip title="针对定义为 json schema 的返回数据进行格式校验">
<Icon type="question-circle-o" />
</Tooltip>
</span>
}
type="warning"
showIcon
description={this.state.test_valid_msg}
/>
)}

<div className="container-header-body">
<div className="header">
Expand All @@ -861,7 +899,7 @@ export default class Run extends Component {
readOnly={true}
className="pretty-editor-header"
data={this.state.test_res_header}
mode="json"
mode="json"
/>
</div>
<div className="resizer">
Expand Down
64 changes: 9 additions & 55 deletions client/components/TimeLine/TimeLine.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@ const formattersHtml = jsondiffpatch.formatters.html;
import 'jsondiffpatch/dist/formatters-styles/annotated.css';
import 'jsondiffpatch/dist/formatters-styles/html.css';
import './TimeLine.scss';
import { timeago } from '../../../common/utils.js';

// const Option = AutoComplete.Option;
const {Option, OptGroup} = AutoComplete;
const { Option, OptGroup } = AutoComplete;

const AddDiffView = props => {
const { title, content, className } = props;

if (!content) {
return null;
}

return (
<div className={className}>
<h3 className="title">{title}</h3>
Expand All @@ -39,51 +40,6 @@ AddDiffView.propTypes = {
className: PropTypes.string
};

function timeago(timestamp) {
let minutes, hours, days, seconds, mouth, year;
const timeNow = parseInt(new Date().getTime() / 1000);
seconds = timeNow - timestamp;
if (seconds > 86400 * 30 * 12) {
year = parseInt(seconds / (86400 * 30 * 12));
} else {
year = 0;
}
if (seconds > 86400 * 30) {
mouth = parseInt(seconds / (86400 * 30));
} else {
mouth = 0;
}
if (seconds > 86400) {
days = parseInt(seconds / 86400);
} else {
days = 0;
}
if (seconds > 3600) {
hours = parseInt(seconds / 3600);
} else {
hours = 0;
}
minutes = parseInt(seconds / 60);
if (year > 0) {
return year + '年前';
} else if (mouth > 0 && year <= 0) {
return mouth + '月前';
} else if (days > 0 && mouth <= 0) {
return days + '天前';
} else if (days <= 0 && hours > 0) {
return hours + '小时前';
} else if (hours <= 0 && minutes > 0) {
return minutes + '分钟前';
} else if (minutes <= 0 && seconds > 0) {
if (seconds < 30) {
return '刚刚';
} else {
return seconds + '秒前';
}
} else {
return '刚刚';
}
}
// timeago(new Date().getTime() - 40);

@connect(
Expand Down Expand Up @@ -260,8 +216,7 @@ class TimeTree extends Component {
pending = <Spin />;
}
let diffView = showDiffMsg(jsondiffpatch, formattersHtml, curDiffData);



return (
<section className="news-timeline">
<Modal
Expand Down Expand Up @@ -308,12 +263,11 @@ class TimeTree extends Component {
>
{/* {children} */}
<OptGroup label="other">
<Option value="wiki" path="" title="wiki">wiki</Option>
</OptGroup>
<OptGroup label="api">
{children}
<Option value="wiki" path="" title="wiki">
wiki
</Option>
</OptGroup>

<OptGroup label="api">{children}</OptGroup>
</AutoComplete>
</Col>
</Row>
Expand Down
4 changes: 2 additions & 2 deletions client/containers/AddProject/AddProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ class ProjectList extends Component {
rules: [
{
required: false,
message: '描述不超过50字!',
max: 50
message: '描述不超过144字!',
max: 144
}
]
})(<TextArea rows={4} />)}
Expand Down
Loading

0 comments on commit dae289b

Please sign in to comment.