mirror of
https://github.com/HangarMC/Hangar.git
synced 2024-11-27 06:01:08 +08:00
removed swagger-ui webjar
This commit is contained in:
parent
3c0127f3eb
commit
adb725ddb8
5
pom.xml
5
pom.xml
@ -203,11 +203,6 @@
|
||||
<artifactId>chart.js</artifactId>
|
||||
<version>${chart.js.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.webjars</groupId>
|
||||
<artifactId>swagger-ui</artifactId>
|
||||
<version>${swagger-ui.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- runtime -->
|
||||
<dependency>
|
||||
|
@ -24,6 +24,7 @@
|
||||
"lodash": "4.17.20",
|
||||
"popper.js": "^1.16.1",
|
||||
"query-string": "6.13.1",
|
||||
"swagger-ui": "^3.34.0",
|
||||
"vue": "^3.0.0",
|
||||
"webpack-jquery-ui": "^2.0.1"
|
||||
},
|
||||
|
87
src/main/frontend/src/components/Swagger.vue
Normal file
87
src/main/frontend/src/components/Swagger.vue
Normal file
@ -0,0 +1,87 @@
|
||||
<template>
|
||||
<div id="swagger-ui"></div>
|
||||
</template>
|
||||
<script>
|
||||
import { getApiSession } from '@/js/apiRequests';
|
||||
import SwaggerUIBundle from 'swagger-ui';
|
||||
|
||||
export default {
|
||||
name: 'SwaggerUI',
|
||||
mounted() {
|
||||
// console.log(SwaggerUIBundle);
|
||||
window.onload = () => {
|
||||
window.ui = SwaggerUIBundle({
|
||||
url: '/v2/api-docs',
|
||||
dom_id: '#swagger-ui',
|
||||
deepLinking: true,
|
||||
presets: [SwaggerUIBundle.presets.apis, SwaggerUIBundle.SwaggerUIStandalonePreset],
|
||||
plugins: [SwaggerUIBundle.plugins.DownloadUrl],
|
||||
layout: 'BaseLayout',
|
||||
requestInterceptor: req => {
|
||||
if (!req.loadSpec) {
|
||||
const promise = getApiSession().then(session => {
|
||||
req.headers.authorization = 'HangarApi session=' + session;
|
||||
return req;
|
||||
});
|
||||
// Workaround for fixing the curl URL
|
||||
// https://github.com/swagger-api/swagger-ui/issues/4778#issuecomment-456403631
|
||||
promise.url = req.url;
|
||||
return promise;
|
||||
} else {
|
||||
return req;
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss">
|
||||
@import '~swagger-ui/dist/swagger-ui.css';
|
||||
|
||||
html {
|
||||
box-sizing: border-box;
|
||||
overflow: -moz-scrollbars-vertical;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
*,
|
||||
*:before,
|
||||
*:after {
|
||||
box-sizing: inherit;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
.swagger-ui .topbar .download-url-wrapper,
|
||||
.swagger-ui .info hgroup.main a {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.swagger-ui .info {
|
||||
margin: 2rem 0;
|
||||
}
|
||||
|
||||
.swagger-ui .info .title small pre {
|
||||
background-color: unset;
|
||||
border: unset;
|
||||
}
|
||||
|
||||
.model-container,
|
||||
.responses-inner {
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.swagger-ui .info .description h2 {
|
||||
padding-top: 1.5rem;
|
||||
margin: 1.5rem 0 0;
|
||||
border-top: 3px solid #333333;
|
||||
}
|
||||
|
||||
.swagger-ui .scheme-container {
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
</style>
|
4
src/main/frontend/src/entrypoints/swagger.js
Normal file
4
src/main/frontend/src/entrypoints/swagger.js
Normal file
@ -0,0 +1,4 @@
|
||||
import { createApp } from 'vue';
|
||||
import Swagger from '@/components/Swagger';
|
||||
|
||||
createApp(Swagger).mount('#swagger-ui-vue');
|
@ -42,7 +42,7 @@ export function apiV2Request(url, method = 'GET', data = {}) {
|
||||
});
|
||||
}
|
||||
|
||||
function getApiSession() {
|
||||
export function getApiSession() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
let session;
|
||||
const date = new Date();
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -6,94 +6,14 @@ Mostly copied from swagger-ui's index file
|
||||
<#import "*/utils/hangar.ftlh" as hangar />
|
||||
<#import "*/layout/base.ftlh" as base />
|
||||
|
||||
<#macro scripts>
|
||||
<script type="text/javascript" src="<@hangar.url "lib/jquery/dist/jquery.min.js" />"></script>
|
||||
<script src="<@hangar.url "lib/swagger-ui/swagger-ui-bundle.js" />"></script>
|
||||
<script src="<@hangar.url "lib/swagger-ui/swagger-ui-standalone-preset.js" />"></script>
|
||||
<script src="<@hangar.url "js/apiRequests.js" />"></script>
|
||||
<script <#--@CSPNonce.attr-->>
|
||||
window.onload = () => {
|
||||
window.ui = SwaggerUIBundle({
|
||||
url: "/v2/api-docs",
|
||||
dom_id: '#swagger-ui',
|
||||
deepLinking: true,
|
||||
presets: [
|
||||
SwaggerUIBundle.presets.apis,
|
||||
SwaggerUIStandalonePreset
|
||||
],
|
||||
plugins: [
|
||||
SwaggerUIBundle.plugins.DownloadUrl
|
||||
],
|
||||
layout: "BaseLayout",
|
||||
requestInterceptor: (req) => {
|
||||
if (!req.loadSpec) {
|
||||
const promise = getApiSession().then((session) => {
|
||||
req.headers.authorization = 'HangarApi session=' + session;
|
||||
return req;
|
||||
});
|
||||
// Workaround for fixing the curl URL
|
||||
// https://github.com/swagger-api/swagger-ui/issues/4778#issuecomment-456403631
|
||||
promise.url = req.url;
|
||||
return promise;
|
||||
} else {
|
||||
return req;
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
<#if request??>
|
||||
<script <#--@CSPNonce.attr-->>
|
||||
csrf = '@play.filters.csrf.CSRF.getToken.get.value';
|
||||
isLoggedIn = ${request.hasUser};
|
||||
</script>
|
||||
</#if>
|
||||
</#macro>
|
||||
|
||||
<#macro stylesheets>
|
||||
<link rel="stylesheet" type="text/css" href="<@hangar.url "lib/swagger-ui/swagger-ui.css" />">
|
||||
|
||||
<style>
|
||||
html {
|
||||
box-sizing: border-box;
|
||||
overflow: -moz-scrollbars-vertical;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
*, *:before, *:after {
|
||||
box-sizing: inherit;
|
||||
}
|
||||
body {
|
||||
margin:0;
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
.swagger-ui .topbar .download-url-wrapper, .swagger-ui .info hgroup.main a {
|
||||
display: none;
|
||||
}
|
||||
.swagger-ui .info {
|
||||
margin: 2rem 0;
|
||||
}
|
||||
.swagger-ui .info .title small pre {
|
||||
background-color: unset;
|
||||
border: unset;
|
||||
}
|
||||
.model-container, .responses-inner {
|
||||
overflow-x: auto;
|
||||
}
|
||||
.swagger-ui .info .description h2 {
|
||||
padding-top: 1.5rem;
|
||||
margin: 1.5rem 0 0;
|
||||
border-top: 3px solid #333333;
|
||||
}
|
||||
.swagger-ui .scheme-container {
|
||||
border-top: 1px solid rgba(0,0,0,.15);
|
||||
}
|
||||
</style>
|
||||
</#macro>
|
||||
<#assign scriptsVar>
|
||||
<script type="text/javascript" src="<@hangar.url "js/swagger.js" />"></script>
|
||||
</#assign>
|
||||
<#assign styleVar>
|
||||
<link rel="stylesheet" type="text/css" href="<@hangar.url "css/swagger.css" />">
|
||||
</#assign>
|
||||
|
||||
<#assign message><@spring.message "general.openapi" /></#assign>
|
||||
<#assign scriptsVar><@scripts /></#assign>
|
||||
<#assign stylesheetsVar><@stylesheets /></#assign>
|
||||
<@base.base title="${message}" additionalScripts=scriptsVar additionalStyling=stylesheetsVar>
|
||||
<div id="swagger-ui"></div>
|
||||
<@base.base title="${message}" additionalScripts=scriptsVar additionalStyling=styleVar>
|
||||
<div id="swagger-ui-vue"></div>
|
||||
</@base.base>
|
||||
|
Loading…
Reference in New Issue
Block a user