1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

fix: swagger /api/api duplication

Resolves #289
This commit is contained in:
Steven Tang
2022-01-02 11:22:58 +11:00
parent aaa907a7b2
commit 9950da3e7e
14 changed files with 722 additions and 706 deletions

View File

@ -2,12 +2,13 @@ package api
import (
"encoding/json"
"net/http"
"github.com/gorilla/mux"
conf "github.com/muety/wakapi/config"
"github.com/muety/wakapi/middlewares"
"github.com/muety/wakapi/services"
"github.com/muety/wakapi/utils"
"net/http"
"github.com/muety/wakapi/models"
)
@ -41,7 +42,7 @@ func (h *DiagnosticsApiHandler) RegisterRoutes(router *mux.Router) {
// @Param diagnostics body models.Diagnostics true "A single diagnostics object sent by WakaTime CLI"
// @Security ApiKeyAuth
// @Success 201
// @Router /api/plugins/errors [post]
// @Router /plugins/errors [post]
func (h *DiagnosticsApiHandler) Post(w http.ResponseWriter, r *http.Request) {
var diagnostics models.Diagnostics

View File

@ -2,9 +2,10 @@ package api
import (
"fmt"
"net/http"
"github.com/gorilla/mux"
"gorm.io/gorm"
"net/http"
)
type HealthApiHandler struct {
@ -25,7 +26,7 @@ func (h *HealthApiHandler) RegisterRoutes(router *mux.Router) {
// @Tags misc
// @Produce plain
// @Success 200 {string} string
// @Router /api/health [get]
// @Router /health [get]
func (h *HealthApiHandler) Get(w http.ResponseWriter, r *http.Request) {
var dbStatus int
if sqlDb, err := h.db.DB(); err == nil {

View File

@ -3,6 +3,9 @@ package api
import (
"bytes"
"encoding/json"
"io/ioutil"
"net/http"
"github.com/gorilla/mux"
conf "github.com/muety/wakapi/config"
"github.com/muety/wakapi/middlewares"
@ -10,8 +13,6 @@ import (
routeutils "github.com/muety/wakapi/routes/utils"
"github.com/muety/wakapi/services"
"github.com/muety/wakapi/utils"
"io/ioutil"
"net/http"
"github.com/muety/wakapi/models"
)
@ -60,7 +61,7 @@ func (h *HeartbeatApiHandler) RegisterRoutes(router *mux.Router) {
// @Param heartbeat body models.Heartbeat true "A single heartbeat"
// @Security ApiKeyAuth
// @Success 201
// @Router /api/heartbeat [post]
// @Router /heartbeat [post]
func (h *HeartbeatApiHandler) Post(w http.ResponseWriter, r *http.Request) {
user, err := routeutils.CheckEffectiveUser(w, r, h.userSrvc, "current")
if err != nil {
@ -182,7 +183,7 @@ func constructSuccessResponse(n int) *heartbeatResponseVm {
// @Param heartbeat body models.Heartbeat true "A single heartbeat"
// @Security ApiKeyAuth
// @Success 201
// @Router /api/v1/users/{user}/heartbeats [post]
// @Router /v1/users/{user}/heartbeats [post]
func (h *HeartbeatApiHandler) postAlias1() {}
// @Summary Push a new heartbeat
@ -192,7 +193,7 @@ func (h *HeartbeatApiHandler) postAlias1() {}
// @Param heartbeat body models.Heartbeat true "A single heartbeat"
// @Security ApiKeyAuth
// @Success 201
// @Router /api/compat/wakatime/v1/users/{user}/heartbeats [post]
// @Router /compat/wakatime/v1/users/{user}/heartbeats [post]
func (h *HeartbeatApiHandler) postAlias2() {}
// @Summary Push a new heartbeat
@ -202,7 +203,7 @@ func (h *HeartbeatApiHandler) postAlias2() {}
// @Param heartbeat body models.Heartbeat true "A single heartbeat"
// @Security ApiKeyAuth
// @Success 201
// @Router /api/users/{user}/heartbeats [post]
// @Router /users/{user}/heartbeats [post]
func (h *HeartbeatApiHandler) postAlias3() {}
// @Summary Push new heartbeats
@ -212,7 +213,7 @@ func (h *HeartbeatApiHandler) postAlias3() {}
// @Param heartbeat body []models.Heartbeat true "Multiple heartbeats"
// @Security ApiKeyAuth
// @Success 201
// @Router /api/heartbeats [post]
// @Router /heartbeats [post]
func (h *HeartbeatApiHandler) postAlias4() {}
// @Summary Push new heartbeats
@ -222,7 +223,7 @@ func (h *HeartbeatApiHandler) postAlias4() {}
// @Param heartbeat body []models.Heartbeat true "Multiple heartbeats"
// @Security ApiKeyAuth
// @Success 201
// @Router /api/v1/users/{user}/heartbeats.bulk [post]
// @Router /v1/users/{user}/heartbeats.bulk [post]
func (h *HeartbeatApiHandler) postAlias5() {}
// @Summary Push new heartbeats
@ -232,7 +233,7 @@ func (h *HeartbeatApiHandler) postAlias5() {}
// @Param heartbeat body []models.Heartbeat true "Multiple heartbeats"
// @Security ApiKeyAuth
// @Success 201
// @Router /api/compat/wakatime/v1/users/{user}/heartbeats.bulk [post]
// @Router /compat/wakatime/v1/users/{user}/heartbeats.bulk [post]
func (h *HeartbeatApiHandler) postAlias6() {}
// @Summary Push new heartbeats
@ -242,5 +243,5 @@ func (h *HeartbeatApiHandler) postAlias6() {}
// @Param heartbeat body []models.Heartbeat true "Multiple heartbeats"
// @Security ApiKeyAuth
// @Success 201
// @Router /api/users/{user}/heartbeats.bulk [post]
// @Router /users/{user}/heartbeats.bulk [post]
func (h *HeartbeatApiHandler) postAlias7() {}

View File

@ -1,13 +1,14 @@
package api
import (
"net/http"
"github.com/gorilla/mux"
conf "github.com/muety/wakapi/config"
"github.com/muety/wakapi/middlewares"
su "github.com/muety/wakapi/routes/utils"
"github.com/muety/wakapi/services"
"github.com/muety/wakapi/utils"
"net/http"
)
type SummaryApiHandler struct {
@ -42,7 +43,7 @@ func (h *SummaryApiHandler) RegisterRoutes(router *mux.Router) {
// @Param recompute query bool false "Whether to recompute the summary from raw heartbeat or use cache"
// @Security ApiKeyAuth
// @Success 200 {object} models.Summary
// @Router /api/summary [get]
// @Router /summary [get]
func (h *SummaryApiHandler) Get(w http.ResponseWriter, r *http.Request) {
summary, err, status := su.LoadUserSummary(h.summarySrvc, r)
if err != nil {