-
Notifications
You must be signed in to change notification settings - Fork 2
/
parameter_map_gen.go
65 lines (54 loc) · 1.29 KB
/
parameter_map_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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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 *ParameterMap) Clear() error {
*v = make(ParameterMap)
return nil
}
// Validate checks the correctness of values in ParameterMap
func (v *ParameterMap) Validate(recurse bool) error {
for name, elem := range *v {
if validator, ok := elem.(Validator); ok {
if err := validator.Validate(recurse); err != nil {
return errors.Wrapf(err, `failed to validate element %v`, name)
}
}
}
return nil
}
func (v ParameterMap) QueryJSON(path string) (ret interface{}, ok bool) {
if path == `` {
return v, true
}
var frag string
frag, path = extractFragFromPath(path)
target, ok := v[frag]
if !ok {
return nil, false
}
if qj, ok := target.(QueryJSONer); ok {
return qj.QueryJSON(path)
}
if path == `` {
return target, true
}
return nil, false
}
func (v *ParameterMap) UnmarshalJSON(data []byte) error {
var proxy map[string]*parameter
if err := json.Unmarshal(data, &proxy); err != nil {
return errors.Wrap(err, `failed to unmarshal ParameterMap`)
}
tmp := make(map[string]Parameter)
for name, value := range proxy {
tmp[name] = value
}
*v = tmp
return nil
}