diff --git a/docs/guidelines-backend.md b/docs/guidelines-backend.md index b46f9214ad1..4c6421a838a 100644 --- a/docs/guidelines-backend.md +++ b/docs/guidelines-backend.md @@ -140,8 +140,8 @@ breaking v1. ### Adding and maintaining API routes -- All possible results (errors, success, and failure messages) must be documented in - the swagger comments on the route. +- Document success responses in the swagger comments on the route. Replace explicit + error responses with a `default` response referencing `#/responses/error`. - Every JSON request body must be defined as a struct in `modules/structs/` and registered in [`routers/api/v1/swagger/options.go`](../routers/api/v1/swagger/options.go). - Every JSON response must be defined as a struct in `modules/structs/` and diff --git a/routers/api/v1/admin/action.go b/routers/api/v1/admin/action.go index 38e9cc314ed..12e0d69298e 100644 --- a/routers/api/v1/admin/action.go +++ b/routers/api/v1/admin/action.go @@ -40,12 +40,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, 0, 0, 0, nil) } @@ -94,10 +90,8 @@ func ListWorkflowRuns(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/WorkflowRunsList" - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" shared.ListRuns(ctx, 0, 0, "") } diff --git a/routers/api/v1/admin/adopt.go b/routers/api/v1/admin/adopt.go index 2bc8ddc4bd6..fec4f3eebd2 100644 --- a/routers/api/v1/admin/adopt.go +++ b/routers/api/v1/admin/adopt.go @@ -38,8 +38,8 @@ func ListUnadoptedRepositories(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/StringSlice" - // "403": - // "$ref": "#/responses/forbidden" + // default: + // "$ref": "#/responses/error" listOptions := utils.GetListOptions(ctx) if listOptions.Page == 0 { @@ -77,10 +77,8 @@ func AdoptRepository(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "404": - // "$ref": "#/responses/notFound" - // "403": - // "$ref": "#/responses/forbidden" + // default: + // "$ref": "#/responses/error" ownerName := ctx.PathParam("username") repoName := ctx.PathParam("reponame") @@ -141,8 +139,8 @@ func DeleteUnadoptedRepository(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "403": - // "$ref": "#/responses/forbidden" + // default: + // "$ref": "#/responses/error" ownerName := ctx.PathParam("username") repoName := ctx.PathParam("reponame") diff --git a/routers/api/v1/admin/cron.go b/routers/api/v1/admin/cron.go index 58c48757644..525a147232d 100644 --- a/routers/api/v1/admin/cron.go +++ b/routers/api/v1/admin/cron.go @@ -33,8 +33,8 @@ func ListCronTasks(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/CronList" - // "403": - // "$ref": "#/responses/forbidden" + // default: + // "$ref": "#/responses/error" tasks := cron.ListTasks() count := len(tasks) @@ -72,8 +72,8 @@ func PostCronTask(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" task := cron.GetTask(ctx.PathParam("task")) if task == nil { ctx.APIErrorNotFound() diff --git a/routers/api/v1/admin/email.go b/routers/api/v1/admin/email.go index 358e350fca4..96d64a303ce 100644 --- a/routers/api/v1/admin/email.go +++ b/routers/api/v1/admin/email.go @@ -32,8 +32,8 @@ func GetAllEmails(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/EmailList" - // "403": - // "$ref": "#/responses/forbidden" + // default: + // "$ref": "#/responses/error" listOptions := utils.GetListOptions(ctx) @@ -79,8 +79,8 @@ func SearchEmail(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/EmailList" - // "403": - // "$ref": "#/responses/forbidden" + // default: + // "$ref": "#/responses/error" ctx.SetPathParam("email", ctx.FormTrim("q")) GetAllEmails(ctx) diff --git a/routers/api/v1/admin/org.go b/routers/api/v1/admin/org.go index 236fb8a30d3..aa8e746fad3 100644 --- a/routers/api/v1/admin/org.go +++ b/routers/api/v1/admin/org.go @@ -41,10 +41,8 @@ func CreateOrg(ctx *context.APIContext) { // responses: // "201": // "$ref": "#/responses/Organization" - // "403": - // "$ref": "#/responses/forbidden" - // "422": - // "$ref": "#/responses/validationError" + // default: + // "$ref": "#/responses/error" form := web.GetForm[*api.CreateOrgOption](ctx) @@ -100,8 +98,8 @@ func GetAllOrgs(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/OrganizationList" - // "403": - // "$ref": "#/responses/forbidden" + // default: + // "$ref": "#/responses/error" listOptions := utils.GetListOptions(ctx) diff --git a/routers/api/v1/admin/packages.go b/routers/api/v1/admin/packages.go index 20f87d2d0c5..247b16056aa 100644 --- a/routers/api/v1/admin/packages.go +++ b/routers/api/v1/admin/packages.go @@ -42,8 +42,8 @@ func ListPackages(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/PackageList" - // "403": - // "$ref": "#/responses/forbidden" + // default: + // "$ref": "#/responses/error" listOptions := utils.GetListOptions(ctx) diff --git a/routers/api/v1/admin/repo.go b/routers/api/v1/admin/repo.go index 30d45683a55..3fed82ba484 100644 --- a/routers/api/v1/admin/repo.go +++ b/routers/api/v1/admin/repo.go @@ -32,16 +32,8 @@ func CreateRepo(ctx *context.APIContext) { // responses: // "201": // "$ref": "#/responses/Repository" - // "400": + // default: // "$ref": "#/responses/error" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" - // "409": - // "$ref": "#/responses/error" - // "422": - // "$ref": "#/responses/validationError" form := web.GetForm[*api.CreateRepoOption](ctx) diff --git a/routers/api/v1/admin/runners.go b/routers/api/v1/admin/runners.go index 93af28942c8..92fc6582bbe 100644 --- a/routers/api/v1/admin/runners.go +++ b/routers/api/v1/admin/runners.go @@ -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, 0, 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, 0, 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, 0, 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, 0, 0, ctx.PathParamInt64("runner_id")) } diff --git a/routers/api/v1/admin/user.go b/routers/api/v1/admin/user.go index 0a09493b983..8205b12f2e8 100644 --- a/routers/api/v1/admin/user.go +++ b/routers/api/v1/admin/user.go @@ -70,14 +70,8 @@ func CreateUser(ctx *context.APIContext) { // responses: // "201": // "$ref": "#/responses/User" - // "400": + // default: // "$ref": "#/responses/error" - // "403": - // "$ref": "#/responses/forbidden" - // "409": - // "$ref": "#/responses/error" - // "422": - // "$ref": "#/responses/validationError" form := web.GetForm[*api.CreateUserOption](ctx) @@ -179,14 +173,8 @@ func EditUser(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/User" - // "400": + // default: // "$ref": "#/responses/error" - // "403": - // "$ref": "#/responses/forbidden" - // "409": - // "$ref": "#/responses/error" - // "422": - // "$ref": "#/responses/validationError" form := web.GetForm[*api.EditUserOption](ctx) @@ -282,12 +270,8 @@ func DeleteUser(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" - // "422": - // "$ref": "#/responses/validationError" + // default: + // "$ref": "#/responses/error" if ctx.ContextUser.IsOrganization() { ctx.APIError(http.StatusUnprocessableEntity, "target is an organization but not user") @@ -338,10 +322,8 @@ func CreatePublicKey(ctx *context.APIContext) { // responses: // "201": // "$ref": "#/responses/PublicKey" - // "403": - // "$ref": "#/responses/forbidden" - // "422": - // "$ref": "#/responses/validationError" + // default: + // "$ref": "#/responses/error" form := web.GetForm[*api.CreateKeyOption](ctx) @@ -370,10 +352,8 @@ func DeleteUserPublicKey(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" if err := asymkey_service.DeletePublicKey(ctx, ctx.ContextUser, ctx.PathParamInt64("id")); err != nil { if asymkey_model.IsErrKeyNotExist(err) { @@ -458,10 +438,8 @@ func SearchUsers(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/UserList" - // "403": - // "$ref": "#/responses/forbidden" - // "422": - // "$ref": "#/responses/validationError" + // default: + // "$ref": "#/responses/error" listOptions := utils.GetListOptions(ctx) @@ -544,10 +522,8 @@ func RenameUser(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "403": - // "$ref": "#/responses/forbidden" - // "422": - // "$ref": "#/responses/validationError" + // default: + // "$ref": "#/responses/error" if ctx.ContextUser.IsOrganization() { ctx.APIError(http.StatusUnprocessableEntity, "target is an organization but not user") diff --git a/routers/api/v1/admin/user_badge.go b/routers/api/v1/admin/user_badge.go index 878b763cdbb..ddbcb37345d 100644 --- a/routers/api/v1/admin/user_badge.go +++ b/routers/api/v1/admin/user_badge.go @@ -28,8 +28,8 @@ func ListUserBadges(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/BadgeList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" badges, maxResults, err := user_model.GetUserBadges(ctx, ctx.ContextUser) if err != nil { @@ -63,8 +63,8 @@ func AddUserBadges(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "403": - // "$ref": "#/responses/forbidden" + // default: + // "$ref": "#/responses/error" form := web.GetForm[*api.UserBadgeOption](ctx) badges := prepareBadgesForReplaceOrAdd(*form) @@ -97,10 +97,8 @@ func DeleteUserBadges(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "403": - // "$ref": "#/responses/forbidden" - // "422": - // "$ref": "#/responses/validationError" + // default: + // "$ref": "#/responses/error" form := web.GetForm[*api.UserBadgeOption](ctx) badges := prepareBadgesForReplaceOrAdd(*form) diff --git a/routers/api/v1/misc/gitignore.go b/routers/api/v1/misc/gitignore.go index 6e4800fd588..72b09df78da 100644 --- a/routers/api/v1/misc/gitignore.go +++ b/routers/api/v1/misc/gitignore.go @@ -42,8 +42,8 @@ func GetGitignoreTemplateInfo(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/GitignoreTemplateInfo" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" name := util.PathJoinRelX(ctx.PathParam("name")) text, err := options.Gitignore(name) diff --git a/routers/api/v1/misc/label_templates.go b/routers/api/v1/misc/label_templates.go index 1ddc948b75a..dc2714cd014 100644 --- a/routers/api/v1/misc/label_templates.go +++ b/routers/api/v1/misc/label_templates.go @@ -46,8 +46,8 @@ func GetLabelTemplate(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/LabelTemplateInfo" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" name := util.PathJoinRelX(ctx.PathParam("name")) labels, err := repo_module.LoadTemplateLabelsByDisplayName(name) diff --git a/routers/api/v1/misc/licenses.go b/routers/api/v1/misc/licenses.go index ee3fac131ea..a4bb2ef5995 100644 --- a/routers/api/v1/misc/licenses.go +++ b/routers/api/v1/misc/licenses.go @@ -52,8 +52,8 @@ func GetLicenseTemplateInfo(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/LicenseTemplateInfo" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" name := util.PathJoinRelX(ctx.PathParam("name")) text, err := options.License(name) diff --git a/routers/api/v1/misc/markup.go b/routers/api/v1/misc/markup.go index deef088a4da..48f8d160623 100644 --- a/routers/api/v1/misc/markup.go +++ b/routers/api/v1/misc/markup.go @@ -31,8 +31,8 @@ func Markup(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/MarkupRender" - // "422": - // "$ref": "#/responses/validationError" + // default: + // "$ref": "#/responses/error" form := web.GetForm[*api.MarkupOption](ctx) mode := util.Iif(form.Wiki, "wiki", form.Mode) //nolint:staticcheck // form.Wiki is deprecated @@ -56,8 +56,8 @@ func Markdown(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/MarkdownRender" - // "422": - // "$ref": "#/responses/validationError" + // default: + // "$ref": "#/responses/error" form := web.GetForm[*api.MarkdownOption](ctx) mode := util.Iif(form.Wiki, "wiki", form.Mode) //nolint:staticcheck // form.Wiki is deprecated @@ -83,8 +83,8 @@ func MarkdownRaw(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/MarkdownRender" - // "422": - // "$ref": "#/responses/validationError" + // default: + // "$ref": "#/responses/error" textBytes, _ := io.ReadAll(io.LimitReader(ctx.Req.Body, setting.UI.MaxDisplayFileSize)) common.RenderMarkup(ctx.Base, ctx.Repo, "markdown", util.UnsafeBytesToString(textBytes), "", "") } diff --git a/routers/api/v1/notify/threads.go b/routers/api/v1/notify/threads.go index 7fdf7d7846c..82df2e8b6c9 100644 --- a/routers/api/v1/notify/threads.go +++ b/routers/api/v1/notify/threads.go @@ -33,10 +33,8 @@ func GetThread(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/NotificationThread" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" n := getThread(ctx) if n == nil { @@ -74,10 +72,8 @@ func ReadThread(ctx *context.APIContext) { // responses: // "205": // "$ref": "#/responses/NotificationThread" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" n := getThread(ctx) if n == nil { diff --git a/routers/api/v1/org/action.go b/routers/api/v1/org/action.go index c79830ce0fa..3cc1fe4efe3 100644 --- a/routers/api/v1/org/action.go +++ b/routers/api/v1/org/action.go @@ -45,8 +45,8 @@ func (Action) ListActionsSecrets(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/SecretList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" opts := &secret_model.FindSecretsOptions{ BelongingScope: actions_model.BelongingScopeOwner(ctx.Org.Organization.ID), @@ -102,10 +102,8 @@ func (Action) 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) @@ -151,10 +149,8 @@ func (Action) DeleteSecret(ctx *context.APIContext) { // responses: // "204": // description: delete one secret of the organization - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" s, err := secret_service.DeleteSecretByName(ctx, actions_model.BelongingScopeOwner(ctx.Org.Organization.ID), ctx.PathParam("secretname")) if err != nil { @@ -212,10 +208,8 @@ func (Action) 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{ @@ -263,10 +257,8 @@ func (Action) 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.Org.Organization.ID), @@ -313,10 +305,8 @@ func (Action) 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.Org.Organization.ID), ctx.PathParam("variablename")); err != nil { ctx.APIErrorAuto(err) @@ -353,11 +343,7 @@ func (Action) CreateVariable(ctx *context.APIContext) { // responses: // "201": // description: successfully created the org-level variable - // "400": - // "$ref": "#/responses/error" - // "409": - // description: variable name already exists. - // "500": + // default: // "$ref": "#/responses/error" opt := web.GetForm[*api.CreateVariableOption](ctx) @@ -415,10 +401,8 @@ func (Action) UpdateVariable(ctx *context.APIContext) { // description: response when updating an org-level variable // "204": // description: response when updating an org-level variable - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" opt := web.GetForm[*api.UpdateVariableOption](ctx) @@ -468,10 +452,8 @@ func (Action) ListRunners(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/RunnerList" - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" shared.ListRunners(ctx, ctx.Org.Organization.ID, 0) } @@ -496,10 +478,8 @@ func (Action) GetRunner(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/Runner" - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" shared.GetRunner(ctx, ctx.Org.Organization.ID, 0, ctx.PathParamInt64("runner_id")) } @@ -524,10 +504,8 @@ func (Action) DeleteRunner(ctx *context.APIContext) { // responses: // "204": // description: runner has been deleted - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" shared.DeleteRunner(ctx, ctx.Org.Organization.ID, 0, ctx.PathParamInt64("runner_id")) } @@ -558,12 +536,8 @@ func (Action) 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.Org.Organization.ID, 0, ctx.PathParamInt64("runner_id")) } @@ -595,10 +569,8 @@ func (Action) ListWorkflowJobs(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/WorkflowJobsList" - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" shared.ListJobs(ctx, ctx.Org.Organization.ID, 0, 0, nil) } @@ -650,10 +622,8 @@ func (Action) ListWorkflowRuns(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/WorkflowRunsList" - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" shared.ListRuns(ctx, ctx.Org.Organization.ID, 0, "") } diff --git a/routers/api/v1/org/avatar.go b/routers/api/v1/org/avatar.go index b6a077df663..220c292c55c 100644 --- a/routers/api/v1/org/avatar.go +++ b/routers/api/v1/org/avatar.go @@ -33,8 +33,8 @@ func UpdateAvatar(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" form := web.GetForm[*api.UpdateUserAvatarOption](ctx) content, err := base64.StdEncoding.DecodeString(form.Image) @@ -68,8 +68,8 @@ func DeleteAvatar(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" err := user_service.DeleteAvatar(ctx, ctx.Org.Organization.AsUser()) if err != nil { ctx.APIErrorInternal(err) diff --git a/routers/api/v1/org/block.go b/routers/api/v1/org/block.go index a43a7b5d7a6..6a32e7e6aae 100644 --- a/routers/api/v1/org/block.go +++ b/routers/api/v1/org/block.go @@ -53,8 +53,8 @@ func CheckUserBlock(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" shared.CheckUserBlock(ctx, ctx.Org.Organization.AsUser()) } @@ -81,10 +81,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.Org.Organization.AsUser()) } @@ -107,10 +105,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.Org.Organization.AsUser()) } diff --git a/routers/api/v1/org/hook.go b/routers/api/v1/org/hook.go index cc19781dbc7..86bd970eb3b 100644 --- a/routers/api/v1/org/hook.go +++ b/routers/api/v1/org/hook.go @@ -37,8 +37,8 @@ func ListHooks(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/HookList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" utils.ListOwnerHooks( ctx, @@ -68,8 +68,8 @@ func GetHook(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/Hook" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" hook, err := utils.GetOwnerHook(ctx, ctx.ContextUser.ID, ctx.PathParamInt64("id")) if err != nil { @@ -107,8 +107,8 @@ func CreateHook(ctx *context.APIContext) { // responses: // "201": // "$ref": "#/responses/Hook" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" utils.AddOwnerHook( ctx, @@ -145,8 +145,8 @@ func EditHook(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/Hook" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" utils.EditOwnerHook( ctx, @@ -178,8 +178,8 @@ func DeleteHook(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" utils.DeleteOwnerHook( ctx, diff --git a/routers/api/v1/org/label.go b/routers/api/v1/org/label.go index 0c5c8386996..a2e3629bab0 100644 --- a/routers/api/v1/org/label.go +++ b/routers/api/v1/org/label.go @@ -41,8 +41,8 @@ func ListLabels(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/LabelList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" labels, err := issues_model.GetLabelsByOrgID(ctx, ctx.Org.Organization.ID, ctx.FormString("sort"), utils.GetListOptions(ctx)) if err != nil { @@ -82,10 +82,8 @@ func CreateLabel(ctx *context.APIContext) { // responses: // "201": // "$ref": "#/responses/Label" - // "404": - // "$ref": "#/responses/notFound" - // "422": - // "$ref": "#/responses/validationError" + // default: + // "$ref": "#/responses/error" form := web.GetForm[*api.CreateLabelOption](ctx) form.Color = strings.Trim(form.Color, " ") color, err := label.NormalizeColor(form.Color) @@ -132,8 +130,8 @@ func GetLabel(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/Label" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" var ( label *issues_model.Label @@ -185,10 +183,8 @@ func EditLabel(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/Label" - // "404": - // "$ref": "#/responses/notFound" - // "422": - // "$ref": "#/responses/validationError" + // default: + // "$ref": "#/responses/error" form := web.GetForm[*api.EditLabelOption](ctx) l, err := issues_model.GetLabelInOrgByID(ctx, ctx.Org.Organization.ID, ctx.PathParamInt64("id")) if err != nil { @@ -246,8 +242,8 @@ func DeleteLabel(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" if err := issues_model.DeleteOrgLabel(ctx, ctx.Org.Organization.ID, ctx.PathParamInt64("id")); err != nil { ctx.APIErrorInternal(err) diff --git a/routers/api/v1/org/member.go b/routers/api/v1/org/member.go index 9c66fdad0ed..6f523905fa0 100644 --- a/routers/api/v1/org/member.go +++ b/routers/api/v1/org/member.go @@ -74,8 +74,8 @@ func ListMembers(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/UserList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" var ( isMember bool @@ -116,8 +116,8 @@ func ListPublicMembers(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/UserList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" listMembers(ctx, false) } @@ -143,8 +143,8 @@ func IsMember(ctx *context.APIContext) { // description: user is a member // "303": // description: redirection to /orgs/{org}/public_members/{username} - // "404": - // description: user is not a member + // default: + // "$ref": "#/responses/error" userToCheck := user.GetContextUserByPathParam(ctx) if ctx.Written() { @@ -194,8 +194,8 @@ func IsPublicMember(ctx *context.APIContext) { // responses: // "204": // description: user is a public member - // "404": - // description: user is not a public member + // default: + // "$ref": "#/responses/error" userToCheck := user.GetContextUserByPathParam(ctx) if ctx.Written() { @@ -248,10 +248,8 @@ func PublicizeMember(ctx *context.APIContext) { // responses: // "204": // description: membership publicized - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" userToPublicize := user.GetContextUserByPathParam(ctx) if ctx.Written() { @@ -290,10 +288,8 @@ func ConcealMember(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" userToConceal := user.GetContextUserByPathParam(ctx) if ctx.Written() { @@ -332,8 +328,8 @@ func DeleteMember(ctx *context.APIContext) { // responses: // "204": // description: member removed - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" member := user.GetContextUserByPathParam(ctx) if ctx.Written() { diff --git a/routers/api/v1/org/org.go b/routers/api/v1/org/org.go index 7b17e12773b..9f01428714f 100644 --- a/routers/api/v1/org/org.go +++ b/routers/api/v1/org/org.go @@ -77,8 +77,8 @@ func ListMyOrgs(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/OrganizationList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" listUserOrgs(ctx, ctx.Doer) } @@ -107,8 +107,8 @@ func ListUserOrgs(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/OrganizationList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" listUserOrgs(ctx, ctx.ContextUser) } @@ -134,10 +134,8 @@ func GetUserOrgsPermissions(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/OrganizationPermissions" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" var o *user_model.User if o = user.GetUserByPathParam(ctx, "org"); o == nil { @@ -250,10 +248,8 @@ func Create(ctx *context.APIContext) { // responses: // "201": // "$ref": "#/responses/Organization" - // "403": - // "$ref": "#/responses/forbidden" - // "422": - // "$ref": "#/responses/validationError" + // default: + // "$ref": "#/responses/error" form := web.GetForm[*api.CreateOrgOption](ctx) if !ctx.Doer.CanCreateOrganization() { ctx.APIError(http.StatusForbidden, "not allowed to create org") @@ -310,8 +306,8 @@ func Get(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/Organization" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" if !organization.HasOrgOrUserVisible(ctx, ctx.Org.Organization.AsUser(), ctx.Doer) { ctx.APIErrorNotFound() @@ -348,10 +344,8 @@ func Rename(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "403": - // "$ref": "#/responses/forbidden" - // "422": - // "$ref": "#/responses/validationError" + // default: + // "$ref": "#/responses/error" form := web.GetForm[*api.RenameOrgOption](ctx) orgUser := ctx.Org.Organization.AsUser() @@ -389,8 +383,8 @@ func Edit(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/Organization" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" form := web.GetForm[*api.EditOrgOption](ctx) @@ -435,8 +429,8 @@ func Delete(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" if err := org.DeleteOrganization(ctx, ctx.Org.Organization, false); err != nil { ctx.APIErrorInternal(err) @@ -473,8 +467,8 @@ func ListOrgActivityFeeds(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/ActivityFeedsList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" includePrivate := false if ctx.IsSigned { @@ -554,10 +548,8 @@ func DeleteOrgRepos(ctx *context.APIContext) { // "$ref": "#/responses/empty" // "204": // "$ref": "#/responses/empty" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" // Intentionally it only loads repository IDs to avoid loading too much data into memory // There is no need to do pagination here as the number of repositories is expected to be manageable diff --git a/routers/api/v1/org/team.go b/routers/api/v1/org/team.go index 0dcf95003a3..8bd00976f2b 100644 --- a/routers/api/v1/org/team.go +++ b/routers/api/v1/org/team.go @@ -53,8 +53,8 @@ func ListTeams(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/TeamList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" listOptions := utils.GetListOptions(ctx) opts := &organization.SearchTeamOptions{ @@ -140,8 +140,8 @@ func GetTeam(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/Team" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" apiTeam, err := convert.ToTeam(ctx, ctx.Org.Team, true) if err != nil { @@ -207,10 +207,8 @@ func CreateTeam(ctx *context.APIContext) { // responses: // "201": // "$ref": "#/responses/Team" - // "404": - // "$ref": "#/responses/notFound" - // "422": - // "$ref": "#/responses/validationError" + // default: + // "$ref": "#/responses/error" form := web.GetForm[*api.CreateTeamOption](ctx) team := &organization.Team{ OrgID: ctx.Org.Organization.ID, @@ -265,8 +263,8 @@ func EditTeam(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/Team" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" form := web.GetForm[*api.EditTeamOption](ctx) team := ctx.Org.Team @@ -336,8 +334,8 @@ func DeleteTeam(ctx *context.APIContext) { // responses: // "204": // description: team deleted - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" if err := org_service.DeleteTeam(ctx, ctx.Org.Team); err != nil { ctx.APIErrorInternal(err) @@ -371,8 +369,8 @@ func GetTeamMembers(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/UserList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" listOptions := utils.GetListOptions(ctx) teamMembers, err := organization.GetTeamMembers(ctx, &organization.SearchMembersOptions{ @@ -416,8 +414,8 @@ func GetTeamMember(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/User" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" u := user.GetContextUserByPathParam(ctx) if ctx.Written() { @@ -457,10 +455,8 @@ func AddTeamMember(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" u := user.GetContextUserByPathParam(ctx) if ctx.Written() { @@ -499,8 +495,8 @@ func RemoveTeamMember(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" u := user.GetContextUserByPathParam(ctx) if ctx.Written() { @@ -539,8 +535,8 @@ func GetTeamRepos(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/RepositoryList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" team := ctx.Org.Team listOptions := utils.GetListOptions(ctx) @@ -608,8 +604,8 @@ func GetTeamRepo(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/Repository" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" repo, permission := getRepositoryByParams(ctx) if ctx.Written() { @@ -682,10 +678,8 @@ func AddTeamRepository(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" repo, perm := getRepositoryByParams(ctx) if ctx.Written() { @@ -730,10 +724,8 @@ func RemoveTeamRepository(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" repo, perm := getRepositoryByParams(ctx) if ctx.Written() { @@ -790,8 +782,8 @@ func SearchTeam(ctx *context.APIContext) { // type: array // items: // "$ref": "#/definitions/Team" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" listOptions := utils.GetListOptions(ctx) @@ -860,8 +852,8 @@ func ListTeamActivityFeeds(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/ActivityFeedsList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" listOptions := utils.GetListOptions(ctx) diff --git a/routers/api/v1/packages/package.go b/routers/api/v1/packages/package.go index d06d2a636b8..15c3a62288b 100644 --- a/routers/api/v1/packages/package.go +++ b/routers/api/v1/packages/package.go @@ -51,8 +51,8 @@ func ListPackages(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/PackageList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" listOptions := utils.GetListOptions(ctx) @@ -104,8 +104,8 @@ func GetPackage(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/Package" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" apiPackage, err := convert.ToPackage(ctx, ctx.Package.Descriptor, ctx.Doer) if err != nil { @@ -140,8 +140,8 @@ func DeletePackage(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" err := packages_service.RemovePackage(ctx, ctx.Doer, ctx.Package.Descriptor.Package) if err != nil { @@ -180,8 +180,8 @@ func DeletePackageVersion(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" err := packages_service.RemovePackageVersion(ctx, ctx.Doer, ctx.Package.Descriptor.Version) if err != nil { @@ -222,8 +222,8 @@ func ListPackageFiles(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/PackageFileList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" apiPackageFiles := make([]*api.PackageFile, 0, len(ctx.Package.Descriptor.Files)) for _, pfd := range ctx.Package.Descriptor.Files { @@ -267,8 +267,8 @@ func ListPackageVersions(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/PackageList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" listOptions := utils.GetListOptions(ctx) @@ -315,8 +315,8 @@ func GetLatestPackageVersion(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/Package" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" pvs, _, err := packages.SearchLatestVersions(ctx, &packages.PackageSearchOptions{ OwnerID: ctx.Package.Owner.ID, @@ -377,8 +377,8 @@ func LinkPackage(ctx *context.APIContext) { // responses: // "201": // "$ref": "#/responses/empty" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" pkg, err := packages.GetPackageByName(ctx, ctx.ContextUser.ID, packages.Type(ctx.PathParam("type")), ctx.PathParam("name")) if err != nil { @@ -439,8 +439,8 @@ func UnlinkPackage(ctx *context.APIContext) { // responses: // "201": // "$ref": "#/responses/empty" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" pkg, err := packages.GetPackageByName(ctx, ctx.ContextUser.ID, packages.Type(ctx.PathParam("type")), ctx.PathParam("name")) if err != nil { diff --git a/routers/api/v1/repo/action.go b/routers/api/v1/repo/action.go index f3a4cc0c471..d8f33437bf7 100644 --- a/routers/api/v1/repo/action.go +++ b/routers/api/v1/repo/action.go @@ -65,8 +65,8 @@ func (Action) ListActionsSecrets(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/SecretList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" repo := ctx.Repo.Repository listOptions := utils.GetListOptions(ctx) @@ -129,10 +129,8 @@ func (Action) 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" repo := ctx.Repo.Repository @@ -185,10 +183,8 @@ func (Action) DeleteSecret(ctx *context.APIContext) { // responses: // "204": // description: delete one secret of the repository - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" repo := ctx.Repo.Repository @@ -229,10 +225,8 @@ func (Action) 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.BelongingScopeRepo(ctx.Repo.Repository.ID), Name: ctx.PathParam("variablename"), @@ -283,10 +277,8 @@ func (Action) 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.BelongingScopeRepo(ctx.Repo.Repository.ID), ctx.PathParam("variablename")); err != nil { ctx.APIErrorAuto(err) @@ -326,11 +318,7 @@ func (Action) CreateVariable(ctx *context.APIContext) { // responses: // "201": // description: response when creating a repo-level variable - // "400": - // "$ref": "#/responses/error" - // "409": - // description: variable name already exists. - // "500": + // default: // "$ref": "#/responses/error" opt := web.GetForm[*api.CreateVariableOption](ctx) @@ -391,10 +379,8 @@ func (Action) UpdateVariable(ctx *context.APIContext) { // description: response when updating a repo-level variable // "204": // description: response when updating a repo-level variable - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" opt := web.GetForm[*api.UpdateVariableOption](ctx) @@ -452,10 +438,8 @@ func (Action) ListVariables(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/VariableList" - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" listOptions := utils.GetListOptions(ctx) @@ -535,10 +519,8 @@ func (Action) ListRunners(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/RunnerList" - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" shared.ListRunners(ctx, 0, ctx.Repo.Repository.ID) } @@ -568,10 +550,8 @@ func (Action) GetRunner(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/Runner" - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" shared.GetRunner(ctx, 0, ctx.Repo.Repository.ID, ctx.PathParamInt64("runner_id")) } @@ -601,10 +581,8 @@ func (Action) DeleteRunner(ctx *context.APIContext) { // responses: // "204": // description: runner has been deleted - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" shared.DeleteRunner(ctx, 0, ctx.Repo.Repository.ID, ctx.PathParamInt64("runner_id")) } @@ -640,12 +618,8 @@ func (Action) 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, 0, ctx.Repo.Repository.ID, ctx.PathParamInt64("runner_id")) } @@ -691,12 +665,8 @@ func (Action) ListWorkflowJobs(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/WorkflowJobsList" - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" - // "422": - // "$ref": "#/responses/validationError" repoID := ctx.Repo.Repository.ID @@ -762,10 +732,8 @@ func (Action) ListWorkflowRuns(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/WorkflowRunsList" - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" repoID := ctx.Repo.Repository.ID @@ -811,16 +779,8 @@ func ListActionTasks(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/TasksList" - // "400": + // default: // "$ref": "#/responses/error" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" - // "409": - // "$ref": "#/responses/conflict" - // "422": - // "$ref": "#/responses/validationError" listOptions := utils.GetListOptions(ctx) tasks, total, err := db.FindAndCount[actions_model.ActionTask](ctx, &actions_model.FindTaskOptions{ @@ -876,15 +836,7 @@ func ActionsListRepositoryWorkflows(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/ActionWorkflowList" - // "400": - // "$ref": "#/responses/error" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" - // "422": - // "$ref": "#/responses/validationError" - // "500": + // default: // "$ref": "#/responses/error" workflows, err := convert.ListActionWorkflows(ctx, ctx.Repo.GitRepo, ctx.Repo.Repository) @@ -921,15 +873,7 @@ func ActionsGetWorkflow(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/ActionWorkflow" - // "400": - // "$ref": "#/responses/error" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" - // "422": - // "$ref": "#/responses/validationError" - // "500": + // default: // "$ref": "#/responses/error" workflowID := ctx.PathParam("workflow_id") @@ -1010,12 +954,8 @@ func ActionsListWorkflowRuns(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/WorkflowRunsList" - // "400": + // default: // "$ref": "#/responses/error" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" workflowID := ctx.PathParam("workflow_id") scopedWorkflowSourceRepoID := ctx.FormInt64("scoped_workflow_source_repo_id") @@ -1068,14 +1008,8 @@ func ActionsDisableWorkflow(ctx *context.APIContext) { // responses: // "204": // description: No Content - // "400": + // default: // "$ref": "#/responses/error" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" - // "422": - // "$ref": "#/responses/validationError" workflowID := ctx.PathParam("workflow_id") err := actions_service.EnableOrDisableWorkflow(ctx, workflowID, false) @@ -1127,14 +1061,8 @@ func ActionsDispatchWorkflow(ctx *context.APIContext) { // "$ref": "#/responses/RunDetails" // "204": // description: No Content, if return_run_details is missing or false - // "400": + // default: // "$ref": "#/responses/error" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" - // "422": - // "$ref": "#/responses/validationError" workflowID := ctx.PathParam("workflow_id") opt := web.GetForm[*api.CreateActionWorkflowDispatch](ctx) @@ -1215,16 +1143,8 @@ func ActionsEnableWorkflow(ctx *context.APIContext) { // responses: // "204": // description: No Content - // "400": + // default: // "$ref": "#/responses/error" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" - // "409": - // "$ref": "#/responses/conflict" - // "422": - // "$ref": "#/responses/validationError" workflowID := ctx.PathParam("workflow_id") err := actions_service.EnableOrDisableWorkflow(ctx, workflowID, true) @@ -1313,10 +1233,8 @@ func GetWorkflowRun(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/WorkflowRun" - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" run := getCurrentRepoActionRunByID(ctx) if ctx.Written() { @@ -1357,10 +1275,8 @@ func GetWorkflowRunAttempt(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/WorkflowRun" - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" run, attempt := getCurrentRepoActionRunAttemptByNumber(ctx) if ctx.Written() { @@ -1401,16 +1317,8 @@ func RerunWorkflowRun(ctx *context.APIContext) { // responses: // "201": // "$ref": "#/responses/WorkflowRun" - // "400": + // default: // "$ref": "#/responses/error" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" - // "409": - // "$ref": "#/responses/error" - // "422": - // "$ref": "#/responses/validationError" run, jobs := getCurrentRepoActionRunJobsByID(ctx) if ctx.Written() { @@ -1454,16 +1362,8 @@ func RerunFailedWorkflowRun(ctx *context.APIContext) { // responses: // "201": // "$ref": "#/responses/empty" - // "400": + // default: // "$ref": "#/responses/error" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" - // "409": - // "$ref": "#/responses/error" - // "422": - // "$ref": "#/responses/validationError" run, jobs := getCurrentRepoActionRunJobsByID(ctx) if ctx.Written() { @@ -1516,16 +1416,8 @@ func RerunWorkflowJob(ctx *context.APIContext) { // responses: // "201": // "$ref": "#/responses/WorkflowJob" - // "400": + // default: // "$ref": "#/responses/error" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" - // "409": - // "$ref": "#/responses/error" - // "422": - // "$ref": "#/responses/validationError" run, jobs := getCurrentRepoActionRunJobsByID(ctx) if ctx.Written() { @@ -1616,12 +1508,8 @@ func ListWorkflowRunJobs(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/WorkflowJobsList" - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" - // "422": - // "$ref": "#/responses/validationError" repoID, runID := ctx.Repo.Repository.ID, ctx.PathParamInt64("run") @@ -1685,10 +1573,8 @@ func ListWorkflowRunAttemptJobs(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/WorkflowJobsList" - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" run, attempt := getCurrentRepoActionRunAttemptByNumber(ctx) if ctx.Written() { @@ -1724,10 +1610,8 @@ func GetWorkflowJob(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/WorkflowJob" - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" jobID := ctx.PathParamInt64("job_id") job, has, err := db.GetByID[actions_model.ActionRunJob](ctx, jobID) @@ -1780,10 +1664,8 @@ func GetArtifactsOfRun(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/ArtifactsList" - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" artifactName := ctx.Req.URL.Query().Get("name") repoID, runID := ctx.Repo.Repository.ID, ctx.PathParamInt64("run") @@ -1837,10 +1719,8 @@ func DeleteActionRun(ctx *context.APIContext) { // responses: // "204": // description: "No Content" - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" run := getCurrentRepoActionRunByID(ctx) if ctx.Written() { @@ -1885,10 +1765,8 @@ func GetArtifacts(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/ArtifactsList" - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" repoID := ctx.Repo.Repository.ID artifactName := ctx.Req.URL.Query().Get("name") @@ -1941,10 +1819,8 @@ func GetArtifact(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/Artifact" - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" art := getArtifactByPathParam(ctx, ctx.Repo.Repository) if ctx.Written() { @@ -1985,10 +1861,8 @@ func DeleteArtifact(ctx *context.APIContext) { // responses: // "204": // description: "No Content" - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" art := getArtifactByPathParam(ctx, ctx.Repo.Repository) if ctx.Written() { @@ -2048,10 +1922,8 @@ func DownloadArtifact(ctx *context.APIContext) { // responses: // "302": // description: redirect to the blob download - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" art := getArtifactByPathParam(ctx, ctx.Repo.Repository) if ctx.Written() { diff --git a/routers/api/v1/repo/actions_run.go b/routers/api/v1/repo/actions_run.go index 90c14d03a1d..34ac387b0b8 100644 --- a/routers/api/v1/repo/actions_run.go +++ b/routers/api/v1/repo/actions_run.go @@ -37,10 +37,8 @@ func DownloadActionsRunJobLogs(ctx *context.APIContext) { // responses: // "200": // description: output blob content - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" jobID := ctx.PathParamInt64("job_id") curJob, err := actions_model.GetRunJobByRepoAndID(ctx, ctx.Repo.Repository.ID, jobID) @@ -79,14 +77,8 @@ func CancelWorkflowRun(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/WorkflowRun" - // "400": + // default: // "$ref": "#/responses/error" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" - // "409": - // "$ref": "#/responses/conflict" cancelWorkflowRun(ctx, false) } @@ -120,14 +112,8 @@ func ForceCancelWorkflowRun(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/WorkflowRun" - // "400": + // default: // "$ref": "#/responses/error" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" - // "409": - // "$ref": "#/responses/conflict" cancelWorkflowRun(ctx, true) } @@ -182,14 +168,8 @@ func ApproveWorkflowRun(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/WorkflowRun" - // "400": + // default: // "$ref": "#/responses/error" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" - // "409": - // "$ref": "#/responses/conflict" run := getCurrentRepoActionRunByID(ctx) if ctx.Written() { @@ -240,8 +220,8 @@ func GetWorkflowRunLogs(ctx *context.APIContext) { // responses: // "200": // description: Logs archive - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" run := getCurrentRepoActionRunByID(ctx) if ctx.Written() { diff --git a/routers/api/v1/repo/avatar.go b/routers/api/v1/repo/avatar.go index 8a17f2ef2e4..da8088974dd 100644 --- a/routers/api/v1/repo/avatar.go +++ b/routers/api/v1/repo/avatar.go @@ -38,8 +38,8 @@ func UpdateAvatar(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" form := web.GetForm[*api.UpdateRepoAvatarOption](ctx) content, err := base64.StdEncoding.DecodeString(form.Image) @@ -77,8 +77,8 @@ func DeleteAvatar(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" err := repo_service.DeleteAvatar(ctx, ctx.Repo.Repository) if err != nil { ctx.APIErrorInternal(err) diff --git a/routers/api/v1/repo/blob.go b/routers/api/v1/repo/blob.go index d16cff07657..7c3062592a6 100644 --- a/routers/api/v1/repo/blob.go +++ b/routers/api/v1/repo/blob.go @@ -36,10 +36,8 @@ func GetBlob(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/GitBlobResponse" - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" sha := ctx.PathParam("sha") if len(sha) == 0 { diff --git a/routers/api/v1/repo/branch.go b/routers/api/v1/repo/branch.go index 619fb210e0b..45ead66b306 100644 --- a/routers/api/v1/repo/branch.go +++ b/routers/api/v1/repo/branch.go @@ -54,8 +54,8 @@ func GetBranch(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/Branch" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" branchName := ctx.PathParam("*") @@ -115,12 +115,8 @@ func DeleteBranch(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "403": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" - // "423": - // "$ref": "#/responses/repoArchivedError" if ctx.Repo.Repository.IsEmpty { ctx.APIError(http.StatusNotFound, "Git Repository is empty.") return @@ -194,14 +190,8 @@ func CreateBranch(ctx *context.APIContext) { // responses: // "201": // "$ref": "#/responses/Branch" - // "403": - // description: The branch is archived or a mirror. - // "404": - // description: The old branch does not exist. - // "409": - // description: The branch with the same name already exists. - // "423": - // "$ref": "#/responses/repoArchivedError" + // default: + // "$ref": "#/responses/error" if ctx.Repo.Repository.IsEmpty { ctx.APIError(http.StatusNotFound, "Git Repository is empty.") @@ -418,14 +408,8 @@ func UpdateBranch(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" - // "409": - // "$ref": "#/responses/conflict" - // "422": - // "$ref": "#/responses/validationError" + // default: + // "$ref": "#/responses/error" opt := web.GetForm[*api.UpdateBranchRepoOption](ctx) @@ -493,12 +477,8 @@ func RenameBranch(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" - // "422": - // "$ref": "#/responses/validationError" + // default: + // "$ref": "#/responses/error" opt := web.GetForm[*api.RenameBranchRepoOption](ctx) @@ -565,8 +545,8 @@ func GetBranchProtection(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/BranchProtection" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" repo := ctx.Repo.Repository bpName := ctx.PathParam("*") @@ -674,14 +654,8 @@ func CreateBranchProtection(ctx *context.APIContext) { // responses: // "201": // "$ref": "#/responses/BranchProtection" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" - // "422": - // "$ref": "#/responses/validationError" - // "423": - // "$ref": "#/responses/repoArchivedError" + // default: + // "$ref": "#/responses/error" form := web.GetForm[*api.CreateBranchProtectionOption](ctx) repo := ctx.Repo.Repository @@ -882,12 +856,8 @@ func EditBranchProtection(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/BranchProtection" - // "404": - // "$ref": "#/responses/notFound" - // "422": - // "$ref": "#/responses/validationError" - // "423": - // "$ref": "#/responses/repoArchivedError" + // default: + // "$ref": "#/responses/error" form := web.GetForm[*api.EditBranchProtectionOption](ctx) repo := ctx.Repo.Repository bpName := ctx.PathParam("*") @@ -1231,8 +1201,8 @@ func DeleteBranchProtection(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" repo := ctx.Repo.Repository bpName := ctx.PathParam("*") @@ -1281,12 +1251,8 @@ func UpdateBranchProtectionPriories(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "404": - // "$ref": "#/responses/notFound" - // "422": - // "$ref": "#/responses/validationError" - // "423": - // "$ref": "#/responses/repoArchivedError" + // default: + // "$ref": "#/responses/error" form := web.GetForm[*api.UpdateBranchProtectionPriories](ctx) repo := ctx.Repo.Repository @@ -1322,11 +1288,7 @@ func MergeUpstream(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/MergeUpstreamResponse" - // "400": - // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" - // "409": + // default: // "$ref": "#/responses/error" form := web.GetForm[*api.MergeUpstreamRequest](ctx) mergeStyle, err := repo_service.MergeUpstream(ctx, ctx.Doer, ctx.Repo.Repository, form.Branch, form.FfOnly) diff --git a/routers/api/v1/repo/collaborators.go b/routers/api/v1/repo/collaborators.go index bf74299f3d5..0e7f2ef2632 100644 --- a/routers/api/v1/repo/collaborators.go +++ b/routers/api/v1/repo/collaborators.go @@ -52,8 +52,8 @@ func ListCollaborators(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/UserList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" collaborators, total, err := repo_model.GetCollaborators(ctx, &repo_model.FindCollaborationOptions{ ListOptions: utils.GetListOptions(ctx), @@ -99,10 +99,8 @@ func IsCollaborator(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "404": - // "$ref": "#/responses/notFound" - // "422": - // "$ref": "#/responses/validationError" + // default: + // "$ref": "#/responses/error" user, err := user_model.GetUserByName(ctx, ctx.PathParam("collaborator")) if err != nil { @@ -155,12 +153,8 @@ func AddOrUpdateCollaborator(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" - // "422": - // "$ref": "#/responses/validationError" + // default: + // "$ref": "#/responses/error" form := web.GetForm[*api.AddCollaboratorOption](ctx) @@ -222,10 +216,8 @@ func DeleteCollaborator(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "404": - // "$ref": "#/responses/notFound" - // "422": - // "$ref": "#/responses/validationError" + // default: + // "$ref": "#/responses/error" collaborator, err := user_model.GetUserByName(ctx, ctx.PathParam("collaborator")) if err != nil { @@ -270,10 +262,8 @@ func GetRepoPermissions(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/RepoCollaboratorPermission" - // "404": - // "$ref": "#/responses/notFound" - // "403": - // "$ref": "#/responses/forbidden" + // default: + // "$ref": "#/responses/error" collaboratorUsername := ctx.PathParam("collaborator") if !ctx.Doer.IsAdmin && !strings.EqualFold(ctx.Doer.LowerName, collaboratorUsername) && !ctx.IsUserRepoAdmin() { @@ -321,8 +311,8 @@ func GetReviewers(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/UserList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" canChooseReviewer := issue_service.CanDoerChangeReviewRequests(ctx, ctx.Doer, ctx.Repo.Repository, 0) if !canChooseReviewer { @@ -359,8 +349,8 @@ func GetAssignees(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/UserList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" assignees, err := repo_model.GetRepoAssignees(ctx, ctx.Repo.Repository) if err != nil { @@ -397,10 +387,8 @@ func CheckRepoIssueAssignee(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" if checkAssignableUser(ctx, ctx.PathParam("assignee"), ctx.Repo.Repository) { ctx.Status(http.StatusNoContent) diff --git a/routers/api/v1/repo/commits.go b/routers/api/v1/repo/commits.go index 25effda94f1..30a13295377 100644 --- a/routers/api/v1/repo/commits.go +++ b/routers/api/v1/repo/commits.go @@ -58,10 +58,8 @@ func GetSingleCommit(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/Commit" - // "422": - // "$ref": "#/responses/validationError" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" sha := ctx.PathParam("sha") if !git.IsValidRefPattern(sha) { @@ -154,10 +152,8 @@ func GetAllCommits(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/CommitList" - // "404": - // "$ref": "#/responses/notFound" - // "409": - // "$ref": "#/responses/EmptyRepository" + // default: + // "$ref": "#/responses/error" since := ctx.FormString("since") until := ctx.FormString("until") @@ -354,8 +350,8 @@ func DownloadCommitDiffOrPatch(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/string" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" sha := ctx.PathParam("sha") diffType := git.RawDiffType(ctx.PathParam("diffType")) @@ -395,8 +391,8 @@ func GetCommitPullRequest(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/PullRequest" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" pr, err := issues_model.GetPullRequestByMergedCommit(ctx, ctx.Repo.Repository.ID, ctx.PathParam("sha")) if err != nil { diff --git a/routers/api/v1/repo/compare.go b/routers/api/v1/repo/compare.go index 05573603052..f5b1a9b54f7 100644 --- a/routers/api/v1/repo/compare.go +++ b/routers/api/v1/repo/compare.go @@ -59,10 +59,8 @@ func CompareDiff(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/Compare" - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" if ctx.Repo.GitRepo == nil { var err error diff --git a/routers/api/v1/repo/file.go b/routers/api/v1/repo/file.go index 6a97b5dc591..75ea20ca06b 100644 --- a/routers/api/v1/repo/file.go +++ b/routers/api/v1/repo/file.go @@ -67,8 +67,8 @@ func GetRawFile(ctx *context.APIContext) { // description: Returns raw file content. // schema: // type: file - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" if ctx.Repo.Repository.IsEmpty { ctx.APIErrorNotFound() @@ -120,8 +120,8 @@ func GetRawFileOrLFS(ctx *context.APIContext) { // description: Returns raw file content. // schema: // type: file - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" if ctx.Repo.Repository.IsEmpty { ctx.APIErrorNotFound() @@ -260,8 +260,8 @@ func GetArchive(ctx *context.APIContext) { // responses: // 200: // description: success - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" serveRepoArchive(ctx, ctx.PathParam("*"), ctx.FormStrings("path")) } @@ -296,8 +296,8 @@ func GetEditorconfig(ctx *context.APIContext) { // responses: // 200: // description: success - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" ec, _, err := ctx.Repo.GetEditorconfig(ctx) if err != nil { @@ -391,14 +391,8 @@ func ChangeFiles(ctx *context.APIContext) { // responses: // "201": // "$ref": "#/responses/FilesResponse" - // "403": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" - // "422": - // "$ref": "#/responses/error" - // "423": - // "$ref": "#/responses/repoArchivedError" apiOpts, opts := getAPIChangeRepoFileOptions[*api.ChangeFilesOptions](ctx) if ctx.Written() { return @@ -465,14 +459,8 @@ func CreateFile(ctx *context.APIContext) { // responses: // "201": // "$ref": "#/responses/FileResponse" - // "403": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" - // "422": - // "$ref": "#/responses/error" - // "423": - // "$ref": "#/responses/repoArchivedError" apiOpts, opts := getAPIChangeRepoFileOptions[*api.CreateFileOptions](ctx) if ctx.Written() { @@ -536,14 +524,8 @@ func UpdateFile(ctx *context.APIContext) { // "$ref": "#/responses/FileResponse" // "201": // "$ref": "#/responses/FileResponse" - // "403": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" - // "422": - // "$ref": "#/responses/error" - // "423": - // "$ref": "#/responses/repoArchivedError" apiOpts, opts := getAPIChangeRepoFileOptions[*api.UpdateFileOptions](ctx) if ctx.Written() { @@ -659,16 +641,8 @@ func DeleteFile(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/FileDeleteResponse" - // "400": + // default: // "$ref": "#/responses/error" - // "403": - // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/error" - // "422": - // "$ref": "#/responses/error" - // "423": - // "$ref": "#/responses/repoArchivedError" apiOpts, opts := getAPIChangeRepoFileOptions[*api.DeleteFileOptions](ctx) if ctx.Written() { @@ -743,8 +717,8 @@ func GetContentsExt(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/ContentsExtResponse" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" if treePath := ctx.PathParam("*"); treePath == "." || treePath == "/" { ctx.SetPathParam("*", "") // workaround for swagger, it requires path parameter to be "required", but we need to list root directory @@ -802,8 +776,8 @@ func GetContents(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/ContentsResponse" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" ret := getRepoContents(ctx, files_service.GetContentsOrListOptions{ TreePath: ctx.PathParam("*"), IncludeSingleFileContent: true, @@ -854,8 +828,8 @@ func GetContentsList(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/ContentsListResponse" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" // same as GetContents(), this function is here because swagger fails if path is empty in GetContents() interface GetContents(ctx) @@ -892,8 +866,8 @@ func GetFileContentsGet(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/ContentsListResponse" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" // The POST method requires "write" permission, so we also support this "GET" method opts := &api.GetFilesOptions{} @@ -939,8 +913,8 @@ func GetFileContentsPost(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/ContentsListResponse" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" // This is actually a "read" request, but we need to accept a "files" list, then POST method seems easy to use. // But the permission system requires that the caller must have "write" permission to use POST method. diff --git a/routers/api/v1/repo/fork.go b/routers/api/v1/repo/fork.go index 4749c2fd6d6..cab8aef1957 100644 --- a/routers/api/v1/repo/fork.go +++ b/routers/api/v1/repo/fork.go @@ -51,8 +51,8 @@ func ListForks(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/RepositoryList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" listOptions := utils.GetListOptions(ctx) forks, total, err := repo_service.FindForks(ctx, ctx.Repo.Repository, ctx.Doer, listOptions) @@ -138,14 +138,8 @@ func CreateFork(ctx *context.APIContext) { // responses: // "202": // "$ref": "#/responses/Repository" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" - // "409": - // description: The repository with the same name already exists. - // "422": - // "$ref": "#/responses/validationError" + // default: + // "$ref": "#/responses/error" form := web.GetForm[*api.CreateForkOption](ctx) forkOwner := ctx.Doer // user/org that will own the fork diff --git a/routers/api/v1/repo/git_hook.go b/routers/api/v1/repo/git_hook.go index eb1bffcc207..4b55a9b55ab 100644 --- a/routers/api/v1/repo/git_hook.go +++ b/routers/api/v1/repo/git_hook.go @@ -35,8 +35,8 @@ func ListGitHooks(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/GitHookList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" hooks, err := git.ListHooks(ctx.Repo.GitRepo) if err != nil { @@ -77,8 +77,8 @@ func GetGitHook(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/GitHook" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" hookID := ctx.PathParam("id") hook, err := git.GetHook(ctx.Repo.GitRepo, hookID) @@ -123,8 +123,8 @@ func EditGitHook(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/GitHook" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" form := web.GetForm[*api.EditGitHookOption](ctx) hookID := ctx.PathParam("id") @@ -173,8 +173,8 @@ func DeleteGitHook(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" hookID := ctx.PathParam("id") hook, err := git.GetHook(ctx.Repo.GitRepo, hookID) diff --git a/routers/api/v1/repo/git_ref.go b/routers/api/v1/repo/git_ref.go index c6014e73118..e48d7e1109d 100644 --- a/routers/api/v1/repo/git_ref.go +++ b/routers/api/v1/repo/git_ref.go @@ -36,8 +36,8 @@ func GetGitAllRefs(ctx *context.APIContext) { // "200": // # "$ref": "#/responses/Reference" TODO: swagger doesn't support different output formats by ref // "$ref": "#/responses/ReferenceList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" getGitRefsInternal(ctx, "") } @@ -69,8 +69,8 @@ func GetGitRefs(ctx *context.APIContext) { // "200": // # "$ref": "#/responses/Reference" TODO: swagger doesn't support different output formats by ref // "$ref": "#/responses/ReferenceList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" getGitRefsInternal(ctx, ctx.PathParam("*")) } diff --git a/routers/api/v1/repo/hook.go b/routers/api/v1/repo/hook.go index 3796d61aed0..af757d0fd0e 100644 --- a/routers/api/v1/repo/hook.go +++ b/routers/api/v1/repo/hook.go @@ -51,8 +51,8 @@ func ListHooks(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/HookList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" opts := &webhook.ListWebhookOptions{ ListOptions: utils.GetListOptions(ctx), @@ -105,8 +105,8 @@ func GetHook(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/Hook" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" repo := ctx.Repo hookID := ctx.PathParamInt64("id") @@ -156,8 +156,8 @@ func ListDeliveries(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/HookDeliveryList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" hookID := ctx.PathParamInt64("id") if _, err := utils.GetRepoHook(ctx, ctx.Repo.Repository.ID, hookID); err != nil { @@ -224,8 +224,8 @@ func GetDelivery(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/HookDelivery" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" hookID := ctx.PathParamInt64("id") if _, err := utils.GetRepoHook(ctx, ctx.Repo.Repository.ID, hookID); err != nil { @@ -276,8 +276,8 @@ func TestHook(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" if ctx.Repo.Commit == nil { // if repo does not have any commits, then don't send a webhook @@ -345,8 +345,8 @@ func CreateHook(ctx *context.APIContext) { // responses: // "201": // "$ref": "#/responses/Hook" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" utils.AddRepoHook(ctx, web.GetForm[*api.CreateHookOption](ctx)) } @@ -382,8 +382,8 @@ func EditHook(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/Hook" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" form := web.GetForm[*api.EditHookOption](ctx) hookID := ctx.PathParamInt64("id") utils.EditRepoHook(ctx, form, hookID) @@ -416,8 +416,8 @@ func DeleteHook(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" if err := webhook.DeleteWebhookByRepoID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("id")); err != nil { if webhook.IsErrWebhookNotExist(err) { ctx.APIErrorNotFound() diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go index 035d40cf8b9..705bc1b751d 100644 --- a/routers/api/v1/repo/issue.go +++ b/routers/api/v1/repo/issue.go @@ -122,10 +122,8 @@ func SearchIssues(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/IssueList" - // "400": + // default: // "$ref": "#/responses/error" - // "422": - // "$ref": "#/responses/validationError" before, since, err := context.GetQueryBeforeSince(ctx.Base) if err != nil { @@ -322,8 +320,8 @@ func ListIssues(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/IssueList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" before, since, err := context.GetQueryBeforeSince(ctx.Base) if err != nil { ctx.APIError(http.StatusUnprocessableEntity, err.Error()) @@ -507,8 +505,8 @@ func GetIssue(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/Issue" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" issue := getRepoIssueByIndexForDoer(ctx, ctx.PathParamInt64("index")) if issue == nil { @@ -581,16 +579,8 @@ func CreateIssue(ctx *context.APIContext) { // responses: // "201": // "$ref": "#/responses/Issue" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" - // "412": + // default: // "$ref": "#/responses/error" - // "422": - // "$ref": "#/responses/validationError" - // "423": - // "$ref": "#/responses/repoArchivedError" form := web.GetForm[*api.CreateIssueOption](ctx) issue := &issues_model.Issue{ @@ -689,14 +679,8 @@ func EditIssue(ctx *context.APIContext) { // responses: // "201": // "$ref": "#/responses/Issue" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" - // "412": + // default: // "$ref": "#/responses/error" - // "423": - // "$ref": "#/responses/repoArchivedError" form := web.GetForm[*api.EditIssueOption](ctx) issue := getRepoIssueByIndexForDoer(ctx, ctx.PathParamInt64("index")) @@ -872,12 +856,8 @@ func DeleteIssue(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" - // "423": - // "$ref": "#/responses/repoArchivedError" + // default: + // "$ref": "#/responses/error" issue := getRepoIssueByIndexForDoer(ctx, ctx.PathParamInt64("index")) if issue == nil { return @@ -941,10 +921,8 @@ func UpdateIssueDeadline(ctx *context.APIContext) { // responses: // "201": // "$ref": "#/responses/IssueDeadline" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" form := web.GetForm[*api.EditDeadlineOption](ctx) issue := getRepoIssueByIndexForDoer(ctx, ctx.PathParamInt64("index")) if issue == nil { diff --git a/routers/api/v1/repo/issue_assignee.go b/routers/api/v1/repo/issue_assignee.go index eee47dd190b..2fe242fbbdc 100644 --- a/routers/api/v1/repo/issue_assignee.go +++ b/routers/api/v1/repo/issue_assignee.go @@ -53,14 +53,8 @@ func AddIssueAssignees(ctx *context.APIContext) { // responses: // "201": // "$ref": "#/responses/Issue" - // "400": + // default: // "$ref": "#/responses/error" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" - // "422": - // "$ref": "#/responses/validationError" opts := web.GetForm[*api.IssueAssigneesOption](ctx) updateIssueAssignees(ctx, *opts, true) @@ -100,12 +94,8 @@ func DeleteIssueAssignees(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/Issue" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" - // "422": - // "$ref": "#/responses/validationError" + // default: + // "$ref": "#/responses/error" opts := web.GetForm[*api.IssueAssigneesOption](ctx) updateIssueAssignees(ctx, *opts, false) @@ -143,10 +133,8 @@ func CheckIssueAssignee(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" issue := getRepoIssueByIndexForDoer(ctx, ctx.PathParamInt64("index")) if issue == nil { diff --git a/routers/api/v1/repo/issue_attachment.go b/routers/api/v1/repo/issue_attachment.go index 3bb3ac99a4e..37ac66f90a0 100644 --- a/routers/api/v1/repo/issue_attachment.go +++ b/routers/api/v1/repo/issue_attachment.go @@ -54,7 +54,7 @@ func GetIssueAttachment(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/Attachment" - // "404": + // default: // "$ref": "#/responses/error" issue := getRepoIssueByIndexForDoer(ctx, ctx.PathParamInt64("index")) @@ -97,7 +97,7 @@ func ListIssueAttachments(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/AttachmentList" - // "404": + // default: // "$ref": "#/responses/error" issue := getRepoIssueByIndexForDoer(ctx, ctx.PathParamInt64("index")) @@ -152,16 +152,8 @@ func CreateIssueAttachment(ctx *context.APIContext) { // responses: // "201": // "$ref": "#/responses/Attachment" - // "400": + // default: // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/error" - // "413": - // "$ref": "#/responses/error" - // "422": - // "$ref": "#/responses/validationError" - // "423": - // "$ref": "#/responses/repoArchivedError" issue := getRepoIssueByIndexForDoer(ctx, ctx.PathParamInt64("index")) if issue == nil { @@ -252,12 +244,8 @@ func EditIssueAttachment(ctx *context.APIContext) { // responses: // "201": // "$ref": "#/responses/Attachment" - // "404": + // default: // "$ref": "#/responses/error" - // "422": - // "$ref": "#/responses/validationError" - // "423": - // "$ref": "#/responses/repoArchivedError" attachment := getIssueAttachmentSafeWrite(ctx) if attachment == nil { @@ -315,10 +303,8 @@ func DeleteIssueAttachment(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "404": + // default: // "$ref": "#/responses/error" - // "423": - // "$ref": "#/responses/repoArchivedError" attachment := getIssueAttachmentSafeWrite(ctx) if attachment == nil { diff --git a/routers/api/v1/repo/issue_comment.go b/routers/api/v1/repo/issue_comment.go index eb98ee43f56..65599005e5f 100644 --- a/routers/api/v1/repo/issue_comment.go +++ b/routers/api/v1/repo/issue_comment.go @@ -58,8 +58,8 @@ func ListIssueComments(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/CommentList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" before, since, err := context.GetQueryBeforeSince(ctx.Base) if err != nil { @@ -155,8 +155,8 @@ func ListIssueCommentsAndTimeline(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/TimelineList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" before, since, err := context.GetQueryBeforeSince(ctx.Base) if err != nil { @@ -242,8 +242,8 @@ func ListRepoIssueComments(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/CommentList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" before, since, err := context.GetQueryBeforeSince(ctx.Base) if err != nil { @@ -345,12 +345,8 @@ func CreateIssueComment(ctx *context.APIContext) { // responses: // "201": // "$ref": "#/responses/Comment" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" - // "423": - // "$ref": "#/responses/repoArchivedError" + // default: + // "$ref": "#/responses/error" form := web.GetForm[*api.CreateIssueCommentOption](ctx) issue := getRepoIssueByIndexForDoer(ctx, ctx.PathParamInt64("index")) @@ -407,10 +403,8 @@ func GetIssueComment(ctx *context.APIContext) { // "$ref": "#/responses/Comment" // "204": // "$ref": "#/responses/empty" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" comment, err := issues_model.GetCommentWithRepoID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("id")) if err != nil { @@ -471,12 +465,8 @@ func EditIssueComment(ctx *context.APIContext) { // "$ref": "#/responses/Comment" // "204": // "$ref": "#/responses/empty" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" - // "423": - // "$ref": "#/responses/repoArchivedError" + // default: + // "$ref": "#/responses/error" form := web.GetForm[*api.EditIssueCommentOption](ctx) editIssueComment(ctx, *form) @@ -523,10 +513,8 @@ func EditIssueCommentDeprecated(ctx *context.APIContext) { // "$ref": "#/responses/Comment" // "204": // "$ref": "#/responses/empty" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" form := web.GetForm[*api.EditIssueCommentOption](ctx) editIssueComment(ctx, *form) @@ -589,10 +577,8 @@ func DeleteIssueComment(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" deleteIssueComment(ctx) } @@ -628,10 +614,8 @@ func DeleteIssueCommentDeprecated(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" deleteIssueComment(ctx) } diff --git a/routers/api/v1/repo/issue_comment_attachment.go b/routers/api/v1/repo/issue_comment_attachment.go index 9eea903bf36..cb718a51aaf 100644 --- a/routers/api/v1/repo/issue_comment_attachment.go +++ b/routers/api/v1/repo/issue_comment_attachment.go @@ -56,7 +56,7 @@ func GetIssueCommentAttachment(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/Attachment" - // "404": + // default: // "$ref": "#/responses/error" comment := getIssueCommentSafe(ctx) @@ -103,7 +103,7 @@ func ListIssueCommentAttachments(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/AttachmentList" - // "404": + // default: // "$ref": "#/responses/error" comment := getIssueCommentSafe(ctx) if comment == nil { @@ -157,18 +157,8 @@ func CreateIssueCommentAttachment(ctx *context.APIContext) { // responses: // "201": // "$ref": "#/responses/Attachment" - // "400": + // default: // "$ref": "#/responses/error" - // "403": - // "$ref": "#/responses/forbidden" - // "404": - // "$ref": "#/responses/error" - // "413": - // "$ref": "#/responses/error" - // "422": - // "$ref": "#/responses/validationError" - // "423": - // "$ref": "#/responses/repoArchivedError" // Check if comment exists and load comment comment := getIssueCommentSafe(ctx) @@ -268,12 +258,8 @@ func EditIssueCommentAttachment(ctx *context.APIContext) { // responses: // "201": // "$ref": "#/responses/Attachment" - // "404": + // default: // "$ref": "#/responses/error" - // "422": - // "$ref": "#/responses/validationError" - // "423": - // "$ref": "#/responses/repoArchivedError" attach := getIssueCommentAttachmentSafeWrite(ctx) if attach == nil { return @@ -328,10 +314,8 @@ func DeleteIssueCommentAttachment(ctx *context.APIContext) { // responses: // "204": // "$ref": "#/responses/empty" - // "404": + // default: // "$ref": "#/responses/error" - // "423": - // "$ref": "#/responses/repoArchivedError" attach := getIssueCommentAttachmentSafeWrite(ctx) if attach == nil { return diff --git a/routers/api/v1/repo/issue_dependency.go b/routers/api/v1/repo/issue_dependency.go index c7a23d01d4a..972e946a481 100644 --- a/routers/api/v1/repo/issue_dependency.go +++ b/routers/api/v1/repo/issue_dependency.go @@ -52,8 +52,8 @@ func GetIssueDependencies(ctx *context.APIContext) { // responses: // "200": // "$ref": "#/responses/IssueList" - // "404": - // "$ref": "#/responses/notFound" + // default: + // "$ref": "#/responses/error" // If this issue's repository does not enable dependencies then there can be no dependencies by default if !ctx.Repo.Repository.IsDependenciesEnabled(ctx) { @@ -164,10 +164,8 @@ func CreateIssueDependency(ctx *context.APIContext) { // responses: // "201": // "$ref": "#/responses/Issue" - // "404": - // description: the issue does not exist - // "423": - // "$ref": "#/responses/repoArchivedError" + // default: + // "$ref": "#/responses/error" // We want to make <:index> depend on