fix(接口测试): 文档结构根保护处理防止解析错误

--bug=1009952 --user=赵勇 【接口测试】文档结构断言-跟随api定义,接口响应格式错误时会报错 https://www.tapd.cn/55049933/s/1098029
This commit is contained in:
fit2-zhao 2022-01-25 13:59:57 +08:00 committed by 刘瑞斌
parent a3c6f213b6
commit d3b810c062
2 changed files with 340 additions and 329 deletions

View File

@ -17,11 +17,11 @@
</el-col>
<el-col :span="4">
<el-select v-model="pickValue.type" :disabled="disabledType" class="ms-col-type" @change="onChangeType" size="small">
<el-option :key="t" :value="t" :label="t" v-for="t in TYPE_NAME"/>
<el-option :key="t" :value="t" :label="t" v-for="t in types"/>
</el-select>
</el-col>
<el-col :span="4">
<ms-mock :disabled="pickValue.type==='object' || pickValue.type==='array' || pickValue.type==='null'" :schema="pickValue"/>
<ms-mock :disabled="pickKey ==='root' || pickValue.type==='object' || pickValue.type==='array' || pickValue.type==='null'" :schema="pickValue"/>
</el-col>
<el-col :span="4">
<el-input v-model="pickValue.description" class="ms-col-title" :placeholder="$t('schema.description')" size="small"/>
@ -84,7 +84,7 @@
</template>
<script>
import {isNull} from './util'
import {TYPE_NAME, TYPE} from './type/type'
import {TYPE_NAME, TYPE, TYPES} from './type/type'
import MsMock from './mock/MockComplete'
import MsDialogFooter from '../../../components/MsDialogFooter'
import {getUUID} from "@/common/js/utils";
@ -149,6 +149,9 @@
advanced() {
return TYPE[this.pickValue.type]
},
types(){
return TYPES(this.pickKey);
},
advancedAttr() {
return TYPE[this.pickValue.type].attr
},
@ -169,7 +172,6 @@
},
data() {
return {
TYPE_NAME,
hidden: false,
countAdd: 1,
modalVisible: false,

View File

@ -4,6 +4,8 @@ import _array from './array'
import _boolean from './boolean'
import _integer from './integer'
import _number from './number'
import {LicenseKey} from "@/common/js/constants";
const TYPE_NAME = ['string', 'number', 'integer', 'object', 'array', 'boolean']
const TYPE = {
@ -15,3 +17,10 @@ const TYPE = {
'number': _number
}
export {TYPE, TYPE_NAME}
export function TYPES(key) {
if (key && key === 'root') {
return ['object', 'array'];
}
return TYPE_NAME;
}