API: GetReleaseByID return 404 if not found (#12933)
* API: GetReleaseByID return 404 if not found * update swagger docs
This commit is contained in:
		
							parent
							
								
									ba20dd7a7b
								
							
						
					
					
						commit
						efebb824ac
					
				
					 2 changed files with 24 additions and 2 deletions
				
			
		|  | @ -41,17 +41,21 @@ func GetRelease(ctx *context.APIContext) { | ||||||
| 	// responses:
 | 	// responses:
 | ||||||
| 	//   "200":
 | 	//   "200":
 | ||||||
| 	//     "$ref": "#/responses/Release"
 | 	//     "$ref": "#/responses/Release"
 | ||||||
|  | 	//   "404":
 | ||||||
|  | 	//     "$ref": "#/responses/notFound"
 | ||||||
| 
 | 
 | ||||||
| 	id := ctx.ParamsInt64(":id") | 	id := ctx.ParamsInt64(":id") | ||||||
| 	release, err := models.GetReleaseByID(id) | 	release, err := models.GetReleaseByID(id) | ||||||
| 	if err != nil { | 	if err != nil && !models.IsErrReleaseNotExist(err) { | ||||||
| 		ctx.Error(http.StatusInternalServerError, "GetReleaseByID", err) | 		ctx.Error(http.StatusInternalServerError, "GetReleaseByID", err) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 	if release.RepoID != ctx.Repo.Repository.ID { | 	if err != nil && models.IsErrReleaseNotExist(err) || | ||||||
|  | 		release.IsTag || release.RepoID != ctx.Repo.Repository.ID { | ||||||
| 		ctx.NotFound() | 		ctx.NotFound() | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
|  | 
 | ||||||
| 	if err := release.LoadAttributes(); err != nil { | 	if err := release.LoadAttributes(); err != nil { | ||||||
| 		ctx.Error(http.StatusInternalServerError, "LoadAttributes", err) | 		ctx.Error(http.StatusInternalServerError, "LoadAttributes", err) | ||||||
| 		return | 		return | ||||||
|  | @ -145,6 +149,8 @@ func CreateRelease(ctx *context.APIContext, form api.CreateReleaseOption) { | ||||||
| 	// responses:
 | 	// responses:
 | ||||||
| 	//   "201":
 | 	//   "201":
 | ||||||
| 	//     "$ref": "#/responses/Release"
 | 	//     "$ref": "#/responses/Release"
 | ||||||
|  | 	//   "404":
 | ||||||
|  | 	//     "$ref": "#/responses/notFound"
 | ||||||
| 	//   "409":
 | 	//   "409":
 | ||||||
| 	//     "$ref": "#/responses/error"
 | 	//     "$ref": "#/responses/error"
 | ||||||
| 
 | 
 | ||||||
|  | @ -235,6 +241,8 @@ func EditRelease(ctx *context.APIContext, form api.EditReleaseOption) { | ||||||
| 	// responses:
 | 	// responses:
 | ||||||
| 	//   "200":
 | 	//   "200":
 | ||||||
| 	//     "$ref": "#/responses/Release"
 | 	//     "$ref": "#/responses/Release"
 | ||||||
|  | 	//   "404":
 | ||||||
|  | 	//     "$ref": "#/responses/notFound"
 | ||||||
| 
 | 
 | ||||||
| 	id := ctx.ParamsInt64(":id") | 	id := ctx.ParamsInt64(":id") | ||||||
| 	rel, err := models.GetReleaseByID(id) | 	rel, err := models.GetReleaseByID(id) | ||||||
|  | @ -308,6 +316,8 @@ func DeleteRelease(ctx *context.APIContext) { | ||||||
| 	// responses:
 | 	// responses:
 | ||||||
| 	//   "204":
 | 	//   "204":
 | ||||||
| 	//     "$ref": "#/responses/empty"
 | 	//     "$ref": "#/responses/empty"
 | ||||||
|  | 	//   "404":
 | ||||||
|  | 	//     "$ref": "#/responses/notFound"
 | ||||||
| 
 | 
 | ||||||
| 	id := ctx.ParamsInt64(":id") | 	id := ctx.ParamsInt64(":id") | ||||||
| 	rel, err := models.GetReleaseByID(id) | 	rel, err := models.GetReleaseByID(id) | ||||||
|  |  | ||||||
|  | @ -7563,6 +7563,9 @@ | ||||||
|           "201": { |           "201": { | ||||||
|             "$ref": "#/responses/Release" |             "$ref": "#/responses/Release" | ||||||
|           }, |           }, | ||||||
|  |           "404": { | ||||||
|  |             "$ref": "#/responses/notFound" | ||||||
|  |           }, | ||||||
|           "409": { |           "409": { | ||||||
|             "$ref": "#/responses/error" |             "$ref": "#/responses/error" | ||||||
|           } |           } | ||||||
|  | @ -7606,6 +7609,9 @@ | ||||||
|         "responses": { |         "responses": { | ||||||
|           "200": { |           "200": { | ||||||
|             "$ref": "#/responses/Release" |             "$ref": "#/responses/Release" | ||||||
|  |           }, | ||||||
|  |           "404": { | ||||||
|  |             "$ref": "#/responses/notFound" | ||||||
|           } |           } | ||||||
|         } |         } | ||||||
|       }, |       }, | ||||||
|  | @ -7642,6 +7648,9 @@ | ||||||
|         "responses": { |         "responses": { | ||||||
|           "204": { |           "204": { | ||||||
|             "$ref": "#/responses/empty" |             "$ref": "#/responses/empty" | ||||||
|  |           }, | ||||||
|  |           "404": { | ||||||
|  |             "$ref": "#/responses/notFound" | ||||||
|           } |           } | ||||||
|         } |         } | ||||||
|       }, |       }, | ||||||
|  | @ -7691,6 +7700,9 @@ | ||||||
|         "responses": { |         "responses": { | ||||||
|           "200": { |           "200": { | ||||||
|             "$ref": "#/responses/Release" |             "$ref": "#/responses/Release" | ||||||
|  |           }, | ||||||
|  |           "404": { | ||||||
|  |             "$ref": "#/responses/notFound" | ||||||
|           } |           } | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue