fix接口定义_请求体为form-data_的json参数的可以增加参数--story=1003216 --user=王孝刚 请求体为form-data 的json参数的可以增加参数说明填写 https://www.tapd.cn/55049933/s/1051283
This commit is contained in:
parent
ac546e04c1
commit
7f0bd60858
|
@ -24,6 +24,7 @@
|
||||||
@change="typeChange(item)">
|
@change="typeChange(item)">
|
||||||
<el-option value="text"/>
|
<el-option value="text"/>
|
||||||
<el-option value="file"/>
|
<el-option value="file"/>
|
||||||
|
<el-option value="json"/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</template>
|
</template>
|
||||||
</el-input>
|
</el-input>
|
||||||
|
@ -90,6 +91,7 @@
|
||||||
<ms-api-variable-advance ref="variableAdvance" :environment="environment" :scenario="scenario"
|
<ms-api-variable-advance ref="variableAdvance" :environment="environment" :scenario="scenario"
|
||||||
:parameters="parameters"
|
:parameters="parameters"
|
||||||
:current-item="currentItem"/>
|
:current-item="currentItem"/>
|
||||||
|
<ms-api-variable-json ref="variableJson" @callback="callback"/>
|
||||||
|
|
||||||
<api-variable-setting
|
<api-variable-setting
|
||||||
ref="apiVariableSetting"/>
|
ref="apiVariableSetting"/>
|
||||||
|
@ -101,6 +103,7 @@
|
||||||
import {KeyValue, Scenario} from "../model/ApiTestModel";
|
import {KeyValue, Scenario} from "../model/ApiTestModel";
|
||||||
import {JMETER_FUNC, MOCKJS_FUNC} from "@/common/js/constants";
|
import {JMETER_FUNC, MOCKJS_FUNC} from "@/common/js/constants";
|
||||||
import MsApiVariableAdvance from "./ApiVariableAdvance";
|
import MsApiVariableAdvance from "./ApiVariableAdvance";
|
||||||
|
import MsApiVariableJson from "./ApiVariableJson";
|
||||||
import MsApiBodyFileUpload from "./body/ApiBodyFileUpload";
|
import MsApiBodyFileUpload from "./body/ApiBodyFileUpload";
|
||||||
import {REQUIRED} from "../model/JsonData";
|
import {REQUIRED} from "../model/JsonData";
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
|
@ -108,7 +111,7 @@
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "MsApiVariable",
|
name: "MsApiVariable",
|
||||||
components: {ApiVariableSetting, MsApiBodyFileUpload, MsApiVariableAdvance},
|
components: {ApiVariableSetting, MsApiBodyFileUpload, MsApiVariableAdvance , MsApiVariableJson},
|
||||||
props: {
|
props: {
|
||||||
keyPlaceholder: String,
|
keyPlaceholder: String,
|
||||||
valuePlaceholder: String,
|
valuePlaceholder: String,
|
||||||
|
@ -140,7 +143,7 @@
|
||||||
{name: this.$t('commons.selector.not_required'), id: false}
|
{name: this.$t('commons.selector.not_required'), id: false}
|
||||||
],
|
],
|
||||||
isSelectAll: true,
|
isSelectAll: true,
|
||||||
isActive: true
|
isActive: true,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
@ -237,14 +240,22 @@
|
||||||
return (((1 + Math.random()) * 0x100000) | 0).toString(16).substring(1);
|
return (((1 + Math.random()) * 0x100000) | 0).toString(16).substring(1);
|
||||||
},
|
},
|
||||||
advanced(item) {
|
advanced(item) {
|
||||||
this.$refs.variableAdvance.open();
|
if (item.type === 'json'){
|
||||||
this.currentItem = item;
|
this.$refs.variableJson.open(item);
|
||||||
|
this.currentItem = item;
|
||||||
|
}else {
|
||||||
|
this.$refs.variableAdvance.open();
|
||||||
|
this.currentItem = item;
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
typeChange(item) {
|
typeChange(item) {
|
||||||
if (item.type === 'file') {
|
if (item.type === 'file') {
|
||||||
item.contentType = 'application/octet-stream';
|
item.contentType = 'application/octet-stream';
|
||||||
} else {
|
} else if (item.type === 'text'){
|
||||||
item.contentType = 'text/plain';
|
item.contentType = 'text/plain';
|
||||||
|
} else {
|
||||||
|
item.contentType = 'application/json'
|
||||||
}
|
}
|
||||||
this.reload();
|
this.reload();
|
||||||
},
|
},
|
||||||
|
@ -266,6 +277,9 @@
|
||||||
},
|
},
|
||||||
openApiVariableSetting(item) {
|
openApiVariableSetting(item) {
|
||||||
this.$refs.apiVariableSetting.open(item);
|
this.$refs.apiVariableSetting.open(item);
|
||||||
|
},
|
||||||
|
callback(item){
|
||||||
|
this.currentItem.value=item;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
|
|
@ -0,0 +1,108 @@
|
||||||
|
<template>
|
||||||
|
|
||||||
|
<el-dialog
|
||||||
|
:visible.sync="dialogVisible" destroy-on-close @close="close">
|
||||||
|
<div style="padding: 10px">
|
||||||
|
<el-switch active-text="JSON-SCHEMA" v-model="item.jsonType" @change="formatChange" active-value="JSON-SCHEMA"/>
|
||||||
|
</div>
|
||||||
|
<div v-if="codeEditActive">
|
||||||
|
<ms-json-code-edit
|
||||||
|
v-if="item.jsonType==='JSON-SCHEMA'"
|
||||||
|
:body="item"
|
||||||
|
ref="jsonCodeEdit"/>
|
||||||
|
<ms-code-edit
|
||||||
|
v-else
|
||||||
|
:read-only="isReadOnly"
|
||||||
|
:data.sync="item.value"
|
||||||
|
:mode="'json'"
|
||||||
|
height="400px"
|
||||||
|
ref="codeEdit"/>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
import MsCodeEdit from "../../../common/components/MsCodeEdit";
|
||||||
|
import Convert from "@/business/components/common/json-schema/convert/convert";
|
||||||
|
import MsJsonCodeEdit from "../../../common/json-schema/JsonSchemaEditor";
|
||||||
|
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "MsApiVariableJson",
|
||||||
|
components: {MsJsonCodeEdit, MsCodeEdit},
|
||||||
|
props: {
|
||||||
|
isReadOnly: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
dialogVisible: false,
|
||||||
|
jsonSchema: "JSON",
|
||||||
|
codeEditActive: true,
|
||||||
|
item: {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
'item.value'() {
|
||||||
|
if (this.item.jsonType !== 'JSON-SCHEMA' && this.item.value) {
|
||||||
|
try {
|
||||||
|
const MsConvert = new Convert();
|
||||||
|
let data = MsConvert.format(JSON.parse(this.item.value));
|
||||||
|
if (this.item.jsonSchema) {
|
||||||
|
this.item.jsonSchema = this.deepAssign(this.item.jsonSchema, data);
|
||||||
|
}
|
||||||
|
} catch (ex) {
|
||||||
|
this.item.jsonSchema = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
open(item) {
|
||||||
|
this.item.value = item.value;
|
||||||
|
this.dialogVisible = true;
|
||||||
|
this.reloadCodeEdit();
|
||||||
|
},
|
||||||
|
reloadCodeEdit() {
|
||||||
|
this.codeEditActive = false;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.codeEditActive = true;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
formatChange() {
|
||||||
|
const MsConvert = new Convert();
|
||||||
|
if (this.item.jsonType === 'JSON-SCHEMA') {
|
||||||
|
if (this.item.value && !this.item.jsonSchema) {
|
||||||
|
this.item.jsonSchema = MsConvert.format(JSON.parse(this.item.value));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (this.item.jsonSchema) {
|
||||||
|
MsConvert.schemaToJsonStr(this.item.jsonSchema, (result) => {
|
||||||
|
this.$set(this.item, 'value', result);
|
||||||
|
this.$emit('callback', result);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
saveAdvanced() {
|
||||||
|
this.dialogVisible = false;
|
||||||
|
if (this.item.jsonType === 'JSON-SCHEMA') {
|
||||||
|
this.item.jsonType = 'JSON';
|
||||||
|
this.formatChange();
|
||||||
|
} else {
|
||||||
|
this.$emit('callback', this.item.value);
|
||||||
|
}
|
||||||
|
this.item = {};
|
||||||
|
this.reloadCodeEdit();
|
||||||
|
},
|
||||||
|
close(){
|
||||||
|
this.saveAdvanced();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -208,6 +208,7 @@ export default {
|
||||||
},
|
},
|
||||||
formatChange() {
|
formatChange() {
|
||||||
const MsConvert = new Convert();
|
const MsConvert = new Convert();
|
||||||
|
|
||||||
if (this.body.format === 'JSON-SCHEMA') {
|
if (this.body.format === 'JSON-SCHEMA') {
|
||||||
if (this.body.raw && !this.body.jsonSchema) {
|
if (this.body.raw && !this.body.jsonSchema) {
|
||||||
this.body.jsonSchema = MsConvert.format(JSON.parse(this.body.raw));
|
this.body.jsonSchema = MsConvert.format(JSON.parse(this.body.raw));
|
||||||
|
@ -266,24 +267,48 @@ export default {
|
||||||
batchAdd() {
|
batchAdd() {
|
||||||
this.$refs.batchAddParameter.open();
|
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.body.kvs.unshift(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
batchSave(data) {
|
batchSave(data) {
|
||||||
if (data) {
|
if (data) {
|
||||||
let params = data.split("\n");
|
let params = data.split("\n");
|
||||||
let keyValues = [];
|
let keyValues = [];
|
||||||
params.forEach(item => {
|
params.forEach(item => {
|
||||||
let line = item.split(/,|,/);
|
let line = [];
|
||||||
|
line[0] = item.substring(0,item.indexOf(":"));
|
||||||
|
line[1] = item.substring(item.indexOf(":")+1,item.length);
|
||||||
let required = false;
|
let required = false;
|
||||||
if (line[1] === '必填' || line[1] === 'Required' || line[1] === 'true') {
|
keyValues.unshift(new KeyValue({
|
||||||
required = true;
|
name: line[0],
|
||||||
}
|
required: required,
|
||||||
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"}));
|
value: line[1],
|
||||||
|
description: line[2],
|
||||||
|
type: "text",
|
||||||
|
valid: false,
|
||||||
|
file: false,
|
||||||
|
encode: true,
|
||||||
|
enable: true,
|
||||||
|
contentType: "text/plain"
|
||||||
|
}));
|
||||||
})
|
})
|
||||||
keyValues.forEach(item => {
|
keyValues.forEach(item => {
|
||||||
this.body.kvs.unshift(item);
|
this.format(this.body.kvs, item);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
if (!this.body.type) {
|
if (!this.body.type) {
|
||||||
|
@ -296,6 +321,7 @@ export default {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue