Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1102,14 +1102,20 @@ const docTemplate = `{
"name": "id",
"in": "path",
"required": true
},
{
"description": "Set whether this token is permanent (does not expire)",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handler.UpdateTokenPayload"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/Token"
}
"description": "OK"
},
"400": {
"description": "Bad Request"
Expand Down Expand Up @@ -1148,10 +1154,7 @@ const docTemplate = `{
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/Token"
}
"description": "OK"
},
"400": {
"description": "Bad Request"
Expand Down Expand Up @@ -1475,6 +1478,14 @@ const docTemplate = `{
"type": "string"
}
}
},
"handler.UpdateTokenPayload": {
"type": "object",
"properties": {
"permanent": {
"type": "boolean"
}
}
}
}
}`
Expand Down
27 changes: 19 additions & 8 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1096,14 +1096,20 @@
"name": "id",
"in": "path",
"required": true
},
{
"description": "Set whether this token is permanent (does not expire)",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handler.UpdateTokenPayload"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/Token"
}
"description": "OK"
},
"400": {
"description": "Bad Request"
Expand Down Expand Up @@ -1142,10 +1148,7 @@
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/Token"
}
"description": "OK"
},
"400": {
"description": "Bad Request"
Expand Down Expand Up @@ -1469,6 +1472,14 @@
"type": "string"
}
}
},
"handler.UpdateTokenPayload": {
"type": "object",
"properties": {
"permanent": {
"type": "boolean"
}
}
}
}
}
15 changes: 11 additions & 4 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ definitions:
username:
type: string
type: object
handler.UpdateTokenPayload:
properties:
permanent:
type: boolean
type: object
host: https://lighthouse.uni-kiel.de
info:
contact: {}
Expand Down Expand Up @@ -895,8 +900,6 @@ paths:
responses:
"200":
description: OK
schema:
$ref: '#/definitions/Token'
"400":
description: Bad Request
"401":
Expand Down Expand Up @@ -948,13 +951,17 @@ paths:
name: id
required: true
type: integer
- description: Set whether this token is permanent (does not expire)
in: body
name: payload
required: true
schema:
$ref: '#/definitions/handler.UpdateTokenPayload'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/Token'
"400":
description: Bad Request
"401":
Expand Down
9 changes: 5 additions & 4 deletions handler/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (tc *TokenHandler) Get(c *fiber.Ctx) error {
return c.JSON(user.ApiToken)
}

type UpdateTokenRequest struct {
type UpdateTokenPayload struct {
Permanent bool `json:"permanent"`
}

Expand All @@ -54,7 +54,8 @@ type UpdateTokenRequest struct {
// @Tags Users
// @Produce json
// @Param id path int true "User ID"
// @Success 200 {object} model.Token
// @Param payload body UpdateTokenPayload true "Set whether this token is permanent (does not expire)"
// @Success 200 "OK"
// @Failure 400 "Bad Request"
// @Failure 401 "Unauthorized"
// @Failure 403 "Forbidden"
Expand All @@ -67,7 +68,7 @@ func (tc *TokenHandler) Update(c *fiber.Ctx) error {
if id < 0 {
return c.SendStatus(fiber.StatusBadRequest)
}
var payload UpdateTokenRequest
var payload UpdateTokenPayload
if err := c.BodyParser(&payload); err != nil {
return UnwrapAndSendError(c, model.BadRequestError{Message: "Could not parse request body", Err: err})
}
Expand All @@ -87,7 +88,7 @@ func (tc *TokenHandler) Update(c *fiber.Ctx) error {
// @Tags Users
// @Produce plain
// @Param id path int true "User ID"
// @Success 200 {object} model.Token
// @Success 200 "OK"
// @Failure 400 "Bad Request"
// @Failure 401 "Unauthorized"
// @Failure 403 "Forbidden"
Expand Down
Loading