fix(接口自动化): 修改转换方法
This commit is contained in:
parent
199327be75
commit
4b5e4bbea9
|
@ -57,6 +57,7 @@
|
||||||
methods: {
|
methods: {
|
||||||
handleClick() {
|
handleClick() {
|
||||||
if (this.activeName === 'preview') {
|
if (this.activeName === 'preview') {
|
||||||
|
console.log(this.schema)
|
||||||
this.preview = schemaToJson(json5.parse(JSON.stringify(this.schema)));
|
this.preview = schemaToJson(json5.parse(JSON.stringify(this.schema)));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -64,10 +65,7 @@
|
||||||
this.$refs.importJson.openOneClickOperation();
|
this.$refs.importJson.openOneClickOperation();
|
||||||
},
|
},
|
||||||
jsonData(data) {
|
jsonData(data) {
|
||||||
let obj =
|
let obj = {"root": data}
|
||||||
{
|
|
||||||
"root": data
|
|
||||||
}
|
|
||||||
this.schema = obj;
|
this.schema = obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,11 @@ const jsf = require('json-schema-faker');
|
||||||
jsf.extend('mock', function () {
|
jsf.extend('mock', function () {
|
||||||
return {
|
return {
|
||||||
mock: function (xx) {
|
mock: function (xx) {
|
||||||
|
if (xx && xx.startsWith("@")) {
|
||||||
return Mock.mock(xx);
|
return Mock.mock(xx);
|
||||||
}
|
}
|
||||||
|
return xx;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,8 @@
|
||||||
created() {
|
created() {
|
||||||
if (this.schema.mock && Object.prototype.toString.call(this.schema.mock).match(/\[object (\w+)\]/)[1].toLowerCase() === 'object') {
|
if (this.schema.mock && Object.prototype.toString.call(this.schema.mock).match(/\[object (\w+)\]/)[1].toLowerCase() === 'object') {
|
||||||
this.mock = this.schema.mock;
|
this.mock = this.schema.mock;
|
||||||
|
} else {
|
||||||
|
this.schema.mock = this.mock;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|
Loading…
Reference in New Issue