-
Notifications
You must be signed in to change notification settings - Fork 21
/
enumSchema.go
33 lines (26 loc) · 1.06 KB
/
enumSchema.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
package cwl
import (
"fmt"
"github.com/mitchellh/mapstructure"
)
type EnumSchema struct {
Symbols []string `yaml:"symbols,omitempty" bson:"symbols,omitempty" json:"symbols,omitempty" mapstructure:"symbols,omitempty"`
Type string `yaml:"type,omitempty" bson:"type,omitempty" json:"type,omitempty" mapstructure:"type,omitempty"` // must be enum
Label string `yaml:"label,omitempty" bson:"label,omitempty" json:"label,omitempty" mapstructure:"label,omitempty"`
Name string `yaml:"name,omitempty" bson:"name,omitempty" json:"name,omitempty" mapstructure:"name,omitempty"`
}
func (s EnumSchema) GetId() string { return s.Name }
func (s EnumSchema) Is_Type() {}
func (s EnumSchema) Type2String() string { return "EnumSchema" }
func NewEnumSchemaFromInterface(original interface{}) (es EnumSchema, err error) {
original, err = MakeStringMap(original)
if err != nil {
return
}
err = mapstructure.Decode(original, &es)
if err != nil {
err = fmt.Errorf("(NewEnumSchemaFromInterface) mapstructure returned: %s", err.Error())
return
}
return
}