fix(接口自动化): 存储JSON-SCHEMA

This commit is contained in:
fit2-zhao 2020-12-31 13:48:47 +08:00
parent b84abd3713
commit 75bb894228
19 changed files with 24 additions and 8 deletions

View File

@ -17,6 +17,7 @@ public class Body {
private String format;
private List<KeyValue> kvs;
private List<KeyValue> binary;
private Object jsonSchema;
public final static String KV = "KeyValue";
public final static String FORM_DATA = "Form Data";

View File

@ -41,7 +41,7 @@
v-if="body.type == 'WWW_FORM'"/>
<div v-if="body.type == 'JSON'">
<ms-json-code-edit @json-change="jsonChange" @onError="jsonError" :value="body.raw" ref="jsonCodeEdit"/>
<ms-json-code-edit :body="body" ref="jsonCodeEdit"/>
</div>
<div class="ms-body" v-if="body.type == 'XML'">

View File

@ -23,9 +23,24 @@
import json5 from 'json5';
import MsImportJson from './import/ImportJson';
const GenerateSchema = require('generate-schema/src/schemas/json.js');
export default {
name: 'App',
components: {MsImportJson},
props: {
body: {},
},
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;
}
else if (this.body.jsonSchema) {
this.schema = this.body.jsonSchema;
}
},
data() {
return {
schema:

View File

@ -46,14 +46,14 @@
<json-schema-editor :value="{items:pickValue.items}" :deep="deep+1" disabled isItem :root="false" class="children" :lang="lang" :custom="custom"/>
</template>
<!-- 高级设置-->
<el-dialog :close-on-click-modal="false" :title="local['adv_setting']" :visible.sync="modalVisible" width="800px" :destroy-on-close="true"
<el-dialog :close-on-click-modal="false" :title="local['adv_setting']" :visible.sync="modalVisible" :destroy-on-close="true"
@close="handleClose">
<p class="tip">基础设置 </p>
<el-form v-model="advancedValue" class="ant-advanced-search-form">
<el-form :inline="true" v-model="advancedValue" class="ant-advanced-search-form">
<el-row :gutter="6">
<el-col :span="8" v-for="(item,key) in advancedValue" :key="key">
<el-col :span="8" v-for="(item,key) in advancedValue" :key="key" style="float: right">
<el-form-item>
<span>{{ local[key] }}</span>
<div>{{ local[key] }}</div>
<el-input-number v-model="advancedValue[key]" v-if="advancedAttr[key].type === 'integer'" style="width:100%" :placeholder="key" size="small"/>
<el-input-number v-model="advancedValue[key]" v-else-if="advancedAttr[key].type === 'number'" style="width:100%" :placeholder="key" size="small"/>
<span v-else-if="advancedAttr[key].type === 'boolean'" style="display:inline-block;width:100%">
@ -63,7 +63,7 @@
<el-option value="" :label="local['nothing']"></el-option>
<el-option :key="t" :value="t" :label="t" v-for="t in advancedAttr[key].enums"/>
</el-select>
<el-input v-model="advancedValue[key]" v-else style="width:100%" :placeholder="key" size="small"/>
<el-input v-model="advancedValue[key]" v-else style="width:100%;" :placeholder="key" size="small"/>
</el-form-item>
</el-col>
</el-row>
@ -109,7 +109,7 @@
import {TYPE_NAME, TYPE} from './type/type'
import MsMock from './mock/index'
import MsDialogFooter from '../../../components/MsDialogFooter'
import LocalProvider from './LocalProvider/index'
import LocalProvider from './provider/index'
export default {
name: 'JsonSchemaEditor',

View File

@ -19,7 +19,7 @@ import '../common/css/main.css';
import CKEditor from '@ckeditor/ckeditor5-vue';
import VueFab from 'vue-float-action-button'
import {horizontalDrag} from "../common/js/directive";
import JsonSchemaEditor from './components/common/json-schema/packages/index';
import JsonSchemaEditor from './components/common/json-schema/schema/index';
Vue.use(JsonSchemaEditor);
Vue.config.productionTip = false;