-
Notifications
You must be signed in to change notification settings - Fork 2
/
schema_list_gen.go
50 lines (41 loc) · 1.01 KB
/
schema_list_gen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package openapi
// This file was automatically generated.
// DO NOT EDIT MANUALLY. All changes will be lost
import (
"encoding/json"
"github.com/pkg/errors"
)
var _ = json.Unmarshal
var _ = errors.Cause
func (v *SchemaList) Clear() error {
*v = SchemaList(nil)
return nil
}
// Validate checks for the values for correctness. If `recurse`
// is specified, child elements are also validated
func (v *SchemaList) Validate(recurse bool) error {
for i, elem := range *v {
if validator, ok := elem.(Validator); ok {
if err := validator.Validate(recurse); err != nil {
return errors.Wrapf(err, `failed to validate element %d`, i)
}
}
}
return nil
}
func (v *SchemaList) UnmarshalJSON(data []byte) error {
var proxy []*schema
if err := json.Unmarshal(data, &proxy); err != nil {
return errors.Wrap(err, `failed to unmarshal SchemaList`)
}
if len(proxy) == 0 {
*v = SchemaList(nil)
return nil
}
tmp := make(SchemaList, len(proxy))
for i, value := range proxy {
tmp[i] = value
}
*v = tmp
return nil
}