diff options
author | 6543 <6543@obermui.de> | 2019-12-20 18:07:12 +0100 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2019-12-20 19:07:12 +0200 |
commit | 2848c5eb8f7333b6791afd296b12d21751d0516b (patch) | |
tree | 67ff6244026174116edbff1b4c4cdb5934401968 /routers/api/v1/repo/tree.go | |
parent | 050a8af4243d7f5fff0a2f492b9166f4dfdf0ecf (diff) | |
download | gitea-2848c5eb8f7333b6791afd296b12d21751d0516b.tar.gz gitea-2848c5eb8f7333b6791afd296b12d21751d0516b.zip |
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 :+1:
* use ctx.InternalServerError
* Revert "use numbers and not http.Status___ enum"
This reverts commit b1ff386e2418ed6a7f183e756b13277d701278ef.
* use http.Status* enum everywhere
Diffstat (limited to 'routers/api/v1/repo/tree.go')
-rw-r--r-- | routers/api/v1/repo/tree.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/routers/api/v1/repo/tree.go b/routers/api/v1/repo/tree.go index 066ca662f8..987f2fb808 100644 --- a/routers/api/v1/repo/tree.go +++ b/routers/api/v1/repo/tree.go @@ -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) } } |