json-schema 2.2.4 → 2.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/README.textile +2 -2
- data/lib/json-schema/attributes/format.rb +1 -1
- data/test/test_jsonschema_draft3.rb +3 -0
- data/test/test_jsonschema_draft4.rb +3 -0
- data/test/test_suite.rb +71 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZWEyNDAyZWRhMzlhYTFjZjdhNDA0NTFkOGE5NmY3OWVmN2JlYjFmOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDg2MjAzYWUxZjYzM2JlNTVkNTY0YTcyNjUwYjk4MDI3OWQyZjVmOA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YmNjZDBkNjg0MTVmMmU0NDdkZmI0NjcyODgwNjZmMDIzMTBiMmJkYzUwZDYx
|
10
|
+
NGI3NTY5ZDFmNTI3NmIxMTQyOTVjODNjNWNjOWMyY2E1YmUyMzY5YjJhMmIz
|
11
|
+
MWUwNmJmOGE5YzMxOTNhMjU2ZjIwNjYzNGE1ODgzYzc4NWRkYWI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YzQ0NTQ1NmNiOWUwNDZjNzIzNTY0OGIzMzM3MzRkYzFhNzQxMTVkYjdmYjQ1
|
14
|
+
OGRmYjUzNjhjZjlmMjc3ZGUyODlhYzU0ZjcwMGQ2YjU1NDU0NmYxMGRiNGZj
|
15
|
+
M2E5ZWIwMmMwMDJkNzhlNDQ2YzI0NTJjMDg1YWVkOTBjMjgwNDQ=
|
data/README.textile
CHANGED
@@ -24,7 +24,7 @@ From the git repo:
|
|
24
24
|
|
25
25
|
<pre>
|
26
26
|
$ gem build json-schema.gemspec
|
27
|
-
$ gem install json-schema-2.2.
|
27
|
+
$ gem install json-schema-2.2.5.gem
|
28
28
|
</pre>
|
29
29
|
|
30
30
|
|
@@ -78,7 +78,7 @@ JSON::Validator.validate('user.json', data, :list => true)
|
|
78
78
|
|
79
79
|
h3. Strictly validate an object's properties
|
80
80
|
|
81
|
-
With the <code>:strict</code>
|
81
|
+
With the <code>:strict</code> option, validation fails when an object contains properties that are not defined in the schema's property list or doesn't match the <code>additionalProperties</code> property. Furthermore, all properties are treated as <code>required</code> by default.
|
82
82
|
|
83
83
|
<pre>
|
84
84
|
require 'rubygems'
|
@@ -107,7 +107,7 @@ module JSON
|
|
107
107
|
if data.is_a?(String)
|
108
108
|
error_message = "The property '#{build_fragment(fragments)}' must be a valid URI"
|
109
109
|
begin
|
110
|
-
URI.parse(data)
|
110
|
+
URI.parse(URI.escape(data))
|
111
111
|
rescue URI::InvalidURIError
|
112
112
|
validation_error(processor, error_message, fragments, current_schema, self, options[:record_errors])
|
113
113
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
require 'test/unit'
|
2
3
|
require File.dirname(__FILE__) + '/../lib/json-schema'
|
3
4
|
|
@@ -1092,6 +1093,7 @@ class JSONSchemaDraft3Test < Test::Unit::TestCase
|
|
1092
1093
|
def test_format_uri
|
1093
1094
|
data1 = {"a" => "http://gitbuh.com"}
|
1094
1095
|
data2 = {"a" => "::boo"}
|
1096
|
+
data3 = {"a" => "http://ja.wikipedia.org/wiki/メインページ"}
|
1095
1097
|
|
1096
1098
|
schema = {
|
1097
1099
|
"$schema" => "http://json-schema.org/draft-03/schema#",
|
@@ -1101,6 +1103,7 @@ class JSONSchemaDraft3Test < Test::Unit::TestCase
|
|
1101
1103
|
|
1102
1104
|
assert(JSON::Validator.validate(schema,data1))
|
1103
1105
|
assert(!JSON::Validator.validate(schema,data2))
|
1106
|
+
assert(JSON::Validator.validate(schema,data3))
|
1104
1107
|
end
|
1105
1108
|
|
1106
1109
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
require 'test/unit'
|
2
3
|
require File.dirname(__FILE__) + '/../lib/json-schema'
|
3
4
|
|
@@ -1011,6 +1012,7 @@ class JSONSchemaDraft4Test < Test::Unit::TestCase
|
|
1011
1012
|
def test_format_uri
|
1012
1013
|
data1 = {"a" => "http://gitbuh.com"}
|
1013
1014
|
data2 = {"a" => "::boo"}
|
1015
|
+
data3 = {"a" => "http://ja.wikipedia.org/wiki/メインページ"}
|
1014
1016
|
|
1015
1017
|
schema = {
|
1016
1018
|
"$schema" => "http://json-schema.org/draft-04/schema#",
|
@@ -1020,6 +1022,7 @@ class JSONSchemaDraft4Test < Test::Unit::TestCase
|
|
1020
1022
|
|
1021
1023
|
assert(JSON::Validator.validate(schema,data1))
|
1022
1024
|
assert(!JSON::Validator.validate(schema,data2))
|
1025
|
+
assert(JSON::Validator.validate(schema,data3))
|
1023
1026
|
end
|
1024
1027
|
|
1025
1028
|
|
data/test/test_suite.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.dirname(__FILE__) + '/../lib/json-schema'
|
3
|
+
|
4
|
+
class SuiteTest < Test::Unit::TestCase
|
5
|
+
def test_draft_4
|
6
|
+
print "\n\nDRAFT-04 SUITE TESTS\n"
|
7
|
+
print "--------------------\n"
|
8
|
+
tests = 0
|
9
|
+
passes = 0
|
10
|
+
Dir.glob(File.dirname(__FILE__) + "/suite/tests/draft4/*.json").each do |file_path|
|
11
|
+
data = JSON.parse(File.read(file_path))
|
12
|
+
data.each do |test_desc|
|
13
|
+
puts "Suite Test: #{test_desc["description"]}"
|
14
|
+
test_desc["tests"].each do |test|
|
15
|
+
tests = tests + 1
|
16
|
+
print " - #{test["description"]}: "
|
17
|
+
begin
|
18
|
+
if JSON::Validator.validate(test_desc["schema"], test["data"], :version => :draft4) == test["valid"]
|
19
|
+
puts green("pass")
|
20
|
+
passes = passes + 1
|
21
|
+
else
|
22
|
+
puts "#{red("fail")} - expected #{test["valid"]}, got #{JSON::Validator.validate(test_desc["schema"], test["data"], :version => :draft4)}"
|
23
|
+
end
|
24
|
+
rescue
|
25
|
+
puts "#{red("fail")} - exception thrown"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_draft_3
|
33
|
+
print "\n\nDRAFT-03 SUITE TESTS\n"
|
34
|
+
print "--------------------\n"
|
35
|
+
|
36
|
+
tests = 0
|
37
|
+
passes = 0
|
38
|
+
Dir.glob(File.dirname(__FILE__) + "/suite/tests/draft3/*.json").each do |file_path|
|
39
|
+
data = JSON.parse(File.read(file_path))
|
40
|
+
data.each do |test_desc|
|
41
|
+
puts "Suite Test: #{test_desc["description"]}"
|
42
|
+
test_desc["tests"].each do |test|
|
43
|
+
tests = tests + 1
|
44
|
+
print " - #{test["description"]}: "
|
45
|
+
begin
|
46
|
+
if JSON::Validator.validate(test_desc["schema"], test["data"], :version => :draft3) == test["valid"]
|
47
|
+
puts green("pass")
|
48
|
+
passes = passes + 1
|
49
|
+
else
|
50
|
+
puts "#{red("fail")} - expected #{test["valid"]}, got #{JSON::Validator.validate(test_desc["schema"], test["data"], :version => :draft3)}"
|
51
|
+
end
|
52
|
+
rescue
|
53
|
+
puts "#{red("fail")} - exception thrown"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def colorize(color_code,text)
|
61
|
+
"\e[#{color_code}m#{text}\e[0m"
|
62
|
+
end
|
63
|
+
|
64
|
+
def red(text)
|
65
|
+
colorize(31,text)
|
66
|
+
end
|
67
|
+
|
68
|
+
def green(text)
|
69
|
+
colorize(32,text)
|
70
|
+
end
|
71
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json-schema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenny Hoxworth
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: hoxworth@gmail.com
|
@@ -88,6 +88,7 @@ files:
|
|
88
88
|
- test/test_ruby_schema.rb
|
89
89
|
- test/test_schema_type_attribute.rb
|
90
90
|
- test/test_schema_validation.rb
|
91
|
+
- test/test_suite.rb
|
91
92
|
- test/data/all_of_ref_data.json
|
92
93
|
- test/data/any_of_ref_data.json
|
93
94
|
- test/data/bad_data_1.json
|
@@ -153,6 +154,7 @@ test_files:
|
|
153
154
|
- test/test_ruby_schema.rb
|
154
155
|
- test/test_schema_type_attribute.rb
|
155
156
|
- test/test_schema_validation.rb
|
157
|
+
- test/test_suite.rb
|
156
158
|
- test/data/all_of_ref_data.json
|
157
159
|
- test/data/any_of_ref_data.json
|
158
160
|
- test/data/bad_data_1.json
|