swagger文档展示开发
This commit is contained in:
@@ -32,9 +32,9 @@ public class ZyplayerDocConfig {
|
|||||||
@EnableDocDb
|
@EnableDocDb
|
||||||
public class enableDocDb{}
|
public class enableDocDb{}
|
||||||
|
|
||||||
@EnableDocSwagger(selfDoc = false)
|
// @EnableDocSwagger(selfDoc = false)
|
||||||
public class enableDocSwagger{}
|
// public class enableDocSwagger{}
|
||||||
|
|
||||||
// @EnableDocSwaggerPlus
|
@EnableDocSwaggerPlus
|
||||||
// public class enableDocSwaggerPlus{}
|
public class enableDocSwaggerPlus{}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class SwaggerProxyController {
|
|||||||
List<SwaggerDoc> docList = swaggerDocService.getSwaggerDocList();
|
List<SwaggerDoc> docList = swaggerDocService.getSwaggerDocList();
|
||||||
for (SwaggerDoc swaggerDoc : docList) {
|
for (SwaggerDoc swaggerDoc : docList) {
|
||||||
SwaggerResource resource = new SwaggerResource();
|
SwaggerResource resource = new SwaggerResource();
|
||||||
resource.setLocation(swaggerDoc.getDocUrl());
|
resource.setUrl("/doc-swagger/doc/content?id=" + swaggerDoc.getId());
|
||||||
resource.setName(swaggerDoc.getName());
|
resource.setName(swaggerDoc.getName());
|
||||||
resource.setSwaggerVersion("2.0");
|
resource.setSwaggerVersion("2.0");
|
||||||
resourceList.add(resource);
|
resourceList.add(resource);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import java.lang.annotation.*;
|
|||||||
@Documented
|
@Documented
|
||||||
@Configuration
|
@Configuration
|
||||||
@ComponentScan(basePackages = {
|
@ComponentScan(basePackages = {
|
||||||
"com.zyplayer.doc.swagger",
|
"com.zyplayer.doc.swaggerplus",
|
||||||
})
|
})
|
||||||
public @interface EnableDocSwaggerPlus {
|
public @interface EnableDocSwaggerPlus {
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
VITE_APP_TITLE=swagger文档管理
|
VITE_APP_TITLE=swagger文档管理
|
||||||
|
|
||||||
本地切换环境改这个参数,可选值:dev、online
|
本地切换环境改这个参数,可选值:dev、online
|
||||||
VITE_APP_ENV=online
|
VITE_APP_ENV=dev
|
||||||
|
|
||||||
# 线上环境
|
# 线上环境
|
||||||
VITE_APP_BASE_URL_ONLINE=http://doc.zyplayer.com/zyplayer-doc-manage
|
VITE_APP_BASE_URL_ONLINE=http://doc.zyplayer.com/zyplayer-doc-manage
|
||||||
|
VITE_APP_CUSTOM_URL_ONLINE=http://doc.zyplayer.com/zyplayer-doc-manage
|
||||||
|
|
||||||
# 本地环境
|
# 本地环境
|
||||||
VITE_APP_BASE_URL_DEV=http://local.zyplayer.com:8083/zyplayer-doc-manage
|
VITE_APP_BASE_URL_DEV=http://local.zyplayer.com:8083/zyplayer-doc-manage
|
||||||
|
VITE_APP_CUSTOM_URL_DEV=http://local.zyplayer.com:8083/zyplayer-doc-manage
|
||||||
|
|
||||||
|
|||||||
@@ -3,4 +3,5 @@ VITE_APP_TITLE=swagger文档管理
|
|||||||
VITE_APP_ENV=online
|
VITE_APP_ENV=online
|
||||||
|
|
||||||
# 线上环境
|
# 线上环境
|
||||||
VITE_APP_BASE_URL_ONLINE=http://doc.zyplayer.com/zyplayer-doc-manage
|
VITE_APP_BASE_URL_ONLINE=./
|
||||||
|
VITE_APP_CUSTOM_URL_ONLINE=./
|
||||||
|
|||||||
34
zyplayer-doc-ui/swagger-ui/package-lock.json
generated
34
zyplayer-doc-ui/swagger-ui/package-lock.json
generated
@@ -223,26 +223,41 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ant-design-vue": {
|
"ant-design-vue": {
|
||||||
"version": "2.2.8",
|
"version": "3.0.0-alpha.4",
|
||||||
"resolved": "https://registry.npmmirror.com/ant-design-vue/download/ant-design-vue-2.2.8.tgz",
|
"resolved": "https://registry.npmmirror.com/ant-design-vue/download/ant-design-vue-3.0.0-alpha.4.tgz?cache=0&sync_timestamp=1634696108824&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fant-design-vue%2Fdownload%2Fant-design-vue-3.0.0-alpha.4.tgz",
|
||||||
"integrity": "sha1-+ofPaELY7poNivOT/0CZ7MQHLys=",
|
"integrity": "sha1-A+3f7Tv17UCbKBQyC1pxQ+Z2r/U=",
|
||||||
"requires": {
|
"requires": {
|
||||||
|
"@ant-design/colors": "^6.0.0",
|
||||||
"@ant-design/icons-vue": "^6.0.0",
|
"@ant-design/icons-vue": "^6.0.0",
|
||||||
"@babel/runtime": "^7.10.5",
|
"@babel/runtime": "^7.10.5",
|
||||||
"@simonwep/pickr": "~1.8.0",
|
"@simonwep/pickr": "~1.8.0",
|
||||||
"array-tree-filter": "^2.1.0",
|
"array-tree-filter": "^2.1.0",
|
||||||
"async-validator": "^3.3.0",
|
"async-validator": "^4.0.0",
|
||||||
|
"dayjs": "^1.10.5",
|
||||||
"dom-align": "^1.12.1",
|
"dom-align": "^1.12.1",
|
||||||
"dom-scroll-into-view": "^2.0.0",
|
"dom-scroll-into-view": "^2.0.0",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"lodash-es": "^4.17.15",
|
"lodash-es": "^4.17.15",
|
||||||
"moment": "^2.27.0",
|
|
||||||
"omit.js": "^2.0.0",
|
|
||||||
"resize-observer-polyfill": "^1.5.1",
|
"resize-observer-polyfill": "^1.5.1",
|
||||||
"scroll-into-view-if-needed": "^2.2.25",
|
"scroll-into-view-if-needed": "^2.2.25",
|
||||||
"shallow-equal": "^1.0.0",
|
"shallow-equal": "^1.0.0",
|
||||||
"vue-types": "^3.0.0",
|
"vue-types": "^3.0.0",
|
||||||
"warning": "^4.0.0"
|
"warning": "^4.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@ant-design/colors": {
|
||||||
|
"version": "6.0.0",
|
||||||
|
"resolved": "https://registry.npm.taobao.org/@ant-design/colors/download/@ant-design/colors-6.0.0.tgz",
|
||||||
|
"integrity": "sha1-m5NmJXz/zEfbQrnQIDu1ksE8Apg=",
|
||||||
|
"requires": {
|
||||||
|
"@ctrl/tinycolor": "^3.4.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"async-validator": {
|
||||||
|
"version": "4.0.7",
|
||||||
|
"resolved": "https://registry.npmmirror.com/async-validator/download/async-validator-4.0.7.tgz",
|
||||||
|
"integrity": "sha1-A0oP0hA6ay6/AQ2nUYO+wpkkev4="
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"anymatch": {
|
"anymatch": {
|
||||||
@@ -1198,11 +1213,6 @@
|
|||||||
"resolved": "https://registry.nlark.com/object-inspect/download/object-inspect-1.10.3.tgz",
|
"resolved": "https://registry.nlark.com/object-inspect/download/object-inspect-1.10.3.tgz",
|
||||||
"integrity": "sha1-wqp9LQn1DJk3VwT3oK3yTFeC02k="
|
"integrity": "sha1-wqp9LQn1DJk3VwT3oK3yTFeC02k="
|
||||||
},
|
},
|
||||||
"omit.js": {
|
|
||||||
"version": "2.0.2",
|
|
||||||
"resolved": "https://registry.npm.taobao.org/omit.js/download/omit.js-2.0.2.tgz",
|
|
||||||
"integrity": "sha1-3ZuENvq5R6Xz/yFMslOGMeMT7C8="
|
|
||||||
},
|
|
||||||
"param-case": {
|
"param-case": {
|
||||||
"version": "3.0.4",
|
"version": "3.0.4",
|
||||||
"resolved": "https://registry.nlark.com/param-case/download/param-case-3.0.4.tgz",
|
"resolved": "https://registry.nlark.com/param-case/download/param-case-3.0.4.tgz",
|
||||||
@@ -1769,7 +1779,7 @@
|
|||||||
},
|
},
|
||||||
"vue-types": {
|
"vue-types": {
|
||||||
"version": "3.0.2",
|
"version": "3.0.2",
|
||||||
"resolved": "https://registry.nlark.com/vue-types/download/vue-types-3.0.2.tgz",
|
"resolved": "https://registry.npmmirror.com/vue-types/download/vue-types-3.0.2.tgz",
|
||||||
"integrity": "sha1-7BbgXUEsA4Ji/B76TOuWR+f7YB0=",
|
"integrity": "sha1-7BbgXUEsA4Ji/B76TOuWR+f7YB0=",
|
||||||
"requires": {
|
"requires": {
|
||||||
"is-plain-object": "3.0.1"
|
"is-plain-object": "3.0.1"
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ant-design/icons-vue": "^6.0.1",
|
"@ant-design/icons-vue": "^6.0.1",
|
||||||
"ant-design-vue": "^2.2.8",
|
"ant-design-vue": "^3.0.0-alpha.4",
|
||||||
"axios": "^0.19.2",
|
"axios": "^0.19.2",
|
||||||
"brace": "^0.11.1",
|
"brace": "^0.11.1",
|
||||||
"element-plus": "^1.0.2-beta.71",
|
"element-plus": "^1.0.2-beta.71",
|
||||||
|
|||||||
6
zyplayer-doc-ui/swagger-ui/src/api/custom.js
Normal file
6
zyplayer-doc-ui/swagger-ui/src/api/custom.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import apiClient from './request/custom.js'
|
||||||
|
|
||||||
|
export const customApi = {
|
||||||
|
post: (url, data) => apiClient({url: url, method: 'post', data: data}),
|
||||||
|
};
|
||||||
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
export { zyplayerApi } from './zyplayer.js';
|
export { zyplayerApi } from './zyplayer.js';
|
||||||
|
export { customApi } from './custom.js';
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
14
zyplayer-doc-ui/swagger-ui/src/api/request/custom.js
Normal file
14
zyplayer-doc-ui/swagger-ui/src/api/request/custom.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import Axios from 'axios'
|
||||||
|
import interceptors from './interceptors'
|
||||||
|
import {getCustomApiBaseUrl} from "./utils";
|
||||||
|
|
||||||
|
const apiClient = Axios.create({
|
||||||
|
baseURL: getCustomApiBaseUrl(),
|
||||||
|
timeout: 20000,
|
||||||
|
headers: {'Content-type': 'application/x-www-form-urlencoded'},
|
||||||
|
withCredentials: true
|
||||||
|
});
|
||||||
|
interceptors(apiClient);
|
||||||
|
|
||||||
|
export default apiClient;
|
||||||
|
|
||||||
@@ -4,7 +4,7 @@ import {getZyplayerApiBaseUrl} from "./utils";
|
|||||||
|
|
||||||
// 增加不需要验证结果的标记
|
// 增加不需要验证结果的标记
|
||||||
const noValidate = {
|
const noValidate = {
|
||||||
"/zyplayer-doc-db/executor/execute": true,
|
"./swagger-resources": true,
|
||||||
"/zyplayer-doc-db/datasource/test": true,
|
"/zyplayer-doc-db/datasource/test": true,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ export default function (axios) {
|
|||||||
response => {
|
response => {
|
||||||
if (!!response.message) {
|
if (!!response.message) {
|
||||||
vue.$message.error('请求错误:' + response.message);
|
vue.$message.error('请求错误:' + response.message);
|
||||||
}else {
|
} else {
|
||||||
if (!response.config.needValidateResult || response.data.errCode === 200) {
|
if (!response.config.needValidateResult || response.data.errCode === 200) {
|
||||||
return response.data;
|
return response.data;
|
||||||
} else if (response.data.errCode === 400) {
|
} else if (response.data.errCode === 400) {
|
||||||
|
|||||||
@@ -11,3 +11,15 @@ export function getZyplayerApiBaseUrl() {
|
|||||||
return baseUrl;
|
return baseUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取custom后端域名
|
||||||
|
*/
|
||||||
|
export function getCustomApiBaseUrl() {
|
||||||
|
let env = import.meta.env.VITE_APP_ENV;
|
||||||
|
let baseUrl = import.meta.env.VITE_APP_CUSTOM_URL_ONLINE;
|
||||||
|
if ("dev" === env) {
|
||||||
|
baseUrl = import.meta.env.VITE_APP_CUSTOM_URL_DEV;
|
||||||
|
}
|
||||||
|
return baseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,31 +1,20 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="menu-layout">
|
<div class="menu-layout">
|
||||||
|
<div style="padding: 10px 5px;">
|
||||||
|
<a-select placeholder="请选择分组" v-model:value="swaggerDocChoice" style="width: 100%;">
|
||||||
|
<a-select-option :value="item.url" v-for="item in swaggerResourceList">{{item.name}}</a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</div>
|
||||||
<a-menu theme="light" mode="inline" :inline-collapsed="collapsed" v-model:openKeys="openKeys" v-model:selectedKeys="selectedKeys">
|
<a-menu theme="light" mode="inline" :inline-collapsed="collapsed" v-model:openKeys="openKeys" v-model:selectedKeys="selectedKeys">
|
||||||
<menu-children-layout :menuItem="menuItem" v-for="menuItem in menuData"></menu-children-layout>
|
<menu-children-layout :menuItem="menuItem" v-for="menuItem in menuData"></menu-children-layout>
|
||||||
</a-menu>
|
</a-menu>
|
||||||
<a-directory-tree :tree-data="treeData" v-model:expandedKeys="expandedKeys" @select="docChecked">
|
<a-directory-tree :tree-data="treeData" v-model:expandedKeys="expandedKeys" @select="docChecked"></a-directory-tree>
|
||||||
<a-tree-node key="0-0" title="parent 0">
|
|
||||||
<a-tree-node key="0-0-0" is-leaf >
|
|
||||||
<template #title>
|
|
||||||
<router-link :to="{path: '/doc/view', query: {id: 1}}">leaf 0-0</router-link>
|
|
||||||
</template>
|
|
||||||
</a-tree-node>
|
|
||||||
<a-tree-node key="0-0-1" is-leaf >
|
|
||||||
<template #title>
|
|
||||||
<router-link :to="{path: '/doc/view', query: {id: 2}}">leaf 0-1</router-link>
|
|
||||||
</template>
|
|
||||||
</a-tree-node>
|
|
||||||
</a-tree-node>
|
|
||||||
<a-tree-node key="0-1" title="parent 1">
|
|
||||||
<a-tree-node key="0-1-0" title="leaf 1-0" is-leaf />
|
|
||||||
<a-tree-node key="0-1-1" title="leaf 1-1" is-leaf />
|
|
||||||
</a-tree-node>
|
|
||||||
</a-directory-tree>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import MenuChildrenLayout from './MenuChildrenLayout.vue'
|
import MenuChildrenLayout from './MenuChildrenLayout.vue'
|
||||||
|
import {customApi} from '../../api'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'MenuLayout',
|
name: 'MenuLayout',
|
||||||
@@ -54,6 +43,8 @@
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
expandedKeys: [],
|
expandedKeys: [],
|
||||||
|
swaggerResourceList: [],
|
||||||
|
swaggerDocChoice: undefined,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch:{
|
watch:{
|
||||||
@@ -62,7 +53,7 @@
|
|||||||
},
|
},
|
||||||
components: {MenuChildrenLayout},
|
components: {MenuChildrenLayout},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.getMenuData();
|
this.menuData = this.$router.options.routes.find((item) => item.path === '/').children[0].children;
|
||||||
let meta = this.$route.meta || {};
|
let meta = this.$route.meta || {};
|
||||||
let path = this.$route.path;
|
let path = this.$route.path;
|
||||||
if (!!meta.parentPath) {
|
if (!!meta.parentPath) {
|
||||||
@@ -73,35 +64,22 @@
|
|||||||
if (matched.length >= 1) {
|
if (matched.length >= 1) {
|
||||||
this.openKeys = [matched[1].path];
|
this.openKeys = [matched[1].path];
|
||||||
}
|
}
|
||||||
|
this.getSwaggerResourceList();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getMenuData() {
|
|
||||||
let menuData = this.$router.options.routes.find((item) => item.path === '/').children[0].children;
|
|
||||||
this.menuData = JSON.parse(JSON.stringify(menuData));
|
|
||||||
// 模拟数据返回,暂时不以这种展示
|
|
||||||
// setTimeout(() => {
|
|
||||||
// this.menuData.push({
|
|
||||||
// name: '用户管理接口',
|
|
||||||
// meta: {icon: 'FileTextOutlined'},
|
|
||||||
// children: [
|
|
||||||
// {
|
|
||||||
// path: '/doc/view?id=2',
|
|
||||||
// name: '获取用户信息',
|
|
||||||
// query: {id: 222}
|
|
||||||
// }, {
|
|
||||||
// path: '/doc/view?id=3',
|
|
||||||
// name: '删除用户',
|
|
||||||
// query: {id: 333}
|
|
||||||
// }
|
|
||||||
// ]
|
|
||||||
// });
|
|
||||||
// }, 1000);
|
|
||||||
},
|
|
||||||
docChecked(val, node) {
|
docChecked(val, node) {
|
||||||
if (node.node.isLeaf) {
|
if (node.node.isLeaf) {
|
||||||
let dataRef = node.node.dataRef;
|
let dataRef = node.node.dataRef;
|
||||||
this.$router.push({path: dataRef.path, query: dataRef.query});
|
this.$router.push({path: dataRef.path, query: dataRef.query});
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
getSwaggerResourceList() {
|
||||||
|
customApi.post('./swagger-resources').then(res => {
|
||||||
|
this.swaggerResourceList = res || [];
|
||||||
|
if (this.swaggerResourceList.length > 0) {
|
||||||
|
this.swaggerDocChoice = this.swaggerResourceList[0].url;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,10 +20,18 @@ let routers = [
|
|||||||
path: '/doc/console',
|
path: '/doc/console',
|
||||||
name: '控制台',
|
name: '控制台',
|
||||||
meta: {
|
meta: {
|
||||||
icon: 'DashboardOutlined'
|
hidden: true,
|
||||||
},
|
},
|
||||||
component: () => import('./views/common/Console.vue')
|
component: () => import('./views/common/Console.vue')
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/doc/manage',
|
||||||
|
name: '文档管理',
|
||||||
|
meta: {
|
||||||
|
icon: 'DashboardOutlined'
|
||||||
|
},
|
||||||
|
component: () => import('./views/doc/DocManage.vue')
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/doc/setting',
|
path: '/doc/setting',
|
||||||
name: '系统配置',
|
name: '系统配置',
|
||||||
|
|||||||
48
zyplayer-doc-ui/swagger-ui/src/views/doc/DocManage.vue
Normal file
48
zyplayer-doc-ui/swagger-ui/src/views/doc/DocManage.vue
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<template>
|
||||||
|
<a-table :dataSource="dataSource" :columns="columns"/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { ref, onMounted } from 'vue'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
setup() {
|
||||||
|
onMounted(() => {
|
||||||
|
console.log('Component is mounted!');
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
dataSource: [
|
||||||
|
{
|
||||||
|
key: '1',
|
||||||
|
name: '胡彦斌',
|
||||||
|
age: 32,
|
||||||
|
address: '西湖区湖底公园1号',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: '2',
|
||||||
|
name: '胡彦祖',
|
||||||
|
age: 42,
|
||||||
|
address: '西湖区湖底公园1号',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
title: '姓名',
|
||||||
|
dataIndex: 'name',
|
||||||
|
key: 'name',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '年龄',
|
||||||
|
dataIndex: 'age',
|
||||||
|
key: 'age',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '住址',
|
||||||
|
dataIndex: 'address',
|
||||||
|
key: 'address',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
@@ -8,6 +8,7 @@ export default defineConfig({
|
|||||||
server: {
|
server: {
|
||||||
host: 'local.zyplayer.com',
|
host: 'local.zyplayer.com',
|
||||||
port: 80,
|
port: 80,
|
||||||
|
// https: true
|
||||||
},
|
},
|
||||||
base: '',
|
base: '',
|
||||||
plugins: [
|
plugins: [
|
||||||
|
|||||||
Reference in New Issue
Block a user