summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorAntoine GIRARD <sapk@users.noreply.github.com>2017-05-02 15:35:59 +0200
committerKim "BKC" Carlbäcker <kim.carlbacker@gmail.com>2017-05-02 15:35:59 +0200
commit3edb0c58943c003ed3f209b2197d1f43484a3432 (patch)
treee5849cead5053ab505a2c5dc1342111c6bcf0816 /modules
parentbb5f694fc57c3ade9c13e841b9a237f4e192da22 (diff)
downloadgitea-3edb0c58943c003ed3f209b2197d1f43484a3432.tar.gz
gitea-3edb0c58943c003ed3f209b2197d1f43484a3432.zip
Generate swagger json (#1402)
- Generate swagger.json into public/ - Add swagger-ui auto-installation - Add footer link to local swagger-ui - Add /swagger url for using app url. - Fix Swagger-UI version via git tag
Diffstat (limited to 'modules')
-rw-r--r--modules/context/api.go34
1 files changed, 31 insertions, 3 deletions
diff --git a/modules/context/api.go b/modules/context/api.go
index 0d279d93b2..2068285c7a 100644
--- a/modules/context/api.go
+++ b/modules/context/api.go
@@ -23,6 +23,34 @@ type APIContext struct {
Org *APIOrganization
}
+// APIError is error format response
+// swagger:response error
+type APIError struct {
+ Message string `json:"message"`
+ URL string `json:"url"`
+}
+
+// APIValidationError is error format response related to input validation
+// swagger:response validationError
+type APIValidationError struct {
+ Message string `json:"message"`
+ URL string `json:"url"`
+}
+
+//APIEmpty is a empty response
+// swagger:response empty
+type APIEmpty struct{}
+
+//APIForbiddenError is a forbidden error response
+// swagger:response forbidden
+type APIForbiddenError struct {
+ APIError
+}
+
+//APINotFound is a not found empty response
+// swagger:response notFound
+type APINotFound struct{}
+
// Error responses error message to client with given message.
// If status is 500, also it prints error to log.
func (ctx *APIContext) Error(status int, title string, obj interface{}) {
@@ -37,9 +65,9 @@ func (ctx *APIContext) Error(status int, title string, obj interface{}) {
log.Error(4, "%s: %s", title, message)
}
- ctx.JSON(status, map[string]string{
- "message": message,
- "url": base.DocURL,
+ ctx.JSON(status, APIError{
+ Message: message,
+ URL: base.DocURL,
})
}