diff options
author | Antoine GIRARD <sapk@users.noreply.github.com> | 2017-05-02 15:35:59 +0200 |
---|---|---|
committer | Kim "BKC" Carlbäcker <kim.carlbacker@gmail.com> | 2017-05-02 15:35:59 +0200 |
commit | 3edb0c58943c003ed3f209b2197d1f43484a3432 (patch) | |
tree | e5849cead5053ab505a2c5dc1342111c6bcf0816 /routers/api/v1/repo/hook.go | |
parent | bb5f694fc57c3ade9c13e841b9a237f4e192da22 (diff) | |
download | gitea-3edb0c58943c003ed3f209b2197d1f43484a3432.tar.gz gitea-3edb0c58943c003ed3f209b2197d1f43484a3432.zip |
Generate swagger json (#1402)
- Generate swagger.json into public/
- Add swagger-ui auto-installation
- Add footer link to local swagger-ui
- Add /swagger url for using app url.
- Fix Swagger-UI version via git tag
Diffstat (limited to 'routers/api/v1/repo/hook.go')
-rw-r--r-- | routers/api/v1/repo/hook.go | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/routers/api/v1/repo/hook.go b/routers/api/v1/repo/hook.go index 2e3b655a12..93dcd081d7 100644 --- a/routers/api/v1/repo/hook.go +++ b/routers/api/v1/repo/hook.go @@ -14,8 +14,16 @@ import ( ) // ListHooks list all hooks of a repository -// see https://github.com/gogits/go-gogs-client/wiki/Repositories#list-hooks func ListHooks(ctx *context.APIContext) { + // swagger:route GET /repos/{username}/{reponame}/hooks + // + // Produces: + // - application/json + // + // Responses: + // 200: apiHooks + // 500: error + hooks, err := models.GetWebhooksByRepoID(ctx.Repo.Repository.ID) if err != nil { ctx.Error(500, "GetWebhooksByRepoID", err) @@ -41,8 +49,20 @@ func GetHook(ctx *context.APIContext) { } // CreateHook create a hook for a repository -// see https://github.com/gogits/go-gogs-client/wiki/Repositories#create-a-hook func CreateHook(ctx *context.APIContext, form api.CreateHookOption) { + // swagger:route POST /repos/{username}/{reponame}/hooks + // + // Consumes: + // - application/json + // + // Produces: + // - application/json + // + // Responses: + // 200: apiHook + // 422: validationError + // 500: error + if !utils.CheckCreateHookOption(ctx, &form) { return } @@ -50,14 +70,33 @@ func CreateHook(ctx *context.APIContext, form api.CreateHookOption) { } // EditHook modify a hook of a repository -// see https://github.com/gogits/go-gogs-client/wiki/Repositories#edit-a-hook func EditHook(ctx *context.APIContext, form api.EditHookOption) { + // swagger:route PATCH /repos/{username}/{reponame}/hooks/{id} + // + // Produces: + // - application/json + // + // Responses: + // 200: apiHook //TODO + // 422: validationError + // 500: error + hookID := ctx.ParamsInt64(":id") utils.EditRepoHook(ctx, &form, hookID) } // DeleteHook delete a hook of a repository func DeleteHook(ctx *context.APIContext) { + // swagger:route DELETE /repos/{username}/{reponame}/hooks/{id} + // + // Produces: + // - application/json + // + // Responses: + // 204: empty + // 404: notFound + // 500: error + if err := models.DeleteWebhookByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")); err != nil { if models.IsErrWebhookNotExist(err) { ctx.Status(404) |