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

docs: include relay endpoint in swagger docs

This commit is contained in:
Ferdinand Mütsch 2021-10-13 17:47:18 +02:00
parent 2c7977cf63
commit 3b96bd3723
15 changed files with 650 additions and 70 deletions

View File

@ -41,7 +41,7 @@ func (h *DiagnosticsApiHandler) RegisterRoutes(router *mux.Router) {
// @Param diagnostics body models.Diagnostics true "A single diagnostics object sent by WakaTime CLI" // @Param diagnostics body models.Diagnostics true "A single diagnostics object sent by WakaTime CLI"
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Success 201 // @Success 201
// @Router /plugins/errors [post] // @Router /api/plugins/errors [post]
func (h *DiagnosticsApiHandler) Post(w http.ResponseWriter, r *http.Request) { func (h *DiagnosticsApiHandler) Post(w http.ResponseWriter, r *http.Request) {
var diagnostics models.Diagnostics var diagnostics models.Diagnostics

View File

@ -25,7 +25,7 @@ func (h *HealthApiHandler) RegisterRoutes(router *mux.Router) {
// @Tags misc // @Tags misc
// @Produce plain // @Produce plain
// @Success 200 {string} string // @Success 200 {string} string
// @Router /health [get] // @Router /api/health [get]
func (h *HealthApiHandler) Get(w http.ResponseWriter, r *http.Request) { func (h *HealthApiHandler) Get(w http.ResponseWriter, r *http.Request) {
var dbStatus int var dbStatus int
if sqlDb, err := h.db.DB(); err == nil { if sqlDb, err := h.db.DB(); err == nil {

View File

@ -60,7 +60,7 @@ func (h *HeartbeatApiHandler) RegisterRoutes(router *mux.Router) {
// @Param heartbeat body models.Heartbeat true "A single heartbeat" // @Param heartbeat body models.Heartbeat true "A single heartbeat"
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Success 201 // @Success 201
// @Router /heartbeat [post] // @Router /api/heartbeat [post]
func (h *HeartbeatApiHandler) Post(w http.ResponseWriter, r *http.Request) { func (h *HeartbeatApiHandler) Post(w http.ResponseWriter, r *http.Request) {
user, err := routeutils.CheckEffectiveUser(w, r, h.userSrvc, "current") user, err := routeutils.CheckEffectiveUser(w, r, h.userSrvc, "current")
if err != nil { if err != nil {
@ -182,7 +182,7 @@ func constructSuccessResponse(n int) *heartbeatResponseVm {
// @Param heartbeat body models.Heartbeat true "A single heartbeat" // @Param heartbeat body models.Heartbeat true "A single heartbeat"
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Success 201 // @Success 201
// @Router /v1/users/{user}/heartbeats [post] // @Router /api/v1/users/{user}/heartbeats [post]
func (h *HeartbeatApiHandler) postAlias1() {} func (h *HeartbeatApiHandler) postAlias1() {}
// @Summary Push a new heartbeat // @Summary Push a new heartbeat
@ -192,7 +192,7 @@ func (h *HeartbeatApiHandler) postAlias1() {}
// @Param heartbeat body models.Heartbeat true "A single heartbeat" // @Param heartbeat body models.Heartbeat true "A single heartbeat"
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Success 201 // @Success 201
// @Router /compat/wakatime/v1/users/{user}/heartbeats [post] // @Router /api/compat/wakatime/v1/users/{user}/heartbeats [post]
func (h *HeartbeatApiHandler) postAlias2() {} func (h *HeartbeatApiHandler) postAlias2() {}
// @Summary Push a new heartbeat // @Summary Push a new heartbeat
@ -202,7 +202,7 @@ func (h *HeartbeatApiHandler) postAlias2() {}
// @Param heartbeat body models.Heartbeat true "A single heartbeat" // @Param heartbeat body models.Heartbeat true "A single heartbeat"
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Success 201 // @Success 201
// @Router /users/{user}/heartbeats [post] // @Router /api/users/{user}/heartbeats [post]
func (h *HeartbeatApiHandler) postAlias3() {} func (h *HeartbeatApiHandler) postAlias3() {}
// @Summary Push new heartbeats // @Summary Push new heartbeats
@ -212,7 +212,7 @@ func (h *HeartbeatApiHandler) postAlias3() {}
// @Param heartbeat body []models.Heartbeat true "Multiple heartbeats" // @Param heartbeat body []models.Heartbeat true "Multiple heartbeats"
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Success 201 // @Success 201
// @Router /heartbeats [post] // @Router /api/heartbeats [post]
func (h *HeartbeatApiHandler) postAlias4() {} func (h *HeartbeatApiHandler) postAlias4() {}
// @Summary Push new heartbeats // @Summary Push new heartbeats
@ -222,7 +222,7 @@ func (h *HeartbeatApiHandler) postAlias4() {}
// @Param heartbeat body []models.Heartbeat true "Multiple heartbeats" // @Param heartbeat body []models.Heartbeat true "Multiple heartbeats"
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Success 201 // @Success 201
// @Router /v1/users/{user}/heartbeats.bulk [post] // @Router /api/v1/users/{user}/heartbeats.bulk [post]
func (h *HeartbeatApiHandler) postAlias5() {} func (h *HeartbeatApiHandler) postAlias5() {}
// @Summary Push new heartbeats // @Summary Push new heartbeats
@ -232,7 +232,7 @@ func (h *HeartbeatApiHandler) postAlias5() {}
// @Param heartbeat body []models.Heartbeat true "Multiple heartbeats" // @Param heartbeat body []models.Heartbeat true "Multiple heartbeats"
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Success 201 // @Success 201
// @Router /compat/wakatime/v1/users/{user}/heartbeats.bulk [post] // @Router /api/compat/wakatime/v1/users/{user}/heartbeats.bulk [post]
func (h *HeartbeatApiHandler) postAlias6() {} func (h *HeartbeatApiHandler) postAlias6() {}
// @Summary Push new heartbeats // @Summary Push new heartbeats
@ -242,5 +242,5 @@ func (h *HeartbeatApiHandler) postAlias6() {}
// @Param heartbeat body []models.Heartbeat true "Multiple heartbeats" // @Param heartbeat body []models.Heartbeat true "Multiple heartbeats"
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Success 201 // @Success 201
// @Router /users/{user}/heartbeats.bulk [post] // @Router /api/users/{user}/heartbeats.bulk [post]
func (h *HeartbeatApiHandler) postAlias7() {} func (h *HeartbeatApiHandler) postAlias7() {}

View File

@ -42,7 +42,7 @@ func (h *SummaryApiHandler) RegisterRoutes(router *mux.Router) {
// @Param recompute query bool false "Whether to recompute the summary from raw heartbeat or use cache" // @Param recompute query bool false "Whether to recompute the summary from raw heartbeat or use cache"
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Success 200 {object} models.Summary // @Success 200 {object} models.Summary
// @Router /summary [get] // @Router /api/summary [get]
func (h *SummaryApiHandler) Get(w http.ResponseWriter, r *http.Request) { func (h *SummaryApiHandler) Get(w http.ResponseWriter, r *http.Request) {
summary, err, status := su.LoadUserSummary(h.summarySrvc, r) summary, err, status := su.LoadUserSummary(h.summarySrvc, r)
if err != nil { if err != nil {

View File

@ -50,7 +50,7 @@ func (h *BadgeHandler) RegisterRoutes(router *mux.Router) {
// @Param interval path string true "Interval to aggregate data for" Enums(today, yesterday, week, month, year, 7_days, last_7_days, 30_days, last_30_days, 12_months, last_12_months, any) // @Param interval path string true "Interval to aggregate data for" Enums(today, yesterday, week, month, year, 7_days, last_7_days, 30_days, last_30_days, 12_months, last_12_months, any)
// @Param filter path string true "Filter to apply (e.g. 'project:wakapi' or 'language:Go')" // @Param filter path string true "Filter to apply (e.g. 'project:wakapi' or 'language:Go')"
// @Success 200 {object} v1.BadgeData // @Success 200 {object} v1.BadgeData
// @Router /compat/shields/v1/{user}/{interval}/{filter} [get] // @Router /api/compat/shields/v1/{user}/{interval}/{filter} [get]
func (h *BadgeHandler) Get(w http.ResponseWriter, r *http.Request) { func (h *BadgeHandler) Get(w http.ResponseWriter, r *http.Request) {
intervalReg := regexp.MustCompile(intervalPattern) intervalReg := regexp.MustCompile(intervalPattern)
entityFilterReg := regexp.MustCompile(entityFilterPattern) entityFilterReg := regexp.MustCompile(entityFilterPattern)

View File

@ -44,7 +44,7 @@ func (h *AllTimeHandler) RegisterRoutes(router *mux.Router) {
// @Param user path string true "User ID to fetch data for (or 'current')" // @Param user path string true "User ID to fetch data for (or 'current')"
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Success 200 {object} v1.AllTimeViewModel // @Success 200 {object} v1.AllTimeViewModel
// @Router /compat/wakatime/v1/users/{user}/all_time_since_today [get] // @Router /api/compat/wakatime/v1/users/{user}/all_time_since_today [get]
func (h *AllTimeHandler) Get(w http.ResponseWriter, r *http.Request) { func (h *AllTimeHandler) Get(w http.ResponseWriter, r *http.Request) {
values, _ := url.ParseQuery(r.URL.RawQuery) values, _ := url.ParseQuery(r.URL.RawQuery)

View File

@ -44,7 +44,7 @@ func (h *ProjectsHandler) RegisterRoutes(router *mux.Router) {
// @Param q query string true "Query to filter projects by" // @Param q query string true "Query to filter projects by"
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Success 200 {object} v1.ProjectsViewModel // @Success 200 {object} v1.ProjectsViewModel
// @Router /compat/wakatime/v1/users/{user}/projects [get] // @Router /api/compat/wakatime/v1/users/{user}/projects [get]
func (h *ProjectsHandler) Get(w http.ResponseWriter, r *http.Request) { func (h *ProjectsHandler) Get(w http.ResponseWriter, r *http.Request) {
user, err := routeutils.CheckEffectiveUser(w, r, h.userSrvc, "current") user, err := routeutils.CheckEffectiveUser(w, r, h.userSrvc, "current")
if err != nil { if err != nil {

View File

@ -50,7 +50,7 @@ func (h *StatsHandler) RegisterRoutes(router *mux.Router) {
// @Param range path string false "Range interval identifier" Enums(today, yesterday, week, month, year, 7_days, last_7_days, 30_days, last_30_days, 12_months, last_12_months, any) // @Param range path string false "Range interval identifier" Enums(today, yesterday, week, month, year, 7_days, last_7_days, 30_days, last_30_days, 12_months, last_12_months, any)
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Success 200 {object} v1.StatsViewModel // @Success 200 {object} v1.StatsViewModel
// @Router /compat/wakatime/v1/users/{user}/stats/{range} [get] // @Router /api/compat/wakatime/v1/users/{user}/stats/{range} [get]
func (h *StatsHandler) Get(w http.ResponseWriter, r *http.Request) { func (h *StatsHandler) Get(w http.ResponseWriter, r *http.Request) {
var vars = mux.Vars(r) var vars = mux.Vars(r)
var authorizedUser, requestedUser *models.User var authorizedUser, requestedUser *models.User

View File

@ -51,8 +51,8 @@ func (h *StatusBarHandler) RegisterRoutes(router *mux.Router) {
// @Produce json // @Produce json
// @Param user path string true "User ID to fetch data for (or 'current')" // @Param user path string true "User ID to fetch data for (or 'current')"
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Success 200 {object} v1.StatusBarViewModel // @Success 200 {object} StatusBarViewModel
// @Router /users/{user}/statusbar/today [get] // @Router /api/users/{user}/statusbar/today [get]
func (h *StatusBarHandler) Get(w http.ResponseWriter, r *http.Request) { func (h *StatusBarHandler) Get(w http.ResponseWriter, r *http.Request) {
user, err := routeutils.CheckEffectiveUser(w, r, h.userSrvc, "current") user, err := routeutils.CheckEffectiveUser(w, r, h.userSrvc, "current")
if err != nil { if err != nil {

View File

@ -53,7 +53,7 @@ func (h *SummariesHandler) RegisterRoutes(router *mux.Router) {
// @Param end query string false "End date (e.g. '2021-02-08')" // @Param end query string false "End date (e.g. '2021-02-08')"
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Success 200 {object} v1.SummariesViewModel // @Success 200 {object} v1.SummariesViewModel
// @Router /compat/wakatime/v1/users/{user}/summaries [get] // @Router /api/compat/wakatime/v1/users/{user}/summaries [get]
func (h *SummariesHandler) Get(w http.ResponseWriter, r *http.Request) { func (h *SummariesHandler) Get(w http.ResponseWriter, r *http.Request) {
_, err := routeutils.CheckEffectiveUser(w, r, h.userSrvc, "current") _, err := routeutils.CheckEffectiveUser(w, r, h.userSrvc, "current")
if err != nil { if err != nil {

View File

@ -41,7 +41,7 @@ func (h *UsersHandler) RegisterRoutes(router *mux.Router) {
// @Param user path string true "User ID to fetch (or 'current')" // @Param user path string true "User ID to fetch (or 'current')"
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Success 200 {object} v1.UserViewModel // @Success 200 {object} v1.UserViewModel
// @Router /compat/wakatime/v1/users/{user} [get] // @Router /api/compat/wakatime/v1/users/{user} [get]
func (h *UsersHandler) Get(w http.ResponseWriter, r *http.Request) { func (h *UsersHandler) Get(w http.ResponseWriter, r *http.Request) {
wakapiUser, err := routeutils.CheckEffectiveUser(w, r, h.userSrvc, "current") wakapiUser, err := routeutils.CheckEffectiveUser(w, r, h.userSrvc, "current")
if err != nil { if err != nil {

View File

@ -73,3 +73,48 @@ func (h *RelayHandler) Any(w http.ResponseWriter, r *http.Request) {
p.ServeHTTP(w, r) p.ServeHTTP(w, r)
} }
// @Summary Proxy an GET API request to another Wakapi instance
// @ID relay-get
// @Tags relay
// @Param X-Target-URL header string true "Original URL to perform the request to"
// @Failure 403 {string} string "Returned if request path is not whitelisted"
// @Failure 502 {string} string "Returned if upstream host is down"
// @Router /relay [get]
func (h *RelayHandler) alias1() {}
// @Summary Proxy an POST API request to another Wakapi instance
// @ID relay-post
// @Tags relay
// @Param X-Target-URL header string true "Original URL to perform the request to"
// @Failure 403 {string} string "Returned if request path is not whitelisted"
// @Failure 502 {string} string "Returned if upstream host is down"
// @Router /relay [post]
func (h *RelayHandler) alias2() {}
// @Summary Proxy an PUT API request to another Wakapi instance
// @ID relay-put
// @Tags relay
// @Param X-Target-URL header string true "Original URL to perform the request to"
// @Failure 403 {string} string "Returned if request path is not whitelisted"
// @Failure 502 {string} string "Returned if upstream host is down"
// @Router /relay [put]
func (h *RelayHandler) alias3() {}
// @Summary Proxy an PATCH API request to another Wakapi instance
// @ID relay-patch
// @Tags relay
// @Param X-Target-URL header string true "Original URL to perform the request to"
// @Failure 403 {string} string "Returned if request path is not whitelisted"
// @Failure 502 {string} string "Returned if upstream host is down"
// @Router /relay [patch]
func (h *RelayHandler) alias4() {}
// @Summary Proxy an DELETE API request to another Wakapi instance
// @ID relay-delete
// @Tags relay
// @Param X-Target-URL header string true "Original URL to perform the request to"
// @Failure 403 {string} string "Returned if request path is not whitelisted"
// @Failure 502 {string} string "Returned if upstream host is down"
// @Router /relay [delete]
func (h *RelayHandler) alias5() {}

View File

@ -32,7 +32,7 @@ var doc = `{
"host": "{{.Host}}", "host": "{{.Host}}",
"basePath": "{{.BasePath}}", "basePath": "{{.BasePath}}",
"paths": { "paths": {
"/compat/shields/v1/{user}/{interval}/{filter}": { "/api/compat/shields/v1/{user}/{interval}/{filter}": {
"get": { "get": {
"description": "Retrieve total time for a given entity (e.g. a project) within a given range (e.g. one week) in a format compatible with [Shields.io](https://shields.io/endpoint). Requires public data access to be allowed.", "description": "Retrieve total time for a given entity (e.g. a project) within a given range (e.g. one week) in a format compatible with [Shields.io](https://shields.io/endpoint). Requires public data access to be allowed.",
"produces": [ "produces": [
@ -90,7 +90,7 @@ var doc = `{
} }
} }
}, },
"/compat/wakatime/v1/users/{user}": { "/api/compat/wakatime/v1/users/{user}": {
"get": { "get": {
"security": [ "security": [
{ {
@ -125,7 +125,7 @@ var doc = `{
} }
} }
}, },
"/compat/wakatime/v1/users/{user}/all_time_since_today": { "/api/compat/wakatime/v1/users/{user}/all_time_since_today": {
"get": { "get": {
"security": [ "security": [
{ {
@ -160,7 +160,7 @@ var doc = `{
} }
} }
}, },
"/compat/wakatime/v1/users/{user}/heartbeats": { "/api/compat/wakatime/v1/users/{user}/heartbeats": {
"post": { "post": {
"security": [ "security": [
{ {
@ -193,7 +193,7 @@ var doc = `{
} }
} }
}, },
"/compat/wakatime/v1/users/{user}/heartbeats.bulk": { "/api/compat/wakatime/v1/users/{user}/heartbeats.bulk": {
"post": { "post": {
"security": [ "security": [
{ {
@ -229,7 +229,7 @@ var doc = `{
} }
} }
}, },
"/compat/wakatime/v1/users/{user}/projects": { "/api/compat/wakatime/v1/users/{user}/projects": {
"get": { "get": {
"security": [ "security": [
{ {
@ -271,7 +271,7 @@ var doc = `{
} }
} }
}, },
"/compat/wakatime/v1/users/{user}/stats/{range}": { "/api/compat/wakatime/v1/users/{user}/stats/{range}": {
"get": { "get": {
"security": [ "security": [
{ {
@ -326,7 +326,7 @@ var doc = `{
} }
} }
}, },
"/compat/wakatime/v1/users/{user}/summaries": { "/api/compat/wakatime/v1/users/{user}/summaries": {
"get": { "get": {
"security": [ "security": [
{ {
@ -393,7 +393,7 @@ var doc = `{
} }
} }
}, },
"/health": { "/api/health": {
"get": { "get": {
"produces": [ "produces": [
"text/plain" "text/plain"
@ -413,7 +413,7 @@ var doc = `{
} }
} }
}, },
"/heartbeat": { "/api/heartbeat": {
"post": { "post": {
"security": [ "security": [
{ {
@ -446,7 +446,7 @@ var doc = `{
} }
} }
}, },
"/heartbeats": { "/api/heartbeats": {
"post": { "post": {
"security": [ "security": [
{ {
@ -482,7 +482,7 @@ var doc = `{
} }
} }
}, },
"/plugins/errors": { "/api/plugins/errors": {
"post": { "post": {
"security": [ "security": [
{ {
@ -515,7 +515,7 @@ var doc = `{
} }
} }
}, },
"/summary": { "/api/summary": {
"get": { "get": {
"security": [ "security": [
{ {
@ -580,7 +580,7 @@ var doc = `{
} }
} }
}, },
"/users/{user}/heartbeats": { "/api/users/{user}/heartbeats": {
"post": { "post": {
"security": [ "security": [
{ {
@ -613,7 +613,7 @@ var doc = `{
} }
} }
}, },
"/users/{user}/heartbeats.bulk": { "/api/users/{user}/heartbeats.bulk": {
"post": { "post": {
"security": [ "security": [
{ {
@ -649,7 +649,42 @@ var doc = `{
} }
} }
}, },
"/v1/users/{user}/heartbeats": { "/api/users/{user}/statusbar/today": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Mimics https://wakatime.com/api/v1/users/current/statusbar/today. Have no official documentation",
"produces": [
"application/json"
],
"tags": [
"wakatime"
],
"summary": "Retrieve summary for statusbar",
"operationId": "statusbar",
"parameters": [
{
"type": "string",
"description": "User ID to fetch data for (or 'current')",
"name": "user",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/v1.StatusBarViewModel"
}
}
}
}
},
"/api/v1/users/{user}/heartbeats": {
"post": { "post": {
"security": [ "security": [
{ {
@ -682,7 +717,7 @@ var doc = `{
} }
} }
}, },
"/v1/users/{user}/heartbeats.bulk": { "/api/v1/users/{user}/heartbeats.bulk": {
"post": { "post": {
"security": [ "security": [
{ {
@ -717,6 +752,158 @@ var doc = `{
} }
} }
} }
},
"/relay": {
"get": {
"tags": [
"relay"
],
"summary": "Proxy an GET API request to another Wakapi instance",
"operationId": "relay-get",
"parameters": [
{
"type": "string",
"description": "Original URL to perform the request to",
"name": "X-Target-URL",
"in": "header",
"required": true
}
],
"responses": {
"403": {
"description": "Returned if request path is not whitelisted",
"schema": {
"type": "string"
}
},
"502": {
"description": "Returned if upstream host is down",
"schema": {
"type": "string"
}
}
}
},
"put": {
"tags": [
"relay"
],
"summary": "Proxy an PUT API request to another Wakapi instance",
"operationId": "relay-put",
"parameters": [
{
"type": "string",
"description": "Original URL to perform the request to",
"name": "X-Target-URL",
"in": "header",
"required": true
}
],
"responses": {
"403": {
"description": "Returned if request path is not whitelisted",
"schema": {
"type": "string"
}
},
"502": {
"description": "Returned if upstream host is down",
"schema": {
"type": "string"
}
}
}
},
"post": {
"tags": [
"relay"
],
"summary": "Proxy an POST API request to another Wakapi instance",
"operationId": "relay-post",
"parameters": [
{
"type": "string",
"description": "Original URL to perform the request to",
"name": "X-Target-URL",
"in": "header",
"required": true
}
],
"responses": {
"403": {
"description": "Returned if request path is not whitelisted",
"schema": {
"type": "string"
}
},
"502": {
"description": "Returned if upstream host is down",
"schema": {
"type": "string"
}
}
}
},
"delete": {
"tags": [
"relay"
],
"summary": "Proxy an DELETE API request to another Wakapi instance",
"operationId": "relay-delete",
"parameters": [
{
"type": "string",
"description": "Original URL to perform the request to",
"name": "X-Target-URL",
"in": "header",
"required": true
}
],
"responses": {
"403": {
"description": "Returned if request path is not whitelisted",
"schema": {
"type": "string"
}
},
"502": {
"description": "Returned if upstream host is down",
"schema": {
"type": "string"
}
}
}
},
"patch": {
"tags": [
"relay"
],
"summary": "Proxy an PATCH API request to another Wakapi instance",
"operationId": "relay-patch",
"parameters": [
{
"type": "string",
"description": "Original URL to perform the request to",
"name": "X-Target-URL",
"in": "header",
"required": true
}
],
"responses": {
"403": {
"description": "Returned if request path is not whitelisted",
"schema": {
"type": "string"
}
},
"502": {
"description": "Returned if upstream host is down",
"schema": {
"type": "string"
}
}
}
}
} }
}, },
"definitions": { "definitions": {
@ -791,6 +978,9 @@ var doc = `{
}, },
"type": { "type": {
"type": "string" "type": "string"
},
"user_agent": {
"type": "string"
} }
} }
}, },
@ -1014,6 +1204,17 @@ var doc = `{
} }
} }
}, },
"v1.StatusBarViewModel": {
"type": "object",
"properties": {
"cached_at": {
"type": "string"
},
"data": {
"$ref": "#/definitions/v1.SummariesData"
}
}
},
"v1.SummariesData": { "v1.SummariesData": {
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -16,7 +16,7 @@
}, },
"basePath": "/api", "basePath": "/api",
"paths": { "paths": {
"/compat/shields/v1/{user}/{interval}/{filter}": { "/api/compat/shields/v1/{user}/{interval}/{filter}": {
"get": { "get": {
"description": "Retrieve total time for a given entity (e.g. a project) within a given range (e.g. one week) in a format compatible with [Shields.io](https://shields.io/endpoint). Requires public data access to be allowed.", "description": "Retrieve total time for a given entity (e.g. a project) within a given range (e.g. one week) in a format compatible with [Shields.io](https://shields.io/endpoint). Requires public data access to be allowed.",
"produces": [ "produces": [
@ -74,7 +74,7 @@
} }
} }
}, },
"/compat/wakatime/v1/users/{user}": { "/api/compat/wakatime/v1/users/{user}": {
"get": { "get": {
"security": [ "security": [
{ {
@ -109,7 +109,7 @@
} }
} }
}, },
"/compat/wakatime/v1/users/{user}/all_time_since_today": { "/api/compat/wakatime/v1/users/{user}/all_time_since_today": {
"get": { "get": {
"security": [ "security": [
{ {
@ -144,7 +144,7 @@
} }
} }
}, },
"/compat/wakatime/v1/users/{user}/heartbeats": { "/api/compat/wakatime/v1/users/{user}/heartbeats": {
"post": { "post": {
"security": [ "security": [
{ {
@ -177,7 +177,7 @@
} }
} }
}, },
"/compat/wakatime/v1/users/{user}/heartbeats.bulk": { "/api/compat/wakatime/v1/users/{user}/heartbeats.bulk": {
"post": { "post": {
"security": [ "security": [
{ {
@ -213,7 +213,7 @@
} }
} }
}, },
"/compat/wakatime/v1/users/{user}/projects": { "/api/compat/wakatime/v1/users/{user}/projects": {
"get": { "get": {
"security": [ "security": [
{ {
@ -255,7 +255,7 @@
} }
} }
}, },
"/compat/wakatime/v1/users/{user}/stats/{range}": { "/api/compat/wakatime/v1/users/{user}/stats/{range}": {
"get": { "get": {
"security": [ "security": [
{ {
@ -310,7 +310,7 @@
} }
} }
}, },
"/compat/wakatime/v1/users/{user}/summaries": { "/api/compat/wakatime/v1/users/{user}/summaries": {
"get": { "get": {
"security": [ "security": [
{ {
@ -377,7 +377,7 @@
} }
} }
}, },
"/health": { "/api/health": {
"get": { "get": {
"produces": [ "produces": [
"text/plain" "text/plain"
@ -397,7 +397,7 @@
} }
} }
}, },
"/heartbeat": { "/api/heartbeat": {
"post": { "post": {
"security": [ "security": [
{ {
@ -430,7 +430,7 @@
} }
} }
}, },
"/heartbeats": { "/api/heartbeats": {
"post": { "post": {
"security": [ "security": [
{ {
@ -466,7 +466,7 @@
} }
} }
}, },
"/plugins/errors": { "/api/plugins/errors": {
"post": { "post": {
"security": [ "security": [
{ {
@ -499,7 +499,7 @@
} }
} }
}, },
"/summary": { "/api/summary": {
"get": { "get": {
"security": [ "security": [
{ {
@ -564,7 +564,7 @@
} }
} }
}, },
"/users/{user}/heartbeats": { "/api/users/{user}/heartbeats": {
"post": { "post": {
"security": [ "security": [
{ {
@ -597,7 +597,7 @@
} }
} }
}, },
"/users/{user}/heartbeats.bulk": { "/api/users/{user}/heartbeats.bulk": {
"post": { "post": {
"security": [ "security": [
{ {
@ -633,7 +633,42 @@
} }
} }
}, },
"/v1/users/{user}/heartbeats": { "/api/users/{user}/statusbar/today": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Mimics https://wakatime.com/api/v1/users/current/statusbar/today. Have no official documentation",
"produces": [
"application/json"
],
"tags": [
"wakatime"
],
"summary": "Retrieve summary for statusbar",
"operationId": "statusbar",
"parameters": [
{
"type": "string",
"description": "User ID to fetch data for (or 'current')",
"name": "user",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/v1.StatusBarViewModel"
}
}
}
}
},
"/api/v1/users/{user}/heartbeats": {
"post": { "post": {
"security": [ "security": [
{ {
@ -666,7 +701,7 @@
} }
} }
}, },
"/v1/users/{user}/heartbeats.bulk": { "/api/v1/users/{user}/heartbeats.bulk": {
"post": { "post": {
"security": [ "security": [
{ {
@ -701,6 +736,158 @@
} }
} }
} }
},
"/relay": {
"get": {
"tags": [
"relay"
],
"summary": "Proxy an GET API request to another Wakapi instance",
"operationId": "relay-get",
"parameters": [
{
"type": "string",
"description": "Original URL to perform the request to",
"name": "X-Target-URL",
"in": "header",
"required": true
}
],
"responses": {
"403": {
"description": "Returned if request path is not whitelisted",
"schema": {
"type": "string"
}
},
"502": {
"description": "Returned if upstream host is down",
"schema": {
"type": "string"
}
}
}
},
"put": {
"tags": [
"relay"
],
"summary": "Proxy an PUT API request to another Wakapi instance",
"operationId": "relay-put",
"parameters": [
{
"type": "string",
"description": "Original URL to perform the request to",
"name": "X-Target-URL",
"in": "header",
"required": true
}
],
"responses": {
"403": {
"description": "Returned if request path is not whitelisted",
"schema": {
"type": "string"
}
},
"502": {
"description": "Returned if upstream host is down",
"schema": {
"type": "string"
}
}
}
},
"post": {
"tags": [
"relay"
],
"summary": "Proxy an POST API request to another Wakapi instance",
"operationId": "relay-post",
"parameters": [
{
"type": "string",
"description": "Original URL to perform the request to",
"name": "X-Target-URL",
"in": "header",
"required": true
}
],
"responses": {
"403": {
"description": "Returned if request path is not whitelisted",
"schema": {
"type": "string"
}
},
"502": {
"description": "Returned if upstream host is down",
"schema": {
"type": "string"
}
}
}
},
"delete": {
"tags": [
"relay"
],
"summary": "Proxy an DELETE API request to another Wakapi instance",
"operationId": "relay-delete",
"parameters": [
{
"type": "string",
"description": "Original URL to perform the request to",
"name": "X-Target-URL",
"in": "header",
"required": true
}
],
"responses": {
"403": {
"description": "Returned if request path is not whitelisted",
"schema": {
"type": "string"
}
},
"502": {
"description": "Returned if upstream host is down",
"schema": {
"type": "string"
}
}
}
},
"patch": {
"tags": [
"relay"
],
"summary": "Proxy an PATCH API request to another Wakapi instance",
"operationId": "relay-patch",
"parameters": [
{
"type": "string",
"description": "Original URL to perform the request to",
"name": "X-Target-URL",
"in": "header",
"required": true
}
],
"responses": {
"403": {
"description": "Returned if request path is not whitelisted",
"schema": {
"type": "string"
}
},
"502": {
"description": "Returned if upstream host is down",
"schema": {
"type": "string"
}
}
}
}
} }
}, },
"definitions": { "definitions": {
@ -775,6 +962,9 @@
}, },
"type": { "type": {
"type": "string" "type": "string"
},
"user_agent": {
"type": "string"
} }
} }
}, },
@ -998,6 +1188,17 @@
} }
} }
}, },
"v1.StatusBarViewModel": {
"type": "object",
"properties": {
"cached_at": {
"type": "string"
},
"data": {
"$ref": "#/definitions/v1.SummariesData"
}
}
},
"v1.SummariesData": { "v1.SummariesData": {
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -49,6 +49,8 @@ definitions:
type: number type: number
type: type:
type: string type: string
user_agent:
type: string
type: object type: object
models.Summary: models.Summary:
properties: properties:
@ -198,6 +200,13 @@ definitions:
data: data:
$ref: '#/definitions/v1.StatsData' $ref: '#/definitions/v1.StatsData'
type: object type: object
v1.StatusBarViewModel:
properties:
cached_at:
type: string
data:
$ref: '#/definitions/v1.SummariesData'
type: object
v1.SummariesData: v1.SummariesData:
properties: properties:
categories: categories:
@ -342,7 +351,7 @@ info:
title: Wakapi API title: Wakapi API
version: "1.0" version: "1.0"
paths: paths:
/compat/shields/v1/{user}/{interval}/{filter}: /api/compat/shields/v1/{user}/{interval}/{filter}:
get: get:
description: Retrieve total time for a given entity (e.g. a project) within description: Retrieve total time for a given entity (e.g. a project) within
a given range (e.g. one week) in a format compatible with [Shields.io](https://shields.io/endpoint). a given range (e.g. one week) in a format compatible with [Shields.io](https://shields.io/endpoint).
@ -387,7 +396,7 @@ paths:
summary: Get badge data summary: Get badge data
tags: tags:
- badges - badges
/compat/wakatime/v1/users/{user}: /api/compat/wakatime/v1/users/{user}:
get: get:
description: Mimics https://wakatime.com/developers#users description: Mimics https://wakatime.com/developers#users
operationId: get-wakatime-user operationId: get-wakatime-user
@ -409,7 +418,7 @@ paths:
summary: Retrieve the given user summary: Retrieve the given user
tags: tags:
- wakatime - wakatime
/compat/wakatime/v1/users/{user}/all_time_since_today: /api/compat/wakatime/v1/users/{user}/all_time_since_today:
get: get:
description: Mimics https://wakatime.com/developers#all_time_since_today description: Mimics https://wakatime.com/developers#all_time_since_today
operationId: get-all-time operationId: get-all-time
@ -431,7 +440,7 @@ paths:
summary: Retrieve summary for all time summary: Retrieve summary for all time
tags: tags:
- wakatime - wakatime
/compat/wakatime/v1/users/{user}/heartbeats: /api/compat/wakatime/v1/users/{user}/heartbeats:
post: post:
consumes: consumes:
- application/json - application/json
@ -451,7 +460,7 @@ paths:
summary: Push a new heartbeat summary: Push a new heartbeat
tags: tags:
- heartbeat - heartbeat
/compat/wakatime/v1/users/{user}/heartbeats.bulk: /api/compat/wakatime/v1/users/{user}/heartbeats.bulk:
post: post:
consumes: consumes:
- application/json - application/json
@ -473,7 +482,7 @@ paths:
summary: Push new heartbeats summary: Push new heartbeats
tags: tags:
- heartbeat - heartbeat
/compat/wakatime/v1/users/{user}/projects: /api/compat/wakatime/v1/users/{user}/projects:
get: get:
description: Mimics https://wakatime.com/developers#projects description: Mimics https://wakatime.com/developers#projects
operationId: get-wakatime-projects operationId: get-wakatime-projects
@ -500,7 +509,7 @@ paths:
summary: Retrieve and fitler the user's projects summary: Retrieve and fitler the user's projects
tags: tags:
- wakatime - wakatime
/compat/wakatime/v1/users/{user}/stats/{range}: /api/compat/wakatime/v1/users/{user}/stats/{range}:
get: get:
description: Mimics https://wakatime.com/developers#stats description: Mimics https://wakatime.com/developers#stats
operationId: get-wakatimes-tats operationId: get-wakatimes-tats
@ -539,7 +548,7 @@ paths:
summary: Retrieve statistics for a given user summary: Retrieve statistics for a given user
tags: tags:
- wakatime - wakatime
/compat/wakatime/v1/users/{user}/summaries: /api/compat/wakatime/v1/users/{user}/summaries:
get: get:
description: Mimics https://wakatime.com/developers#summaries. description: Mimics https://wakatime.com/developers#summaries.
operationId: get-wakatime-summaries operationId: get-wakatime-summaries
@ -586,7 +595,7 @@ paths:
summary: Retrieve WakaTime-compatible summaries summary: Retrieve WakaTime-compatible summaries
tags: tags:
- wakatime - wakatime
/health: /api/health:
get: get:
operationId: get-health operationId: get-health
produces: produces:
@ -599,7 +608,7 @@ paths:
summary: Check the application's health status summary: Check the application's health status
tags: tags:
- misc - misc
/heartbeat: /api/heartbeat:
post: post:
consumes: consumes:
- application/json - application/json
@ -619,7 +628,7 @@ paths:
summary: Push a new heartbeat summary: Push a new heartbeat
tags: tags:
- heartbeat - heartbeat
/heartbeats: /api/heartbeats:
post: post:
consumes: consumes:
- application/json - application/json
@ -641,7 +650,7 @@ paths:
summary: Push new heartbeats summary: Push new heartbeats
tags: tags:
- heartbeat - heartbeat
/plugins/errors: /api/plugins/errors:
post: post:
consumes: consumes:
- application/json - application/json
@ -661,7 +670,7 @@ paths:
summary: Push a new diagnostics object summary: Push a new diagnostics object
tags: tags:
- diagnostics - diagnostics
/summary: /api/summary:
get: get:
operationId: get-summary operationId: get-summary
parameters: parameters:
@ -706,7 +715,7 @@ paths:
summary: Retrieve a summary summary: Retrieve a summary
tags: tags:
- summary - summary
/users/{user}/heartbeats: /api/users/{user}/heartbeats:
post: post:
consumes: consumes:
- application/json - application/json
@ -726,7 +735,7 @@ paths:
summary: Push a new heartbeat summary: Push a new heartbeat
tags: tags:
- heartbeat - heartbeat
/users/{user}/heartbeats.bulk: /api/users/{user}/heartbeats.bulk:
post: post:
consumes: consumes:
- application/json - application/json
@ -748,7 +757,30 @@ paths:
summary: Push new heartbeats summary: Push new heartbeats
tags: tags:
- heartbeat - heartbeat
/v1/users/{user}/heartbeats: /api/users/{user}/statusbar/today:
get:
description: Mimics https://wakatime.com/api/v1/users/current/statusbar/today.
Have no official documentation
operationId: statusbar
parameters:
- description: User ID to fetch data for (or 'current')
in: path
name: user
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/v1.StatusBarViewModel'
security:
- ApiKeyAuth: []
summary: Retrieve summary for statusbar
tags:
- wakatime
/api/v1/users/{user}/heartbeats:
post: post:
consumes: consumes:
- application/json - application/json
@ -768,7 +800,7 @@ paths:
summary: Push a new heartbeat summary: Push a new heartbeat
tags: tags:
- heartbeat - heartbeat
/v1/users/{user}/heartbeats.bulk: /api/v1/users/{user}/heartbeats.bulk:
post: post:
consumes: consumes:
- application/json - application/json
@ -790,6 +822,107 @@ paths:
summary: Push new heartbeats summary: Push new heartbeats
tags: tags:
- heartbeat - heartbeat
/relay:
delete:
operationId: relay-delete
parameters:
- description: Original URL to perform the request to
in: header
name: X-Target-URL
required: true
type: string
responses:
"403":
description: Returned if request path is not whitelisted
schema:
type: string
"502":
description: Returned if upstream host is down
schema:
type: string
summary: Proxy an DELETE API request to another Wakapi instance
tags:
- relay
get:
operationId: relay-get
parameters:
- description: Original URL to perform the request to
in: header
name: X-Target-URL
required: true
type: string
responses:
"403":
description: Returned if request path is not whitelisted
schema:
type: string
"502":
description: Returned if upstream host is down
schema:
type: string
summary: Proxy an GET API request to another Wakapi instance
tags:
- relay
patch:
operationId: relay-patch
parameters:
- description: Original URL to perform the request to
in: header
name: X-Target-URL
required: true
type: string
responses:
"403":
description: Returned if request path is not whitelisted
schema:
type: string
"502":
description: Returned if upstream host is down
schema:
type: string
summary: Proxy an PATCH API request to another Wakapi instance
tags:
- relay
post:
operationId: relay-post
parameters:
- description: Original URL to perform the request to
in: header
name: X-Target-URL
required: true
type: string
responses:
"403":
description: Returned if request path is not whitelisted
schema:
type: string
"502":
description: Returned if upstream host is down
schema:
type: string
summary: Proxy an POST API request to another Wakapi instance
tags:
- relay
put:
operationId: relay-put
parameters:
- description: Original URL to perform the request to
in: header
name: X-Target-URL
required: true
type: string
responses:
"403":
description: Returned if request path is not whitelisted
schema:
type: string
"502":
description: Returned if upstream host is down
schema:
type: string
summary: Proxy an PUT API request to another Wakapi instance
tags:
- relay
securityDefinitions: securityDefinitions:
ApiKeyAuth: ApiKeyAuth:
in: header in: header