Skip to content

Commit

Permalink
swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
fmartingr committed Jun 4, 2024
1 parent 6ba4722 commit e126bee
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 36 deletions.
46 changes: 35 additions & 11 deletions docs/swagger/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,38 @@ const docTemplate = `{
}
}
}
},
"patch": {
"produces": [
"application/json"
],
"tags": [
"accounts"
],
"summary": "Update an account",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/model.AccountDTO"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "string"
}
}
}
}
},
"/api/v1/auth/account": {
Expand All @@ -109,14 +141,14 @@ const docTemplate = `{
"tags": [
"Auth"
],
"summary": "Perform actions on the currently logged-in user.",
"summary": "Update account information",
"parameters": [
{
"description": "Config data",
"description": "Account data",
"name": "payload",
"in": "body",
"schema": {
"$ref": "#/definitions/api_v1.settingRequestPayload"
"$ref": "#/definitions/model.AccountDTO"
}
}
],
Expand Down Expand Up @@ -359,14 +391,6 @@ const docTemplate = `{
}
}
},
"api_v1.settingRequestPayload": {
"type": "object",
"properties": {
"config": {
"$ref": "#/definitions/model.UserConfig"
}
}
},
"api_v1.updateCachePayload": {
"type": "object",
"required": [
Expand Down
46 changes: 35 additions & 11 deletions docs/swagger/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,38 @@
}
}
}
},
"patch": {
"produces": [
"application/json"
],
"tags": [
"accounts"
],
"summary": "Update an account",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/model.AccountDTO"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "string"
}
}
}
}
},
"/api/v1/auth/account": {
Expand All @@ -98,14 +130,14 @@
"tags": [
"Auth"
],
"summary": "Perform actions on the currently logged-in user.",
"summary": "Update account information",
"parameters": [
{
"description": "Config data",
"description": "Account data",
"name": "payload",
"in": "body",
"schema": {
"$ref": "#/definitions/api_v1.settingRequestPayload"
"$ref": "#/definitions/model.AccountDTO"
}
}
],
Expand Down Expand Up @@ -348,14 +380,6 @@
}
}
},
"api_v1.settingRequestPayload": {
"type": "object",
"properties": {
"config": {
"$ref": "#/definitions/model.UserConfig"
}
}
},
"api_v1.updateCachePayload": {
"type": "object",
"required": [
Expand Down
32 changes: 24 additions & 8 deletions docs/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ definitions:
html:
type: string
type: object
api_v1.settingRequestPayload:
properties:
config:
$ref: '#/definitions/model.UserConfig'
type: object
api_v1.updateCachePayload:
properties:
create_archive:
Expand Down Expand Up @@ -201,14 +196,35 @@ paths:
summary: Delete an account
tags:
- accounts
patch:
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/model.AccountDTO'
type: array
"400":
description: Bad Request
schema:
type: string
"500":
description: Internal Server Error
schema:
type: string
summary: Update an account
tags:
- accounts
/api/v1/auth/account:
patch:
parameters:
- description: Config data
- description: Account data
in: body
name: payload
schema:
$ref: '#/definitions/api_v1.settingRequestPayload'
$ref: '#/definitions/model.AccountDTO'
produces:
- application/json
responses:
Expand All @@ -218,7 +234,7 @@ paths:
$ref: '#/definitions/model.Account'
"403":
description: Token not provided/invalid
summary: Perform actions on the currently logged-in user.
summary: Update account information
tags:
- Auth
/api/v1/auth/login:
Expand Down
3 changes: 1 addition & 2 deletions internal/http/routes/api/v1/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ func (r *AccountsAPIRoutes) Setup(g *gin.RouterGroup) model.Routes {
g.GET("/", r.listHandler)
g.POST("/", r.createHandler)
g.DELETE("/:id", r.deleteHandler)
g.PUT("/:id", r.updateHandler)
g.PATCH("/:id", r.updateHandler)

return r
Expand Down Expand Up @@ -155,7 +154,7 @@ func (r *AccountsAPIRoutes) deleteHandler(c *gin.Context) {
// @Success 200 {array} model.AccountDTO
// @Failure 400 {string} string "Bad Request"
// @Failure 500 {string} string "Internal Server Error"
// @Router /api/v1/accounts/{id} [put,patch]
// @Router /api/v1/accounts/{id} [patch]
func (r *AccountsAPIRoutes) updateHandler(c *gin.Context) {
accountID, err := strconv.Atoi(c.Param("id"))
if err != nil {
Expand Down
4 changes: 0 additions & 4 deletions internal/http/routes/api/v1/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ type loginResponseMessage struct {
Expiration int64 `json:"expires"` // Deprecated, used only for legacy APIs
}

type settingRequestPayload struct {
Config model.UserConfig `json:"config"`
}

// loginHandler godoc
//
// @Summary Login to an account using username and password
Expand Down

0 comments on commit e126bee

Please sign in to comment.