Skip to content

Add missing 404 response to Swagger #27038

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions routers/api/v1/org/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ func ListActionsSecrets(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/SecretList"
// "404":
// "$ref": "#/responses/notFound"

opts := &secret_model.FindSecretsOptions{
OwnerID: ctx.Org.Organization.ID,
Expand Down
4 changes: 4 additions & 0 deletions routers/api/v1/org/avatar.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ func UpdateAvatar(ctx *context.APIContext) {
// responses:
// "204":
// "$ref": "#/responses/empty"
// "404":
// "$ref": "#/responses/notFound"
form := web.GetForm(ctx).(*api.UpdateUserAvatarOption)

content, err := base64.StdEncoding.DecodeString(form.Image)
Expand Down Expand Up @@ -65,6 +67,8 @@ func DeleteAvatar(ctx *context.APIContext) {
// responses:
// "204":
// "$ref": "#/responses/empty"
// "404":
// "$ref": "#/responses/notFound"
err := user_service.DeleteAvatar(ctx.Org.Organization.AsUser())
if err != nil {
ctx.Error(http.StatusInternalServerError, "DeleteAvatar", err)
Expand Down
10 changes: 10 additions & 0 deletions routers/api/v1/org/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ func ListHooks(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/HookList"
// "404":
// "$ref": "#/responses/notFound"

utils.ListOwnerHooks(
ctx,
Expand Down Expand Up @@ -66,6 +68,8 @@ func GetHook(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/Hook"
// "404":
// "$ref": "#/responses/notFound"

hook, err := utils.GetOwnerHook(ctx, ctx.ContextUser.ID, ctx.ParamsInt64("id"))
if err != nil {
Expand Down Expand Up @@ -103,6 +107,8 @@ func CreateHook(ctx *context.APIContext) {
// responses:
// "201":
// "$ref": "#/responses/Hook"
// "404":
// "$ref": "#/responses/notFound"

utils.AddOwnerHook(
ctx,
Expand Down Expand Up @@ -139,6 +145,8 @@ func EditHook(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/Hook"
// "404":
// "$ref": "#/responses/notFound"

utils.EditOwnerHook(
ctx,
Expand Down Expand Up @@ -170,6 +178,8 @@ func DeleteHook(ctx *context.APIContext) {
// responses:
// "204":
// "$ref": "#/responses/empty"
// "404":
// "$ref": "#/responses/notFound"

utils.DeleteOwnerHook(
ctx,
Expand Down
10 changes: 10 additions & 0 deletions routers/api/v1/org/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ func ListLabels(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/LabelList"
// "404":
// "$ref": "#/responses/notFound"

labels, err := issues_model.GetLabelsByOrgID(ctx, ctx.Org.Organization.ID, ctx.FormString("sort"), utils.GetListOptions(ctx))
if err != nil {
Expand Down Expand Up @@ -80,6 +82,8 @@ func CreateLabel(ctx *context.APIContext) {
// responses:
// "201":
// "$ref": "#/responses/Label"
// "404":
// "$ref": "#/responses/notFound"
// "422":
// "$ref": "#/responses/validationError"
form := web.GetForm(ctx).(*api.CreateLabelOption)
Expand Down Expand Up @@ -128,6 +132,8 @@ func GetLabel(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/Label"
// "404":
// "$ref": "#/responses/notFound"

var (
label *issues_model.Label
Expand Down Expand Up @@ -179,6 +185,8 @@ func EditLabel(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/Label"
// "404":
// "$ref": "#/responses/notFound"
// "422":
// "$ref": "#/responses/validationError"
form := web.GetForm(ctx).(*api.EditLabelOption)
Expand Down Expand Up @@ -238,6 +246,8 @@ func DeleteLabel(ctx *context.APIContext) {
// responses:
// "204":
// "$ref": "#/responses/empty"
// "404":
// "$ref": "#/responses/notFound"

if err := issues_model.DeleteLabel(ctx.Org.Organization.ID, ctx.ParamsInt64(":id")); err != nil {
ctx.Error(http.StatusInternalServerError, "DeleteLabel", err)
Expand Down
10 changes: 10 additions & 0 deletions routers/api/v1/org/member.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ func ListMembers(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/UserList"
// "404":
// "$ref": "#/responses/notFound"

publicOnly := true
if ctx.Doer != nil {
Expand Down Expand Up @@ -107,6 +109,8 @@ func ListPublicMembers(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/UserList"
// "404":
// "$ref": "#/responses/notFound"

listMembers(ctx, true)
}
Expand Down Expand Up @@ -225,6 +229,8 @@ func PublicizeMember(ctx *context.APIContext) {
// description: membership publicized
// "403":
// "$ref": "#/responses/forbidden"
// "404":
// "$ref": "#/responses/notFound"

userToPublicize := user.GetUserByParams(ctx)
if ctx.Written() {
Expand Down Expand Up @@ -265,6 +271,8 @@ func ConcealMember(ctx *context.APIContext) {
// "$ref": "#/responses/empty"
// "403":
// "$ref": "#/responses/forbidden"
// "404":
// "$ref": "#/responses/notFound"

userToConceal := user.GetUserByParams(ctx)
if ctx.Written() {
Expand Down Expand Up @@ -303,6 +311,8 @@ func DeleteMember(ctx *context.APIContext) {
// responses:
// "204":
// description: member removed
// "404":
// "$ref": "#/responses/notFound"

member := user.GetUserByParams(ctx)
if ctx.Written() {
Expand Down
10 changes: 10 additions & 0 deletions routers/api/v1/org/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ func ListMyOrgs(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/OrganizationList"
// "404":
// "$ref": "#/responses/notFound"

listUserOrgs(ctx, ctx.Doer)
}
Expand Down Expand Up @@ -98,6 +100,8 @@ func ListUserOrgs(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/OrganizationList"
// "404":
// "$ref": "#/responses/notFound"

listUserOrgs(ctx, ctx.ContextUser)
}
Expand Down Expand Up @@ -295,6 +299,8 @@ func Get(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/Organization"
// "404":
// "$ref": "#/responses/notFound"

if !organization.HasOrgOrUserVisible(ctx, ctx.Org.Organization.AsUser(), ctx.Doer) {
ctx.NotFound("HasOrgOrUserVisible", nil)
Expand Down Expand Up @@ -334,6 +340,8 @@ func Edit(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/Organization"
// "404":
// "$ref": "#/responses/notFound"
form := web.GetForm(ctx).(*api.EditOrgOption)
org := ctx.Org.Organization
org.FullName = form.FullName
Expand Down Expand Up @@ -374,6 +382,8 @@ func Delete(ctx *context.APIContext) {
// responses:
// "204":
// "$ref": "#/responses/empty"
// "404":
// "$ref": "#/responses/notFound"

if err := org.DeleteOrganization(ctx.Org.Organization); err != nil {
ctx.Error(http.StatusInternalServerError, "DeleteOrganization", err)
Expand Down
20 changes: 20 additions & 0 deletions routers/api/v1/org/team.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ func ListTeams(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/TeamList"
// "404":
// "$ref": "#/responses/notFound"

teams, count, err := organization.SearchTeam(&organization.SearchTeamOptions{
ListOptions: utils.GetListOptions(ctx),
Expand Down Expand Up @@ -126,6 +128,8 @@ func GetTeam(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/Team"
// "404":
// "$ref": "#/responses/notFound"

apiTeam, err := convert.ToTeam(ctx, ctx.Org.Team, true)
if err != nil {
Expand Down Expand Up @@ -204,6 +208,8 @@ func CreateTeam(ctx *context.APIContext) {
// responses:
// "201":
// "$ref": "#/responses/Team"
// "404":
// "$ref": "#/responses/notFound"
// "422":
// "$ref": "#/responses/validationError"
form := web.GetForm(ctx).(*api.CreateTeamOption)
Expand Down Expand Up @@ -272,6 +278,8 @@ func EditTeam(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/Team"
// "404":
// "$ref": "#/responses/notFound"

form := web.GetForm(ctx).(*api.EditTeamOption)
team := ctx.Org.Team
Expand Down Expand Up @@ -350,6 +358,8 @@ func DeleteTeam(ctx *context.APIContext) {
// responses:
// "204":
// description: team deleted
// "404":
// "$ref": "#/responses/notFound"

if err := models.DeleteTeam(ctx.Org.Team); err != nil {
ctx.Error(http.StatusInternalServerError, "DeleteTeam", err)
Expand Down Expand Up @@ -383,6 +393,8 @@ func GetTeamMembers(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/UserList"
// "404":
// "$ref": "#/responses/notFound"

isMember, err := organization.IsOrganizationMember(ctx, ctx.Org.Team.OrgID, ctx.Doer.ID)
if err != nil {
Expand Down Expand Up @@ -550,6 +562,8 @@ func GetTeamRepos(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/RepositoryList"
// "404":
// "$ref": "#/responses/notFound"

team := ctx.Org.Team
teamRepos, err := organization.GetTeamRepositories(ctx, &organization.SearchTeamRepoOptions{
Expand Down Expand Up @@ -665,6 +679,8 @@ func AddTeamRepository(ctx *context.APIContext) {
// "$ref": "#/responses/empty"
// "403":
// "$ref": "#/responses/forbidden"
// "404":
// "$ref": "#/responses/notFound"

repo := getRepositoryByParams(ctx)
if ctx.Written() {
Expand Down Expand Up @@ -715,6 +731,8 @@ func RemoveTeamRepository(ctx *context.APIContext) {
// "$ref": "#/responses/empty"
// "403":
// "$ref": "#/responses/forbidden"
// "404":
// "$ref": "#/responses/notFound"

repo := getRepositoryByParams(ctx)
if ctx.Written() {
Expand Down Expand Up @@ -775,6 +793,8 @@ func SearchTeam(ctx *context.APIContext) {
// type: array
// items:
// "$ref": "#/definitions/Team"
// "404":
// "$ref": "#/responses/notFound"

listOptions := utils.GetListOptions(ctx)

Expand Down
2 changes: 2 additions & 0 deletions routers/api/v1/packages/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ func ListPackages(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/PackageList"
// "404":
// "$ref": "#/responses/notFound"

listOptions := utils.GetListOptions(ctx)

Expand Down
4 changes: 4 additions & 0 deletions routers/api/v1/repo/avatar.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ func UpdateAvatar(ctx *context.APIContext) {
// responses:
// "204":
// "$ref": "#/responses/empty"
// "404":
// "$ref": "#/responses/notFound"
form := web.GetForm(ctx).(*api.UpdateRepoAvatarOption)

content, err := base64.StdEncoding.DecodeString(form.Image)
Expand Down Expand Up @@ -75,6 +77,8 @@ func DeleteAvatar(ctx *context.APIContext) {
// responses:
// "204":
// "$ref": "#/responses/empty"
// "404":
// "$ref": "#/responses/notFound"
err := repo_service.DeleteAvatar(ctx, ctx.Repo.Repository)
if err != nil {
ctx.Error(http.StatusInternalServerError, "DeleteAvatar", err)
Expand Down
2 changes: 2 additions & 0 deletions routers/api/v1/repo/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ func GetBlob(ctx *context.APIContext) {
// "$ref": "#/responses/GitBlobResponse"
// "400":
// "$ref": "#/responses/error"
// "404":
// "$ref": "#/responses/notFound"

sha := ctx.Params("sha")
if len(sha) == 0 {
Expand Down
10 changes: 10 additions & 0 deletions routers/api/v1/repo/collaborators.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ func ListCollaborators(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/UserList"
// "404":
// "$ref": "#/responses/notFound"

count, err := repo_model.CountCollaborators(ctx.Repo.Repository.ID)
if err != nil {
Expand Down Expand Up @@ -154,6 +156,8 @@ func AddCollaborator(ctx *context.APIContext) {
// responses:
// "204":
// "$ref": "#/responses/empty"
// "404":
// "$ref": "#/responses/notFound"
// "422":
// "$ref": "#/responses/validationError"

Expand Down Expand Up @@ -215,6 +219,8 @@ func DeleteCollaborator(ctx *context.APIContext) {
// responses:
// "204":
// "$ref": "#/responses/empty"
// "404":
// "$ref": "#/responses/notFound"
// "422":
// "$ref": "#/responses/validationError"

Expand Down Expand Up @@ -311,6 +317,8 @@ func GetReviewers(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/UserList"
// "404":
// "$ref": "#/responses/notFound"

reviewers, err := repo_model.GetReviewers(ctx, ctx.Repo.Repository, ctx.Doer.ID, 0)
if err != nil {
Expand Down Expand Up @@ -341,6 +349,8 @@ func GetAssignees(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/UserList"
// "404":
// "$ref": "#/responses/notFound"

assignees, err := repo_model.GetRepoAssignees(ctx, ctx.Repo.Repository)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions routers/api/v1/repo/fork.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ func ListForks(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/RepositoryList"
// "404":
// "$ref": "#/responses/notFound"

forks, err := repo_model.GetForks(ctx.Repo.Repository, utils.GetListOptions(ctx))
if err != nil {
Expand Down Expand Up @@ -99,6 +101,8 @@ func CreateFork(ctx *context.APIContext) {
// "$ref": "#/responses/Repository"
// "403":
// "$ref": "#/responses/forbidden"
// "404":
// "$ref": "#/responses/notFound"
// "409":
// description: The repository with the same name already exists.
// "422":
Expand Down
Loading