summaryrefslogtreecommitdiffstats
path: root/routers/api
diff options
context:
space:
mode:
authorPiotr Orzechowski <piotr@orzechowski.tech>2018-02-14 05:46:00 +0100
committerLauris BH <lauris@nix.lv>2018-02-14 06:46:00 +0200
commitb104ab3ca1690f35d0674d3807681390e640e5c8 (patch)
treedcc2018a27fbc6e6455abafe632660c2a6289137 /routers/api
parent4c9d9c221a0628753f3dc16b469330ee096cbf18 (diff)
downloadgitea-b104ab3ca1690f35d0674d3807681390e640e5c8.tar.gz
gitea-b104ab3ca1690f35d0674d3807681390e640e5c8.zip
Add option to enable or disable swagger endpoints (#3502)
Diffstat (limited to 'routers/api')
-rw-r--r--routers/api/v1/api.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go
index 6bbc014266..240bb2fc4d 100644
--- a/routers/api/v1/api.go
+++ b/routers/api/v1/api.go
@@ -50,6 +50,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/auth"
"code.gitea.io/gitea/modules/context"
+ "code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/routers/api/v1/admin"
"code.gitea.io/gitea/routers/api/v1/misc"
"code.gitea.io/gitea/routers/api/v1/org"
@@ -277,11 +278,15 @@ func mustAllowPulls(ctx *context.Context) {
func RegisterRoutes(m *macaron.Macaron) {
bind := binding.Bind
- m.Get("/swagger", misc.Swagger) //Render V1 by default
+ if setting.API.EnableSwaggerEndpoint {
+ m.Get("/swagger", misc.Swagger) //Render V1 by default
+ }
m.Group("/v1", func() {
// Miscellaneous
- m.Get("/swagger", misc.Swagger)
+ if setting.API.EnableSwaggerEndpoint {
+ m.Get("/swagger", misc.Swagger)
+ }
m.Get("/version", misc.Version)
m.Post("/markdown", bind(api.MarkdownOption{}), misc.Markdown)
m.Post("/markdown/raw", misc.MarkdownRaw)