fix(接口自动化): json 处理

This commit is contained in:
fit2-zhao 2020-12-31 18:49:23 +08:00
parent d29c8bf2a2
commit 9c4e5bfbdb
3 changed files with 11 additions and 6 deletions

View File

@ -34,12 +34,12 @@
created() {
if (!this.body.jsonSchema && this.body.raw) {
let obj = {"root": GenerateSchema(JSON.parse(this.body.raw))}
this.body.jsonSchema = obj;
this.schema = this.body.jsonSchema;
this.schema = obj;
}
else if (this.body.jsonSchema) {
this.schema = this.body.jsonSchema;
this.schema = {"root": this.body.jsonSchema};
}
this.body.jsonSchema = this.schema.root;
},
data() {
return {
@ -57,7 +57,7 @@
methods: {
handleClick() {
if (this.activeName === 'preview') {
this.preview = schemaToJson(Object.values(this.schema)[0]);
this.preview = schemaToJson(this.schema.root);
}
},
openOneClickOperation() {

View File

@ -21,7 +21,7 @@
</el-select>
</el-col>
<el-col :span="8">
<ms-mock :schema="pickValue"/>
<ms-mock :disabled="pickValue.type==='object'" :schema="pickValue"/>
</el-col>
<el-col>
<el-input v-model="pickValue.description" class="ant-col-title" :placeholder="local['description']" size="small"/>
@ -220,6 +220,7 @@
this.$delete(this.pickValue, 'properties')
this.$delete(this.pickValue, 'items')
this.$delete(this.pickValue, 'required')
this.$delete(this.pickValue, 'mock')
if (this.isArray) {
this.$set(this.pickValue, 'items', {type: 'string', mock: {mock: ""}})
}

View File

@ -2,10 +2,10 @@
<div>
<el-autocomplete
size="small"
:disabled="false"
class="input-with-autocomplete"
v-model="mock.mock"
:fetch-suggestions="funcSearch"
:disabled="disabled"
:placeholder="$t('api_test.value')"
value-key="name"
highlight-first-item
@ -31,6 +31,7 @@
default: () => {
}
},
disabled: Boolean,
},
data() {
return {
@ -43,6 +44,9 @@
} else {
this.schema.mock = this.mock;
}
if (this.schema.type === 'object') {
this.$delete(this.schema, 'mock')
}
},
mounted() {
},