fix(接口自动化): 修改转换方法

This commit is contained in:
fit2-zhao 2020-12-31 15:03:44 +08:00
parent 199327be75
commit 4b5e4bbea9
3 changed files with 8 additions and 5 deletions

View File

@ -57,6 +57,7 @@
methods: {
handleClick() {
if (this.activeName === 'preview') {
console.log(this.schema)
this.preview = schemaToJson(json5.parse(JSON.stringify(this.schema)));
}
},
@ -64,10 +65,7 @@
this.$refs.importJson.openOneClickOperation();
},
jsonData(data) {
let obj =
{
"root": data
}
let obj = {"root": data}
this.schema = obj;
}
}

View File

@ -4,7 +4,10 @@ const jsf = require('json-schema-faker');
jsf.extend('mock', function () {
return {
mock: function (xx) {
return Mock.mock(xx);
if (xx && xx.startsWith("@")) {
return Mock.mock(xx);
}
return xx;
}
};
});

View File

@ -40,6 +40,8 @@
created() {
if (this.schema.mock && Object.prototype.toString.call(this.schema.mock).match(/\[object (\w+)\]/)[1].toLowerCase() === 'object') {
this.mock = this.schema.mock;
} else {
this.schema.mock = this.mock;
}
},
mounted() {