json-schema 2.5.1 → 2.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.textile +2 -2
- data/lib/json-schema/attributes/properties.rb +1 -1
- data/lib/json-schema/validator.rb +14 -6
- metadata +6 -121
- data/test/data/all_of_ref_data.json +0 -3
- data/test/data/any_of_ref_data.json +0 -7
- data/test/data/bad_data_1.json +0 -3
- data/test/data/good_data_1.json +0 -3
- data/test/data/one_of_ref_links_data.json +0 -5
- data/test/schemas/address_microformat.json +0 -18
- data/test/schemas/all_of_ref_base_schema.json +0 -6
- data/test/schemas/all_of_ref_schema.json +0 -7
- data/test/schemas/any_of_ref_jane_schema.json +0 -4
- data/test/schemas/any_of_ref_jimmy_schema.json +0 -4
- data/test/schemas/any_of_ref_john_schema.json +0 -4
- data/test/schemas/any_of_ref_schema.json +0 -15
- data/test/schemas/definition_schema.json +0 -15
- data/test/schemas/extends_and_additionalProperties-1-filename.schema.json +0 -34
- data/test/schemas/extends_and_additionalProperties-1-ref.schema.json +0 -34
- data/test/schemas/extends_and_additionalProperties-2-filename.schema.json +0 -33
- data/test/schemas/extends_and_additionalProperties-2-ref.schema.json +0 -33
- data/test/schemas/good_schema_1.json +0 -10
- data/test/schemas/good_schema_2.json +0 -10
- data/test/schemas/good_schema_extends1.json +0 -10
- data/test/schemas/good_schema_extends2.json +0 -13
- data/test/schemas/inner.schema.json +0 -21
- data/test/schemas/one_of_ref_links_schema.json +0 -16
- data/test/schemas/ref john with spaces schema.json +0 -11
- data/test/schemas/relative_definition_schema.json +0 -8
- data/test/schemas/self_link_schema.json +0 -17
- data/test/schemas/up_link_schema.json +0 -17
- data/test/test_all_of_ref_schema.rb +0 -35
- data/test/test_any_of_ref_schema.rb +0 -35
- data/test/test_bad_schema_ref.rb +0 -39
- data/test/test_common_test_suite.rb +0 -66
- data/test/test_custom_format.rb +0 -116
- data/test/test_definition.rb +0 -15
- data/test/test_extended_schema.rb +0 -62
- data/test/test_extends_and_additionalProperties.rb +0 -52
- data/test/test_files_v3.rb +0 -43
- data/test/test_fragment_resolution.rb +0 -30
- data/test/test_fragment_validation_with_ref.rb +0 -34
- data/test/test_full_validation.rb +0 -208
- data/test/test_helper.rb +0 -47
- data/test/test_initialize_data.rb +0 -118
- data/test/test_jsonschema_draft1.rb +0 -141
- data/test/test_jsonschema_draft2.rb +0 -113
- data/test/test_jsonschema_draft3.rb +0 -450
- data/test/test_jsonschema_draft4.rb +0 -657
- data/test/test_list_option.rb +0 -21
- data/test/test_load_ref_schema.rb +0 -40
- data/test/test_merge_missing_values.rb +0 -45
- data/test/test_minitems.rb +0 -16
- data/test/test_one_of.rb +0 -85
- data/test/test_ruby_schema.rb +0 -59
- data/test/test_schema_loader.rb +0 -74
- data/test/test_schema_type_attribute.rb +0 -20
- data/test/test_schema_validation.rb +0 -185
- data/test/test_stringify.rb +0 -48
- data/test/test_uri_related.rb +0 -67
- data/test/test_validator.rb +0 -53
data/test/test_stringify.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
require File.expand_path('../test_helper', __FILE__)
|
2
|
-
|
3
|
-
class StringifyTest < Minitest::Test
|
4
|
-
def test_stringify_on_hash
|
5
|
-
hash = {
|
6
|
-
:a => 'foo',
|
7
|
-
'b' => :bar
|
8
|
-
}
|
9
|
-
assert_equal({'a' => 'foo', 'b' => 'bar'}, JSON::Schema.stringify(hash), 'symbol keys should be converted to strings')
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_stringify_on_array
|
13
|
-
array = [
|
14
|
-
:a,
|
15
|
-
'b'
|
16
|
-
]
|
17
|
-
assert_equal(['a', 'b'], JSON::Schema.stringify(array), 'symbols in an array should be converted to strings')
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_stringify_on_hash_of_arrays
|
21
|
-
hash = {
|
22
|
-
:a => [:foo],
|
23
|
-
'b' => :bar
|
24
|
-
}
|
25
|
-
assert_equal({'a' => ['foo'], 'b' => 'bar'}, JSON::Schema.stringify(hash), 'symbols in a nested array should be converted to strings')
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_stringify_on_array_of_hashes
|
29
|
-
array = [
|
30
|
-
:a,
|
31
|
-
{
|
32
|
-
:b => :bar
|
33
|
-
}
|
34
|
-
]
|
35
|
-
assert_equal(['a', {'b' => 'bar'}], JSON::Schema.stringify(array), 'symbols keys in a nested hash should be converted to strings')
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_stringify_on_hash_of_hashes
|
39
|
-
hash = {
|
40
|
-
:a => {
|
41
|
-
:b => {
|
42
|
-
:foo => :bar
|
43
|
-
}
|
44
|
-
}
|
45
|
-
}
|
46
|
-
assert_equal({'a' => {'b' => {'foo' => 'bar'} } }, JSON::Schema.stringify(hash), 'symbols in a nested hash of hashes should be converted to strings')
|
47
|
-
end
|
48
|
-
end
|
data/test/test_uri_related.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
require File.expand_path('../test_helper', __FILE__)
|
3
|
-
|
4
|
-
class UriRelatedTest < Minitest::Test
|
5
|
-
def test_asian_characters
|
6
|
-
schema = {
|
7
|
-
"$schema"=> "http://json-schema.org/draft-04/schema#",
|
8
|
-
"id"=> "http://俺:鍵@例え.テスト/p?条件#ここ#",
|
9
|
-
"type" => "object",
|
10
|
-
"required" => ["a"],
|
11
|
-
"properties" => {
|
12
|
-
"a" => {
|
13
|
-
"id" => "a",
|
14
|
-
"type" => "integer"
|
15
|
-
}
|
16
|
-
}
|
17
|
-
}
|
18
|
-
data = { "a" => 5 }
|
19
|
-
assert_valid schema, data
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_schema_ref_with_empty_fragment
|
23
|
-
schema = {
|
24
|
-
"$schema" => "http://json-schema.org/draft-04/schema#",
|
25
|
-
"type" => "object",
|
26
|
-
"required" => ["names"],
|
27
|
-
"properties"=> {
|
28
|
-
"names"=> {
|
29
|
-
"type"=> "array",
|
30
|
-
"items"=> {
|
31
|
-
"anyOf"=> [
|
32
|
-
{ "$ref" => "test/schemas/ref john with spaces schema.json#" },
|
33
|
-
]
|
34
|
-
}
|
35
|
-
}
|
36
|
-
}
|
37
|
-
}
|
38
|
-
data = {"names" => [{"first" => "john"}]}
|
39
|
-
assert_valid schema, data
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_schema_ref_from_file_with_spaces
|
43
|
-
schema = {
|
44
|
-
"$schema" => "http://json-schema.org/draft-04/schema#",
|
45
|
-
"type" => "object",
|
46
|
-
"required" => ["names"],
|
47
|
-
"properties"=> {
|
48
|
-
"names"=> {
|
49
|
-
"type"=> "array",
|
50
|
-
"items"=> {
|
51
|
-
"anyOf"=> [
|
52
|
-
{ "$ref" => "test/schemas/ref john with spaces schema.json" }
|
53
|
-
]
|
54
|
-
}
|
55
|
-
}
|
56
|
-
}
|
57
|
-
}
|
58
|
-
data = {"names" => [{"first" => "john"}]}
|
59
|
-
assert_valid schema, data
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_schema_from_file_with_spaces
|
63
|
-
data = {"first" => "john"}
|
64
|
-
schema = "test/schemas/ref john with spaces schema.json"
|
65
|
-
assert_valid schema, data
|
66
|
-
end
|
67
|
-
end
|
data/test/test_validator.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
require File.expand_path('../test_helper', __FILE__)
|
2
|
-
|
3
|
-
class TestValidator < Minitest::Test
|
4
|
-
|
5
|
-
class MockReader
|
6
|
-
def read(location)
|
7
|
-
schema = {
|
8
|
-
'$schema' => 'http://json-schema.org/draft-04/schema#',
|
9
|
-
'type' => 'string',
|
10
|
-
'minLength' => 2
|
11
|
-
}
|
12
|
-
|
13
|
-
JSON::Schema.new(schema, Addressable::URI.parse(location.to_s))
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def setup
|
18
|
-
@original_reader = JSON::Validator.schema_reader
|
19
|
-
end
|
20
|
-
|
21
|
-
def teardown
|
22
|
-
JSON::Validator.schema_reader = @original_reader
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_default_schema_reader
|
26
|
-
reader = JSON::Validator.schema_reader
|
27
|
-
assert reader.accept_uri?(Addressable::URI.parse('http://example.com'))
|
28
|
-
assert reader.accept_file?(Pathname.new('/etc/passwd'))
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_set_default_schema_reader
|
32
|
-
JSON::Validator.schema_reader = MockReader.new
|
33
|
-
|
34
|
-
schema = { '$ref' => 'http://any.url/at/all' }
|
35
|
-
assert_valid schema, 'abc'
|
36
|
-
refute_valid schema, 'a'
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_validate_with_reader
|
40
|
-
reader = MockReader.new
|
41
|
-
schema = { '$ref' => 'http://any.url/at/all' }
|
42
|
-
assert_valid schema, 'abc', :schema_reader => reader
|
43
|
-
refute_valid schema, 'a', :schema_reader => reader
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_validate_list_with_reader
|
47
|
-
reader = MockReader.new
|
48
|
-
schema = { '$ref' => 'http://what.ever/schema' }
|
49
|
-
assert_valid schema, ['abc', 'def'], :schema_reader => reader, :list => true
|
50
|
-
refute_valid schema, ['abc', 'a'], :schema_reader => reader, :list => true
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|