File tree 1 file changed +14
-5
lines changed
1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -104,15 +104,24 @@ func (o Operation) command() *cobra.Command {
104
104
105
105
headers := http.Header {}
106
106
for _ , param := range o .HeaderParams {
107
- if reflect .ValueOf (flags [param .Name ]).Elem ().Interface () == param .Default {
107
+ rv := reflect .ValueOf (flags [param .Name ]).Elem ()
108
+ if rv .Interface () == param .Default {
108
109
// No need to send the default value. Just skip it.
109
110
continue
110
111
}
111
112
112
- if param .Default == nil && reflect .ValueOf (flags [param .Name ]).Elem ().IsZero () {
113
- // No explicit default, so the implied default is the zero value.
114
- // Again no need to send that default, so we skip.
115
- continue
113
+ if param .Default == nil {
114
+ if rv .IsZero () {
115
+ // No explicit default, so the implied default is the zero value.
116
+ // Again no need to send that default, so we skip.
117
+ continue
118
+ }
119
+
120
+ if rv .Kind () == reflect .Slice && rv .Len () == 0 {
121
+ // IsZero() above fails for empty arrays, so if it's empty let's
122
+ // ignore it.
123
+ continue
124
+ }
116
125
}
117
126
118
127
for _ , v := range param .Serialize (flags [param .Name ]) {
You can’t perform that action at this time.
0 commit comments