summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/api.go4
-rw-r--r--routers/api/v1/misc/swagger.go2
-rw-r--r--routers/routes/routes.go6
-rw-r--r--routers/swagger_json.go14
4 files changed, 22 insertions, 4 deletions
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go
index 3174e56374..5d47570c5f 100644
--- a/routers/api/v1/api.go
+++ b/routers/api/v1/api.go
@@ -278,13 +278,13 @@ func mustAllowPulls(ctx *context.Context) {
func RegisterRoutes(m *macaron.Macaron) {
bind := binding.Bind
- if setting.API.EnableSwaggerEndpoint {
+ if setting.API.EnableSwagger {
m.Get("/swagger", misc.Swagger) //Render V1 by default
}
m.Group("/v1", func() {
// Miscellaneous
- if setting.API.EnableSwaggerEndpoint {
+ if setting.API.EnableSwagger {
m.Get("/swagger", misc.Swagger)
}
m.Get("/version", misc.Version)
diff --git a/routers/api/v1/misc/swagger.go b/routers/api/v1/misc/swagger.go
index 0599f85154..e17b775227 100644
--- a/routers/api/v1/misc/swagger.go
+++ b/routers/api/v1/misc/swagger.go
@@ -10,7 +10,7 @@ import (
)
// tplSwagger swagger page template
-const tplSwagger base.TplName = "swagger"
+const tplSwagger base.TplName = "swagger/ui"
// Swagger render swagger-ui page with v1 json
func Swagger(ctx *context.Context) {
diff --git a/routers/routes/routes.go b/routers/routes/routes.go
index 3eaaff60b6..8c196d8bb2 100644
--- a/routers/routes/routes.go
+++ b/routers/routes/routes.go
@@ -79,7 +79,7 @@ func NewMacaron() *macaron.Macaron {
},
))
- m.Use(templates.Renderer())
+ m.Use(templates.HTMLRenderer())
models.InitMailRender(templates.Mailer())
localeNames, err := options.Dir("locale")
@@ -755,6 +755,10 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Post("/purge", user.NotificationPurgePost)
}, reqSignIn)
+ if setting.API.EnableSwagger {
+ m.Get("/swagger.v1.json", templates.JSONRenderer(), routers.SwaggerV1Json)
+ }
+
m.Group("/api", func() {
apiv1.RegisterRoutes(m)
}, ignSignIn)
diff --git a/routers/swagger_json.go b/routers/swagger_json.go
new file mode 100644
index 0000000000..896f1afa2a
--- /dev/null
+++ b/routers/swagger_json.go
@@ -0,0 +1,14 @@
+package routers
+
+import (
+ "code.gitea.io/gitea/modules/base"
+ "code.gitea.io/gitea/modules/context"
+)
+
+// tplSwaggerV1Json swagger v1 json template
+const tplSwaggerV1Json base.TplName = "swagger/v1_json"
+
+// SwaggerV1Json render swagger v1 json
+func SwaggerV1Json(ctx *context.Context) {
+ ctx.HTML(200, tplSwaggerV1Json)
+}