Skip to content

Commit 6172e11

Browse files
committed
adds example and makes examples a slice of json.RawMessage in Schema
1 parent 6e98a8e commit 6172e11

File tree

1 file changed

+34
-31
lines changed

1 file changed

+34
-31
lines changed

schema.go

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -227,31 +227,32 @@ type SchemaObj struct {
227227
// matches the same schema. For this kind of array, set the items keyword to
228228
// a single schema that will be used to validate all of the items in the
229229
// array.
230-
Items *SchemaObj `json:"items,omitempty"`
231-
UnevaluatedObjs *SchemaObj `json:"unevaluatedObjs,omitempty"`
232-
AdditionalObjs *SchemaObj `json:"additionalObjs,omitempty"`
233-
PrefixObjs SchemaSet `json:"prefixObjs,omitempty"`
234-
Contains *SchemaObj `json:"contains,omitempty"`
235-
MinContains *Number `json:"minContains,omitempty"`
236-
MaxContains *Number `json:"maxContains,omitempty"`
237-
MinLength *Number `json:"minLength,omitempty"`
238-
MaxLength *Number `json:"maxLength,omitempty"`
239-
Pattern *Regexp `json:"pattern,omitempty"`
240-
ContentEncoding string `json:"contentEncoding,omitempty"`
241-
ContentMediaType string `json:"contentMediaType,omitempty"`
242-
Minimum *Number `json:"minimum,omitempty"`
243-
ExclusiveMinimum *Number `json:"exclusiveMinimum,omitempty"`
244-
Maximum *Number `json:"maximum,omitempty"`
245-
ExclusiveMaximum *Number `json:"exclusiveMaximum,omitempty"`
246-
MultipleOf *Number `json:"multipleOf,omitempty"`
247-
Title string `json:"title,omitempty"`
248-
Description string `json:"description,omitempty"`
249-
Default json.RawMessage `json:"default,omitempty"`
250-
ReadOnly *bool `json:"readOnly,omitempty"`
251-
WriteOnly *bool `json:"writeOnly,omitempty"`
252-
Examples json.RawMessage `json:"examples,omitempty"`
253-
Deprecated *bool `json:"deprecated,omitempty"`
254-
ExternalDocs string `json:"externalDocs,omitempty"`
230+
Items *SchemaObj `json:"items,omitempty"`
231+
UnevaluatedObjs *SchemaObj `json:"unevaluatedObjs,omitempty"`
232+
AdditionalObjs *SchemaObj `json:"additionalObjs,omitempty"`
233+
PrefixObjs SchemaSet `json:"prefixObjs,omitempty"`
234+
Contains *SchemaObj `json:"contains,omitempty"`
235+
MinContains *Number `json:"minContains,omitempty"`
236+
MaxContains *Number `json:"maxContains,omitempty"`
237+
MinLength *Number `json:"minLength,omitempty"`
238+
MaxLength *Number `json:"maxLength,omitempty"`
239+
Pattern *Regexp `json:"pattern,omitempty"`
240+
ContentEncoding string `json:"contentEncoding,omitempty"`
241+
ContentMediaType string `json:"contentMediaType,omitempty"`
242+
Minimum *Number `json:"minimum,omitempty"`
243+
ExclusiveMinimum *Number `json:"exclusiveMinimum,omitempty"`
244+
Maximum *Number `json:"maximum,omitempty"`
245+
ExclusiveMaximum *Number `json:"exclusiveMaximum,omitempty"`
246+
MultipleOf *Number `json:"multipleOf,omitempty"`
247+
Title string `json:"title,omitempty"`
248+
Description string `json:"description,omitempty"`
249+
Default json.RawMessage `json:"default,omitempty"`
250+
ReadOnly *bool `json:"readOnly,omitempty"`
251+
WriteOnly *bool `json:"writeOnly,omitempty"`
252+
Examples []json.RawMessage `json:"examples,omitempty"`
253+
Example json.RawMessage `json:"example,omitempty"`
254+
Deprecated *bool `json:"deprecated,omitempty"`
255+
ExternalDocs string `json:"externalDocs,omitempty"`
255256
// Deprecated: renamed to dynamicAnchor
256257
RecursiveAnchor *bool `json:"$recursiveAnchor,omitempty"`
257258
// Deprecated: renamed to dynamicRef
@@ -344,7 +345,6 @@ func (s *SchemaObj) SetKeyword(key string, value interface{}) error {
344345
return err
345346
}
346347
return s.SetEncodedKeyword(key, b)
347-
348348
}
349349

350350
// SetEncodedKeyword sets the keyword key to value
@@ -574,7 +574,8 @@ type partialschema struct {
574574
Default json.RawMessage `json:"default,omitempty"`
575575
ReadOnly *bool `json:"readOnly,omitempty"`
576576
WriteOnly *bool `json:"writeOnly,omitempty"`
577-
Examples json.RawMessage `json:"examples,omitempty"`
577+
Examples []json.RawMessage `json:"examples,omitempty"`
578+
Example json.RawMessage `json:"example,omitempty"`
578579
Deprecated *bool `json:"deprecated,omitempty"`
579580
ExternalDocs string `json:"externalDocs,omitempty"`
580581
RecursiveAnchor *bool `json:"$recursiveAnchor,omitempty"`
@@ -585,7 +586,9 @@ type partialschema struct {
585586
Keywords map[string]json.RawMessage `json:"-"`
586587
}
587588

588-
var _ json.Marshaler = (*SchemaObj)(nil)
589-
var _ json.Unmarshaler = (*SchemaObj)(nil)
590-
var _ yaml.Unmarshaler = (*SchemaObj)(nil)
591-
var _ yaml.Marshaler = (*SchemaObj)(nil)
589+
var (
590+
_ json.Marshaler = (*SchemaObj)(nil)
591+
_ json.Unmarshaler = (*SchemaObj)(nil)
592+
_ yaml.Unmarshaler = (*SchemaObj)(nil)
593+
_ yaml.Marshaler = (*SchemaObj)(nil)
594+
)

0 commit comments

Comments
 (0)