From 3f1f5631808d30f817b576cea7be49ac930759ec Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sun, 24 Dec 2023 15:50:01 +0100 Subject: [PATCH] fix and lint swagger file (#3007) Co-authored-by: qwerty287 --- Makefile | 1 + cmd/server/docs/docs.go | 127 ++++++++++++------------------ cmd/server/swagger.go | 1 + cmd/server/woodpecker_docs_gen.go | 18 ++++- server/api/agent.go | 6 +- server/api/badge.go | 5 +- server/api/cron.go | 6 +- server/api/global_secret.go | 6 +- server/api/hook.go | 12 +-- server/api/org_secret.go | 28 +++---- server/api/orgs.go | 2 +- server/api/pipeline.go | 29 ++++--- server/api/registry.go | 10 +-- server/api/repo.go | 13 ++- server/api/repo_secret.go | 6 +- server/api/stream.go | 16 ++-- server/api/user.go | 14 ++-- server/api/users.go | 6 +- 18 files changed, 149 insertions(+), 157 deletions(-) diff --git a/Makefile b/Makefile index 49971e746..6e8114790 100644 --- a/Makefile +++ b/Makefile @@ -105,6 +105,7 @@ generate: generate-swagger ## Run all code generations generate-swagger: install-tools ## Run swagger code generation swag init -g server/api/ -g cmd/server/swagger.go --outputTypes go -output cmd/server/docs + go generate cmd/server/swagger.go generate-license-header: install-tools addlicense -c "Woodpecker Authors" -ignore "vendor/**" **/*.go diff --git a/cmd/server/docs/docs.go b/cmd/server/docs/docs.go index c003e7884..1920cb7e7 100644 --- a/cmd/server/docs/docs.go +++ b/cmd/server/docs/docs.go @@ -261,16 +261,9 @@ const docTemplate = `{ "summary": "Provide pipeline status information to the CCMenu tool", "parameters": [ { - "type": "string", - "description": "the repository owner's name", - "name": "owner", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "the repository name", - "name": "name", + "type": "integer", + "description": "the repository id", + "name": "repo_id", "in": "path", "required": true } @@ -989,6 +982,49 @@ const docTemplate = `{ } } } + }, + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "Organization secrets" + ], + "summary": "Persist/create an organization secret", + "parameters": [ + { + "type": "string", + "default": "Bearer \u003cpersonal access token\u003e", + "description": "Insert your personal access token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "the org's id", + "name": "org_id", + "in": "path", + "required": true + }, + { + "description": "the new secret", + "name": "secretData", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Secret" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/Secret" + } + } + } } }, "/orgs/{org_id}/secrets/{secret}": { @@ -1122,51 +1158,6 @@ const docTemplate = `{ } } }, - "/orgs/{owner}/secrets": { - "post": { - "produces": [ - "application/json" - ], - "tags": [ - "Organization secrets" - ], - "summary": "Persist/create an organization secret", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cpersonal access token\u003e", - "description": "Insert your personal access token", - "name": "Authorization", - "in": "header", - "required": true - }, - { - "type": "string", - "description": "the org's id", - "name": "org_id", - "in": "path", - "required": true - }, - { - "description": "the new secret", - "name": "secretData", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/Secret" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/Secret" - } - } - } - } - }, "/pipelines": { "get": { "produces": [ @@ -2081,16 +2072,9 @@ const docTemplate = `{ "required": true }, { - "type": "string", - "description": "the repository owner's name", - "name": "owner", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "the repository name", - "name": "name", + "type": "integer", + "description": "the repository id", + "name": "repo_id", "in": "path", "required": true } @@ -2262,16 +2246,9 @@ const docTemplate = `{ "required": true }, { - "type": "string", - "description": "the repository owner's name", - "name": "owner", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "the repository name", - "name": "name", + "type": "integer", + "description": "the repository id", + "name": "repo_id", "in": "path", "required": true }, diff --git a/cmd/server/swagger.go b/cmd/server/swagger.go index a09d456e3..d1cefccae 100644 --- a/cmd/server/swagger.go +++ b/cmd/server/swagger.go @@ -21,6 +21,7 @@ import ( // generate docs/swagger.json via: //go:generate go run woodpecker_docs_gen.go swagger.go +//go:generate go run github.com/go-swagger/go-swagger/cmd/swagger@latest validate ../../docs/swagger.json // setupSwaggerStaticConfig initializes static content only (contacts, title and description) // for dynamic configuration of e.g. hostname, etc. see router.setupSwaggerConfigAndRoutes diff --git a/cmd/server/woodpecker_docs_gen.go b/cmd/server/woodpecker_docs_gen.go index 081c0c615..9f5069a62 100644 --- a/cmd/server/woodpecker_docs_gen.go +++ b/cmd/server/woodpecker_docs_gen.go @@ -22,6 +22,7 @@ package main import ( + "encoding/json" "os" "path" @@ -38,8 +39,23 @@ func main() { panic(err) } defer f.Close() - _, err = f.WriteString(docs.SwaggerInfo.ReadDoc()) + doc := docs.SwaggerInfo.ReadDoc() + doc = removeHost(doc) + _, err = f.WriteString(doc) if err != nil { panic(err) } } + +func removeHost(jsonIn string) string { + m := make(map[string]interface{}) + if err := json.Unmarshal([]byte(jsonIn), &m); err != nil { + panic(err) + } + delete(m, "host") + raw, err := json.Marshal(m) + if err != nil { + panic(err) + } + return string(raw) +} diff --git a/server/api/agent.go b/server/api/agent.go index 36bbb0429..8c5bc36f7 100644 --- a/server/api/agent.go +++ b/server/api/agent.go @@ -111,8 +111,8 @@ func GetAgentTasks(c *gin.Context) { // @Produce json // @Success 200 {object} Agent // @Tags Agents -// @Param Authorization header string true "Insert your personal access token" default(Bearer ) -// @Param agent path int true "the agent's id" +// @Param Authorization header string true "Insert your personal access token" default(Bearer ) +// @Param agent path int true "the agent's id" // @Param agentData body Agent true "the agent's data" func PatchAgent(c *gin.Context) { _store := store.FromContext(c) @@ -154,7 +154,7 @@ func PatchAgent(c *gin.Context) { // @Produce json // @Success 200 {object} Agent // @Tags Agents -// @Param Authorization header string true "Insert your personal access token" default(Bearer ) +// @Param Authorization header string true "Insert your personal access token" default(Bearer ) // @Param agent body Agent true "the agent's data (only 'name' and 'no_schedule' are read)" func PostAgent(c *gin.Context) { in := &model.Agent{} diff --git a/server/api/badge.go b/server/api/badge.go index 152fbef6c..7e3b9fdef 100644 --- a/server/api/badge.go +++ b/server/api/badge.go @@ -42,7 +42,7 @@ import ( // @Produce image/svg+xml // @Success 200 // @Tags Badges -// @Param repo_id path int true "the repository id" +// @Param repo_id path int true "the repository id" func GetBadge(c *gin.Context) { _store := store.FromContext(c) @@ -97,8 +97,7 @@ func GetBadge(c *gin.Context) { // @Produce xml // @Success 200 // @Tags Badges -// @Param owner path string true "the repository owner's name" -// @Param name path string true "the repository name" +// @Param repo_id path int true "the repository id" func GetCC(c *gin.Context) { _store := store.FromContext(c) var repo *model.Repo diff --git a/server/api/cron.go b/server/api/cron.go index f1f1a48a3..e496b6d15 100644 --- a/server/api/cron.go +++ b/server/api/cron.go @@ -102,7 +102,7 @@ func RunCron(c *gin.Context) { // @Produce json // @Success 200 {object} Cron // @Tags Repository cron jobs -// @Param Authorization header string true "Insert your personal access token" default(Bearer ) +// @Param Authorization header string true "Insert your personal access token" default(Bearer ) // @Param repo_id path int true "the repository id" // @Param cronJob body Cron true "the new cron job" func PostCron(c *gin.Context) { @@ -158,9 +158,9 @@ func PostCron(c *gin.Context) { // @Produce json // @Success 200 {object} Cron // @Tags Repository cron jobs -// @Param Authorization header string true "Insert your personal access token" default(Bearer ) +// @Param Authorization header string true "Insert your personal access token" default(Bearer ) // @Param repo_id path int true "the repository id" -// @Param cron path string true "the cron job id" +// @Param cron path string true "the cron job id" // @Param cronJob body Cron true "the cron job data" func PatchCron(c *gin.Context) { repo := session.Repo(c) diff --git a/server/api/global_secret.go b/server/api/global_secret.go index d6f992811..9c8a5e5c8 100644 --- a/server/api/global_secret.go +++ b/server/api/global_secret.go @@ -75,7 +75,7 @@ func GetGlobalSecret(c *gin.Context) { // @Produce json // @Success 200 {object} Secret // @Tags Secrets -// @Param Authorization header string true "Insert your personal access token" default(Bearer ) +// @Param Authorization header string true "Insert your personal access token" default(Bearer ) // @Param secret body Secret true "the secret object data" func PostGlobalSecret(c *gin.Context) { in := new(model.Secret) @@ -107,8 +107,8 @@ func PostGlobalSecret(c *gin.Context) { // @Produce json // @Success 200 {object} Secret // @Tags Secrets -// @Param Authorization header string true "Insert your personal access token" default(Bearer ) -// @Param secret path string true "the secret's name" +// @Param Authorization header string true "Insert your personal access token" default(Bearer ) +// @Param secret path string true "the secret's name" // @Param secretData body Secret true "the secret's data" func PatchGlobalSecret(c *gin.Context) { name := c.Param("secret") diff --git a/server/api/hook.go b/server/api/hook.go index 0d3a9b53d..961ec79d5 100644 --- a/server/api/hook.go +++ b/server/api/hook.go @@ -36,13 +36,13 @@ import ( // GetQueueInfo // -// @Summary Get pipeline queue information +// @Summary Get pipeline queue information // @Description TODO: link the InfoT response object - this is blocked, until the `swaggo/swag` tool dependency is v1.18.12 or newer -// @Router /queue/info [get] -// @Produce json -// @Success 200 {object} map[string]string -// @Tags Pipeline queues -// @Param Authorization header string true "Insert your personal access token" default(Bearer ) +// @Router /queue/info [get] +// @Produce json +// @Success 200 {object} map[string]string +// @Tags Pipeline queues +// @Param Authorization header string true "Insert your personal access token" default(Bearer ) func GetQueueInfo(c *gin.Context) { c.IndentedJSON(http.StatusOK, server.Config.Services.Queue.Info(c), diff --git a/server/api/org_secret.go b/server/api/org_secret.go index dbda4c4a5..59bbd1b16 100644 --- a/server/api/org_secret.go +++ b/server/api/org_secret.go @@ -32,7 +32,7 @@ import ( // @Router /orgs/{org_id}/secrets/{secret} [get] // @Produce json // @Success 200 {object} Secret -// @Tags Organization secrets +// @Tags Organization secrets // @Param Authorization header string true "Insert your personal access token" default(Bearer ) // @Param org_id path string true "the org's id" // @Param secret path string true "the secret's name" @@ -59,11 +59,11 @@ func GetOrgSecret(c *gin.Context) { // @Router /orgs/{org_id}/secrets [get] // @Produce json // @Success 200 {array} Secret -// @Tags Organization secrets +// @Tags Organization secrets // @Param Authorization header string true "Insert your personal access token" default(Bearer ) -// @Param org_id path string true "the org's id" +// @Param org_id path string true "the org's id" // @Param page query int false "for response pagination, page offset number" default(1) -// @Param perPage query int false "for response pagination, max items per page" default(50) +// @Param perPage query int false "for response pagination, max items per page" default(50) func GetOrgSecretList(c *gin.Context) { orgID, err := strconv.ParseInt(c.Param("org_id"), 10, 64) if err != nil { @@ -87,12 +87,12 @@ func GetOrgSecretList(c *gin.Context) { // PostOrgSecret // // @Summary Persist/create an organization secret -// @Router /orgs/{owner}/secrets [post] +// @Router /orgs/{org_id}/secrets [post] // @Produce json // @Success 200 {object} Secret -// @Tags Organization secrets -// @Param Authorization header string true "Insert your personal access token" default(Bearer ) -// @Param org_id path string true "the org's id" +// @Tags Organization secrets +// @Param Authorization header string true "Insert your personal access token" default(Bearer ) +// @Param org_id path string true "the org's id" // @Param secretData body Secret true "the new secret" func PostOrgSecret(c *gin.Context) { orgID, err := strconv.ParseInt(c.Param("org_id"), 10, 64) @@ -131,10 +131,10 @@ func PostOrgSecret(c *gin.Context) { // @Produce json // @Success 200 {object} Secret // @Tags Organization secrets -// @Param Authorization header string true "Insert your personal access token" default(Bearer ) -// @Param org_id path string true "the org's id" -// @Param secret path string true "the secret's name" -// @Param secretData body Secret true "the update secret data" +// @Param Authorization header string true "Insert your personal access token" default(Bearer ) +// @Param org_id path string true "the org's id" +// @Param secret path string true "the secret's name" +// @Param secretData body Secret true "the update secret data" func PatchOrgSecret(c *gin.Context) { name := c.Param("secret") orgID, err := strconv.ParseInt(c.Param("org_id"), 10, 64) @@ -184,8 +184,8 @@ func PatchOrgSecret(c *gin.Context) { // @Success 204 // @Tags Organization secrets // @Param Authorization header string true "Insert your personal access token" default(Bearer ) -// @Param org_id path string true "the org's id" -// @Param secret path string true "the secret's name" +// @Param org_id path string true "the org's id" +// @Param secret path string true "the secret's name" func DeleteOrgSecret(c *gin.Context) { name := c.Param("secret") orgID, err := strconv.ParseInt(c.Param("org_id"), 10, 64) diff --git a/server/api/orgs.go b/server/api/orgs.go index e54f77eb1..3e82c060b 100644 --- a/server/api/orgs.go +++ b/server/api/orgs.go @@ -53,7 +53,7 @@ func GetOrgs(c *gin.Context) { // @Success 204 // @Tags Orgs // @Param Authorization header string true "Insert your personal access token" default(Bearer ) -// @Param id path string true "the org's id" +// @Param id path string true "the org's id" func DeleteOrg(c *gin.Context) { _store := store.FromContext(c) diff --git a/server/api/pipeline.go b/server/api/pipeline.go index 6277fdf4b..4f6dce681 100644 --- a/server/api/pipeline.go +++ b/server/api/pipeline.go @@ -41,9 +41,9 @@ import ( // @Router /repos/{repo_id}/pipelines [post] // @Produce json // @Success 200 {object} Pipeline -// @Tags Pipelines -// @Param Authorization header string true "Insert your personal access token" default(Bearer ) -// @Param repo_id path int true "the repository id" +// @Tags Pipelines +// @Param Authorization header string true "Insert your personal access token" default(Bearer ) +// @Param repo_id path int true "the repository id" // @Param options body PipelineOptions true "the options for the pipeline to run" func CreatePipeline(c *gin.Context) { _store := store.FromContext(c) @@ -100,9 +100,9 @@ func createTmpPipeline(event model.WebhookEvent, commitSHA string, repo *model.R // @Success 200 {array} Pipeline // @Tags Pipelines // @Param Authorization header string true "Insert your personal access token" default(Bearer ) -// @Param repo_id path int true "the repository id" +// @Param repo_id path int true "the repository id" // @Param page query int false "for response pagination, page offset number" default(1) -// @Param perPage query int false "for response pagination, max items per page" default(50) +// @Param perPage query int false "for response pagination, max items per page" default(50) func GetPipelines(c *gin.Context) { repo := session.Repo(c) @@ -122,8 +122,8 @@ func GetPipelines(c *gin.Context) { // @Success 200 {object} Pipeline // @Tags Pipelines // @Param Authorization header string true "Insert your personal access token" default(Bearer ) -// @Param repo_id path int true "the repository id" -// @Param number path int true "the number of the pipeline, OR 'latest'" +// @Param repo_id path int true "the repository id" +// @Param number path int true "the number of the pipeline, OR 'latest'" func GetPipeline(c *gin.Context) { _store := store.FromContext(c) if c.Param("number") == "latest" { @@ -174,12 +174,12 @@ func GetPipelineLast(c *gin.Context) { // @Summary Log information // @Router /repos/{repo_id}/logs/{number}/{stepID} [get] // @Produce json -// @Success 200 {array} LogEntry -// @Tags Pipeline logs +// @Success 200 {array} LogEntry +// @Tags Pipeline logs // @Param Authorization header string true "Insert your personal access token" default(Bearer ) -// @Param repo_id path int true "the repository id" -// @Param number path int true "the number of the pipeline" -// @Param stepID path int true "the step id" +// @Param repo_id path int true "the repository id" +// @Param number path int true "the number of the pipeline" +// @Param stepID path int true "the step id" func GetStepLogs(c *gin.Context) { _store := store.FromContext(c) repo := session.Repo(c) @@ -231,7 +231,7 @@ func GetStepLogs(c *gin.Context) { // @Router /repos/{repo_id}/pipelines/{number}/config [get] // @Produce json // @Success 200 {array} Config -// @Tags Pipelines +// @Tags Pipelines // @Param Authorization header string true "Insert your personal access token" default(Bearer ) // @Param repo_id path int true "the repository id" // @Param number path int true "the number of the pipeline" @@ -378,8 +378,7 @@ func GetPipelineQueue(c *gin.Context) { // @Success 200 {object} Pipeline // @Tags Pipelines // @Param Authorization header string true "Insert your personal access token" default(Bearer ) -// @Param owner path string true "the repository owner's name" -// @Param name path string true "the repository name" +// @Param repo_id path int true "the repository id" // @Param number path int true "the number of the pipeline" // @Param event query string false "override the event type" // @Param deploy_to query string false "override the target deploy value" diff --git a/server/api/registry.go b/server/api/registry.go index 731084ab7..d8eb1b567 100644 --- a/server/api/registry.go +++ b/server/api/registry.go @@ -54,8 +54,8 @@ func GetRegistry(c *gin.Context) { // @Produce json // @Success 200 {object} Registry // @Tags Repository registries -// @Param Authorization header string true "Insert your personal access token" default(Bearer ) -// @Param repo_id path int true "the repository id" +// @Param Authorization header string true "Insert your personal access token" default(Bearer ) +// @Param repo_id path int true "the repository id" // @Param registry body Registry true "the new registry data" func PostRegistry(c *gin.Context) { repo := session.Repo(c) @@ -91,9 +91,9 @@ func PostRegistry(c *gin.Context) { // @Produce json // @Success 200 {object} Registry // @Tags Repository registries -// @Param Authorization header string true "Insert your personal access token" default(Bearer ) -// @Param repo_id path int true "the repository id" -// @Param registry path string true "the registry name" +// @Param Authorization header string true "Insert your personal access token" default(Bearer ) +// @Param repo_id path int true "the repository id" +// @Param registry path string true "the registry name" // @Param registryData body Registry true "the attributes for the registry" func PatchRegistry(c *gin.Context) { var ( diff --git a/server/api/repo.go b/server/api/repo.go index 42232faec..db16a49d7 100644 --- a/server/api/repo.go +++ b/server/api/repo.go @@ -42,8 +42,8 @@ import ( // @Produce json // @Success 200 {object} Repo // @Tags Repositories -// @Param Authorization header string true "Insert your personal access token" default(Bearer ) -// @Param forge_remote_id query string true "the id of a repository at the forge" +// @Param Authorization header string true "Insert your personal access token" default(Bearer ) +// @Param forge_remote_id query string true "the id of a repository at the forge" func PostRepo(c *gin.Context) { forge := server.Config.Services.Forge _store := store.FromContext(c) @@ -196,8 +196,8 @@ func PostRepo(c *gin.Context) { // @Produce json // @Success 200 {object} Repo // @Tags Repositories -// @Param Authorization header string true "Insert your personal access token" default(Bearer ) -// @Param repo_id path int true "the repository id" +// @Param Authorization header string true "Insert your personal access token" default(Bearer ) +// @Param repo_id path int true "the repository id" // @Param repo body RepoPatch true "the repository's information" func PatchRepo(c *gin.Context) { _store := store.FromContext(c) @@ -318,8 +318,7 @@ func GetRepo(c *gin.Context) { // @Success 200 {object} Perm // @Tags Repositories // @Param Authorization header string true "Insert your personal access token" default(Bearer ) -// @Param owner path string true "the repository owner's name" -// @Param name path string true "the repository name" +// @Param repo_id path int true "the repository id" func GetRepoPermissions(c *gin.Context) { perm := session.Perm(c) c.JSON(http.StatusOK, perm) @@ -523,7 +522,7 @@ func MoveRepo(c *gin.Context) { // @Success 200 {array} Repo // @Tags Repositories // @Param Authorization header string true "Insert your personal access token" default(Bearer ) -// @Param active query bool false "only list active repos" +// @Param active query bool false "only list active repos" // @Param page query int false "for response pagination, page offset number" default(1) // @Param perPage query int false "for response pagination, max items per page" default(50) func GetAllRepos(c *gin.Context) { diff --git a/server/api/repo_secret.go b/server/api/repo_secret.go index 84fe4ca7b..534af7369 100644 --- a/server/api/repo_secret.go +++ b/server/api/repo_secret.go @@ -55,7 +55,7 @@ func GetSecret(c *gin.Context) { // @Produce json // @Success 200 {object} Secret // @Tags Repository secrets -// @Param Authorization header string true "Insert your personal access token" default(Bearer ) +// @Param Authorization header string true "Insert your personal access token" default(Bearer ) // @Param repo_id path int true "the repository id" // @Param secret body Secret true "the new secret" func PostSecret(c *gin.Context) { @@ -91,9 +91,9 @@ func PostSecret(c *gin.Context) { // @Produce json // @Success 200 {object} Secret // @Tags Repository secrets -// @Param Authorization header string true "Insert your personal access token" default(Bearer ) +// @Param Authorization header string true "Insert your personal access token" default(Bearer ) // @Param repo_id path int true "the repository id" -// @Param secretName path string true "the secret name" +// @Param secretName path string true "the secret name" // @Param secret body Secret true "the secret itself" func PatchSecret(c *gin.Context) { var ( diff --git a/server/api/stream.go b/server/api/stream.go index 7e40dcc36..8fa9c4974 100644 --- a/server/api/stream.go +++ b/server/api/stream.go @@ -36,11 +36,11 @@ import ( // EventStreamSSE // -// @Summary Event stream +// @Summary Event stream // @Description event source streaming for compatibility with quic and http2 -// @Router /stream/events [get] -// @Produce plain -// @Success 200 +// @Router /stream/events [get] +// @Produce plain +// @Success 200 // @Tags Events func EventStreamSSE(c *gin.Context) { c.Header("Content-Type", "text/event-stream") @@ -128,10 +128,10 @@ func EventStreamSSE(c *gin.Context) { // @Router /stream/logs/{repo_id}/{pipeline}/{stepID} [get] // @Produce plain // @Success 200 -// @Tags Pipeline logs -// @Param repo_id path int true "the repository id" -// @Param pipeline path int true "the number of the pipeline" -// @Param stepID path int true "the step id" +// @Tags Pipeline logs +// @Param repo_id path int true "the repository id" +// @Param pipeline path int true "the number of the pipeline" +// @Param stepID path int true "the step id" func LogStreamSSE(c *gin.Context) { c.Header("Content-Type", "text/event-stream") c.Header("Cache-Control", "no-cache") diff --git a/server/api/user.go b/server/api/user.go index d9c06d43f..4bd15ed34 100644 --- a/server/api/user.go +++ b/server/api/user.go @@ -83,7 +83,7 @@ func GetFeed(c *gin.Context) { // @Success 200 {array} Repo // @Tags User // @Param Authorization header string true "Insert your personal access token" default(Bearer ) -// @Param all query bool false "query all repos, including inactive ones" +// @Param all query bool false "query all repos, including inactive ones" func GetRepos(c *gin.Context) { _store := store.FromContext(c) _forge := server.Config.Services.Forge @@ -141,12 +141,12 @@ func GetRepos(c *gin.Context) { // PostToken // -// @Summary Return the token of the current user as string -// @Router /user/token [post] -// @Produce plain -// @Success 200 -// @Tags User -// @Param Authorization header string true "Insert your personal access token" default(Bearer ) +// @Summary Return the token of the current user as string +// @Router /user/token [post] +// @Produce plain +// @Success 200 +// @Tags User +// @Param Authorization header string true "Insert your personal access token" default(Bearer ) func PostToken(c *gin.Context) { user := session.User(c) tokenString, err := token.New(token.UserToken, user.Login).Sign(user.Hash) diff --git a/server/api/users.go b/server/api/users.go index 5769d4c02..b94e53043 100644 --- a/server/api/users.go +++ b/server/api/users.go @@ -74,8 +74,8 @@ func GetUser(c *gin.Context) { // @Accept json // @Success 200 {object} User // @Tags Users -// @Param Authorization header string true "Insert your personal access token" default(Bearer ) -// @Param login path string true "the user's login name" +// @Param Authorization header string true "Insert your personal access token" default(Bearer ) +// @Param login path string true "the user's login name" // @Param user body User true "the user's data" func PatchUser(c *gin.Context) { _store := store.FromContext(c) @@ -116,7 +116,7 @@ func PatchUser(c *gin.Context) { // @Produce json // @Success 200 {object} User // @Tags Users -// @Param Authorization header string true "Insert your personal access token" default(Bearer ) +// @Param Authorization header string true "Insert your personal access token" default(Bearer ) // @Param user body User true "the user's data" func PostUser(c *gin.Context) { in := &model.User{}