File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ const (
2929// SimpleSchema describe swagger simple schemas for parameters and headers
3030type SimpleSchema struct {
3131 Type string `json:"type,omitempty"`
32+ Nullable bool `json:"nullable,omitempty"`
3233 Format string `json:"format,omitempty"`
3334 Items * Items `json:"items,omitempty"`
3435 CollectionFormat string `json:"collectionFormat,omitempty"`
@@ -91,6 +92,12 @@ func (i *Items) Typed(tpe, format string) *Items {
9192 return i
9293}
9394
95+ // AsNullable flags this schema as nullable.
96+ func (i * Items ) AsNullable () * Items {
97+ i .Nullable = true
98+ return i
99+ }
100+
94101// CollectionOf a fluent builder method for an array item
95102func (i * Items ) CollectionOf (items * Items , format string ) * Items {
96103 i .Type = jsonArray
Original file line number Diff line number Diff line change @@ -163,6 +163,7 @@ type SchemaProps struct {
163163 Schema SchemaURL `json:"-"`
164164 Description string `json:"description,omitempty"`
165165 Type StringOrArray `json:"type,omitempty"`
166+ Nullable bool `json:"nullable,omitempty"`
166167 Format string `json:"format,omitempty"`
167168 Title string `json:"title,omitempty"`
168169 Default interface {} `json:"default,omitempty"`
@@ -302,6 +303,12 @@ func (s *Schema) AddType(tpe, format string) *Schema {
302303 return s
303304}
304305
306+ // AsNullable flags this schema as nullable.
307+ func (s * Schema ) AsNullable () * Schema {
308+ s .Nullable = true
309+ return s
310+ }
311+
305312// CollectionOf a fluent builder method for an array parameter
306313func (s * Schema ) CollectionOf (items Schema ) * Schema {
307314 s .Type = []string {jsonArray }
You can’t perform that action at this time.
0 commit comments