aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-09-25 00:36:56 +0200
committerGitHub <noreply@github.com>2020-09-24 18:36:56 -0400
commitefebb824ac9fc6717d89daa0542f03534451a532 (patch)
tree9e0000b9503335da835d344d4a43731b6ae976f4 /routers
parentba20dd7a7b59157d9232de7dfa99a23b0fb0d2aa (diff)
downloadgitea-efebb824ac9fc6717d89daa0542f03534451a532.tar.gz
gitea-efebb824ac9fc6717d89daa0542f03534451a532.zip
API: GetReleaseByID return 404 if not found (#12933)
* API: GetReleaseByID return 404 if not found * update swagger docs
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/repo/release.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/routers/api/v1/repo/release.go b/routers/api/v1/repo/release.go
index e7cc1e8671..c2ed1fe024 100644
--- a/routers/api/v1/repo/release.go
+++ b/routers/api/v1/repo/release.go
@@ -41,17 +41,21 @@ func GetRelease(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/Release"
+ // "404":
+ // "$ref": "#/responses/notFound"
id := ctx.ParamsInt64(":id")
release, err := models.GetReleaseByID(id)
- if err != nil {
+ if err != nil && !models.IsErrReleaseNotExist(err) {
ctx.Error(http.StatusInternalServerError, "GetReleaseByID", err)
return
}
- if release.RepoID != ctx.Repo.Repository.ID {
+ if err != nil && models.IsErrReleaseNotExist(err) ||
+ release.IsTag || release.RepoID != ctx.Repo.Repository.ID {
ctx.NotFound()
return
}
+
if err := release.LoadAttributes(); err != nil {
ctx.Error(http.StatusInternalServerError, "LoadAttributes", err)
return
@@ -145,6 +149,8 @@ func CreateRelease(ctx *context.APIContext, form api.CreateReleaseOption) {
// responses:
// "201":
// "$ref": "#/responses/Release"
+ // "404":
+ // "$ref": "#/responses/notFound"
// "409":
// "$ref": "#/responses/error"
@@ -235,6 +241,8 @@ func EditRelease(ctx *context.APIContext, form api.EditReleaseOption) {
// responses:
// "200":
// "$ref": "#/responses/Release"
+ // "404":
+ // "$ref": "#/responses/notFound"
id := ctx.ParamsInt64(":id")
rel, err := models.GetReleaseByID(id)
@@ -308,6 +316,8 @@ func DeleteRelease(ctx *context.APIContext) {
// responses:
// "204":
// "$ref": "#/responses/empty"
+ // "404":
+ // "$ref": "#/responses/notFound"
id := ctx.ParamsInt64(":id")
rel, err := models.GetReleaseByID(id)