1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Swagger info corrections (#9441)

* use numbers and not http.Status___ enum

* fix test

* add many missing swagger responses

* code format

* Deletion Sould return 204 ...

* error handling improvements

* if special error type ... then add it to swagger too

* one smal nit

* invalidTopicsError is []string

* valid swagger specification 2.0
 - if you add responses swagger can tell you if you do it right 👍

* use ctx.InternalServerError

* Revert "use numbers and not http.Status___ enum"

This reverts commit b1ff386e24.

* use http.Status* enum everywhere
This commit is contained in:
6543
2019-12-20 18:07:12 +01:00
committed by Lauris BH
parent 050a8af424
commit 2848c5eb8f
52 changed files with 1262 additions and 648 deletions

View File

@@ -5,6 +5,8 @@
package repo
import (
"net/http"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/repofiles"
)
@@ -50,15 +52,17 @@ func GetTree(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/GitTreeResponse"
// "400":
// "$ref": "#/responses/error"
sha := ctx.Params(":sha")
if len(sha) == 0 {
ctx.Error(400, "", "sha not provided")
ctx.Error(http.StatusBadRequest, "", "sha not provided")
return
}
if tree, err := repofiles.GetTreeBySHA(ctx.Repo.Repository, sha, ctx.QueryInt("page"), ctx.QueryInt("per_page"), ctx.QueryBool("recursive")); err != nil {
ctx.Error(400, "", err.Error())
ctx.Error(http.StatusBadRequest, "", err.Error())
} else {
ctx.JSON(200, tree)
ctx.JSON(http.StatusOK, tree)
}
}