Skip to content

Commit 077036b

Browse files
committed
fix: naming of models and set required flags
1 parent 157defb commit 077036b

File tree

7 files changed

+19
-7
lines changed

7 files changed

+19
-7
lines changed

apps/api/api/add.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import (
1212

1313
type AddRuleRequest struct {
1414
PathParams
15-
Rule models.Rule `json:"rule"`
15+
Rule models.Rule `json:"rule" validate:"required"`
1616
}
1717

1818
type AddRuleResponse struct {
19-
Rule models.Rule `json:"rule"`
19+
Rule models.Rule `json:"rule" validate:"required"`
2020
}
2121

2222
func (b *BreaseHandler) AddRule(c *gin.Context, r *AddRuleRequest) (*AddRuleResponse, error) {

apps/api/api/handler.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ type BreaseHandler struct {
2121
}
2222

2323
func NewHandler(db storage.Database, c cache.Cache, logger *zap.Logger) *BreaseHandler {
24-
2524
if db == nil {
2625
panic("database cannot be nil")
2726
}

apps/api/api/openapi.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func OpenAPISpecHandler(f *fizz.Fizz, logger *zap.Logger) func(*gin.Context) {
2525
patchExpression(doc)
2626

2727
// update usage of expression in rule model
28-
doc.Components.Schemas["ModelsRule"].Value.Properties["expression"] = &openapi3.SchemaRef{Ref: "#/components/schemas/Expression"}
28+
doc.Components.Schemas["Rule"].Value.Properties["expression"] = &openapi3.SchemaRef{Ref: "#/components/schemas/Expression"}
2929

3030
// FIXME: should we validate the override result?
3131

apps/api/api/token.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
type RefreshTokenPairRequest struct {
15-
RefreshToken string `json:"refreshToken"`
15+
RefreshToken string `json:"refreshToken" validate:"required"`
1616
}
1717

1818
func (b *BreaseHandler) generateTokenPair(ownerID string, userID string) (tp models.TokenPair, err error) {

apps/api/models/auth.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package models
22

33
type TokenPair struct {
4-
AccessToken string `json:"accessToken"`
5-
RefreshToken string `json:"refreshToken"`
4+
AccessToken string `json:"accessToken" validate:"required"`
5+
RefreshToken string `json:"refreshToken" validate:"required"`
66
}
7+
8+
func (*TokenPair) TypeName() string { return "TokenPair" }

apps/api/models/models.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ type Target struct {
1212
Value string `json:"value,omitempty"`
1313
}
1414

15+
func (*Target) TypeName() string { return "Target" }
16+
1517
type Rule struct {
1618
ID string `json:"id" validate:"required"`
1719
Description string `json:"description,omitempty"`
@@ -30,13 +32,17 @@ type Rule struct {
3032
Expression map[string]interface{} `json:"expression" validate:"required"`
3133
}
3234

35+
func (*Rule) TypeName() string { return "Rule" }
36+
3337
type EvaluationResult struct {
3438
TargetID string `json:"targetID"`
3539
TargetType string `json:"actionTargetType"`
3640
Action string `json:"action"`
3741
Value string `json:"value"`
3842
}
3943

44+
func (*EvaluationResult) TypeName() string { return "EvaluationResult" }
45+
4046
func (e EvaluationResult) MarshalLogObject(enc zapcore.ObjectEncoder) error {
4147
enc.AddString("targetID", e.TargetID)
4248
enc.AddString("targetType", e.TargetType)

apps/api/moon.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ project:
88
description: Business rules engine service and go package
99

1010
tasks:
11+
build_types:
12+
command: noop
13+
build_types_watch:
14+
command: noop
1115
clean:
1216
command: rm -rf ./dist
1317
platform: system
@@ -42,3 +46,4 @@ tasks:
4246
- dev
4347
options:
4448
cache: false
49+
local: true

0 commit comments

Comments
 (0)