summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-06-22 20:21:31 +0200
committerGitHub <noreply@github.com>2020-06-22 14:21:31 -0400
commitfc2f2c7602c0bea8de76172f6d3303eab374a01e (patch)
treea3cbccd543b846ff5410248caf5110022bfc38ca /routers
parentb948ecb2d29bfe373d966d10a33e7c195eb47da4 (diff)
downloadgitea-fc2f2c7602c0bea8de76172f6d3303eab374a01e.tar.gz
gitea-fc2f2c7602c0bea8de76172f6d3303eab374a01e.zip
API: Move AllowedReactions endpoint into GetGenneralUI endpoint + creat new swagger section settings (#11854)
* move Setting function into its own package * swagger add&use new section "settings" * move api AllowedReactions into general UI-Settings endpoint * prepare TEST * lint
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/api.go5
-rw-r--r--routers/api/v1/settings/settings.go (renamed from routers/api/v1/misc/settings.go)18
-rw-r--r--routers/api/v1/swagger/misc.go7
-rw-r--r--routers/api/v1/swagger/settings.go21
4 files changed, 34 insertions, 17 deletions
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go
index f356d7a2bc..b03f547a6b 100644
--- a/routers/api/v1/api.go
+++ b/routers/api/v1/api.go
@@ -73,6 +73,7 @@ import (
"code.gitea.io/gitea/routers/api/v1/notify"
"code.gitea.io/gitea/routers/api/v1/org"
"code.gitea.io/gitea/routers/api/v1/repo"
+ "code.gitea.io/gitea/routers/api/v1/settings"
_ "code.gitea.io/gitea/routers/api/v1/swagger" // for swagger generation
"code.gitea.io/gitea/routers/api/v1/user"
@@ -513,8 +514,8 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Post("/markdown", bind(api.MarkdownOption{}), misc.Markdown)
m.Post("/markdown/raw", misc.MarkdownRaw)
m.Group("/settings", func() {
- m.Get("/allowed_reactions", misc.SettingGetsAllowedReactions)
- m.Get("/repository", misc.GetGeneralRepoSettings)
+ m.Get("/ui", settings.GetGeneralUISettings)
+ m.Get("/repository", settings.GetGeneralRepoSettings)
})
// Notifications
diff --git a/routers/api/v1/misc/settings.go b/routers/api/v1/settings/settings.go
index 925cde835c..8403a51d3e 100644
--- a/routers/api/v1/misc/settings.go
+++ b/routers/api/v1/settings/settings.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
-package misc
+package settings
import (
"net/http"
@@ -12,22 +12,24 @@ import (
api "code.gitea.io/gitea/modules/structs"
)
-// SettingGetsAllowedReactions return allowed reactions
-func SettingGetsAllowedReactions(ctx *context.APIContext) {
- // swagger:operation GET /settings/allowed_reactions miscellaneous getAllowedReactions
+// GetGeneralUISettings returns instance's global settings for ui
+func GetGeneralUISettings(ctx *context.APIContext) {
+ // swagger:operation GET /settings/ui settings getGeneralUISettings
// ---
- // summary: Returns string array of allowed reactions
+ // summary: Get instance's global settings for ui
// produces:
// - application/json
// responses:
// "200":
- // "$ref": "#/responses/StringSlice"
- ctx.JSON(http.StatusOK, setting.UI.Reactions)
+ // "$ref": "#/responses/GeneralUISettings"
+ ctx.JSON(http.StatusOK, api.GeneralUISettings{
+ AllowedReactions: setting.UI.Reactions,
+ })
}
// GetGeneralRepoSettings returns instance's global settings for repositories
func GetGeneralRepoSettings(ctx *context.APIContext) {
- // swagger:operation GET /settings/repository miscellaneous getGeneralRepositorySettings
+ // swagger:operation GET /settings/repository settings getGeneralRepositorySettings
// ---
// summary: Get instance's global settings for repositories
// produces:
diff --git a/routers/api/v1/swagger/misc.go b/routers/api/v1/swagger/misc.go
index 50f5cbdbf5..1d3c257efa 100644
--- a/routers/api/v1/swagger/misc.go
+++ b/routers/api/v1/swagger/misc.go
@@ -21,10 +21,3 @@ type swaggerResponseStringSlice struct {
// in:body
Body []string `json:"body"`
}
-
-// GeneralRepoSettings
-// swagger:response GeneralRepoSettings
-type swaggerResponseGeneralRepoSettings struct {
- // in:body
- Body api.GeneralRepoSettings `json:"body"`
-}
diff --git a/routers/api/v1/swagger/settings.go b/routers/api/v1/swagger/settings.go
new file mode 100644
index 0000000000..45266e51df
--- /dev/null
+++ b/routers/api/v1/swagger/settings.go
@@ -0,0 +1,21 @@
+// Copyright 2020 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 swagger
+
+import api "code.gitea.io/gitea/modules/structs"
+
+// GeneralRepoSettings
+// swagger:response GeneralRepoSettings
+type swaggerResponseGeneralRepoSettings struct {
+ // in:body
+ Body api.GeneralRepoSettings `json:"body"`
+}
+
+// GeneralUISettings
+// swagger:response GeneralUISettings
+type swaggerResponseGeneralUISettings struct {
+ // in:body
+ Body api.GeneralUISettings `json:"body"`
+}