json-schema 0.9.9 → 0.9.10
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +2 -2
- data/resources/draft-01.json +155 -0
- data/resources/draft-02.json +166 -0
- data/resources/draft-03.json +174 -0
- data/test/data/bad_data_1.json +3 -0
- data/test/data/good_data_1.json +3 -0
- data/test/schemas/good_schema_1.json +10 -0
- data/test/schemas/good_schema_2.json +10 -0
- metadata +14 -3
data/README.textile
CHANGED
@@ -18,7 +18,7 @@ From the git repo:
|
|
18
18
|
|
19
19
|
<pre>
|
20
20
|
$ gem build json-schema.gemspec
|
21
|
-
$ gem install json-schema-0.9.
|
21
|
+
$ gem install json-schema-0.9.10.gem
|
22
22
|
</pre>
|
23
23
|
|
24
24
|
|
@@ -110,7 +110,7 @@ data = {
|
|
110
110
|
"a" => 5
|
111
111
|
}
|
112
112
|
|
113
|
-
JSON::Validator.validate(schema, data, :validate_schema =>
|
113
|
+
JSON::Validator.validate(schema, data, :validate_schema => true)
|
114
114
|
</pre>
|
115
115
|
|
116
116
|
h3. Validate an object against a JSON Schema Draft 2 schema
|
@@ -0,0 +1,155 @@
|
|
1
|
+
{
|
2
|
+
"$schema" : "http://json-schema.org/draft-01/hyper-schema#",
|
3
|
+
"id" : "http://json-schema.org/draft-01/schema#",
|
4
|
+
"type" : "object",
|
5
|
+
|
6
|
+
"properties" : {
|
7
|
+
"type" : {
|
8
|
+
"type" : ["string", "array"],
|
9
|
+
"items" : {
|
10
|
+
"type" : ["string", {"$ref" : "#"}]
|
11
|
+
},
|
12
|
+
"optional" : true,
|
13
|
+
"default" : "any"
|
14
|
+
},
|
15
|
+
|
16
|
+
"properties" : {
|
17
|
+
"type" : "object",
|
18
|
+
"additionalProperties" : {"$ref" : "#"},
|
19
|
+
"optional" : true,
|
20
|
+
"default" : {}
|
21
|
+
},
|
22
|
+
|
23
|
+
"items" : {
|
24
|
+
"type" : [{"$ref" : "#"}, "array"],
|
25
|
+
"items" : {"$ref" : "#"},
|
26
|
+
"optional" : true,
|
27
|
+
"default" : {}
|
28
|
+
},
|
29
|
+
|
30
|
+
"optional" : {
|
31
|
+
"type" : "boolean",
|
32
|
+
"optional" : true,
|
33
|
+
"default" : false
|
34
|
+
},
|
35
|
+
|
36
|
+
"additionalProperties" : {
|
37
|
+
"type" : [{"$ref" : "#"}, "boolean"],
|
38
|
+
"optional" : true,
|
39
|
+
"default" : {}
|
40
|
+
},
|
41
|
+
|
42
|
+
"requires" : {
|
43
|
+
"type" : ["string", {"$ref" : "#"}],
|
44
|
+
"optional" : true
|
45
|
+
},
|
46
|
+
|
47
|
+
"minimum" : {
|
48
|
+
"type" : "number",
|
49
|
+
"optional" : true
|
50
|
+
},
|
51
|
+
|
52
|
+
"maximum" : {
|
53
|
+
"type" : "number",
|
54
|
+
"optional" : true
|
55
|
+
},
|
56
|
+
|
57
|
+
"minimumCanEqual" : {
|
58
|
+
"type" : "boolean",
|
59
|
+
"optional" : true,
|
60
|
+
"requires" : "minimum",
|
61
|
+
"default" : true
|
62
|
+
},
|
63
|
+
|
64
|
+
"maximumCanEqual" : {
|
65
|
+
"type" : "boolean",
|
66
|
+
"optional" : true,
|
67
|
+
"requires" : "maximum",
|
68
|
+
"default" : true
|
69
|
+
},
|
70
|
+
|
71
|
+
"minItems" : {
|
72
|
+
"type" : "integer",
|
73
|
+
"optional" : true,
|
74
|
+
"minimum" : 0,
|
75
|
+
"default" : 0
|
76
|
+
},
|
77
|
+
|
78
|
+
"maxItems" : {
|
79
|
+
"type" : "integer",
|
80
|
+
"optional" : true,
|
81
|
+
"minimum" : 0
|
82
|
+
},
|
83
|
+
|
84
|
+
"pattern" : {
|
85
|
+
"type" : "string",
|
86
|
+
"optional" : true,
|
87
|
+
"format" : "regex"
|
88
|
+
},
|
89
|
+
|
90
|
+
"minLength" : {
|
91
|
+
"type" : "integer",
|
92
|
+
"optional" : true,
|
93
|
+
"minimum" : 0,
|
94
|
+
"default" : 0
|
95
|
+
},
|
96
|
+
|
97
|
+
"maxLength" : {
|
98
|
+
"type" : "integer",
|
99
|
+
"optional" : true
|
100
|
+
},
|
101
|
+
|
102
|
+
"enum" : {
|
103
|
+
"type" : "array",
|
104
|
+
"optional" : true,
|
105
|
+
"minItems" : 1
|
106
|
+
},
|
107
|
+
|
108
|
+
"title" : {
|
109
|
+
"type" : "string",
|
110
|
+
"optional" : true
|
111
|
+
},
|
112
|
+
|
113
|
+
"description" : {
|
114
|
+
"type" : "string",
|
115
|
+
"optional" : true
|
116
|
+
},
|
117
|
+
|
118
|
+
"format" : {
|
119
|
+
"type" : "string",
|
120
|
+
"optional" : true
|
121
|
+
},
|
122
|
+
|
123
|
+
"contentEncoding" : {
|
124
|
+
"type" : "string",
|
125
|
+
"optional" : true
|
126
|
+
},
|
127
|
+
|
128
|
+
"default" : {
|
129
|
+
"type" : "any",
|
130
|
+
"optional" : true
|
131
|
+
},
|
132
|
+
|
133
|
+
"maxDecimal" : {
|
134
|
+
"type" : "integer",
|
135
|
+
"optional" : true,
|
136
|
+
"minimum" : 0
|
137
|
+
},
|
138
|
+
|
139
|
+
"disallow" : {
|
140
|
+
"type" : ["string", "array"],
|
141
|
+
"items" : {"type" : "string"},
|
142
|
+
"optional" : true
|
143
|
+
},
|
144
|
+
|
145
|
+
"extends" : {
|
146
|
+
"type" : [{"$ref" : "#"}, "array"],
|
147
|
+
"items" : {"$ref" : "#"},
|
148
|
+
"optional" : true,
|
149
|
+
"default" : {}
|
150
|
+
}
|
151
|
+
},
|
152
|
+
|
153
|
+
"optional" : true,
|
154
|
+
"default" : {}
|
155
|
+
}
|
@@ -0,0 +1,166 @@
|
|
1
|
+
{
|
2
|
+
"$schema" : "http://json-schema.org/draft-02/hyper-schema#",
|
3
|
+
"id" : "http://json-schema.org/draft-02/schema#",
|
4
|
+
"type" : "object",
|
5
|
+
|
6
|
+
"properties" : {
|
7
|
+
"type" : {
|
8
|
+
"type" : ["string", "array"],
|
9
|
+
"items" : {
|
10
|
+
"type" : ["string", {"$ref" : "#"}]
|
11
|
+
},
|
12
|
+
"optional" : true,
|
13
|
+
"uniqueItems" : true,
|
14
|
+
"default" : "any"
|
15
|
+
},
|
16
|
+
|
17
|
+
"properties" : {
|
18
|
+
"type" : "object",
|
19
|
+
"additionalProperties" : {"$ref" : "#"},
|
20
|
+
"optional" : true,
|
21
|
+
"default" : {}
|
22
|
+
},
|
23
|
+
|
24
|
+
"items" : {
|
25
|
+
"type" : [{"$ref" : "#"}, "array"],
|
26
|
+
"items" : {"$ref" : "#"},
|
27
|
+
"optional" : true,
|
28
|
+
"default" : {}
|
29
|
+
},
|
30
|
+
|
31
|
+
"optional" : {
|
32
|
+
"type" : "boolean",
|
33
|
+
"optional" : true,
|
34
|
+
"default" : false
|
35
|
+
},
|
36
|
+
|
37
|
+
"additionalProperties" : {
|
38
|
+
"type" : [{"$ref" : "#"}, "boolean"],
|
39
|
+
"optional" : true,
|
40
|
+
"default" : {}
|
41
|
+
},
|
42
|
+
|
43
|
+
"requires" : {
|
44
|
+
"type" : ["string", {"$ref" : "#"}],
|
45
|
+
"optional" : true
|
46
|
+
},
|
47
|
+
|
48
|
+
"minimum" : {
|
49
|
+
"type" : "number",
|
50
|
+
"optional" : true
|
51
|
+
},
|
52
|
+
|
53
|
+
"maximum" : {
|
54
|
+
"type" : "number",
|
55
|
+
"optional" : true
|
56
|
+
},
|
57
|
+
|
58
|
+
"minimumCanEqual" : {
|
59
|
+
"type" : "boolean",
|
60
|
+
"optional" : true,
|
61
|
+
"requires" : "minimum",
|
62
|
+
"default" : true
|
63
|
+
},
|
64
|
+
|
65
|
+
"maximumCanEqual" : {
|
66
|
+
"type" : "boolean",
|
67
|
+
"optional" : true,
|
68
|
+
"requires" : "maximum",
|
69
|
+
"default" : true
|
70
|
+
},
|
71
|
+
|
72
|
+
"minItems" : {
|
73
|
+
"type" : "integer",
|
74
|
+
"optional" : true,
|
75
|
+
"minimum" : 0,
|
76
|
+
"default" : 0
|
77
|
+
},
|
78
|
+
|
79
|
+
"maxItems" : {
|
80
|
+
"type" : "integer",
|
81
|
+
"optional" : true,
|
82
|
+
"minimum" : 0
|
83
|
+
},
|
84
|
+
|
85
|
+
"uniqueItems" : {
|
86
|
+
"type" : "boolean",
|
87
|
+
"optional" : true,
|
88
|
+
"default" : false
|
89
|
+
},
|
90
|
+
|
91
|
+
"pattern" : {
|
92
|
+
"type" : "string",
|
93
|
+
"optional" : true,
|
94
|
+
"format" : "regex"
|
95
|
+
},
|
96
|
+
|
97
|
+
"minLength" : {
|
98
|
+
"type" : "integer",
|
99
|
+
"optional" : true,
|
100
|
+
"minimum" : 0,
|
101
|
+
"default" : 0
|
102
|
+
},
|
103
|
+
|
104
|
+
"maxLength" : {
|
105
|
+
"type" : "integer",
|
106
|
+
"optional" : true
|
107
|
+
},
|
108
|
+
|
109
|
+
"enum" : {
|
110
|
+
"type" : "array",
|
111
|
+
"optional" : true,
|
112
|
+
"minItems" : 1,
|
113
|
+
"uniqueItems" : true
|
114
|
+
},
|
115
|
+
|
116
|
+
"title" : {
|
117
|
+
"type" : "string",
|
118
|
+
"optional" : true
|
119
|
+
},
|
120
|
+
|
121
|
+
"description" : {
|
122
|
+
"type" : "string",
|
123
|
+
"optional" : true
|
124
|
+
},
|
125
|
+
|
126
|
+
"format" : {
|
127
|
+
"type" : "string",
|
128
|
+
"optional" : true
|
129
|
+
},
|
130
|
+
|
131
|
+
"contentEncoding" : {
|
132
|
+
"type" : "string",
|
133
|
+
"optional" : true
|
134
|
+
},
|
135
|
+
|
136
|
+
"default" : {
|
137
|
+
"type" : "any",
|
138
|
+
"optional" : true
|
139
|
+
},
|
140
|
+
|
141
|
+
"divisibleBy" : {
|
142
|
+
"type" : "number",
|
143
|
+
"minimum" : 0,
|
144
|
+
"minimumCanEqual" : false,
|
145
|
+
"optional" : true,
|
146
|
+
"default" : 1
|
147
|
+
},
|
148
|
+
|
149
|
+
"disallow" : {
|
150
|
+
"type" : ["string", "array"],
|
151
|
+
"items" : {"type" : "string"},
|
152
|
+
"optional" : true,
|
153
|
+
"uniqueItems" : true
|
154
|
+
},
|
155
|
+
|
156
|
+
"extends" : {
|
157
|
+
"type" : [{"$ref" : "#"}, "array"],
|
158
|
+
"items" : {"$ref" : "#"},
|
159
|
+
"optional" : true,
|
160
|
+
"default" : {}
|
161
|
+
}
|
162
|
+
},
|
163
|
+
|
164
|
+
"optional" : true,
|
165
|
+
"default" : {}
|
166
|
+
}
|
@@ -0,0 +1,174 @@
|
|
1
|
+
{
|
2
|
+
"$schema" : "http://json-schema.org/draft-03/schema#",
|
3
|
+
"id" : "http://json-schema.org/draft-03/schema#",
|
4
|
+
"type" : "object",
|
5
|
+
|
6
|
+
"properties" : {
|
7
|
+
"type" : {
|
8
|
+
"type" : ["string", "array"],
|
9
|
+
"items" : {
|
10
|
+
"type" : ["string", {"$ref" : "#"}]
|
11
|
+
},
|
12
|
+
"uniqueItems" : true,
|
13
|
+
"default" : "any"
|
14
|
+
},
|
15
|
+
|
16
|
+
"properties" : {
|
17
|
+
"type" : "object",
|
18
|
+
"additionalProperties" : {"$ref" : "#"},
|
19
|
+
"default" : {}
|
20
|
+
},
|
21
|
+
|
22
|
+
"patternProperties" : {
|
23
|
+
"type" : "object",
|
24
|
+
"additionalProperties" : {"$ref" : "#"},
|
25
|
+
"default" : {}
|
26
|
+
},
|
27
|
+
|
28
|
+
"additionalProperties" : {
|
29
|
+
"type" : [{"$ref" : "#"}, "boolean"],
|
30
|
+
"default" : {}
|
31
|
+
},
|
32
|
+
|
33
|
+
"items" : {
|
34
|
+
"type" : [{"$ref" : "#"}, "array"],
|
35
|
+
"items" : {"$ref" : "#"},
|
36
|
+
"default" : {}
|
37
|
+
},
|
38
|
+
|
39
|
+
"additionalItems" : {
|
40
|
+
"type" : [{"$ref" : "#"}, "boolean"],
|
41
|
+
"default" : {}
|
42
|
+
},
|
43
|
+
|
44
|
+
"required" : {
|
45
|
+
"type" : "boolean",
|
46
|
+
"default" : false
|
47
|
+
},
|
48
|
+
|
49
|
+
"dependencies" : {
|
50
|
+
"type" : "object",
|
51
|
+
"additionalProperties" : {
|
52
|
+
"type" : ["string", "array", {"$ref" : "#"}],
|
53
|
+
"items" : {
|
54
|
+
"type" : "string"
|
55
|
+
}
|
56
|
+
},
|
57
|
+
"default" : {}
|
58
|
+
},
|
59
|
+
|
60
|
+
"minimum" : {
|
61
|
+
"type" : "number"
|
62
|
+
},
|
63
|
+
|
64
|
+
"maximum" : {
|
65
|
+
"type" : "number"
|
66
|
+
},
|
67
|
+
|
68
|
+
"exclusiveMinimum" : {
|
69
|
+
"type" : "boolean",
|
70
|
+
"default" : false
|
71
|
+
},
|
72
|
+
|
73
|
+
"exclusiveMaximum" : {
|
74
|
+
"type" : "boolean",
|
75
|
+
"default" : false
|
76
|
+
},
|
77
|
+
|
78
|
+
"minItems" : {
|
79
|
+
"type" : "integer",
|
80
|
+
"minimum" : 0,
|
81
|
+
"default" : 0
|
82
|
+
},
|
83
|
+
|
84
|
+
"maxItems" : {
|
85
|
+
"type" : "integer",
|
86
|
+
"minimum" : 0
|
87
|
+
},
|
88
|
+
|
89
|
+
"uniqueItems" : {
|
90
|
+
"type" : "boolean",
|
91
|
+
"default" : false
|
92
|
+
},
|
93
|
+
|
94
|
+
"pattern" : {
|
95
|
+
"type" : "string",
|
96
|
+
"format" : "regex"
|
97
|
+
},
|
98
|
+
|
99
|
+
"minLength" : {
|
100
|
+
"type" : "integer",
|
101
|
+
"minimum" : 0,
|
102
|
+
"default" : 0
|
103
|
+
},
|
104
|
+
|
105
|
+
"maxLength" : {
|
106
|
+
"type" : "integer"
|
107
|
+
},
|
108
|
+
|
109
|
+
"enum" : {
|
110
|
+
"type" : "array",
|
111
|
+
"minItems" : 1,
|
112
|
+
"uniqueItems" : true
|
113
|
+
},
|
114
|
+
|
115
|
+
"default" : {
|
116
|
+
"type" : "any"
|
117
|
+
},
|
118
|
+
|
119
|
+
"title" : {
|
120
|
+
"type" : "string"
|
121
|
+
},
|
122
|
+
|
123
|
+
"description" : {
|
124
|
+
"type" : "string"
|
125
|
+
},
|
126
|
+
|
127
|
+
"format" : {
|
128
|
+
"type" : "string"
|
129
|
+
},
|
130
|
+
|
131
|
+
"divisibleBy" : {
|
132
|
+
"type" : "number",
|
133
|
+
"minimum" : 0,
|
134
|
+
"exclusiveMinimum" : true,
|
135
|
+
"default" : 1
|
136
|
+
},
|
137
|
+
|
138
|
+
"disallow" : {
|
139
|
+
"type" : ["string", "array"],
|
140
|
+
"items" : {
|
141
|
+
"type" : ["string", {"$ref" : "#"}]
|
142
|
+
},
|
143
|
+
"uniqueItems" : true
|
144
|
+
},
|
145
|
+
|
146
|
+
"extends" : {
|
147
|
+
"type" : [{"$ref" : "#"}, "array"],
|
148
|
+
"items" : {"$ref" : "#"},
|
149
|
+
"default" : {}
|
150
|
+
},
|
151
|
+
|
152
|
+
"id" : {
|
153
|
+
"type" : "string",
|
154
|
+
"format" : "uri"
|
155
|
+
},
|
156
|
+
|
157
|
+
"$ref" : {
|
158
|
+
"type" : "string",
|
159
|
+
"format" : "uri"
|
160
|
+
},
|
161
|
+
|
162
|
+
"$schema" : {
|
163
|
+
"type" : "string",
|
164
|
+
"format" : "uri"
|
165
|
+
}
|
166
|
+
},
|
167
|
+
|
168
|
+
"dependencies" : {
|
169
|
+
"exclusiveMinimum" : "minimum",
|
170
|
+
"exclusiveMaximum" : "maximum"
|
171
|
+
},
|
172
|
+
|
173
|
+
"default" : {}
|
174
|
+
}
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 9
|
8
|
-
-
|
9
|
-
version: 0.9.
|
8
|
+
- 10
|
9
|
+
version: 0.9.10
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Kenny Hoxworth
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-07-
|
17
|
+
date: 2011-07-26 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -60,6 +60,9 @@ files:
|
|
60
60
|
- lib/json-schema/validators/draft2.rb
|
61
61
|
- lib/json-schema/validators/draft3.rb
|
62
62
|
- lib/json-schema.rb
|
63
|
+
- resources/draft-01.json
|
64
|
+
- resources/draft-02.json
|
65
|
+
- resources/draft-03.json
|
63
66
|
- README.textile
|
64
67
|
- test/test_extended_schema.rb
|
65
68
|
- test/test_files.rb
|
@@ -67,6 +70,10 @@ files:
|
|
67
70
|
- test/test_jsonschema_draft2.rb
|
68
71
|
- test/test_jsonschema_draft3.rb
|
69
72
|
- test/test_schema_validation.rb
|
73
|
+
- test/data/bad_data_1.json
|
74
|
+
- test/data/good_data_1.json
|
75
|
+
- test/schemas/good_schema_1.json
|
76
|
+
- test/schemas/good_schema_2.json
|
70
77
|
has_rdoc: true
|
71
78
|
homepage: http://github.com/hoxworth/json-schema/tree/master
|
72
79
|
licenses: []
|
@@ -106,3 +113,7 @@ test_files:
|
|
106
113
|
- test/test_jsonschema_draft2.rb
|
107
114
|
- test/test_jsonschema_draft3.rb
|
108
115
|
- test/test_schema_validation.rb
|
116
|
+
- test/data/bad_data_1.json
|
117
|
+
- test/data/good_data_1.json
|
118
|
+
- test/schemas/good_schema_1.json
|
119
|
+
- test/schemas/good_schema_2.json
|