forked from omissis/go-jsonschema
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.go
45 lines (33 loc) · 782 Bytes
/
utils.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
package generator
import (
"sort"
"github.com/andrew-farries/go-jsonschema/pkg/codegen"
"github.com/andrew-farries/go-jsonschema/pkg/schemas"
)
func sortPropertiesByName(props map[string]*schemas.Type) []string {
names := make([]string, 0, len(props))
for name := range props {
names = append(names, name)
}
sort.Strings(names)
return names
}
func sortDefinitionsByName(defs schemas.Definitions) []string {
names := make([]string, 0, len(defs))
for name := range defs {
names = append(names, name)
}
sort.Strings(names)
return names
}
func isNamedType(t codegen.Type) bool {
switch x := t.(type) {
case *codegen.NamedType:
return true
case *codegen.PointerType:
if _, ok := x.Type.(*codegen.NamedType); ok {
return true
}
}
return false
}