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

@ -7,6 +7,7 @@ package repo
import (
"math"
"net/http"
"strconv"
"time"
@ -64,7 +65,7 @@ func GetSingleCommit(ctx *context.APIContext) {
return
}
ctx.JSON(200, json)
ctx.JSON(http.StatusOK, json)
}
// GetAllCommits get all commits via
@ -102,7 +103,7 @@ func GetAllCommits(ctx *context.APIContext) {
// "$ref": "#/responses/EmptyRepository"
if ctx.Repo.Repository.IsEmpty {
ctx.JSON(409, api.APIError{
ctx.JSON(http.StatusConflict, api.APIError{
Message: "Git Repository is empty.",
URL: setting.API.SwaggerURL,
})
@ -188,7 +189,7 @@ func GetAllCommits(ctx *context.APIContext) {
ctx.Header().Set("X-PageCount", strconv.Itoa(pageCount))
ctx.Header().Set("X-HasMore", strconv.FormatBool(page < pageCount))
ctx.JSON(200, &apiCommits)
ctx.JSON(http.StatusOK, &apiCommits)
}
func toCommit(ctx *context.APIContext, repo *models.Repository, commit *git.Commit, userCache map[string]*models.User) (*api.Commit, error) {