File tree Expand file tree Collapse file tree 3 files changed +12
-10
lines changed Expand file tree Collapse file tree 3 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,8 @@ import (
19
19
"fmt"
20
20
"reflect"
21
21
22
- validator "github.com/go-playground/validator/v10"
22
+ "github.com/go-playground/validator/v10"
23
+
23
24
val "github.com/serverlessworkflow/sdk-go/v2/validator"
24
25
)
25
26
@@ -43,7 +44,7 @@ func AuthDefinitionsStructLevelValidation(structLevel validator.StructLevel) {
43
44
44
45
// AuthDefinitions used to define authentication information applied to resources defined in the operation property of function definitions
45
46
type AuthDefinitions struct {
46
- Defs []Auth
47
+ Defs []Auth `json:"defs,omitempty"`
47
48
}
48
49
49
50
// AuthType ...
@@ -105,9 +106,12 @@ func (a *AuthDefinitions) UnmarshalJSON(b []byte) error {
105
106
return a .unmarshalFile (b )
106
107
case '[' :
107
108
return a .unmarshalMany (b )
109
+ case '{' : // single values are not supported, should we support it?
110
+ return fmt .Errorf ("authDefinitions value '%s' is not supported, it must be an object or string" , string (b ))
111
+ default :
112
+ // nil can be returned as both cases are returning errors in case of unmarshal problem.
113
+ return nil
108
114
}
109
-
110
- return fmt .Errorf ("auth value '%s' is not supported, it must be an array or string" , string (b ))
111
115
}
112
116
113
117
func (a * AuthDefinitions ) unmarshalFile (data []byte ) error {
Original file line number Diff line number Diff line change @@ -31,11 +31,9 @@ func TestAuthDefinitionsStructLevelValidation(t *testing.T) {
31
31
}
32
32
testCases := []testCase {
33
33
{
34
- desp : "nil defs" ,
35
- authDefs : AuthDefinitions {
36
- Defs : nil ,
37
- },
38
- err : `` ,
34
+ desp : "nil defs" ,
35
+ authDefs : AuthDefinitions {},
36
+ err : `` ,
39
37
},
40
38
{
41
39
desp : "zero length defs" ,
Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ type BaseWorkflow struct {
108
108
// Auth definitions can be used to define authentication information that should be applied to resources defined in the operation
109
109
// property of function definitions. It is not used as authentication information for the function invocation,
110
110
// but just to access the resource containing the function invocation information.
111
- Auth AuthDefinitions `json:"auth,omitempty"`
111
+ Auth * AuthDefinitions `json:"auth,omitempty"`
112
112
}
113
113
114
114
// Workflow base definition
You can’t perform that action at this time.
0 commit comments