1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-25 11:48:37 +00:00

fix: return 201 Created for CreateVariable API responses (#34517)

- Change CreateVariable API response status from 204 No Content to 201
Created
- Update related integration tests to expect 201 Created instead of 204
No Content

## ⚠️ BREAKING ⚠️

Change the response status code of the Create Variable API under both
Org and Repo levels to `201` instead of 204.

API SDK: https://gitea.com/gitea/go-sdk/pulls/713

---------

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Signed-off-by: appleboy <appleboy.tw@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
This commit is contained in:
Bo-Yi Wu
2025-05-27 00:12:49 +08:00
committed by GitHub
parent 9b295e984a
commit 11ee7ff3bf
6 changed files with 37 additions and 42 deletions

View File

@@ -127,13 +127,11 @@ func CreateVariable(ctx *context.APIContext) {
// "$ref": "#/definitions/CreateVariableOption"
// responses:
// "201":
// description: response when creating a variable
// "204":
// description: response when creating a variable
// description: successfully created the user-level variable
// "400":
// "$ref": "#/responses/error"
// "404":
// "$ref": "#/responses/notFound"
// "409":
// description: variable name already exists.
opt := web.GetForm(ctx).(*api.CreateVariableOption)
@@ -162,7 +160,7 @@ func CreateVariable(ctx *context.APIContext) {
return
}
ctx.Status(http.StatusNoContent)
ctx.Status(http.StatusCreated)
}
// UpdateVariable update a user-level variable which is created by current doer