mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-24 10:07:21 +02:00
Allow to disable swagger (#2093)
https://github.com/woodpecker-ci/woodpecker/issues/1944
This commit is contained in:
parent
f06e0acdc6
commit
1a7f7a9427
@ -272,6 +272,11 @@ var flags = []cli.Flag{
|
||||
Name: "migrations-allow-long",
|
||||
Value: false,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
EnvVars: []string{"WOODPECKER_ENABLE_SWAGGER"},
|
||||
Name: "enable-swagger",
|
||||
Value: true,
|
||||
},
|
||||
//
|
||||
// resource limit parameters
|
||||
//
|
||||
|
@ -364,6 +364,7 @@ func setupEvilGlobals(c *cli.Context, v store.Store, f forge.Forge) {
|
||||
server.Config.Pipeline.Volumes = c.StringSlice("volume")
|
||||
server.Config.Pipeline.Privileged = c.StringSlice("escalate")
|
||||
server.Config.Server.Migrations.AllowLong = c.Bool("migrations-allow-long")
|
||||
server.Config.Server.EnableSwagger = c.Bool("enable-swagger")
|
||||
|
||||
// prometheus
|
||||
server.Config.Prometheus.AuthToken = c.String("prometheus-auth-token")
|
||||
|
@ -535,6 +535,11 @@ Server URL path prefix (used for statics loading when having a url path prefix),
|
||||
|
||||
Example: `WOODPECKER_ROOT_URL=/woodpecker`
|
||||
|
||||
### `WOODPECKER_ENABLE_SWAGGER`
|
||||
> Default: true
|
||||
|
||||
Enable the Swagger UI for API documentation.
|
||||
|
||||
---
|
||||
|
||||
### `WOODPECKER_GITHUB_...`
|
||||
|
@ -73,6 +73,7 @@ var Config = struct {
|
||||
Migrations struct {
|
||||
AllowLong bool
|
||||
}
|
||||
EnableSwagger bool
|
||||
// Open bool
|
||||
// Orgs map[string]struct{}
|
||||
// Admins map[string]struct{}
|
||||
|
@ -69,7 +69,9 @@ func Load(noRouteHandler http.HandlerFunc, middleware ...gin.HandlerFunc) http.H
|
||||
e.GET("/healthz", api.Health)
|
||||
|
||||
apiRoutes(e)
|
||||
setupSwaggerConfigAndRoutes(e)
|
||||
if server.Config.Server.EnableSwagger {
|
||||
setupSwaggerConfigAndRoutes(e)
|
||||
}
|
||||
|
||||
return e
|
||||
}
|
||||
|
@ -40,12 +40,13 @@ func Config(c *gin.Context) {
|
||||
}
|
||||
|
||||
configData := map[string]interface{}{
|
||||
"user": user,
|
||||
"csrf": csrf,
|
||||
"docs": server.Config.Server.Docs,
|
||||
"version": version.String(),
|
||||
"forge": server.Config.Services.Forge.Name(),
|
||||
"root_url": server.Config.Server.RootURL,
|
||||
"user": user,
|
||||
"csrf": csrf,
|
||||
"docs": server.Config.Server.Docs,
|
||||
"version": version.String(),
|
||||
"forge": server.Config.Services.Forge.Name(),
|
||||
"root_url": server.Config.Server.RootURL,
|
||||
"enable_swagger": server.Config.Server.EnableSwagger,
|
||||
}
|
||||
|
||||
// default func map with json parser.
|
||||
@ -75,4 +76,5 @@ window.WOODPECKER_VERSION = "{{ .version }}";
|
||||
window.WOODPECKER_DOCS = "{{ .docs }}";
|
||||
window.WOODPECKER_FORGE = "{{ .forge }}";
|
||||
window.WOODPECKER_ROOT_URL = "{{ .root_url }}";
|
||||
window.WOODPECKER_ENABLE_SWAGGER = {{ .enable_swagger }};
|
||||
`
|
||||
|
@ -18,7 +18,9 @@
|
||||
<!-- Docs Link -->
|
||||
<a :href="docsUrl" target="_blank" class="navbar-link navbar-clickable hidden md:flex">{{ $t('docs') }}</a>
|
||||
<!-- API Link -->
|
||||
<a :href="apiUrl" target="_blank" class="navbar-link navbar-clickable hidden md:flex">{{ $t('api') }}</a>
|
||||
<a v-if="enableSwagger" :href="apiUrl" target="_blank" class="navbar-link navbar-clickable hidden md:flex">{{
|
||||
$t('api')
|
||||
}}</a>
|
||||
</div>
|
||||
<!-- Right Icons Box -->
|
||||
<div class="flex ml-auto -m-1.5 items-center space-x-2">
|
||||
@ -82,7 +84,15 @@ export default defineComponent({
|
||||
|
||||
const version = config.version?.startsWith('next') ? 'next' : config.version;
|
||||
|
||||
return { darkMode, user: authentication.user, doLogin, docsUrl, version, apiUrl };
|
||||
return {
|
||||
darkMode,
|
||||
user: authentication.user,
|
||||
doLogin,
|
||||
docsUrl,
|
||||
version,
|
||||
apiUrl,
|
||||
enableSwagger: config.enableSwagger,
|
||||
};
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
@ -8,6 +8,7 @@ declare global {
|
||||
WOODPECKER_CSRF: string | undefined;
|
||||
WOODPECKER_FORGE: string | undefined;
|
||||
WOODPECKER_ROOT_URL: string | undefined;
|
||||
WOODPECKER_ENABLE_SWAGGER: boolean | undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,4 +19,5 @@ export default () => ({
|
||||
csrf: window.WOODPECKER_CSRF || null,
|
||||
forge: window.WOODPECKER_FORGE || null,
|
||||
rootURL: window.WOODPECKER_ROOT_URL || null,
|
||||
enableSwagger: window.WOODPECKER_ENABLE_SWAGGER || false,
|
||||
});
|
||||
|
@ -22,6 +22,7 @@
|
||||
<div class="flex items-center">
|
||||
<h2 class="text-lg text-wp-text-100">{{ $t('user.api_usage') }}</h2>
|
||||
<a
|
||||
v-if="enableSwagger"
|
||||
:href="`${address}/swagger/index.html`"
|
||||
target="_blank"
|
||||
class="ml-4 text-wp-link-100 hover:text-wp-link-200"
|
||||
@ -56,9 +57,11 @@ import Button from '~/components/atomic/Button.vue';
|
||||
import SelectField from '~/components/form/SelectField.vue';
|
||||
import Scaffold from '~/components/layout/scaffold/Scaffold.vue';
|
||||
import useApiClient from '~/compositions/useApiClient';
|
||||
import useConfig from '~/compositions/useConfig';
|
||||
import { setI18nLanguage } from '~/compositions/useI18n';
|
||||
|
||||
const { t, locale } = useI18n();
|
||||
const { enableSwagger } = useConfig();
|
||||
|
||||
const apiClient = useApiClient();
|
||||
const token = ref<string | undefined>();
|
||||
|
Loading…
Reference in New Issue
Block a user