File tree 2 files changed +14
-0
lines changed
2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ const (
29
29
// SimpleSchema describe swagger simple schemas for parameters and headers
30
30
type SimpleSchema struct {
31
31
Type string `json:"type,omitempty"`
32
+ Nullable bool `json:"nullable,omitempty"`
32
33
Format string `json:"format,omitempty"`
33
34
Items * Items `json:"items,omitempty"`
34
35
CollectionFormat string `json:"collectionFormat,omitempty"`
@@ -91,6 +92,12 @@ func (i *Items) Typed(tpe, format string) *Items {
91
92
return i
92
93
}
93
94
95
+ // AsNullable flags this schema as nullable.
96
+ func (i * Items ) AsNullable () * Items {
97
+ i .Nullable = true
98
+ return i
99
+ }
100
+
94
101
// CollectionOf a fluent builder method for an array item
95
102
func (i * Items ) CollectionOf (items * Items , format string ) * Items {
96
103
i .Type = jsonArray
Original file line number Diff line number Diff line change @@ -163,6 +163,7 @@ type SchemaProps struct {
163
163
Schema SchemaURL `json:"-"`
164
164
Description string `json:"description,omitempty"`
165
165
Type StringOrArray `json:"type,omitempty"`
166
+ Nullable bool `json:"nullable,omitempty"`
166
167
Format string `json:"format,omitempty"`
167
168
Title string `json:"title,omitempty"`
168
169
Default interface {} `json:"default,omitempty"`
@@ -302,6 +303,12 @@ func (s *Schema) AddType(tpe, format string) *Schema {
302
303
return s
303
304
}
304
305
306
+ // AsNullable flags this schema as nullable.
307
+ func (s * Schema ) AsNullable () * Schema {
308
+ s .Nullable = true
309
+ return s
310
+ }
311
+
305
312
// CollectionOf a fluent builder method for an array parameter
306
313
func (s * Schema ) CollectionOf (items Schema ) * Schema {
307
314
s .Type = []string {jsonArray }
You can’t perform that action at this time.
0 commit comments