mirror of
https://github.com/go-gitea/gitea.git
synced 2026-11-02 13:44:16 +09:00
refactor: use default error response for swagger (#40048)
ref: https://github.com/go-gitea/gitea/pull/39942#discussion_r4393487959
This commit is contained in:
1 parent
30e5ef4228
commit
5671c5192d
93 files changed
+2600
-6894
No files matched your search
@@ -44,10 +44,8 @@ func CreateOrUpdateSecret(ctx *context.APIContext) {
|
||||
// description: response when creating a secret
|
||||
// "204":
|
||||
// description: response when updating a secret
|
||||
// "400":
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
|
||||
opt := web.GetForm[*api.CreateOrUpdateSecretOption](ctx)
|
||||
|
||||
@@ -88,10 +86,8 @@ func DeleteSecret(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "204":
|
||||
// description: delete one secret of the user
|
||||
// "400":
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
|
||||
s, err := secret_service.DeleteSecretByName(ctx, actions_model.BelongingScopeOwner(ctx.Doer.ID), ctx.PathParam("secretname"))
|
||||
if err != nil {
|
||||
@@ -126,10 +122,8 @@ func CreateVariable(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "201":
|
||||
// description: successfully created the user-level variable
|
||||
// "400":
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
// "409":
|
||||
// description: variable name already exists.
|
||||
|
||||
opt := web.GetForm[*api.CreateVariableOption](ctx)
|
||||
|
||||
@@ -181,10 +175,8 @@ func UpdateVariable(ctx *context.APIContext) {
|
||||
// description: response when updating a variable
|
||||
// "204":
|
||||
// description: response when updating a variable
|
||||
// "400":
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
|
||||
opt := web.GetForm[*api.UpdateVariableOption](ctx)
|
||||
|
||||
@@ -231,10 +223,8 @@ func DeleteVariable(ctx *context.APIContext) {
|
||||
// description: response when deleting a variable
|
||||
// "204":
|
||||
// description: response when deleting a variable
|
||||
// "400":
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
|
||||
if err := actions_service.DeleteVariableByName(ctx, actions_model.BelongingScopeOwner(ctx.Doer.ID), ctx.PathParam("variablename")); err != nil {
|
||||
ctx.APIErrorAuto(err)
|
||||
@@ -260,10 +250,8 @@ func GetVariable(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/ActionVariable"
|
||||
// "400":
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
|
||||
v, err := actions_service.GetVariable(ctx, actions_model.FindVariablesOpts{
|
||||
BelongingScope: actions_model.BelongingScopeOwner(ctx.Doer.ID),
|
||||
@@ -304,10 +292,8 @@ func ListVariables(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/VariableList"
|
||||
// "400":
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
listOptions := utils.GetListOptions(ctx)
|
||||
vars, count, err := db.FindAndCount[actions_model.ActionVariable](ctx, &actions_model.FindVariablesOpts{
|
||||
BelongingScope: actions_model.BelongingScopeOwner(ctx.Doer.ID),
|
||||
@@ -378,10 +364,8 @@ func ListWorkflowRuns(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/WorkflowRunsList"
|
||||
// "400":
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
shared.ListRuns(ctx, ctx.Doer.ID, 0, "")
|
||||
}
|
||||
|
||||
@@ -417,12 +401,8 @@ func ListWorkflowJobs(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/WorkflowJobsList"
|
||||
// "400":
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// "422":
|
||||
// "$ref": "#/responses/validationError"
|
||||
|
||||
shared.ListJobs(ctx, ctx.Doer.ID, 0, 0, nil)
|
||||
}
|
||||
+10
-18
@@ -47,8 +47,8 @@ func ListAccessTokens(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/AccessTokenList"
|
||||
// "403":
|
||||
// "$ref": "#/responses/forbidden"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
opts := auth_model.ListAccessTokensOptions{UserID: ctx.ContextUser.ID, ListOptions: utils.GetListOptions(ctx)}
|
||||
|
||||
@@ -96,10 +96,8 @@ func CreateAccessToken(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "201":
|
||||
// "$ref": "#/responses/AccessToken"
|
||||
// "400":
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
// "403":
|
||||
// "$ref": "#/responses/forbidden"
|
||||
|
||||
form := web.GetForm[*api.CreateAccessTokenOption](ctx)
|
||||
|
||||
@@ -185,11 +183,7 @@ func DeleteAccessToken(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "204":
|
||||
// "$ref": "#/responses/empty"
|
||||
// "403":
|
||||
// "$ref": "#/responses/forbidden"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// "422":
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
token := ctx.PathParam("id")
|
||||
@@ -249,7 +243,7 @@ func CreateOauth2Application(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "201":
|
||||
// "$ref": "#/responses/OAuth2Application"
|
||||
// "400":
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
data := web.GetForm[*api.CreateOAuth2ApplicationOptions](ctx)
|
||||
@@ -336,8 +330,8 @@ func DeleteOauth2Application(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "204":
|
||||
// "$ref": "#/responses/empty"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
appID := ctx.PathParamInt64("id")
|
||||
app, err := auth_model.GetOAuth2ApplicationByID(ctx, appID)
|
||||
if err != nil {
|
||||
@@ -379,8 +373,8 @@ func GetOauth2Application(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/OAuth2Application"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
appID := ctx.PathParamInt64("id")
|
||||
app, err := auth_model.GetOAuth2ApplicationByID(ctx, appID)
|
||||
if err != nil {
|
||||
@@ -423,10 +417,8 @@ func UpdateOauth2Application(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/OAuth2Application"
|
||||
// "400":
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
appID := ctx.PathParamInt64("id")
|
||||
|
||||
data := web.GetForm[*api.CreateOAuth2ApplicationOptions](ctx)
|
||||
|
||||
@@ -43,8 +43,8 @@ func CheckUserBlock(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "204":
|
||||
// "$ref": "#/responses/empty"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
shared.CheckUserBlock(ctx, ctx.Doer)
|
||||
}
|
||||
@@ -66,10 +66,8 @@ func BlockUser(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "204":
|
||||
// "$ref": "#/responses/empty"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// "422":
|
||||
// "$ref": "#/responses/validationError"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
shared.BlockUser(ctx, ctx.Doer)
|
||||
}
|
||||
@@ -87,10 +85,8 @@ func UnblockUser(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "204":
|
||||
// "$ref": "#/responses/empty"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// "422":
|
||||
// "$ref": "#/responses/validationError"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
shared.UnblockUser(ctx, ctx.Doer, ctx.Doer)
|
||||
}
|
||||
@@ -54,12 +54,8 @@ func AddEmail(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// '201':
|
||||
// "$ref": "#/responses/EmailList"
|
||||
// "400":
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
// "409":
|
||||
// "$ref": "#/responses/error"
|
||||
// "422":
|
||||
// "$ref": "#/responses/validationError"
|
||||
|
||||
if user_model.IsFeatureDisabledWithLoginType(ctx.Doer, setting.UserFeatureManageCredentials) {
|
||||
ctx.APIErrorNotFound("emails are not allowed to be changed")
|
||||
@@ -105,8 +101,8 @@ func DeleteEmail(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "204":
|
||||
// "$ref": "#/responses/empty"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
if user_model.IsFeatureDisabledWithLoginType(ctx.Doer, setting.UserFeatureManageCredentials) {
|
||||
ctx.APIErrorNotFound("emails are not allowed to be changed")
|
||||
|
||||
@@ -83,8 +83,8 @@ func ListFollowers(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/UserList"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
listUserFollowers(ctx, ctx.ContextUser)
|
||||
}
|
||||
@@ -149,8 +149,8 @@ func ListFollowing(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/UserList"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
listUserFollowing(ctx, ctx.ContextUser)
|
||||
}
|
||||
@@ -177,8 +177,8 @@ func CheckMyFollowing(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "204":
|
||||
// "$ref": "#/responses/empty"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
checkUserFollowing(ctx, ctx.Doer, ctx.ContextUser.ID)
|
||||
}
|
||||
@@ -202,8 +202,8 @@ func CheckFollowing(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "204":
|
||||
// "$ref": "#/responses/empty"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
target := GetUserByPathParam(ctx, "target") // FIXME: it is not right to call this function, it should load the "target" directly
|
||||
if ctx.Written() {
|
||||
@@ -226,10 +226,8 @@ func Follow(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "204":
|
||||
// "$ref": "#/responses/empty"
|
||||
// "403":
|
||||
// "$ref": "#/responses/forbidden"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
if err := user_model.FollowUser(ctx, ctx.Doer, ctx.ContextUser); err != nil {
|
||||
if errors.Is(err, user_model.ErrBlockedUser) {
|
||||
@@ -256,8 +254,8 @@ func Unfollow(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "204":
|
||||
// "$ref": "#/responses/empty"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
if err := user_model.UnfollowUser(ctx, ctx.Doer.ID, ctx.ContextUser.ID); err != nil {
|
||||
ctx.APIErrorInternal(err)
|
||||
|
||||
@@ -66,8 +66,8 @@ func ListGPGKeys(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/GPGKeyList"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
listGPGKeys(ctx, ctx.ContextUser.ID, utils.GetListOptions(ctx))
|
||||
}
|
||||
@@ -91,10 +91,8 @@ func ListMyGPGKeys(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/GPGKeyList"
|
||||
// "401":
|
||||
// "$ref": "#/responses/unauthorized"
|
||||
// "403":
|
||||
// "$ref": "#/responses/forbidden"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
listGPGKeys(ctx, ctx.Doer.ID, utils.GetListOptions(ctx))
|
||||
}
|
||||
@@ -116,12 +114,8 @@ func GetGPGKey(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/GPGKey"
|
||||
// "401":
|
||||
// "$ref": "#/responses/unauthorized"
|
||||
// "403":
|
||||
// "$ref": "#/responses/forbidden"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
key, err := asymkey_model.GetGPGKeyForUserByID(ctx, ctx.Doer.ID, ctx.PathParamInt64("id"))
|
||||
if err != nil {
|
||||
@@ -171,12 +165,8 @@ func GetVerificationToken(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/string"
|
||||
// "401":
|
||||
// "$ref": "#/responses/unauthorized"
|
||||
// "403":
|
||||
// "$ref": "#/responses/forbidden"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
token := asymkey_model.VerificationToken(ctx.Doer, 1)
|
||||
ctx.PlainText(http.StatusOK, token)
|
||||
@@ -194,14 +184,8 @@ func VerifyUserGPGKey(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "201":
|
||||
// "$ref": "#/responses/GPGKey"
|
||||
// "401":
|
||||
// "$ref": "#/responses/unauthorized"
|
||||
// "403":
|
||||
// "$ref": "#/responses/forbidden"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// "422":
|
||||
// "$ref": "#/responses/validationError"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
form := web.GetForm[*api.VerifyGPGKeyOption](ctx)
|
||||
token := asymkey_model.VerificationToken(ctx.Doer, 1)
|
||||
@@ -259,14 +243,8 @@ func CreateGPGKey(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "201":
|
||||
// "$ref": "#/responses/GPGKey"
|
||||
// "401":
|
||||
// "$ref": "#/responses/unauthorized"
|
||||
// "403":
|
||||
// "$ref": "#/responses/forbidden"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// "422":
|
||||
// "$ref": "#/responses/validationError"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
form := web.GetForm[*api.CreateGPGKeyOption](ctx)
|
||||
CreateUserGPGKey(ctx, *form, ctx.Doer.ID)
|
||||
@@ -289,12 +267,8 @@ func DeleteGPGKey(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "204":
|
||||
// "$ref": "#/responses/empty"
|
||||
// "401":
|
||||
// "$ref": "#/responses/unauthorized"
|
||||
// "403":
|
||||
// "$ref": "#/responses/forbidden"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
if user_model.IsFeatureDisabledWithLoginType(ctx.Doer, setting.UserFeatureManageGPGKeys) {
|
||||
ctx.APIErrorNotFound("gpg keys setting is not allowed to be changed")
|
||||
|
||||
+10
-24
@@ -121,10 +121,8 @@ func ListMyPublicKeys(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/PublicKeyList"
|
||||
// "401":
|
||||
// "$ref": "#/responses/unauthorized"
|
||||
// "403":
|
||||
// "$ref": "#/responses/forbidden"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
listPublicKeys(ctx, ctx.Doer)
|
||||
}
|
||||
@@ -157,8 +155,8 @@ func ListPublicKeys(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/PublicKeyList"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
listPublicKeys(ctx, ctx.ContextUser)
|
||||
}
|
||||
@@ -180,12 +178,8 @@ func GetPublicKey(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/PublicKey"
|
||||
// "401":
|
||||
// "$ref": "#/responses/unauthorized"
|
||||
// "403":
|
||||
// "$ref": "#/responses/forbidden"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
key, err := asymkey_model.GetPublicKeyByID(ctx, ctx.PathParamInt64("id"))
|
||||
if err != nil {
|
||||
@@ -248,12 +242,8 @@ func CreatePublicKey(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "201":
|
||||
// "$ref": "#/responses/PublicKey"
|
||||
// "401":
|
||||
// "$ref": "#/responses/unauthorized"
|
||||
// "403":
|
||||
// "$ref": "#/responses/forbidden"
|
||||
// "422":
|
||||
// "$ref": "#/responses/validationError"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
form := web.GetForm[*api.CreateKeyOption](ctx)
|
||||
CreateUserPublicKey(ctx, *form, ctx.Doer.ID)
|
||||
@@ -276,12 +266,8 @@ func DeletePublicKey(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "204":
|
||||
// "$ref": "#/responses/empty"
|
||||
// "401":
|
||||
// "$ref": "#/responses/unauthorized"
|
||||
// "403":
|
||||
// "$ref": "#/responses/forbidden"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
if user_model.IsFeatureDisabledWithLoginType(ctx.Doer, setting.UserFeatureManageSSHKeys) {
|
||||
ctx.APIErrorNotFound("ssh keys setting is not allowed to be changed")
|
||||
|
||||
@@ -77,8 +77,8 @@ func ListUserRepos(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/RepositoryList"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
listUserRepos(ctx, ctx.ContextUser, ctx.IsSigned)
|
||||
}
|
||||
@@ -159,8 +159,8 @@ func ListOrgRepos(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/RepositoryList"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
listUserRepos(ctx, ctx.Org.Organization.AsUser(), ctx.IsSigned)
|
||||
}
|
||||
@@ -41,10 +41,8 @@ func ListRunners(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/RunnerList"
|
||||
// "400":
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
shared.ListRunners(ctx, ctx.Doer.ID, 0)
|
||||
}
|
||||
|
||||
@@ -64,10 +62,8 @@ func GetRunner(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/Runner"
|
||||
// "400":
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
shared.GetRunner(ctx, ctx.Doer.ID, 0, ctx.PathParamInt64("runner_id"))
|
||||
}
|
||||
|
||||
@@ -87,10 +83,8 @@ func DeleteRunner(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "204":
|
||||
// description: runner has been deleted
|
||||
// "400":
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
shared.DeleteRunner(ctx, ctx.Doer.ID, 0, ctx.PathParamInt64("runner_id"))
|
||||
}
|
||||
|
||||
@@ -116,11 +110,7 @@ func UpdateRunner(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/Runner"
|
||||
// "400":
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// "422":
|
||||
// "$ref": "#/responses/validationError"
|
||||
shared.UpdateRunner(ctx, ctx.Doer.ID, 0, ctx.PathParamInt64("runner_id"))
|
||||
}
|
||||
+10
-18
@@ -70,10 +70,8 @@ func GetStarredRepos(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/RepositoryList"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// "403":
|
||||
// "$ref": "#/responses/forbidden"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
private := ctx.ContextUser.ID == ctx.Doer.ID
|
||||
repos, err := getStarredRepos(ctx, ctx.ContextUser, private)
|
||||
@@ -106,8 +104,8 @@ func GetMyStarredRepos(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/RepositoryList"
|
||||
// "403":
|
||||
// "$ref": "#/responses/forbidden"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
repos, err := getStarredRepos(ctx, ctx.Doer, true)
|
||||
if err != nil {
|
||||
@@ -138,10 +136,8 @@ func IsStarring(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "204":
|
||||
// "$ref": "#/responses/empty"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// "403":
|
||||
// "$ref": "#/responses/forbidden"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
if repo_model.IsStaring(ctx, ctx.Doer.ID, ctx.Repo.Repository.ID) {
|
||||
ctx.Status(http.StatusNoContent)
|
||||
@@ -169,10 +165,8 @@ func Star(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "204":
|
||||
// "$ref": "#/responses/empty"
|
||||
// "403":
|
||||
// "$ref": "#/responses/forbidden"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
err := repo_model.StarRepo(ctx, ctx.Doer, ctx.Repo.Repository, true)
|
||||
if err != nil {
|
||||
@@ -205,10 +199,8 @@ func Unstar(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "204":
|
||||
// "$ref": "#/responses/empty"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// "403":
|
||||
// "$ref": "#/responses/forbidden"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
err := repo_model.StarRepo(ctx, ctx.Doer, ctx.Repo.Repository, false)
|
||||
if err != nil {
|
||||
|
||||
@@ -109,8 +109,8 @@ func GetInfo(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/User"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
if !user_model.IsUserVisibleToViewer(ctx, ctx.ContextUser, ctx.Doer) {
|
||||
// fake ErrUserNotExist error message to not leak information about existence
|
||||
@@ -150,8 +150,8 @@ func GetUserHeatmapData(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/UserHeatmapData"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
heatmap, err := activities_model.GetUserHeatmapDataByUser(ctx, ctx.ContextUser, ctx.Doer)
|
||||
if err != nil {
|
||||
@@ -193,8 +193,8 @@ func ListUserActivityFeeds(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/ActivityFeedsList"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
includePrivate := ctx.IsSigned && (ctx.Doer.IsAdmin || ctx.Doer.ID == ctx.ContextUser.ID)
|
||||
listOptions := utils.GetListOptions(ctx)
|
||||
|
||||
@@ -65,8 +65,8 @@ func GetWatchedRepos(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/RepositoryList"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
private := ctx.ContextUser.ID == ctx.Doer.ID
|
||||
repos, total, err := getWatchedRepos(ctx, ctx.ContextUser, private)
|
||||
@@ -128,8 +128,8 @@ func IsWatching(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/WatchInfo"
|
||||
// "404":
|
||||
// description: User is not watching this repo or repo do not exist
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
if repo_model.IsWatchingRepo(ctx, ctx.Doer.ID, ctx.Repo.Repository.ID) {
|
||||
ctx.JSON(http.StatusOK, api.WatchInfo{
|
||||
@@ -164,10 +164,8 @@ func Watch(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/WatchInfo"
|
||||
// "403":
|
||||
// "$ref": "#/responses/forbidden"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
err := repo_model.WatchRepoAuto(ctx, ctx.Doer, ctx.Repo.Repository, true)
|
||||
if err != nil {
|
||||
@@ -207,8 +205,8 @@ func Unwatch(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "204":
|
||||
// "$ref": "#/responses/empty"
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
// default:
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
err := repo_model.WatchRepoAuto(ctx, ctx.Doer, ctx.Repo.Repository, false)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user