Skip to content

Commit c08a01e

Browse files
authored
fix: swagger docs response status and objects (#807)
This fixes the wrong swagger documentation status and objects on various API endpoints.
1 parent 5fba4e4 commit c08a01e

File tree

16 files changed

+931
-448
lines changed

16 files changed

+931
-448
lines changed

api/docs.go

Lines changed: 305 additions & 125 deletions
Large diffs are not rendered by default.

api/swagger.json

Lines changed: 305 additions & 125 deletions
Large diffs are not rendered by default.

api/swagger.yaml

Lines changed: 178 additions & 58 deletions
Large diffs are not rendered by default.

pkg/controllers/account_v1.go

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ func (co Controller) RegisterAccountRoutes(r *gin.RouterGroup) {
124124
// @Description Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs
125125
// @Tags Accounts
126126
// @Success 204
127-
// @Failure 400 {object} httperrors.HTTPError
128-
// @Failure 404
129127
// @Router /v1/accounts [options]
130128
func (co Controller) OptionsAccountList(c *gin.Context) {
131129
httputil.OptionsGetPost(c)
@@ -137,9 +135,10 @@ func (co Controller) OptionsAccountList(c *gin.Context) {
137135
// @Description Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs
138136
// @Tags Accounts
139137
// @Success 204
140-
// @Failure 400 {object} httperrors.HTTPError
141-
// @Failure 404
142-
// @Param accountId path string true "ID formatted as string"
138+
// @Failure 400 {object} httperrors.HTTPError
139+
// @Failure 404 {object} httperrors.HTTPError
140+
// @Failure 500 {object} httperrors.HTTPError
141+
// @Param accountId path string true "ID formatted as string"
143142
// @Router /v1/accounts/{accountId} [options]
144143
func (co Controller) OptionsAccountDetail(c *gin.Context) {
145144
id, err := uuid.Parse(c.Param("accountId"))
@@ -161,9 +160,9 @@ func (co Controller) OptionsAccountDetail(c *gin.Context) {
161160
// @Description Creates a new account
162161
// @Tags Accounts
163162
// @Produce json
164-
// @Success 201 {object} AccountResponse
165-
// @Failure 400 {object} httperrors.HTTPError
166-
// @Failure 404
163+
// @Success 201 {object} AccountResponse
164+
// @Failure 400 {object} httperrors.HTTPError
165+
// @Failure 404 {object} httperrors.HTTPError
167166
// @Failure 500 {object} httperrors.HTTPError
168167
// @Param account body models.AccountCreate true "Account"
169168
// @Router /v1/accounts [post]
@@ -203,7 +202,6 @@ func (co Controller) CreateAccount(c *gin.Context) {
203202
// @Produce json
204203
// @Success 200 {object} AccountListResponse
205204
// @Failure 400 {object} httperrors.HTTPError
206-
// @Failure 404
207205
// @Failure 500 {object} httperrors.HTTPError
208206
// @Router /v1/accounts [get]
209207
// @Param name query string false "Filter by name"
@@ -264,9 +262,9 @@ func (co Controller) GetAccounts(c *gin.Context) {
264262
// @Description Returns a specific account
265263
// @Tags Accounts
266264
// @Produce json
267-
// @Success 200 {object} AccountResponse
268-
// @Failure 400 {object} httperrors.HTTPError
269-
// @Failure 404
265+
// @Success 200 {object} AccountResponse
266+
// @Failure 400 {object} httperrors.HTTPError
267+
// @Failure 404 {object} httperrors.HTTPError
270268
// @Failure 500 {object} httperrors.HTTPError
271269
// @Param accountId path string true "ID formatted as string"
272270
// @Router /v1/accounts/{accountId} [get]
@@ -291,9 +289,9 @@ func (co Controller) GetAccount(c *gin.Context) {
291289
// @Description Updates an account. Only values to be updated need to be specified.
292290
// @Tags Accounts
293291
// @Produce json
294-
// @Success 200 {object} AccountResponse
295-
// @Failure 400 {object} httperrors.HTTPError
296-
// @Failure 404
292+
// @Success 200 {object} AccountResponse
293+
// @Failure 400 {object} httperrors.HTTPError
294+
// @Failure 404 {object} httperrors.HTTPError
297295
// @Failure 500 {object} httperrors.HTTPError
298296
// @Param accountId path string true "ID formatted as string"
299297
// @Param account body models.AccountCreate true "Account"
@@ -338,8 +336,8 @@ func (co Controller) UpdateAccount(c *gin.Context) {
338336
// @Tags Accounts
339337
// @Produce json
340338
// @Success 204
341-
// @Failure 400 {object} httperrors.HTTPError
342-
// @Failure 404
339+
// @Failure 400 {object} httperrors.HTTPError
340+
// @Failure 404 {object} httperrors.HTTPError
343341
// @Failure 500 {object} httperrors.HTTPError
344342
// @Param accountId path string true "ID formatted as string"
345343
// @Router /v1/accounts/{accountId} [delete]

pkg/controllers/account_v2.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ func (co Controller) RegisterAccountRoutesV2(r *gin.RouterGroup) {
9292
// @Description Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs
9393
// @Tags Accounts
9494
// @Success 204
95-
// @Failure 400 {object} httperrors.HTTPError
96-
// @Failure 404
9795
// @Router /v2/accounts [options]
9896
func (co Controller) OptionsAccountListV2(c *gin.Context) {
9997
httputil.OptionsGet(c)
@@ -107,7 +105,6 @@ func (co Controller) OptionsAccountListV2(c *gin.Context) {
107105
// @Produce json
108106
// @Success 200 {object} AccountListResponse
109107
// @Failure 400 {object} httperrors.HTTPError
110-
// @Failure 404
111108
// @Failure 500 {object} httperrors.HTTPError
112109
// @Router /v2/accounts [get]
113110
// @Param name query string false "Filter by name"

pkg/controllers/allocation.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ func (co Controller) OptionsAllocationList(c *gin.Context) {
8282
// @Description Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs
8383
// @Tags Allocations
8484
// @Success 204
85-
// @Param allocationId path string true "ID formatted as string"
85+
// @Failure 400 {object} httperrors.HTTPError
86+
// @Failure 404 {object} httperrors.HTTPError
87+
// @Failure 500 {object} httperrors.HTTPError
88+
// @Param allocationId path string true "ID formatted as string"
8689
// @Router /v1/allocations/{allocationId} [options]
8790
func (co Controller) OptionsAllocationDetail(c *gin.Context) {
8891
id, err := uuid.Parse(c.Param("allocationId"))
@@ -104,9 +107,9 @@ func (co Controller) OptionsAllocationDetail(c *gin.Context) {
104107
// @Description Create a new allocation of funds to an envelope for a specific month
105108
// @Tags Allocations
106109
// @Produce json
107-
// @Success 201 {object} AllocationResponse
108-
// @Failure 400 {object} httperrors.HTTPError
109-
// @Failure 404
110+
// @Success 201 {object} AllocationResponse
111+
// @Failure 400 {object} httperrors.HTTPError
112+
// @Failure 404 {object} httperrors.HTTPError
110113
// @Failure 500 {object} httperrors.HTTPError
111114
// @Param allocation body models.AllocationCreate true "Allocation"
112115
// @Router /v1/allocations [post]
@@ -138,7 +141,6 @@ func (co Controller) CreateAllocation(c *gin.Context) {
138141
// @Produce json
139142
// @Success 200 {object} AllocationListResponse
140143
// @Failure 400 {object} httperrors.HTTPError
141-
// @Failure 404
142144
// @Failure 500 {object} httperrors.HTTPError
143145
// @Router /v1/allocations [get]
144146
// @Param month query string false "Filter by month"
@@ -183,9 +185,9 @@ func (co Controller) GetAllocations(c *gin.Context) {
183185
// @Description Returns a specific allocation
184186
// @Tags Allocations
185187
// @Produce json
186-
// @Success 200 {object} AllocationResponse
187-
// @Failure 400 {object} httperrors.HTTPError
188-
// @Failure 404
188+
// @Success 200 {object} AllocationResponse
189+
// @Failure 400 {object} httperrors.HTTPError
190+
// @Failure 404 {object} httperrors.HTTPError
189191
// @Failure 500 {object} httperrors.HTTPError
190192
// @Param allocationId path string true "ID formatted as string"
191193
// @Router /v1/allocations/{allocationId} [get]
@@ -211,9 +213,9 @@ func (co Controller) GetAllocation(c *gin.Context) {
211213
// @Tags Allocations
212214
// @Accept json
213215
// @Produce json
214-
// @Success 200 {object} AllocationResponse
215-
// @Failure 400 {object} httperrors.HTTPError
216-
// @Failure 404
216+
// @Success 200 {object} AllocationResponse
217+
// @Failure 400 {object} httperrors.HTTPError
218+
// @Failure 404 {object} httperrors.HTTPError
217219
// @Failure 500 {object} httperrors.HTTPError
218220
// @Param allocationId path string true "ID formatted as string"
219221
// @Param allocation body models.AllocationCreate true "Allocation"
@@ -253,8 +255,8 @@ func (co Controller) UpdateAllocation(c *gin.Context) {
253255
// @Description Deletes an allocation
254256
// @Tags Allocations
255257
// @Success 204
256-
// @Failure 400 {object} httperrors.HTTPError
257-
// @Failure 404
258+
// @Failure 400 {object} httperrors.HTTPError
259+
// @Failure 404 {object} httperrors.HTTPError
258260
// @Failure 500 {object} httperrors.HTTPError
259261
// @Param allocationId path string true "ID formatted as string"
260262
// @Router /v1/allocations/{allocationId} [delete]

pkg/controllers/budget.go

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ func (co Controller) RegisterBudgetRoutes(r *gin.RouterGroup) {
7373
// @Description Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs
7474
// @Tags Budgets
7575
// @Success 204
76-
// @Failure 500 {object} httperrors.HTTPError
7776
// @Router /v1/budgets [options]
7877
func (co Controller) OptionsBudgetList(c *gin.Context) {
7978
httputil.OptionsGetPost(c)
@@ -85,8 +84,8 @@ func (co Controller) OptionsBudgetList(c *gin.Context) {
8584
// @Description Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs
8685
// @Tags Budgets
8786
// @Success 204
88-
// @Failure 400 {object} httperrors.HTTPError
89-
// @Failure 404
87+
// @Failure 400 {object} httperrors.HTTPError
88+
// @Failure 404 {object} httperrors.HTTPError
9089
// @Failure 500 {object} httperrors.HTTPError
9190
// @Param budgetId path string true "ID formatted as string"
9291
// @Router /v1/budgets/{budgetId} [options]
@@ -110,8 +109,8 @@ func (co Controller) OptionsBudgetDetail(c *gin.Context) {
110109
// @Description Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs. **Use OPTIONS /month endpoint with month and budgetId query parameters instead.**
111110
// @Tags Budgets
112111
// @Success 204
113-
// @Failure 400 {object} httperrors.HTTPError
114-
// @Failure 404
112+
// @Failure 400 {object} httperrors.HTTPError
113+
// @Failure 404 {object} httperrors.HTTPError
115114
// @Failure 500 {object} httperrors.HTTPError
116115
// @Param budgetId path string true "ID formatted as string"
117116
// @Param month path string true "The month in YYYY-MM format"
@@ -143,9 +142,8 @@ func (co Controller) OptionsBudgetMonth(c *gin.Context) {
143142
// @Description Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs. **Use OPTIONS /month endpoint with month and budgetId query parameters instead.**
144143
// @Tags Budgets
145144
// @Success 204
146-
// @Failure 400 {object} httperrors.HTTPError
147-
// @Failure 404
148-
// @Failure 500 {object} httperrors.HTTPError
145+
// @Failure 400 {object} httperrors.HTTPError
146+
// @Failure 404 {object} httperrors.HTTPError
149147
// @Failure 500 {object} httperrors.HTTPError
150148
// @Param budgetId path string true "ID formatted as string"
151149
// @Param month path string true "The month in YYYY-MM format"
@@ -251,9 +249,9 @@ func (co Controller) GetBudgets(c *gin.Context) {
251249
// @Description Returns a specific budget
252250
// @Tags Budgets
253251
// @Produce json
254-
// @Success 200 {object} BudgetResponse
255-
// @Failure 400 {object} httperrors.HTTPError
256-
// @Failure 404
252+
// @Success 200 {object} BudgetResponse
253+
// @Failure 400 {object} httperrors.HTTPError
254+
// @Failure 404 {object} httperrors.HTTPError
257255
// @Failure 500 {object} httperrors.HTTPError
258256
// @Param budgetId path string true "ID formatted as string"
259257
// @Router /v1/budgets/{budgetId} [get]
@@ -278,9 +276,9 @@ func (co Controller) GetBudget(c *gin.Context) {
278276
// @Description Returns data about a budget for a for a specific month. **Use GET /month endpoint with month and budgetId query parameters instead.**
279277
// @Tags Budgets
280278
// @Produce json
281-
// @Success 200 {object} BudgetMonthResponse
282-
// @Failure 400 {object} httperrors.HTTPError
283-
// @Failure 404
279+
// @Success 200 {object} BudgetMonthResponse
280+
// @Failure 400 {object} httperrors.HTTPError
281+
// @Failure 404 {object} httperrors.HTTPError
284282
// @Failure 500 {object} httperrors.HTTPError
285283
// @Param budgetId path string true "ID formatted as string"
286284
// @Param month path string true "The month in YYYY-MM format"
@@ -393,9 +391,9 @@ func (co Controller) GetBudgetMonth(c *gin.Context) {
393391
// @Tags Budgets
394392
// @Accept json
395393
// @Produce json
396-
// @Success 200 {object} BudgetResponse
397-
// @Failure 400 {object} httperrors.HTTPError
398-
// @Failure 404
394+
// @Success 200 {object} BudgetResponse
395+
// @Failure 400 {object} httperrors.HTTPError
396+
// @Failure 404 {object} httperrors.HTTPError
399397
// @Failure 500 {object} httperrors.HTTPError
400398
// @Param budgetId path string true "ID formatted as string"
401399
// @Param budget body models.BudgetCreate true "Budget"
@@ -435,8 +433,8 @@ func (co Controller) UpdateBudget(c *gin.Context) {
435433
// @Description Deletes a budget
436434
// @Tags Budgets
437435
// @Success 204
438-
// @Failure 400 {object} httperrors.HTTPError
439-
// @Failure 404
436+
// @Failure 400 {object} httperrors.HTTPError
437+
// @Failure 404 {object} httperrors.HTTPError
440438
// @Failure 500 {object} httperrors.HTTPError
441439
// @Param budgetId path string true "ID formatted as string"
442440
// @Router /v1/budgets/{budgetId} [delete]
@@ -515,10 +513,11 @@ func (co Controller) DeleteAllocationsMonth(c *gin.Context) {
515513
// SetAllocationsMonth sets all allocations for a specific month
516514
//
517515
// @Summary Set allocations for a month
518-
// @Description Sets allocations for a month for all envelopes that do not have an allocation yet. **Use POST /month endpoint with month and budgetId query parameters instead.**
516+
// @Description Sets allocations for a month for all envelopes that do not have an allocation yet. **Deprecated. Use POST /month endpoint with month and budgetId query parameters instead.**
519517
// @Tags Budgets
520518
// @Success 204
521519
// @Failure 400 {object} httperrors.HTTPError
520+
// @Failure 404 {object} httperrors.HTTPError
522521
// @Failure 500 {object} httperrors.HTTPError
523522
// @Param month path string true "The month in YYYY-MM format"
524523
// @Param budgetId path string true "Budget ID formatted as string"

pkg/controllers/category.go

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ func (co Controller) RegisterCategoryRoutes(r *gin.RouterGroup) {
6363
// @Description Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs
6464
// @Tags Categories
6565
// @Success 204
66-
// @Failure 400 {object} httperrors.HTTPError
67-
// @Failure 404
6866
// @Router /v1/categories [options]
6967
func (co Controller) OptionsCategoryList(c *gin.Context) {
7068
httputil.OptionsGetPost(c)
@@ -76,9 +74,10 @@ func (co Controller) OptionsCategoryList(c *gin.Context) {
7674
// @Description Returns an empty response with the HTTP Header "allow" set to the allowed HTTP verbs
7775
// @Tags Categories
7876
// @Success 204
79-
// @Failure 400 {object} httperrors.HTTPError
80-
// @Failure 404
81-
// @Param categoryId path string true "ID formatted as string"
77+
// @Failure 400 {object} httperrors.HTTPError
78+
// @Failure 404 {object} httperrors.HTTPError
79+
// @Failure 500 {object} httperrors.HTTPError
80+
// @Param categoryId path string true "ID formatted as string"
8281
// @Router /v1/categories/{categoryId} [options]
8382
func (co Controller) OptionsCategoryDetail(c *gin.Context) {
8483
id, err := uuid.Parse(c.Param("categoryId"))
@@ -100,9 +99,9 @@ func (co Controller) OptionsCategoryDetail(c *gin.Context) {
10099
// @Description Creates a new category
101100
// @Tags Categories
102101
// @Produce json
103-
// @Success 201 {object} CategoryResponse
104-
// @Failure 400 {object} httperrors.HTTPError
105-
// @Failure 404
102+
// @Success 201 {object} CategoryResponse
103+
// @Failure 400 {object} httperrors.HTTPError
104+
// @Failure 404 {object} httperrors.HTTPError
106105
// @Failure 500 {object} httperrors.HTTPError
107106
// @Param category body models.CategoryCreate true "Category"
108107
// @Router /v1/categories [post]
@@ -135,7 +134,6 @@ func (co Controller) CreateCategory(c *gin.Context) {
135134
// @Produce json
136135
// @Success 200 {object} CategoryListResponse
137136
// @Failure 400 {object} httperrors.HTTPError
138-
// @Failure 404
139137
// @Failure 500 {object} httperrors.HTTPError
140138
// @Router /v1/categories [get]
141139
// @Param name query string false "Filter by name"
@@ -188,9 +186,9 @@ func (co Controller) GetCategories(c *gin.Context) {
188186
// @Description Returns a specific category
189187
// @Tags Categories
190188
// @Produce json
191-
// @Success 200 {object} CategoryResponse
192-
// @Failure 400 {object} httperrors.HTTPError
193-
// @Failure 404
189+
// @Success 200 {object} CategoryResponse
190+
// @Failure 400 {object} httperrors.HTTPError
191+
// @Failure 404 {object} httperrors.HTTPError
194192
// @Failure 500 {object} httperrors.HTTPError
195193
// @Param categoryId path string true "ID formatted as string"
196194
// @Router /v1/categories/{categoryId} [get]
@@ -216,9 +214,9 @@ func (co Controller) GetCategory(c *gin.Context) {
216214
// @Tags Categories
217215
// @Accept json
218216
// @Produce json
219-
// @Success 200 {object} CategoryResponse
220-
// @Failure 400 {object} httperrors.HTTPError
221-
// @Failure 404
217+
// @Success 200 {object} CategoryResponse
218+
// @Failure 400 {object} httperrors.HTTPError
219+
// @Failure 404 {object} httperrors.HTTPError
222220
// @Failure 500 {object} httperrors.HTTPError
223221
// @Param categoryId path string true "ID formatted as string"
224222
// @Param category body models.CategoryCreate true "Category"
@@ -259,8 +257,8 @@ func (co Controller) UpdateCategory(c *gin.Context) {
259257
// @Description Deletes a category
260258
// @Tags Categories
261259
// @Success 204
262-
// @Failure 400 {object} httperrors.HTTPError
263-
// @Failure 404
260+
// @Failure 400 {object} httperrors.HTTPError
261+
// @Failure 404 {object} httperrors.HTTPError
264262
// @Failure 500 {object} httperrors.HTTPError
265263
// @Param categoryId path string true "ID formatted as string"
266264
// @Router /v1/categories/{categoryId} [delete]

0 commit comments

Comments
 (0)