forked from github/dataease
fix: API 数据源
This commit is contained in:
parent
d05ff66a68
commit
287948c426
@ -20,6 +20,7 @@ public class ShiroServiceImpl implements ShiroService {
|
||||
// ----------------------------------------------------------
|
||||
// 放行Swagger2页面,需要放行这些
|
||||
|
||||
filterChainDefinitionMap.put("/api/data/demo", ANON);
|
||||
filterChainDefinitionMap.put("/doc.html**", "doc");
|
||||
filterChainDefinitionMap.put("/deApi**", ANON);
|
||||
filterChainDefinitionMap.put("/swagger-ui.html", ANON);
|
||||
|
@ -59,7 +59,6 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
options: [{name: "No Auth"}, {name: "Basic Auth"}],
|
||||
encryptOptions: [{id: false, name: this.$t('commons.encrypted')}],
|
||||
activeName: "verified",
|
||||
rule: {},
|
||||
authConfig: {}
|
||||
|
@ -36,32 +36,14 @@
|
||||
highlight-first-item
|
||||
@select="change">
|
||||
</el-input>
|
||||
<!-- <el-autocomplete-->
|
||||
<!-- :disabled="isReadOnly"-->
|
||||
<!-- size="small"-->
|
||||
<!-- class="input-with-autocomplete"-->
|
||||
<!-- v-model="item.value"-->
|
||||
<!-- placeholder="valueText"-->
|
||||
<!-- value-key="name"-->
|
||||
<!-- highlight-first-item-->
|
||||
<!-- @select="change">-->
|
||||
<!-- </el-autocomplete>-->
|
||||
</el-col>
|
||||
|
||||
<el-col class="item">
|
||||
<el-input v-model="item.description" size="small" maxlength="200"
|
||||
:placeholder="$t('commons.description')" show-word-limit>
|
||||
</el-input>
|
||||
|
||||
<el-autocomplete :disabled="isReadOnly" v-if="suggestions" v-model="item.name" size="small"
|
||||
:fetch-suggestions="querySearch" @change="change" :placeholder="keyText" show-word-limit/>
|
||||
|
||||
</el-col>
|
||||
|
||||
<el-col v-if="type === 'body'" class="item kv-select">
|
||||
<el-input :disabled="isReadOnly" v-model="item.contentType" size="small"
|
||||
@change="change" :placeholder="$t('api_test.request.content_type')" show-word-limit>
|
||||
</el-input>
|
||||
</el-col>
|
||||
|
||||
<el-col class="item kv-delete">
|
||||
@ -114,10 +96,6 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
currentItem: null,
|
||||
requireds: [
|
||||
{name: this.$t('commons.selector.required'), id: true},
|
||||
{name: this.$t('commons.selector.not_required'), id: false}
|
||||
],
|
||||
isSelectAll: true,
|
||||
isActive: true,
|
||||
}
|
||||
|
@ -1,118 +0,0 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
:title="$t('commons.import')"
|
||||
:visible.sync="importVisible"
|
||||
width="50%"
|
||||
append-to-body
|
||||
show-close
|
||||
:close-on-click-modal="false"
|
||||
@closed="handleClose">
|
||||
|
||||
<el-tabs v-model="activeName">
|
||||
<el-tab-pane label="JSON" name="JSON">
|
||||
<div style="height: 400px">
|
||||
<ms-code-edit :mode="mode"
|
||||
:data.sync="json" theme="eclipse" :modes="[]"
|
||||
ref="codeEdit"/>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="JSON-SCHEMA" name="JSON-SCHEMA">
|
||||
<div style="height: 400px">
|
||||
<ms-code-edit :mode="mode"
|
||||
:data.sync="jsonSchema" theme="eclipse" :modes="[]"
|
||||
ref="codeEdit"/>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<ms-dialog-footer
|
||||
@cancel="importVisible = false"
|
||||
@confirm="saveConfirm"/>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import DialogFooter from './DialogFooter'
|
||||
import CodeEdit from "./CodeEdit";
|
||||
import json5 from 'json5';
|
||||
const Convert = require('./convert.js');
|
||||
const MsConvert = new Convert();
|
||||
|
||||
export default {
|
||||
name: "MsImportJson",
|
||||
components: {DialogFooter, CodeEdit},
|
||||
data() {
|
||||
return {
|
||||
importVisible: false,
|
||||
activeName: "JSON",
|
||||
mode: "json",
|
||||
json: "",
|
||||
jsonSchema: "",
|
||||
};
|
||||
},
|
||||
watch: {},
|
||||
props: {},
|
||||
methods: {
|
||||
openOneClickOperation() {
|
||||
this.importVisible = true;
|
||||
},
|
||||
checkIsJson(json) {
|
||||
try {
|
||||
json5.parse(json);
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
checkIsJsonSchema(json) {
|
||||
try {
|
||||
json = json5.parse(json);
|
||||
if (json.properties && typeof json.properties === 'object' && !json.type) {
|
||||
json.type = 'object';
|
||||
}
|
||||
if (json.items && typeof json.items === 'object' && !json.type) {
|
||||
json.type = 'array';
|
||||
}
|
||||
if (!json.type) {
|
||||
return false;
|
||||
}
|
||||
json.type = json.type.toLowerCase();
|
||||
let types = ['object', 'string', 'number', 'array', 'boolean', 'integer'];
|
||||
if (types.indexOf(json.type) === -1) {
|
||||
return false;
|
||||
}
|
||||
return JSON.stringify(json);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
saveConfirm() {
|
||||
if (this.activeName === 'JSON') {
|
||||
if (!this.checkIsJson(this.json)) {
|
||||
this.$error(this.$t('schema.json_warning'));
|
||||
return;
|
||||
}
|
||||
let jsonData = MsConvert.format(json5.parse(this.json));
|
||||
//let jsonData = GenerateSchema(json5.parse(this.json));
|
||||
this.$emit('jsonData', jsonData);
|
||||
} else {
|
||||
if (!this.checkIsJsonSchema(this.jsonSchema)) {
|
||||
this.$error(this.$t('schema.json_schema_warning'));
|
||||
return;
|
||||
}
|
||||
let obj = json5.parse(this.jsonSchema);
|
||||
this.$emit('jsonData', obj);
|
||||
}
|
||||
this.importVisible = false;
|
||||
},
|
||||
handleClose() {
|
||||
this.importVisible = false;
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
@ -189,18 +189,5 @@ class Convert {
|
||||
|
||||
return objectTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台转换
|
||||
* @param callback
|
||||
*/
|
||||
// schemaToJsonStr(schema, callback) {
|
||||
// post('/api/definition/preview', schema, (response) => {
|
||||
// if (callback) {
|
||||
// callback(response.data);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
|
||||
module.exports = Convert;
|
||||
|
Loading…
Reference in New Issue
Block a user