fix (接口定义): case历史数据兼容处理
This commit is contained in:
parent
ec1b4bbdfd
commit
d7b0000505
|
@ -109,7 +109,7 @@ public class JSONSchemaGenerator {
|
|||
concept.put(propertyName, analyzeEnumProperty(object));
|
||||
} else if (propertyObjType.equals("string")) {
|
||||
// 先设置空值
|
||||
concept.put(propertyName, null);
|
||||
concept.put(propertyName, "");
|
||||
if (object.has("format")) {
|
||||
String propertyFormat = object.get("format").getAsString();
|
||||
if (propertyFormat.equals("date-time")) {
|
||||
|
|
|
@ -27,211 +27,232 @@
|
|||
</el-radio-group>
|
||||
<div style="min-width: 1200px;" v-if="body.type == 'Form Data' || body.type == 'WWW_FORM'">
|
||||
<el-row v-if="body.type == 'Form Data' || body.type == 'WWW_FORM'">
|
||||
<el-link class="ms-el-link" @click="batchAdd"> {{$t("commons.batch_add")}}</el-link>
|
||||
<el-link class="ms-el-link" @click="batchAdd"> {{ $t("commons.batch_add") }}</el-link>
|
||||
</el-row>
|
||||
<ms-api-variable :with-mor-setting="true" :is-read-only="isReadOnly"
|
||||
:parameters="body.kvs"
|
||||
:isShowEnable="isShowEnable" type="body"/>
|
||||
<ms-api-variable
|
||||
:with-mor-setting="true"
|
||||
:is-read-only="isReadOnly"
|
||||
:parameters="body.kvs"
|
||||
:isShowEnable="isShowEnable"
|
||||
type="body"/>
|
||||
</div>
|
||||
<div v-if="body.type == 'JSON'">
|
||||
<div style="padding: 10px">
|
||||
<el-switch active-text="JSON-SCHEMA" v-model="body.format" @change="formatChange" active-value="JSON-SCHEMA"/>
|
||||
</div>
|
||||
<ms-json-code-edit v-if="body.format==='JSON-SCHEMA'" :body="body" ref="jsonCodeEdit"/>
|
||||
<ms-code-edit v-else-if="codeEditActive" :read-only="isReadOnly" height="400px" :data.sync="body.raw" :modes="modes" :mode="'json'" ref="codeEdit"/>
|
||||
<ms-json-code-edit
|
||||
v-if="body.format==='JSON-SCHEMA'"
|
||||
:body="body"
|
||||
ref="jsonCodeEdit"/>
|
||||
<ms-code-edit
|
||||
v-else-if="codeEditActive"
|
||||
:read-only="isReadOnly"
|
||||
:data.sync="body.raw"
|
||||
:modes="modes"
|
||||
:mode="'json'"
|
||||
height="400px"
|
||||
ref="codeEdit"/>
|
||||
</div>
|
||||
|
||||
<div class="ms-body" v-if="body.type == 'XML'">
|
||||
<ms-code-edit :read-only="isReadOnly" :data.sync="body.raw" :modes="modes" :mode="'text'" ref="codeEdit"/>
|
||||
<ms-code-edit
|
||||
:read-only="isReadOnly"
|
||||
:data.sync="body.raw"
|
||||
:modes="modes"
|
||||
:mode="'text'"
|
||||
ref="codeEdit"/>
|
||||
</div>
|
||||
|
||||
<div class="ms-body" v-if="body.type == 'Raw'">
|
||||
<ms-code-edit :read-only="isReadOnly" :data.sync="body.raw" :modes="modes" ref="codeEdit"/>
|
||||
<ms-code-edit
|
||||
:read-only="isReadOnly"
|
||||
:data.sync="body.raw"
|
||||
:modes="modes"
|
||||
ref="codeEdit"/>
|
||||
</div>
|
||||
|
||||
<ms-api-binary-variable :is-read-only="isReadOnly"
|
||||
:parameters="body.binary"
|
||||
:isShowEnable="isShowEnable"
|
||||
type="body"
|
||||
v-if="body.type == 'BINARY'"/>
|
||||
|
||||
<ms-api-binary-variable
|
||||
:is-read-only="isReadOnly"
|
||||
:parameters="body.binary"
|
||||
:isShowEnable="isShowEnable"
|
||||
type="body"
|
||||
v-if="body.type == 'BINARY'"/>
|
||||
<batch-add-parameter @batchSave="batchSave" ref="batchAddParameter"/>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import MsApiKeyValue from "../ApiKeyValue";
|
||||
import {BODY_TYPE, KeyValue} from "../../model/ApiTestModel";
|
||||
import MsCodeEdit from "../../../../common/components/MsCodeEdit";
|
||||
import MsJsonCodeEdit from "../../../../common/json-schema/JsonSchemaEditor";
|
||||
import MsDropdown from "../../../../common/components/MsDropdown";
|
||||
import MsApiVariable from "../ApiVariable";
|
||||
import MsApiBinaryVariable from "./ApiBinaryVariable";
|
||||
import MsApiFromUrlVariable from "./ApiFromUrlVariable";
|
||||
import BatchAddParameter from "../basis/BatchAddParameter";
|
||||
import Convert from "@/business/components/common/json-schema/convert/convert";
|
||||
import MsApiKeyValue from "../ApiKeyValue";
|
||||
import {BODY_TYPE, KeyValue} from "../../model/ApiTestModel";
|
||||
import MsCodeEdit from "../../../../common/components/MsCodeEdit";
|
||||
import MsJsonCodeEdit from "../../../../common/json-schema/JsonSchemaEditor";
|
||||
import MsDropdown from "../../../../common/components/MsDropdown";
|
||||
import MsApiVariable from "../ApiVariable";
|
||||
import MsApiBinaryVariable from "./ApiBinaryVariable";
|
||||
import MsApiFromUrlVariable from "./ApiFromUrlVariable";
|
||||
import BatchAddParameter from "../basis/BatchAddParameter";
|
||||
import Convert from "@/business/components/common/json-schema/convert/convert";
|
||||
|
||||
|
||||
export default {
|
||||
name: "MsApiBody",
|
||||
components: {
|
||||
MsApiVariable,
|
||||
MsDropdown,
|
||||
MsCodeEdit,
|
||||
MsApiKeyValue,
|
||||
MsApiBinaryVariable,
|
||||
MsApiFromUrlVariable,
|
||||
MsJsonCodeEdit,
|
||||
BatchAddParameter
|
||||
export default {
|
||||
name: "MsApiBody",
|
||||
components: {
|
||||
MsApiVariable,
|
||||
MsDropdown,
|
||||
MsCodeEdit,
|
||||
MsApiKeyValue,
|
||||
MsApiBinaryVariable,
|
||||
MsApiFromUrlVariable,
|
||||
MsJsonCodeEdit,
|
||||
BatchAddParameter
|
||||
},
|
||||
props: {
|
||||
body: {},
|
||||
headers: Array,
|
||||
isReadOnly: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
props: {
|
||||
body: {},
|
||||
headers: Array,
|
||||
isReadOnly: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
isShowEnable: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
isShowEnable: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
type: BODY_TYPE,
|
||||
modes: ['text', 'json', 'xml', 'html'],
|
||||
jsonSchema: "JSON",
|
||||
codeEditActive: true
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
reloadCodeEdit() {
|
||||
this.codeEditActive = false;
|
||||
this.$nextTick(() => {
|
||||
this.codeEditActive = true;
|
||||
});
|
||||
},
|
||||
formatChange() {
|
||||
const MsConvert = new Convert();
|
||||
if (this.body.format === 'JSON-SCHEMA') {
|
||||
if (this.body.raw) {
|
||||
this.body.jsonSchema = MsConvert.format(JSON.parse(this.body.raw));
|
||||
}
|
||||
} else {
|
||||
if (this.body.jsonSchema) {
|
||||
MsConvert.schemaToJsonStr(this.body.jsonSchema, (result) => {
|
||||
this.$set(this.body, 'raw', result);
|
||||
this.reloadCodeEdit();
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
type: BODY_TYPE,
|
||||
modes: ['text', 'json', 'xml', 'html'],
|
||||
jsonSchema: "JSON",
|
||||
codeEditActive: true
|
||||
};
|
||||
modeChange(mode) {
|
||||
switch (this.body.type) {
|
||||
case "JSON":
|
||||
this.setContentType("application/json");
|
||||
break;
|
||||
case "XML":
|
||||
this.setContentType("text/xml");
|
||||
break;
|
||||
case "WWW_FORM":
|
||||
this.setContentType("application/x-www-form-urlencoded");
|
||||
break;
|
||||
// todo from data
|
||||
case "BINARY":
|
||||
this.setContentType("application/octet-stream");
|
||||
break;
|
||||
default:
|
||||
this.removeContentType();
|
||||
break;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
reloadCodeEdit() {
|
||||
this.codeEditActive = false;
|
||||
this.$nextTick(() => {
|
||||
this.codeEditActive = true;
|
||||
});
|
||||
},
|
||||
formatChange() {
|
||||
const MsConvert = new Convert();
|
||||
if (this.body.format === 'JSON-SCHEMA') {
|
||||
if (this.body.raw) {
|
||||
this.body.jsonSchema = MsConvert.format(JSON.parse(this.body.raw));
|
||||
}
|
||||
} else {
|
||||
if (this.body.jsonSchema) {
|
||||
MsConvert.schemaToJsonStr(this.body.jsonSchema, (result) => {
|
||||
this.$set(this.body, 'raw', result);
|
||||
this.reloadCodeEdit();
|
||||
});
|
||||
}
|
||||
setContentType(value) {
|
||||
let isType = false;
|
||||
this.headers.forEach(item => {
|
||||
if (item.name === "Content-Type") {
|
||||
item.value = value;
|
||||
isType = true;
|
||||
}
|
||||
},
|
||||
modeChange(mode) {
|
||||
switch (this.body.type) {
|
||||
case "JSON":
|
||||
this.setContentType("application/json");
|
||||
break;
|
||||
case "XML":
|
||||
this.setContentType("text/xml");
|
||||
break;
|
||||
case "WWW_FORM":
|
||||
this.setContentType("application/x-www-form-urlencoded");
|
||||
break;
|
||||
// todo from data
|
||||
case "BINARY":
|
||||
this.setContentType("application/octet-stream");
|
||||
break;
|
||||
default:
|
||||
this.removeContentType();
|
||||
break;
|
||||
}
|
||||
},
|
||||
setContentType(value) {
|
||||
let isType = false;
|
||||
this.headers.forEach(item => {
|
||||
if (item.name === "Content-Type") {
|
||||
item.value = value;
|
||||
isType = true;
|
||||
}
|
||||
})
|
||||
if (!isType) {
|
||||
this.headers.unshift(new KeyValue({name: "Content-Type", value: value}));
|
||||
})
|
||||
if (!isType) {
|
||||
this.headers.unshift(new KeyValue({name: "Content-Type", value: value}));
|
||||
this.$emit('headersChange');
|
||||
}
|
||||
},
|
||||
removeContentType() {
|
||||
for (let index in this.headers) {
|
||||
if (this.headers[index].name === "Content-Type") {
|
||||
this.headers.splice(index, 1);
|
||||
this.$emit('headersChange');
|
||||
return;
|
||||
}
|
||||
},
|
||||
removeContentType() {
|
||||
for (let index in this.headers) {
|
||||
if (this.headers[index].name === "Content-Type") {
|
||||
this.headers.splice(index, 1);
|
||||
this.$emit('headersChange');
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
batchAdd() {
|
||||
this.$refs.batchAddParameter.open();
|
||||
},
|
||||
batchSave(data) {
|
||||
if (data) {
|
||||
let params = data.split("\n");
|
||||
let keyValues = [];
|
||||
params.forEach(item => {
|
||||
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.forEach(item => {
|
||||
this.body.kvs.unshift(item);
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
}
|
||||
},
|
||||
created() {
|
||||
if (!this.body.type) {
|
||||
this.body.type = BODY_TYPE.FORM_DATA;
|
||||
}
|
||||
if (this.body.kvs) {
|
||||
this.body.kvs.forEach(param => {
|
||||
if (!param.type) {
|
||||
param.type = 'text';
|
||||
batchAdd() {
|
||||
this.$refs.batchAddParameter.open();
|
||||
},
|
||||
batchSave(data) {
|
||||
if (data) {
|
||||
let params = data.split("\n");
|
||||
let keyValues = [];
|
||||
params.forEach(item => {
|
||||
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.forEach(item => {
|
||||
this.body.kvs.unshift(item);
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
},
|
||||
created() {
|
||||
if (!this.body.type) {
|
||||
this.body.type = BODY_TYPE.FORM_DATA;
|
||||
}
|
||||
if (this.body.kvs) {
|
||||
this.body.kvs.forEach(param => {
|
||||
if (!param.type) {
|
||||
param.type = 'text';
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.textarea {
|
||||
margin-top: 10px;
|
||||
}
|
||||
.textarea {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.ms-body {
|
||||
padding: 15px 0;
|
||||
height: 400px;
|
||||
}
|
||||
.ms-body {
|
||||
padding: 15px 0;
|
||||
height: 400px;
|
||||
}
|
||||
|
||||
.el-dropdown {
|
||||
margin-left: 20px;
|
||||
line-height: 30px;
|
||||
}
|
||||
.el-dropdown {
|
||||
margin-left: 20px;
|
||||
line-height: 30px;
|
||||
}
|
||||
|
||||
.ace_editor {
|
||||
border-radius: 5px;
|
||||
}
|
||||
.ace_editor {
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.el-radio-group {
|
||||
margin: 10px 10px;
|
||||
margin-top: 15px;
|
||||
}
|
||||
.el-radio-group {
|
||||
margin: 10px 10px;
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.ms-el-link {
|
||||
float: right;
|
||||
margin-right: 45px;
|
||||
}
|
||||
.ms-el-link {
|
||||
float: right;
|
||||
margin-right: 45px;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -181,12 +181,12 @@ import {TYPE_TO_C} from "@/business/components/api/automation/scenario/Setting";
|
|||
export default {
|
||||
name: "ApiCaseItem",
|
||||
filters: {
|
||||
ellipsis (value) {
|
||||
ellipsis(value) {
|
||||
if (!value) {
|
||||
return '';
|
||||
}
|
||||
if (value.length > 20) {
|
||||
return value.slice(0,20) + '...'
|
||||
return value.slice(0, 20) + '...'
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
@ -432,8 +432,10 @@ export default {
|
|||
if (tmp.tags instanceof Array) {
|
||||
tmp.tags = JSON.stringify(tmp.tags);
|
||||
}
|
||||
tmp.clazzName = TYPE_TO_C.get(tmp.type);
|
||||
this.sort(tmp.hashTree);
|
||||
if (tmp.request) {
|
||||
tmp.request.clazzName = TYPE_TO_C.get(tmp.request.type);
|
||||
this.sort(tmp.request.hashTree);
|
||||
}
|
||||
this.result = this.$fileUpload(url, null, bodyFiles, tmp, (response) => {
|
||||
let data = response.data;
|
||||
row.id = data.id;
|
||||
|
|
|
@ -67,6 +67,11 @@
|
|||
<el-tab-pane :label="$t('api_test.definition.request.other_config')" name="advancedConfig">
|
||||
<ms-api-advanced-config :is-read-only="isReadOnly" :request="request"/>
|
||||
</el-tab-pane>
|
||||
<!-- <el-tab-pane name="create" v-if="hasPermission('PROJECT_API_DEFINITION:READ+CREATE_API')">-->
|
||||
<!-- <template v-slot:label>-->
|
||||
<!-- <el-button size="mini" type="primary" @click.stop @click="createTestData">生成测试数据</el-button>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-tab-pane>-->
|
||||
|
||||
</el-tabs>
|
||||
</div>
|
||||
|
@ -93,6 +98,7 @@
|
|||
import MsApiAdvancedConfig from "./ApiAdvancedConfig";
|
||||
import MsJsr233Processor from "../../../../automation/scenario/component/Jsr233Processor";
|
||||
import ApiDefinitionStepButton from "../components/ApiDefinitionStepButton";
|
||||
import {hasPermission} from '@/common/js/utils';
|
||||
|
||||
export default {
|
||||
name: "MsApiHttpRequestForm",
|
||||
|
@ -176,6 +182,10 @@
|
|||
},
|
||||
|
||||
methods: {
|
||||
hasPermission,
|
||||
createTestData(){
|
||||
|
||||
},
|
||||
remove(row) {
|
||||
let index = this.request.hashTree.indexOf(row);
|
||||
this.request.hashTree.splice(index, 1);
|
||||
|
|
Loading…
Reference in New Issue