-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.go
52 lines (45 loc) · 943 Bytes
/
schema.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
package json2schema
import (
"encoding/json"
)
/*
Schema interface
*/
type Schema interface {
ToMap() map[string]interface{}
}
type schema struct {
Attributes basicAttributes `json:"attributes"`
Validations `json:"validations"`
Kind string `json:"kind"`
Name string `json:"name"`
Type string `json:"type"`
}
type basicAttributes struct {
Title struct {
language
} `json:"title"`
Placeholder struct {
language
} `json:"placeholder"`
}
type language struct {
En string `json:"en"`
}
/*
Validations is list of validator conditions
*/
type Validations []string
func (schema schema) ToMap() map[string]interface{} {
var js, err = json.Marshal(schema)
if err != nil {
panic(err)
}
var res interface{}
err = json.Unmarshal(js, &res)
if err != nil {
panic(err)
}
return res.(map[string]interface{})
// shayad beshe akhare kar ba Cast ya Convert be type asly dataye kamelo bekeshim birun!!
}