Skip to content

Commit b2056d6

Browse files
authored
Merge pull request kubernetes#91 from sttts/sttts-nullable
Add nullable
2 parents 9d9763c + 915f417 commit b2056d6

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

items.go

+7
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const (
2929
// SimpleSchema describe swagger simple schemas for parameters and headers
3030
type 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
95102
func (i *Items) CollectionOf(items *Items, format string) *Items {
96103
i.Type = jsonArray

schema.go

+7
Original file line numberDiff line numberDiff 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
306313
func (s *Schema) CollectionOf(items Schema) *Schema {
307314
s.Type = []string{jsonArray}

0 commit comments

Comments
 (0)