aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/v1/user/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/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/key.go')
-rw-r--r--routers/api/v1/user/key.go56
1 files changed, 51 insertions, 5 deletions
diff --git a/routers/api/v1/user/key.go b/routers/api/v1/user/key.go
index 39a045df32..a53ed2f8c9 100644
--- a/routers/api/v1/user/key.go
+++ b/routers/api/v1/user/key.go
@@ -54,14 +54,30 @@ func listPublicKeys(ctx *context.APIContext, uid int64) {
}
// ListMyPublicKeys list all my public keys
-// see https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#list-your-public-keys
func ListMyPublicKeys(ctx *context.APIContext) {
+ // swagger:route GET /user/keys userCurrentListKeys
+ //
+ // Produces:
+ // - application/json
+ //
+ // Responses:
+ // 200: PublicKeyList
+ // 500: error
+
listPublicKeys(ctx, ctx.User.ID)
}
// ListPublicKeys list all user's public keys
-// see https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#list-public-keys-for-a-user
func ListPublicKeys(ctx *context.APIContext) {
+ // swagger:route GET /users/{username}/keys userListKeys
+ //
+ // Produces:
+ // - application/json
+ //
+ // Responses:
+ // 200: PublicKeyList
+ // 500: error
+
user := GetUserByParams(ctx)
if ctx.Written() {
return
@@ -70,8 +86,17 @@ func ListPublicKeys(ctx *context.APIContext) {
}
// GetPublicKey get one public key
-// see https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#get-a-single-public-key
func GetPublicKey(ctx *context.APIContext) {
+ // swagger:route GET /user/keys/{id} userCurrentGetKey
+ //
+ // Produces:
+ // - application/json
+ //
+ // Responses:
+ // 200: PublicKey
+ // 404: notFound
+ // 500: error
+
key, err := models.GetPublicKeyByID(ctx.ParamsInt64(":id"))
if err != nil {
if models.IsErrKeyNotExist(err) {
@@ -104,14 +129,35 @@ func CreateUserPublicKey(ctx *context.APIContext, form api.CreateKeyOption, uid
}
// CreatePublicKey create one public key for me
-// see https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#create-a-public-key
func CreatePublicKey(ctx *context.APIContext, form api.CreateKeyOption) {
+ // swagger:route POST /user/keys userCurrentPostKey
+ //
+ // Consumes:
+ // - application/json
+ //
+ // Produces:
+ // - application/json
+ //
+ // Responses:
+ // 201: PublicKey
+ // 422: validationError
+ // 500: error
+
CreateUserPublicKey(ctx, form, ctx.User.ID)
}
// DeletePublicKey delete one public key of mine
-// see https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#delete-a-public-key
func DeletePublicKey(ctx *context.APIContext) {
+ // swagger:route DELETE /user/keys/{id} userCurrentDeleteKey
+ //
+ // Produces:
+ // - application/json
+ //
+ // Responses:
+ // 204: empty
+ // 403: forbidden
+ // 500: error
+
if err := models.DeletePublicKey(ctx.User, ctx.ParamsInt64(":id")); err != nil {
if models.IsErrKeyAccessDenied(err) {
ctx.Error(403, "", "You do not have access to this key")