api文档支持开放访问

This commit is contained in:
暮光:城中城
2021-12-05 22:58:48 +08:00
parent 928c79b747
commit 189e96ff42
70 changed files with 5578 additions and 2983 deletions

View File

@@ -18,7 +18,7 @@
</template>
<script>
import {toRefs, ref, reactive, onMounted, watch} from 'vue';
import {toRefs, ref, reactive, onMounted, watch, nextTick} from 'vue';
import { useRouter, useRoute } from "vue-router";
import {useStore} from 'vuex';
import { message } from 'ant-design-vue';
@@ -53,7 +53,7 @@
let v2Doc = toJsonObj(res.data);
// osdoc.swagger 和 doc.openapi 的区别
if (typeof v2Doc !== 'object' || !v2Doc.openapi) {
message.error('获取文档数据请求失败');
message.error('获取文档数据失败请检查文档是否为标准的OpenApi文档格式');
return;
}
openApiDoc.value = v2Doc;
@@ -72,10 +72,11 @@
}, 0);
});
};
const loadTreeData = () => {
expandedKeys.value = ['main'];
const loadTreeData = async () => {
let metaInfo = {id: choiceDocId.value};
treeData.value = getTreeDataForTag(openApiDoc.value, tagPathMap.value, searchKeywords.value, metaInfo);
await nextTick();
expandedKeys.value = ['main'];
};
const toJsonObj = (value) => {
if (typeof value !== 'string') {

View File

@@ -18,7 +18,7 @@
</template>
<script>
import {toRefs, ref, reactive, onMounted, watch} from 'vue';
import {toRefs, ref, reactive, onMounted, watch, nextTick} from 'vue';
import { useRouter, useRoute } from "vue-router";
import {useStore} from 'vuex';
import { message } from 'ant-design-vue';
@@ -53,7 +53,7 @@
let v2Doc = toJsonObj(res.data);
if (typeof v2Doc !== 'object' || !v2Doc.swagger) {
callback(false);
message.error('获取文档数据请求失败');
message.error('获取文档数据失败请检查文档是否为标准的Swagger文档格式');
return;
}
swaggerDoc.value = v2Doc;
@@ -72,10 +72,11 @@
}, 0);
});
};
const loadTreeData = () => {
expandedKeys.value = ['main'];
const loadTreeData = async () => {
let metaInfo = {id: choiceDocId.value};
treeData.value = getTreeDataForTag(swaggerDoc.value, tagPathMap.value, searchKeywords.value, metaInfo);
await nextTick();
expandedKeys.value = ['main'];
};
const toJsonObj = (value) => {
if (typeof value !== 'string') {