Skip to content

Commit 89093d0

Browse files
committed
chore(deps): new swagger formatting
1 parent 12a7fc7 commit 89093d0

File tree

14 files changed

+743
-656
lines changed

14 files changed

+743
-656
lines changed

api/docs.go

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2847,6 +2847,17 @@ const docTemplate = `{
28472847
}
28482848
}
28492849
},
2850+
"controllers.AllocationMode": {
2851+
"type": "string",
2852+
"enum": [
2853+
"ALLOCATE_LAST_MONTH_BUDGET",
2854+
"ALLOCATE_LAST_MONTH_SPEND"
2855+
],
2856+
"x-enum-varnames": [
2857+
"AllocateLastMonthBudget",
2858+
"AllocateLastMonthSpend"
2859+
]
2860+
},
28502861
"controllers.AllocationResponse": {
28512862
"type": "object",
28522863
"properties": {
@@ -2899,7 +2910,11 @@ const docTemplate = `{
28992910
"type": "object",
29002911
"properties": {
29012912
"mode": {
2902-
"type": "string",
2913+
"allOf": [
2914+
{
2915+
"$ref": "#/definitions/controllers.AllocationMode"
2916+
}
2917+
],
29032918
"example": "ALLOCATE_LAST_MONTH_SPEND"
29042919
}
29052920
}
@@ -3164,8 +3179,12 @@ const docTemplate = `{
31643179
"example": "1969-06-01T00:00:00.000000Z"
31653180
},
31663181
"overspendMode": {
3167-
"type": "string",
31683182
"default": "AFFECT_AVAILABLE",
3183+
"allOf": [
3184+
{
3185+
"$ref": "#/definitions/models.OverspendMode"
3186+
}
3187+
],
31693188
"example": "AFFECT_ENVELOPE"
31703189
},
31713190
"updatedAt": {
@@ -3591,12 +3610,27 @@ const docTemplate = `{
35913610
"type": "object",
35923611
"properties": {
35933612
"overspendMode": {
3594-
"type": "string",
35953613
"default": "AFFECT_AVAILABLE",
3614+
"allOf": [
3615+
{
3616+
"$ref": "#/definitions/models.OverspendMode"
3617+
}
3618+
],
35963619
"example": "AFFECT_ENVELOPE"
35973620
}
35983621
}
35993622
},
3623+
"models.OverspendMode": {
3624+
"type": "string",
3625+
"enum": [
3626+
"AFFECT_AVAILABLE",
3627+
"AFFECT_ENVELOPE"
3628+
],
3629+
"x-enum-varnames": [
3630+
"AffectAvailable",
3631+
"AffectEnvelope"
3632+
]
3633+
},
36003634
"models.TransactionCreate": {
36013635
"type": "object",
36023636
"properties": {

api/swagger.json

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2835,6 +2835,17 @@
28352835
}
28362836
}
28372837
},
2838+
"controllers.AllocationMode": {
2839+
"type": "string",
2840+
"enum": [
2841+
"ALLOCATE_LAST_MONTH_BUDGET",
2842+
"ALLOCATE_LAST_MONTH_SPEND"
2843+
],
2844+
"x-enum-varnames": [
2845+
"AllocateLastMonthBudget",
2846+
"AllocateLastMonthSpend"
2847+
]
2848+
},
28382849
"controllers.AllocationResponse": {
28392850
"type": "object",
28402851
"properties": {
@@ -2887,7 +2898,11 @@
28872898
"type": "object",
28882899
"properties": {
28892900
"mode": {
2890-
"type": "string",
2901+
"allOf": [
2902+
{
2903+
"$ref": "#/definitions/controllers.AllocationMode"
2904+
}
2905+
],
28912906
"example": "ALLOCATE_LAST_MONTH_SPEND"
28922907
}
28932908
}
@@ -3152,8 +3167,12 @@
31523167
"example": "1969-06-01T00:00:00.000000Z"
31533168
},
31543169
"overspendMode": {
3155-
"type": "string",
31563170
"default": "AFFECT_AVAILABLE",
3171+
"allOf": [
3172+
{
3173+
"$ref": "#/definitions/models.OverspendMode"
3174+
}
3175+
],
31573176
"example": "AFFECT_ENVELOPE"
31583177
},
31593178
"updatedAt": {
@@ -3579,12 +3598,27 @@
35793598
"type": "object",
35803599
"properties": {
35813600
"overspendMode": {
3582-
"type": "string",
35833601
"default": "AFFECT_AVAILABLE",
3602+
"allOf": [
3603+
{
3604+
"$ref": "#/definitions/models.OverspendMode"
3605+
}
3606+
],
35843607
"example": "AFFECT_ENVELOPE"
35853608
}
35863609
}
35873610
},
3611+
"models.OverspendMode": {
3612+
"type": "string",
3613+
"enum": [
3614+
"AFFECT_AVAILABLE",
3615+
"AFFECT_ENVELOPE"
3616+
],
3617+
"x-enum-varnames": [
3618+
"AffectAvailable",
3619+
"AffectEnvelope"
3620+
]
3621+
},
35883622
"models.TransactionCreate": {
35893623
"type": "object",
35903624
"properties": {

api/swagger.yaml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ definitions:
116116
$ref: '#/definitions/controllers.Allocation'
117117
type: array
118118
type: object
119+
controllers.AllocationMode:
120+
enum:
121+
- ALLOCATE_LAST_MONTH_BUDGET
122+
- ALLOCATE_LAST_MONTH_SPEND
123+
type: string
124+
x-enum-varnames:
125+
- AllocateLastMonthBudget
126+
- AllocateLastMonthSpend
119127
controllers.AllocationResponse:
120128
properties:
121129
data:
@@ -153,8 +161,9 @@ definitions:
153161
controllers.BudgetAllocationMode:
154162
properties:
155163
mode:
164+
allOf:
165+
- $ref: '#/definitions/controllers.AllocationMode'
156166
example: ALLOCATE_LAST_MONTH_SPEND
157-
type: string
158167
type: object
159168
controllers.BudgetLinks:
160169
properties:
@@ -343,9 +352,10 @@ definitions:
343352
example: "1969-06-01T00:00:00.000000Z"
344353
type: string
345354
overspendMode:
355+
allOf:
356+
- $ref: '#/definitions/models.OverspendMode'
346357
default: AFFECT_AVAILABLE
347358
example: AFFECT_ENVELOPE
348-
type: string
349359
updatedAt:
350360
example: "2022-04-17T20:14:01.048145Z"
351361
type: string
@@ -659,10 +669,19 @@ definitions:
659669
models.MonthConfigCreate:
660670
properties:
661671
overspendMode:
672+
allOf:
673+
- $ref: '#/definitions/models.OverspendMode'
662674
default: AFFECT_AVAILABLE
663675
example: AFFECT_ENVELOPE
664-
type: string
665676
type: object
677+
models.OverspendMode:
678+
enum:
679+
- AFFECT_AVAILABLE
680+
- AFFECT_ENVELOPE
681+
type: string
682+
x-enum-varnames:
683+
- AffectAvailable
684+
- AffectEnvelope
666685
models.TransactionCreate:
667686
properties:
668687
amount:

pkg/controllers/account.go

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -71,25 +71,25 @@ func (co Controller) RegisterAccountRoutes(r *gin.RouterGroup) {
7171
}
7272
}
7373

74-
// @Summary Allowed HTTP verbs
75-
// @Description Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs
76-
// @Tags Accounts
77-
// @Success 204
78-
// @Failure 400 {object} httperrors.HTTPError
79-
// @Failure 404
80-
// @Router /v1/accounts [options]
74+
// @Summary Allowed HTTP verbs
75+
// @Description Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs
76+
// @Tags Accounts
77+
// @Success 204
78+
// @Failure 400 {object} httperrors.HTTPError
79+
// @Failure 404
80+
// @Router /v1/accounts [options]
8181
func (co Controller) OptionsAccountList(c *gin.Context) {
8282
httputil.OptionsGetPost(c)
8383
}
8484

85-
// @Summary Allowed HTTP verbs
86-
// @Description Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs
87-
// @Tags Accounts
88-
// @Success 204
89-
// @Failure 400 {object} httperrors.HTTPError
90-
// @Failure 404
91-
// @Param accountId path string true "ID formatted as string"
92-
// @Router /v1/accounts/{accountId} [options]
85+
// @Summary Allowed HTTP verbs
86+
// @Description Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs
87+
// @Tags Accounts
88+
// @Success 204
89+
// @Failure 400 {object} httperrors.HTTPError
90+
// @Failure 404
91+
// @Param accountId path string true "ID formatted as string"
92+
// @Router /v1/accounts/{accountId} [options]
9393
func (co Controller) OptionsAccountDetail(c *gin.Context) {
9494
p, err := uuid.Parse(c.Param("accountId"))
9595
if err != nil {
@@ -104,16 +104,16 @@ func (co Controller) OptionsAccountDetail(c *gin.Context) {
104104
httputil.OptionsGetPatchDelete(c)
105105
}
106106

107-
// @Summary Create account
108-
// @Description Creates a new account
109-
// @Tags Accounts
110-
// @Produce json
111-
// @Success 201 {object} AccountResponse
112-
// @Failure 400 {object} httperrors.HTTPError
113-
// @Failure 404
114-
// @Failure 500 {object} httperrors.HTTPError
115-
// @Param account body models.AccountCreate true "Account"
116-
// @Router /v1/accounts [post]
107+
// @Summary Create account
108+
// @Description Creates a new account
109+
// @Tags Accounts
110+
// @Produce json
111+
// @Success 201 {object} AccountResponse
112+
// @Failure 400 {object} httperrors.HTTPError
113+
// @Failure 404
114+
// @Failure 500 {object} httperrors.HTTPError
115+
// @Param account body models.AccountCreate true "Account"
116+
// @Router /v1/accounts [post]
117117
func (co Controller) CreateAccount(c *gin.Context) {
118118
var account models.Account
119119

@@ -135,20 +135,20 @@ func (co Controller) CreateAccount(c *gin.Context) {
135135
c.JSON(http.StatusCreated, AccountResponse{Data: accountObject})
136136
}
137137

138-
// @Summary List accounts
139-
// @Description Returns a list of accounts
140-
// @Tags Accounts
141-
// @Produce json
142-
// @Success 200 {object} AccountListResponse
143-
// @Failure 400 {object} httperrors.HTTPError
144-
// @Failure 404
145-
// @Failure 500 {object} httperrors.HTTPError
146-
// @Router /v1/accounts [get]
147-
// @Param name query string false "Filter by name"
148-
// @Param note query string false "Filter by note"
149-
// @Param budget query string false "Filter by budget ID"
150-
// @Param onBudget query bool false "Filter by on/off-budget"
151-
// @Param external query bool false "Filter internal/external"
138+
// @Summary List accounts
139+
// @Description Returns a list of accounts
140+
// @Tags Accounts
141+
// @Produce json
142+
// @Success 200 {object} AccountListResponse
143+
// @Failure 400 {object} httperrors.HTTPError
144+
// @Failure 404
145+
// @Failure 500 {object} httperrors.HTTPError
146+
// @Router /v1/accounts [get]
147+
// @Param name query string false "Filter by name"
148+
// @Param note query string false "Filter by note"
149+
// @Param budget query string false "Filter by budget ID"
150+
// @Param onBudget query bool false "Filter by on/off-budget"
151+
// @Param external query bool false "Filter internal/external"
152152
func (co Controller) GetAccounts(c *gin.Context) {
153153
var filter AccountQueryFilter
154154
if err := c.Bind(&filter); err != nil {
@@ -185,16 +185,16 @@ func (co Controller) GetAccounts(c *gin.Context) {
185185
c.JSON(http.StatusOK, AccountListResponse{Data: accountObjects})
186186
}
187187

188-
// @Summary Get account
189-
// @Description Returns a specific account
190-
// @Tags Accounts
191-
// @Produce json
192-
// @Success 200 {object} AccountResponse
193-
// @Failure 400 {object} httperrors.HTTPError
194-
// @Failure 404
195-
// @Failure 500 {object} httperrors.HTTPError
196-
// @Param accountId path string true "ID formatted as string"
197-
// @Router /v1/accounts/{accountId} [get]
188+
// @Summary Get account
189+
// @Description Returns a specific account
190+
// @Tags Accounts
191+
// @Produce json
192+
// @Success 200 {object} AccountResponse
193+
// @Failure 400 {object} httperrors.HTTPError
194+
// @Failure 404
195+
// @Failure 500 {object} httperrors.HTTPError
196+
// @Param accountId path string true "ID formatted as string"
197+
// @Router /v1/accounts/{accountId} [get]
198198
func (co Controller) GetAccount(c *gin.Context) {
199199
p, err := uuid.Parse(c.Param("accountId"))
200200
if err != nil {
@@ -210,17 +210,17 @@ func (co Controller) GetAccount(c *gin.Context) {
210210
c.JSON(http.StatusOK, AccountResponse{Data: accountObject})
211211
}
212212

213-
// @Summary Update account
214-
// @Description Updates an account. Only values to be updated need to be specified.
215-
// @Tags Accounts
216-
// @Produce json
217-
// @Success 200 {object} AccountResponse
218-
// @Failure 400 {object} httperrors.HTTPError
219-
// @Failure 404
220-
// @Failure 500 {object} httperrors.HTTPError
221-
// @Param accountId path string true "ID formatted as string"
222-
// @Param account body models.AccountCreate true "Account"
223-
// @Router /v1/accounts/{accountId} [patch]
213+
// @Summary Update account
214+
// @Description Updates an account. Only values to be updated need to be specified.
215+
// @Tags Accounts
216+
// @Produce json
217+
// @Success 200 {object} AccountResponse
218+
// @Failure 400 {object} httperrors.HTTPError
219+
// @Failure 404
220+
// @Failure 500 {object} httperrors.HTTPError
221+
// @Param accountId path string true "ID formatted as string"
222+
// @Param account body models.AccountCreate true "Account"
223+
// @Router /v1/accounts/{accountId} [patch]
224224
func (co Controller) UpdateAccount(c *gin.Context) {
225225
p, err := uuid.Parse(c.Param("accountId"))
226226
if err != nil {
@@ -251,16 +251,16 @@ func (co Controller) UpdateAccount(c *gin.Context) {
251251
c.JSON(http.StatusOK, AccountResponse{Data: accountObject})
252252
}
253253

254-
// @Summary Delete account
255-
// @Description Deletes an account
256-
// @Tags Accounts
257-
// @Produce json
258-
// @Success 204
259-
// @Failure 400 {object} httperrors.HTTPError
260-
// @Failure 404
261-
// @Failure 500 {object} httperrors.HTTPError
262-
// @Param accountId path string true "ID formatted as string"
263-
// @Router /v1/accounts/{accountId} [delete]
254+
// @Summary Delete account
255+
// @Description Deletes an account
256+
// @Tags Accounts
257+
// @Produce json
258+
// @Success 204
259+
// @Failure 400 {object} httperrors.HTTPError
260+
// @Failure 404
261+
// @Failure 500 {object} httperrors.HTTPError
262+
// @Param accountId path string true "ID formatted as string"
263+
// @Router /v1/accounts/{accountId} [delete]
264264
func (co Controller) DeleteAccount(c *gin.Context) {
265265
p, err := uuid.Parse(c.Param("accountId"))
266266
if err != nil {

0 commit comments

Comments
 (0)