From 0cd581043caba26c6fc053165f1a73ab1a038a25 Mon Sep 17 00:00:00 2001 From: Antoine GIRARD Date: Thu, 19 Oct 2017 23:41:11 +0200 Subject: [PATCH 1/5] Move swagger interface under /api/v1 --- routers/api/v1/api.go | 1 + routers/api/v1/misc/swagger.go | 18 ++++++++++++++++++ routers/home.go | 7 ------- routers/routes/routes.go | 1 - 4 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 routers/api/v1/misc/swagger.go diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 526940493f0fb..ca3f40ed3c364 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -277,6 +277,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Group("/v1", func() { // Miscellaneous + m.Get("/swagger", misc.Swagger) m.Get("/version", misc.Version) m.Post("/markdown", bind(api.MarkdownOption{}), misc.Markdown) m.Post("/markdown/raw", misc.MarkdownRaw) diff --git a/routers/api/v1/misc/swagger.go b/routers/api/v1/misc/swagger.go new file mode 100644 index 0000000000000..5cbe6ce6e9105 --- /dev/null +++ b/routers/api/v1/misc/swagger.go @@ -0,0 +1,18 @@ +// Copyright 2017 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package misc + +import ( + "code.gitea.io/gitea/modules/base" + "code.gitea.io/gitea/modules/context" +) + +// tplSwagger swagger page template +const tplSwagger base.TplName = "swagger" + +// Swagger render swagger-ui page +func Swagger(ctx *context.Context) { + ctx.HTML(200, tplSwagger) +} diff --git a/routers/home.go b/routers/home.go index cf957c1215e28..768eb220776e2 100644 --- a/routers/home.go +++ b/routers/home.go @@ -20,8 +20,6 @@ import ( const ( // tplHome home page template tplHome base.TplName = "home" - // tplSwagger swagger page template - tplSwagger base.TplName = "swagger" // tplExploreRepos explore repositories page template tplExploreRepos base.TplName = "explore/repos" // tplExploreUsers explore users page template @@ -53,11 +51,6 @@ func Home(ctx *context.Context) { ctx.HTML(200, tplHome) } -// Swagger render swagger-ui page -func Swagger(ctx *context.Context) { - ctx.HTML(200, tplSwagger) -} - // RepoSearchOptions when calling search repositories type RepoSearchOptions struct { OwnerID int64 diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 749f8263f8c3c..46521130f8125 100644 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -160,7 +160,6 @@ func RegisterRoutes(m *macaron.Macaron) { return "" }) m.Get("/", ignSignIn, routers.Home) - m.Get("/swagger", ignSignIn, routers.Swagger) m.Group("/explore", func() { m.Get("", func(ctx *context.Context) { ctx.Redirect(setting.AppSubURL + "/explore/repos") From f2007d5adec90012b1bc98d6e73c9d5d83684a2c Mon Sep 17 00:00:00 2001 From: Antoine GIRARD Date: Thu, 19 Oct 2017 23:51:06 +0200 Subject: [PATCH 2/5] Update swagger-ui --- Makefile | 4 +- public/vendor/assets/swagger-ui/index.html | 12 +- .../assets/swagger-ui/oauth2-redirect.html | 54 ++--- .../assets/swagger-ui/swagger-ui-bundle.js | 190 ++++++++---------- .../swagger-ui/swagger-ui-bundle.js.map | 2 +- .../swagger-ui-standalone-preset.js | 19 +- .../swagger-ui-standalone-preset.js.map | 2 +- .../vendor/assets/swagger-ui/swagger-ui.css | 2 +- public/vendor/assets/swagger-ui/swagger-ui.js | 21 +- .../assets/swagger-ui/swagger-ui.js.map | 2 +- templates/swagger.tmpl | 10 +- 11 files changed, 138 insertions(+), 180 deletions(-) diff --git a/Makefile b/Makefile index 146ef6de818e9..8ac3940b85886 100644 --- a/Makefile +++ b/Makefile @@ -304,10 +304,10 @@ generate-stylesheets: .PHONY: swagger-ui swagger-ui: rm -Rf public/vendor/assets/swagger-ui - git clone --depth=10 -b v3.0.7 --single-branch https://github.com/swagger-api/swagger-ui.git $(TMPDIR)/swagger-ui + git clone --depth=10 -b v3.3.2 --single-branch https://github.com/swagger-api/swagger-ui.git $(TMPDIR)/swagger-ui mv $(TMPDIR)/swagger-ui/dist public/vendor/assets/swagger-ui rm -Rf $(TMPDIR)/swagger-ui - $(SED_INPLACE) "s;http://petstore.swagger.io/v2/swagger.json;../../swagger.v1.json;g" public/assets/swagger-ui/index.html + $(SED_INPLACE) "s;http://petstore.swagger.io/v2/swagger.json;../../../swagger.v1.json;g" public/vendor/assets/swagger-ui/index.html .PHONY: update-translations update-translations: diff --git a/public/vendor/assets/swagger-ui/index.html b/public/vendor/assets/swagger-ui/index.html index 75f52a926d8a9..9bf4493bb36c5 100644 --- a/public/vendor/assets/swagger-ui/index.html +++ b/public/vendor/assets/swagger-ui/index.html @@ -11,15 +11,15 @@