aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/v1/user/gpg_key.go
diff options
context:
space:
mode:
authorAntoine GIRARD <sapk@users.noreply.github.com>2017-05-02 15:35:59 +0200
committerKim "BKC" Carlbäcker <kim.carlbacker@gmail.com>2017-05-02 15:35:59 +0200
commit3edb0c58943c003ed3f209b2197d1f43484a3432 (patch)
treee5849cead5053ab505a2c5dc1342111c6bcf0816 /routers/api/v1/user/gpg_key.go
parentbb5f694fc57c3ade9c13e841b9a237f4e192da22 (diff)
downloadgitea-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/user/gpg_key.go')
-rw-r--r--routers/api/v1/user/gpg_key.go51
1 files changed, 51 insertions, 0 deletions
diff --git a/routers/api/v1/user/gpg_key.go b/routers/api/v1/user/gpg_key.go
index bb4ae42431..678816ccda 100644
--- a/routers/api/v1/user/gpg_key.go
+++ b/routers/api/v1/user/gpg_key.go
@@ -34,6 +34,15 @@ func listGPGKeys(ctx *context.APIContext, uid int64) {
//ListGPGKeys get the GPG key list of a user
func ListGPGKeys(ctx *context.APIContext) {
+ // swagger:route GET /users/{username}/gpg_keys userListGPGKeys
+ //
+ // Produces:
+ // - application/json
+ //
+ // Responses:
+ // 200: GPGKeyList
+ // 500: error
+
user := GetUserByParams(ctx)
if ctx.Written() {
return
@@ -43,11 +52,30 @@ func ListGPGKeys(ctx *context.APIContext) {
//ListMyGPGKeys get the GPG key list of the logged user
func ListMyGPGKeys(ctx *context.APIContext) {
+ // swagger:route GET /user/gpg_keys userCurrentListGPGKeys
+ //
+ // Produces:
+ // - application/json
+ //
+ // Responses:
+ // 200: GPGKeyList
+ // 500: error
+
listGPGKeys(ctx, ctx.User.ID)
}
//GetGPGKey get the GPG key based on a id
func GetGPGKey(ctx *context.APIContext) {
+ // swagger:route GET /user/gpg_keys/{id} userCurrentGetGPGKey
+ //
+ // Produces:
+ // - application/json
+ //
+ // Responses:
+ // 200: GPGKey
+ // 404: notFound
+ // 500: error
+
key, err := models.GetGPGKeyByID(ctx.ParamsInt64(":id"))
if err != nil {
if models.IsErrGPGKeyNotExist(err) {
@@ -72,11 +100,34 @@ func CreateUserGPGKey(ctx *context.APIContext, form api.CreateGPGKeyOption, uid
//CreateGPGKey associate a GPG key to the current user
func CreateGPGKey(ctx *context.APIContext, form api.CreateGPGKeyOption) {
+ // swagger:route POST /user/gpg_keys userCurrentPostGPGKey
+ //
+ // Consumes:
+ // - application/json
+ //
+ // Produces:
+ // - application/json
+ //
+ // Responses:
+ // 201: GPGKey
+ // 422: validationError
+ // 500: error
+
CreateUserGPGKey(ctx, form, ctx.User.ID)
}
//DeleteGPGKey remove a GPG key associated to the current user
func DeleteGPGKey(ctx *context.APIContext) {
+ // swagger:route DELETE /user/gpg_keys/{id} userCurrentDeleteGPGKey
+ //
+ // Produces:
+ // - application/json
+ //
+ // Responses:
+ // 204: empty
+ // 403: forbidden
+ // 500: error
+
if err := models.DeleteGPGKey(ctx.User, ctx.ParamsInt64(":id")); err != nil {
if models.IsErrGPGKeyAccessDenied(err) {
ctx.Error(403, "", "You do not have access to this key")