aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/v1/user/watch.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/watch.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/watch.go')
-rw-r--r--routers/api/v1/user/watch.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/routers/api/v1/user/watch.go b/routers/api/v1/user/watch.go
index 8bf4eeb505..230c819202 100644
--- a/routers/api/v1/user/watch.go
+++ b/routers/api/v1/user/watch.go
@@ -33,6 +33,15 @@ func getWatchedRepos(userID int64, private bool) ([]*api.Repository, error) {
// GetWatchedRepos returns the repos that the user specified in ctx is watching
func GetWatchedRepos(ctx *context.APIContext) {
+ // swagger:route GET /users/{username}/subscriptions userListSubscriptions
+ //
+ // Produces:
+ // - application/json
+ //
+ // Responses:
+ // 200: RepositoryList
+ // 500: error
+
user := GetUserByParams(ctx)
private := user.ID == ctx.User.ID
repos, err := getWatchedRepos(user.ID, private)
@@ -44,6 +53,15 @@ func GetWatchedRepos(ctx *context.APIContext) {
// GetMyWatchedRepos returns the repos that the authenticated user is watching
func GetMyWatchedRepos(ctx *context.APIContext) {
+ // swagger:route GET /user/subscriptions userCurrentListSubscriptions
+ //
+ // Produces:
+ // - application/json
+ //
+ // Responses:
+ // 200: RepositoryList
+ // 500: error
+
repos, err := getWatchedRepos(ctx.User.ID, true)
if err != nil {
ctx.Error(500, "getWatchedRepos", err)
@@ -54,6 +72,12 @@ func GetMyWatchedRepos(ctx *context.APIContext) {
// IsWatching returns whether the authenticated user is watching the repo
// specified in ctx
func IsWatching(ctx *context.APIContext) {
+ // swagger:route GET /repos/{username}/{reponame}/subscription userCurrentCheckSubscription
+ //
+ // Responses:
+ // 200: WatchInfo
+ // 404: notFound
+
if models.IsWatching(ctx.User.ID, ctx.Repo.Repository.ID) {
ctx.JSON(200, api.WatchInfo{
Subscribed: true,
@@ -70,6 +94,12 @@ func IsWatching(ctx *context.APIContext) {
// Watch the repo specified in ctx, as the authenticated user
func Watch(ctx *context.APIContext) {
+ // swagger:route PUT /repos/{username}/{reponame}/subscription userCurrentPutSubscription
+ //
+ // Responses:
+ // 200: WatchInfo
+ // 500: error
+
err := models.WatchRepo(ctx.User.ID, ctx.Repo.Repository.ID, true)
if err != nil {
ctx.Error(500, "WatchRepo", err)
@@ -88,6 +118,12 @@ func Watch(ctx *context.APIContext) {
// Unwatch the repo specified in ctx, as the authenticated user
func Unwatch(ctx *context.APIContext) {
+ // swagger:route DELETE /repos/{username}/{reponame}/subscription userCurrentDeleteSubscription
+ //
+ // Responses:
+ // 204: empty
+ // 500: error
+
err := models.WatchRepo(ctx.User.ID, ctx.Repo.Repository.ID, false)
if err != nil {
ctx.Error(500, "UnwatchRepo", err)