aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/v1/org/hook.go
diff options
context:
space:
mode:
authorEthan Koenig <ethantkoenig@gmail.com>2017-11-12 23:02:25 -0800
committerLauris BH <lauris@nix.lv>2017-11-13 09:02:25 +0200
commitf26f4a7e01f9c380c261fa5bc21bd7e48f2f2f9f (patch)
tree39c2fc0abc5a10f80f8fa31b3bd57ec3604bf7fd /routers/api/v1/org/hook.go
parent4287d100b39ff89e297ba8945e54fb5911226974 (diff)
downloadgitea-f26f4a7e01f9c380c261fa5bc21bd7e48f2f2f9f.tar.gz
gitea-f26f4a7e01f9c380c261fa5bc21bd7e48f2f2f9f.zip
Update swagger documentation (#2899)
* Update swagger documentation Add docs for missing endpoints Add documentation for request parameters Make parameter naming consistent Fix response documentation * Restore delete comments
Diffstat (limited to 'routers/api/v1/org/hook.go')
-rw-r--r--routers/api/v1/org/hook.go100
1 files changed, 44 insertions, 56 deletions
diff --git a/routers/api/v1/org/hook.go b/routers/api/v1/org/hook.go
index d8a4c45fc8..0a77d795e6 100644
--- a/routers/api/v1/org/hook.go
+++ b/routers/api/v1/org/hook.go
@@ -15,15 +15,14 @@ import (
// ListHooks list an organziation's webhooks
func ListHooks(ctx *context.APIContext) {
- // swagger:route GET /orgs/{orgname}/hooks organization orgListHooks
- //
- // Produces:
- // - application/json
- //
- // Responses:
- // 200: HookList
- // 500: error
-
+ // swagger:operation GET /orgs/{org}/hooks organization orgListHooks
+ // ---
+ // summary: List an organization's webhooks
+ // produces:
+ // - application/json
+ // responses:
+ // "200":
+ // "$ref": "#/responses/HookList"
org := ctx.Org.Organization
orgHooks, err := models.GetWebhooksByOrgID(org.ID)
if err != nil {
@@ -39,16 +38,14 @@ func ListHooks(ctx *context.APIContext) {
// GetHook get an organization's hook by id
func GetHook(ctx *context.APIContext) {
- // swagger:route GET /orgs/{orgname}/hooks/{id} organization orgGetHook
- //
- // Produces:
- // - application/json
- //
- // Responses:
- // 200: Hook
- // 404: notFound
- // 500: error
-
+ // swagger:operation GET /orgs/{org}/hooks/{id} organization orgGetHook
+ // ---
+ // summary: Get a hook
+ // produces:
+ // - application/json
+ // responses:
+ // "200":
+ // "$ref": "#/responses/Hook"
org := ctx.Org.Organization
hookID := ctx.ParamsInt64(":id")
hook, err := utils.GetOrgHook(ctx, org.ID, hookID)
@@ -60,19 +57,16 @@ func GetHook(ctx *context.APIContext) {
// CreateHook create a hook for an organization
func CreateHook(ctx *context.APIContext, form api.CreateHookOption) {
- // swagger:route POST /orgs/{orgname}/hooks/ organization orgCreateHook
- //
- // Consumes:
- // - application/json
- //
- // Produces:
- // - application/json
- //
- // Responses:
- // 201: Hook
- // 422: validationError
- // 500: error
-
+ // swagger:operation POST /orgs/{org}/hooks/ organization orgCreateHook
+ // ---
+ // summary: Create a hook
+ // consumes:
+ // - application/json
+ // produces:
+ // - application/json
+ // responses:
+ // "201":
+ // "$ref": "#/responses/Hook"
if !utils.CheckCreateHookOption(ctx, &form) {
return
}
@@ -81,36 +75,30 @@ func CreateHook(ctx *context.APIContext, form api.CreateHookOption) {
// EditHook modify a hook of a repository
func EditHook(ctx *context.APIContext, form api.EditHookOption) {
- // swagger:route PATCH /orgs/{orgname}/hooks/{id} organization orgEditHook
- //
- // Consumes:
- // - application/json
- //
- // Produces:
- // - application/json
- //
- // Responses:
- // 200: Hook
- // 422: validationError
- // 404: notFound
- // 500: error
-
+ // swagger:operation PATCH /orgs/{org}/hooks/{id} organization orgEditHook
+ // ---
+ // summary: Update a hook
+ // consumes:
+ // - application/json
+ // produces:
+ // - application/json
+ // responses:
+ // "200":
+ // "$ref": "#/responses/Hook"
hookID := ctx.ParamsInt64(":id")
utils.EditOrgHook(ctx, &form, hookID)
}
// DeleteHook delete a hook of an organization
func DeleteHook(ctx *context.APIContext) {
- // swagger:route DELETE /orgs/{orgname}/hooks/{id} organization orgDeleteHook
- //
- // Produces:
- // - application/json
- //
- // Responses:
- // 204: empty
- // 404: notFound
- // 500: error
-
+ // swagger:operation DELETE /orgs/{org}/hooks/{id} organization orgDeleteHook
+ // ---
+ // summary: Delete a hook
+ // produces:
+ // - application/json
+ // responses:
+ // "204":
+ // "$ref": "#/responses/empty"
org := ctx.Org.Organization
hookID := ctx.ParamsInt64(":id")
if err := models.DeleteWebhookByOrgID(org.ID, hookID); err != nil {