Skip to content

Commit 02d5666

Browse files
authored
feat: always return all fields (#234)
This makes interaction with the API easier since users can rely on all fields being returned all the time, showing all possible fields to set.
1 parent 7981935 commit 02d5666

File tree

7 files changed

+18
-18
lines changed

7 files changed

+18
-18
lines changed

pkg/models/account.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ type Account struct {
1717
}
1818

1919
type AccountCreate struct {
20-
Name string `json:"name,omitempty" example:"Cash" default:""`
21-
Note string `json:"note,omitempty" example:"Money in my wallet" default:""`
20+
Name string `json:"name" example:"Cash" default:""`
21+
Note string `json:"note" example:"Money in my wallet" default:""`
2222
BudgetID uuid.UUID `json:"budgetId" example:"550dc009-cea6-4c12-b2a5-03446eb7b7cf"`
2323
OnBudget bool `json:"onBudget" example:"true" default:"false"` // Always false when external: true
2424
External bool `json:"external" example:"false" default:"false"`

pkg/models/allocation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ type AllocationCreate struct {
1616
Month uint8 `json:"month" gorm:"uniqueIndex:year_month;check:month_valid,month >= 1 AND month <= 12" minimum:"1" maximum:"12" example:"6"`
1717
Year uint `json:"year" gorm:"uniqueIndex:year_month" example:"2022"`
1818
Amount decimal.Decimal `json:"amount" gorm:"type:DECIMAL(20,8)" example:"22.01" minimum:"0.00000001" maximum:"999999999999.99999999" multipleOf:"0.00000001"` // The maximum value is "999999999999.99999999", swagger unfortunately rounds this.
19-
EnvelopeID uuid.UUID `json:"envelopeId,omitempty" example:"a0909e84-e8f9-4cb6-82a5-025dff105ff2"`
19+
EnvelopeID uuid.UUID `json:"envelopeId" example:"a0909e84-e8f9-4cb6-82a5-025dff105ff2"`
2020
}

pkg/models/budget.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ type Budget struct {
1818
}
1919

2020
type BudgetCreate struct {
21-
Name string `json:"name,omitempty" example:"Morre's Budget" default:""`
22-
Note string `json:"note,omitempty" example:"My personal expenses" default:""`
23-
Currency string `json:"currency,omitempty" example:"€" default:""`
21+
Name string `json:"name" example:"Morre's Budget" default:""`
22+
Note string `json:"note" example:"My personal expenses" default:""`
23+
Currency string `json:"currency" example:"€" default:""`
2424
}
2525

2626
type BudgetMonth struct {
2727
ID uuid.UUID `json:"id" example:"1e777d24-3f5b-4c43-8000-04f65f895578"` // The ID of the Envelope
2828
Name string `json:"name" example:"Groceries"` // The name of the Envelope
2929
Month time.Time `json:"month" example:"2006-05-01T00:00:00.000000Z"` // This is always set to 00:00 UTC on the first of the month.
30-
Envelopes []EnvelopeMonth `json:"envelopes,omitempty"`
30+
Envelopes []EnvelopeMonth `json:"envelopes"`
3131
}

pkg/models/category.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type Category struct {
1010
}
1111

1212
type CategoryCreate struct {
13-
Name string `json:"name,omitempty" example:"Saving" default:""`
13+
Name string `json:"name" example:"Saving" default:""`
1414
BudgetID uuid.UUID `json:"budgetId" example:"52d967d3-33f4-4b04-9ba7-772e5ab9d0ce"`
15-
Note string `json:"note,omitempty" example:"All envelopes for long-term saving" default:""`
15+
Note string `json:"note" example:"All envelopes for long-term saving" default:""`
1616
}

pkg/models/envelope.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ type Envelope struct {
1616
}
1717

1818
type EnvelopeCreate struct {
19-
Name string `json:"name,omitempty" example:"Groceries" default:""`
19+
Name string `json:"name" example:"Groceries" default:""`
2020
CategoryID uuid.UUID `json:"categoryId" example:"878c831f-af99-4a71-b3ca-80deb7d793c1"`
21-
Note string `json:"note,omitempty" example:"For stuff bought at supermarkets and drugstores" default:""`
21+
Note string `json:"note" example:"For stuff bought at supermarkets and drugstores" default:""`
2222
}
2323

2424
// EnvelopeMonth contains data about an Envelope for a specific month.

pkg/models/model.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type Model struct {
1212
ID uuid.UUID `json:"id" example:"65392deb-5e92-4268-b114-297faad6cdce"`
1313
CreatedAt time.Time `json:"createdAt" example:"2022-04-02T19:28:44.491514Z"`
1414
UpdatedAt time.Time `json:"updatedAt" example:"2022-04-17T20:14:01.048145Z"`
15-
DeletedAt *gorm.DeletedAt `json:"deletedAt,omitempty" gorm:"index" example:"2022-04-22T21:01:05.058161Z" swaggertype:"primitive,string"`
15+
DeletedAt *gorm.DeletedAt `json:"deletedAt" gorm:"index" example:"2022-04-22T21:01:05.058161Z" swaggertype:"primitive,string"`
1616
}
1717

1818
// AfterFind updates the timestamps to use UTC as

pkg/models/transaction.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ type Transaction struct {
1919
}
2020

2121
type TransactionCreate struct {
22-
Date time.Time `json:"date,omitempty" example:"1815-12-10T18:43:00.271152Z"`
22+
Date time.Time `json:"date" example:"1815-12-10T18:43:00.271152Z"`
2323
Amount decimal.Decimal `json:"amount" gorm:"type:DECIMAL(20,8)" example:"14.03" minimum:"0.00000001" maximum:"999999999999.99999999" multipleOf:"0.00000001"` // The maximum value is "999999999999.99999999", swagger unfortunately rounds this.
24-
Note string `json:"note,omitempty" example:"Lunch" default:""`
25-
BudgetID uuid.UUID `json:"budgetId,omitempty" example:"55eecbd8-7c46-4b06-ada9-f287802fb05e"`
26-
SourceAccountID uuid.UUID `json:"sourceAccountId,omitempty" example:"fd81dc45-a3a2-468e-a6fa-b2618f30aa45"`
27-
DestinationAccountID uuid.UUID `json:"destinationAccountId,omitempty" example:"8e16b456-a719-48ce-9fec-e115cfa7cbcc"`
28-
EnvelopeID uuid.UUID `json:"envelopeId,omitempty" example:"2649c965-7999-4873-ae16-89d5d5fa972e"`
24+
Note string `json:"note" example:"Lunch" default:""`
25+
BudgetID uuid.UUID `json:"budgetId" example:"55eecbd8-7c46-4b06-ada9-f287802fb05e"`
26+
SourceAccountID uuid.UUID `json:"sourceAccountId" example:"fd81dc45-a3a2-468e-a6fa-b2618f30aa45"`
27+
DestinationAccountID uuid.UUID `json:"destinationAccountId" example:"8e16b456-a719-48ce-9fec-e115cfa7cbcc"`
28+
EnvelopeID uuid.UUID `json:"envelopeId" example:"2649c965-7999-4873-ae16-89d5d5fa972e"`
2929
Reconciled bool `json:"reconciled" example:"true" default:"false"`
3030
}
3131

0 commit comments

Comments
 (0)