feat(接口定义): 参数格式优化

--story=1002976 --user=赵勇 4. #4372  请求头、QU... https://www.tapd.cn/55049933/s/1044789
This commit is contained in:
wxg0103 2021-09-08 14:42:36 +08:00 committed by fit2-zhao
parent a6f916702c
commit 11cfa97f17
3 changed files with 226 additions and 210 deletions

View File

@ -83,24 +83,23 @@
</template>
<script>
import MsApiKeyValue from "../../ApiKeyValue";
import MsApiBody from "../../body/ApiBody";
import MsApiAuthConfig from "../../auth/ApiAuthConfig";
import ApiRequestMethodSelect from "../../collapse/ApiRequestMethodSelect";
import {REQUEST_HEADERS} from "@/common/js/constants";
import MsApiVariable from "../../ApiVariable";
import MsApiAssertions from "../../assertion/ApiAssertions";
import MsApiExtract from "../../extract/ApiExtract";
import {Body, KeyValue} from "../../../model/ApiTestModel";
import {hasLicense, getUUID} from "@/common/js/utils";
import BatchAddParameter from "../../basis/BatchAddParameter";
import MsApiAdvancedConfig from "./ApiAdvancedConfig";
import MsJsr233Processor from "../../../../automation/scenario/component/Jsr233Processor";
import ApiDefinitionStepButton from "../components/ApiDefinitionStepButton";
import {hasPermission} from '@/common/js/utils';
import Convert from "@/business/components/common/json-schema/convert/convert";
export default {
import MsApiKeyValue from "../../ApiKeyValue";
import MsApiBody from "../../body/ApiBody";
import MsApiAuthConfig from "../../auth/ApiAuthConfig";
import ApiRequestMethodSelect from "../../collapse/ApiRequestMethodSelect";
import {REQUEST_HEADERS} from "@/common/js/constants";
import MsApiVariable from "../../ApiVariable";
import MsApiAssertions from "../../assertion/ApiAssertions";
import MsApiExtract from "../../extract/ApiExtract";
import {Body, KeyValue} from "../../../model/ApiTestModel";
import {hasLicense, getUUID} from "@/common/js/utils";
import BatchAddParameter from "../../basis/BatchAddParameter";
import MsApiAdvancedConfig from "./ApiAdvancedConfig";
import MsJsr233Processor from "../../../../automation/scenario/component/Jsr233Processor";
import ApiDefinitionStepButton from "../components/ApiDefinitionStepButton";
import {hasPermission} from '@/common/js/utils';
import Convert from "@/business/components/common/json-schema/convert/convert";
export default {
name: "MsApiHttpRequestForm",
components: {
ApiDefinitionStepButton,
@ -141,7 +140,6 @@ export default {
},
type: String,
},
data() {
let validateURL = (rule, value, callback) => {
try {
@ -171,7 +169,6 @@ export default {
dialogVisible: false
}
},
created() {
if (!this.referenced && this.showScript) {
this.spanCount = 21;
@ -180,7 +177,6 @@ export default {
}
this.init();
},
methods: {
hasPermission,
hasLicense,
@ -221,7 +217,6 @@ export default {
})
},
init() {
if (!this.request.body) {
this.request.body = new Body();
}
@ -245,28 +240,52 @@ export default {
batchAdd() {
this.$refs.batchAddParameter.open();
},
format(array, obj) {
if (array) {
let isAdd = true;
for (let i in array) {
let item = array[i];
if (item.name === obj.name) {
item.value = obj.value;
isAdd = false;
}
}
if (isAdd) {
this.request.arguments.unshift(obj);
}
}
},
batchSave(data) {
if (data) {
let params = data.split("\n");
let keyValues = [];
params.forEach(item => {
let line = item.split(/|,/);
let line = item.split(/|:/);
let required = false;
if (line[1] === '必填' || line[1] === 'Required' || line[1] === 'true') {
required = true;
}
keyValues.push(new KeyValue({name: line[0], required: required, value: line[2], description: line[3], type: "text", valid: false, file: false, encode: true, enable: true, contentType: "text/plain"}));
keyValues.unshift(new KeyValue({
name: line[0],
required: required,
value: line[1],
description: line[2],
type: "text",
valid: false,
file: false,
encode: true,
enable: true,
contentType: "text/plain"
}));
})
keyValues.forEach(item => {
switch (this.activeName) {
case "parameters":
this.request.arguments.unshift(item);
this.format(this.request.arguments,item);
break;
case "rest":
this.request.rest.unshift(item);
this.format(this.request.rest,item);
break;
case "headers":
this.request.headers.unshift(item);
this.format(this.request.headers,item);
break;
default:
break;
@ -274,33 +293,30 @@ export default {
})
}
}
}
}
}
</script>
<style scoped>
.ms-query {
.ms-query {
background: #783887;
color: white;
height: 18px;
border-radius: 42%;
}
.ms-header {
}
.ms-header {
background: #783887;
color: white;
height: 18px;
border-radius: 42%;
}
.request-tabs {
}
.request-tabs {
margin: 20px;
min-height: 200px;
}
.ms-el-link {
}
.ms-el-link {
float: right;
margin-right: 45px;
}
}
</style>

View File

@ -757,7 +757,7 @@ export default {
export_config: "导出",
enable_validate_tip: "没有可用请求",
copy: "复制测试",
batch_add_parameter: "格式:参数名,必填,参数值,备注 <br/> 如Accept-Encoding,必填,utf-8,编码",
batch_add_parameter: "格式:参数名:必填:参数值:备注 <br/> 如Accept-Encoding:必填:utf-8:编码",
jar_config: {
title: "jar包管理",
jar_file: "jar包",

View File

@ -757,7 +757,7 @@ export default {
export_config: "導出",
enable_validate_tip: "沒有可用請求",
copy: "復制測試",
batch_add_parameter: "格式:參數名,必填,參數值,備註 <br/> 如Accept-Encoding,必填,utf-8,編碼",
batch_add_parameter: "格式:參數名:必填:參數值:備註 <br/> 如Accept-Encoding:必填:utf-8:編碼",
jar_config: {
title: "jar包管理",
jar_file: "jar包",