-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcodegenUtils.go
65 lines (48 loc) · 1.2 KB
/
codegenUtils.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 presilo
import (
"strings"
)
/*
Returns true if any string property of the given schema contains a pattern match
*/
func containsRegexpMatch(schema *ObjectSchema) bool {
var schemaType SchemaType
for _, property := range schema.Properties {
schemaType = property.GetSchemaType()
if schemaType == SCHEMATYPE_STRING && property.(*StringSchema).Pattern != nil {
return true
}
}
return false
}
/*
Returns true if any string property of the given schema contains a pattern match
*/
func containsNumberMod(schema *ObjectSchema) bool {
var schemaType SchemaType
for _, property := range schema.Properties {
schemaType = property.GetSchemaType()
if schemaType == SCHEMATYPE_NUMBER && property.(*NumberSchema).MultipleOf != nil {
return true
}
}
return false
}
/*
Returns a string with double-quotes properly escaped
*/
func sanitizeQuotedString(target string) string {
return strings.Replace(target, "\"", "\\\"", -1)
}
/*
Returns true if the given [source] array contains the given [candidate].
False otherwise.
*/
func arrayContainsString(source []string, candidate string) bool {
for _, str := range source {
if str == candidate {
return true
}
}
return false
}