mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-15 22:42:43 +00:00
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
This commit is contained in:
parent
4287d100b3
commit
f26f4a7e01
72 changed files with 8875 additions and 2323 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue