aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/v1/org
diff options
context:
space:
mode:
authorJakobDev <jakobdev@gmx.de>2023-09-13 04:37:54 +0200
committerGitHub <noreply@github.com>2023-09-13 10:37:54 +0800
commitaaeec2a3925c8e45c14179a3e6260b92e53197d2 (patch)
tree09fb0d741cf32adb316e4eedabc0e30fc604f89d /routers/api/v1/org
parent8ecdc93f8b04f2d2e2e26bedb25fde045f0aff64 (diff)
downloadgitea-aaeec2a3925c8e45c14179a3e6260b92e53197d2.tar.gz
gitea-aaeec2a3925c8e45c14179a3e6260b92e53197d2.zip
Add missing 404 response to Swagger (#27038)
Most middleware throw a 404 in case something is not found e.g. a Repo that is not existing. But most API endpoints don't include the 404 response in their documentation. This PR changes this.
Diffstat (limited to 'routers/api/v1/org')
-rw-r--r--routers/api/v1/org/action.go2
-rw-r--r--routers/api/v1/org/avatar.go4
-rw-r--r--routers/api/v1/org/hook.go10
-rw-r--r--routers/api/v1/org/label.go10
-rw-r--r--routers/api/v1/org/member.go10
-rw-r--r--routers/api/v1/org/org.go10
-rw-r--r--routers/api/v1/org/team.go20
7 files changed, 66 insertions, 0 deletions
diff --git a/routers/api/v1/org/action.go b/routers/api/v1/org/action.go
index e50a77f362..5af6125773 100644
--- a/routers/api/v1/org/action.go
+++ b/routers/api/v1/org/action.go
@@ -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,
diff --git a/routers/api/v1/org/avatar.go b/routers/api/v1/org/avatar.go
index b3cb0b81a6..a7b5008525 100644
--- a/routers/api/v1/org/avatar.go
+++ b/routers/api/v1/org/avatar.go
@@ -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)
@@ -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)
diff --git a/routers/api/v1/org/hook.go b/routers/api/v1/org/hook.go
index a6ea618a7d..3c3f058b5d 100644
--- a/routers/api/v1/org/hook.go
+++ b/routers/api/v1/org/hook.go
@@ -37,6 +37,8 @@ func ListHooks(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/HookList"
+ // "404":
+ // "$ref": "#/responses/notFound"
utils.ListOwnerHooks(
ctx,
@@ -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 {
@@ -103,6 +107,8 @@ func CreateHook(ctx *context.APIContext) {
// responses:
// "201":
// "$ref": "#/responses/Hook"
+ // "404":
+ // "$ref": "#/responses/notFound"
utils.AddOwnerHook(
ctx,
@@ -139,6 +145,8 @@ func EditHook(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/Hook"
+ // "404":
+ // "$ref": "#/responses/notFound"
utils.EditOwnerHook(
ctx,
@@ -170,6 +178,8 @@ func DeleteHook(ctx *context.APIContext) {
// responses:
// "204":
// "$ref": "#/responses/empty"
+ // "404":
+ // "$ref": "#/responses/notFound"
utils.DeleteOwnerHook(
ctx,
diff --git a/routers/api/v1/org/label.go b/routers/api/v1/org/label.go
index 9ef28d4db9..2dd4505a91 100644
--- a/routers/api/v1/org/label.go
+++ b/routers/api/v1/org/label.go
@@ -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 {
@@ -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)
@@ -128,6 +132,8 @@ func GetLabel(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/Label"
+ // "404":
+ // "$ref": "#/responses/notFound"
var (
label *issues_model.Label
@@ -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)
@@ -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)
diff --git a/routers/api/v1/org/member.go b/routers/api/v1/org/member.go
index e4afd7f3c6..e5ea584d5d 100644
--- a/routers/api/v1/org/member.go
+++ b/routers/api/v1/org/member.go
@@ -70,6 +70,8 @@ func ListMembers(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/UserList"
+ // "404":
+ // "$ref": "#/responses/notFound"
publicOnly := true
if ctx.Doer != nil {
@@ -107,6 +109,8 @@ func ListPublicMembers(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/UserList"
+ // "404":
+ // "$ref": "#/responses/notFound"
listMembers(ctx, true)
}
@@ -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() {
@@ -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() {
@@ -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() {
diff --git a/routers/api/v1/org/org.go b/routers/api/v1/org/org.go
index b0666c87f8..0216b62352 100644
--- a/routers/api/v1/org/org.go
+++ b/routers/api/v1/org/org.go
@@ -70,6 +70,8 @@ func ListMyOrgs(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/OrganizationList"
+ // "404":
+ // "$ref": "#/responses/notFound"
listUserOrgs(ctx, ctx.Doer)
}
@@ -98,6 +100,8 @@ func ListUserOrgs(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/OrganizationList"
+ // "404":
+ // "$ref": "#/responses/notFound"
listUserOrgs(ctx, ctx.ContextUser)
}
@@ -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)
@@ -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
@@ -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)
diff --git a/routers/api/v1/org/team.go b/routers/api/v1/org/team.go
index 4b52fb8987..abb5381a70 100644
--- a/routers/api/v1/org/team.go
+++ b/routers/api/v1/org/team.go
@@ -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),
@@ -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 {
@@ -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)
@@ -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
@@ -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)
@@ -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 {
@@ -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{
@@ -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() {
@@ -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() {
@@ -775,6 +793,8 @@ func SearchTeam(ctx *context.APIContext) {
// type: array
// items:
// "$ref": "#/definitions/Team"
+ // "404":
+ // "$ref": "#/responses/notFound"
listOptions := utils.GetListOptions(ctx)