forked from puppetlabs-toy-chest/wash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjsonSchema.go
43 lines (34 loc) · 1.06 KB
/
jsonSchema.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
package plugin
import (
"github.com/ekinanp/jsonschema"
)
// This file has wrappers around the jsonschema library so that
// core plugin authors do not need to understand how it works in
// order to use it.
// JSONSchema represents a JSON schema
type JSONSchema = jsonschema.Schema
// TimeSchema represents the schema of a time.Time object
func TimeSchema() *JSONSchema {
return jsonTypeToSchema(jsonschema.TimeType)
}
// IntegerSchema represents an integer's schema (int)
func IntegerSchema() *JSONSchema {
return jsonTypeToSchema(jsonschema.IntegerType)
}
// NumberSchema represents a number's schema (float64)
func NumberSchema() *JSONSchema {
return jsonTypeToSchema(jsonschema.NumberType)
}
// BooleanSchema represents a boolean's schema (bool)
func BooleanSchema() *JSONSchema {
return jsonTypeToSchema(jsonschema.BoolType)
}
// StringSchema represents a string's schema (string)
func StringSchema() *JSONSchema {
return jsonTypeToSchema(jsonschema.StringType)
}
func jsonTypeToSchema(t *jsonschema.Type) *JSONSchema {
return &jsonschema.Schema{
Type: t,
}
}