json-schema-openc-fork 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +15 -0
  2. data/LICENSE.md +19 -0
  3. data/README.textile +452 -0
  4. data/lib/json-schema.rb +19 -0
  5. data/lib/json-schema/attribute.rb +43 -0
  6. data/lib/json-schema/attributes/additionalitems.rb +28 -0
  7. data/lib/json-schema/attributes/additionalproperties.rb +58 -0
  8. data/lib/json-schema/attributes/allof.rb +39 -0
  9. data/lib/json-schema/attributes/anyof.rb +47 -0
  10. data/lib/json-schema/attributes/dependencies.rb +44 -0
  11. data/lib/json-schema/attributes/disallow.rb +12 -0
  12. data/lib/json-schema/attributes/divisibleby.rb +22 -0
  13. data/lib/json-schema/attributes/enum.rb +24 -0
  14. data/lib/json-schema/attributes/extends.rb +50 -0
  15. data/lib/json-schema/attributes/format.rb +14 -0
  16. data/lib/json-schema/attributes/formats/custom.rb +21 -0
  17. data/lib/json-schema/attributes/formats/date.rb +24 -0
  18. data/lib/json-schema/attributes/formats/date_time.rb +36 -0
  19. data/lib/json-schema/attributes/formats/date_time_v4.rb +15 -0
  20. data/lib/json-schema/attributes/formats/ip.rb +41 -0
  21. data/lib/json-schema/attributes/formats/time.rb +22 -0
  22. data/lib/json-schema/attributes/formats/uri.rb +20 -0
  23. data/lib/json-schema/attributes/items.rb +26 -0
  24. data/lib/json-schema/attributes/limit.rb +179 -0
  25. data/lib/json-schema/attributes/maxdecimal.rb +18 -0
  26. data/lib/json-schema/attributes/multipleof.rb +11 -0
  27. data/lib/json-schema/attributes/not.rb +30 -0
  28. data/lib/json-schema/attributes/oneof.rb +56 -0
  29. data/lib/json-schema/attributes/pattern.rb +18 -0
  30. data/lib/json-schema/attributes/patternproperties.rb +22 -0
  31. data/lib/json-schema/attributes/properties.rb +74 -0
  32. data/lib/json-schema/attributes/properties_optional.rb +26 -0
  33. data/lib/json-schema/attributes/ref.rb +74 -0
  34. data/lib/json-schema/attributes/required.rb +28 -0
  35. data/lib/json-schema/attributes/type.rb +83 -0
  36. data/lib/json-schema/attributes/type_v4.rb +29 -0
  37. data/lib/json-schema/attributes/uniqueitems.rb +16 -0
  38. data/lib/json-schema/errors/custom_format_error.rb +6 -0
  39. data/lib/json-schema/errors/json_parse_error.rb +6 -0
  40. data/lib/json-schema/errors/schema_error.rb +6 -0
  41. data/lib/json-schema/errors/validation_error.rb +46 -0
  42. data/lib/json-schema/schema.rb +63 -0
  43. data/lib/json-schema/schema/reader.rb +113 -0
  44. data/lib/json-schema/schema/validator.rb +36 -0
  45. data/lib/json-schema/util/array_set.rb +14 -0
  46. data/lib/json-schema/util/uri.rb +16 -0
  47. data/lib/json-schema/util/uuid.rb +285 -0
  48. data/lib/json-schema/validator.rb +592 -0
  49. data/lib/json-schema/validators/draft1.rb +45 -0
  50. data/lib/json-schema/validators/draft2.rb +46 -0
  51. data/lib/json-schema/validators/draft3.rb +50 -0
  52. data/lib/json-schema/validators/draft4.rb +56 -0
  53. data/lib/json-schema/validators/hyper-draft4.rb +14 -0
  54. data/resources/draft-01.json +155 -0
  55. data/resources/draft-02.json +166 -0
  56. data/resources/draft-03.json +174 -0
  57. data/resources/draft-04.json +150 -0
  58. data/test/data/all_of_ref_data.json +3 -0
  59. data/test/data/any_of_ref_data.json +7 -0
  60. data/test/data/bad_data_1.json +3 -0
  61. data/test/data/good_data_1.json +3 -0
  62. data/test/data/one_of_ref_links_data.json +5 -0
  63. data/test/schemas/address_microformat.json +18 -0
  64. data/test/schemas/all_of_ref_base_schema.json +6 -0
  65. data/test/schemas/all_of_ref_schema.json +7 -0
  66. data/test/schemas/any_of_ref_jane_schema.json +4 -0
  67. data/test/schemas/any_of_ref_jimmy_schema.json +4 -0
  68. data/test/schemas/any_of_ref_john_schema.json +4 -0
  69. data/test/schemas/any_of_ref_schema.json +15 -0
  70. data/test/schemas/definition_schema.json +15 -0
  71. data/test/schemas/extends_and_additionalProperties-1-filename.schema.json +34 -0
  72. data/test/schemas/extends_and_additionalProperties-1-ref.schema.json +34 -0
  73. data/test/schemas/extends_and_additionalProperties-2-filename.schema.json +33 -0
  74. data/test/schemas/extends_and_additionalProperties-2-ref.schema.json +33 -0
  75. data/test/schemas/good_schema_1.json +10 -0
  76. data/test/schemas/good_schema_2.json +10 -0
  77. data/test/schemas/good_schema_extends1.json +10 -0
  78. data/test/schemas/good_schema_extends2.json +13 -0
  79. data/test/schemas/inner.schema.json +21 -0
  80. data/test/schemas/one_of_ref_links_schema.json +16 -0
  81. data/test/schemas/ref john with spaces schema.json +11 -0
  82. data/test/schemas/relative_definition_schema.json +8 -0
  83. data/test/schemas/self_link_schema.json +17 -0
  84. data/test/schemas/up_link_schema.json +17 -0
  85. data/test/test_all_of_ref_schema.rb +35 -0
  86. data/test/test_any_of_ref_schema.rb +35 -0
  87. data/test/test_bad_schema_ref.rb +39 -0
  88. data/test/test_common_test_suite.rb +66 -0
  89. data/test/test_custom_format.rb +116 -0
  90. data/test/test_definition.rb +15 -0
  91. data/test/test_extended_schema.rb +62 -0
  92. data/test/test_extends_and_additionalProperties.rb +52 -0
  93. data/test/test_files_v3.rb +43 -0
  94. data/test/test_fragment_resolution.rb +30 -0
  95. data/test/test_fragment_validation_with_ref.rb +34 -0
  96. data/test/test_full_validation.rb +208 -0
  97. data/test/test_helper.rb +47 -0
  98. data/test/test_initialize_data.rb +118 -0
  99. data/test/test_jsonschema_draft1.rb +171 -0
  100. data/test/test_jsonschema_draft2.rb +142 -0
  101. data/test/test_jsonschema_draft3.rb +502 -0
  102. data/test/test_jsonschema_draft4.rb +704 -0
  103. data/test/test_list_option.rb +21 -0
  104. data/test/test_merge_missing_values.rb +45 -0
  105. data/test/test_minitems.rb +16 -0
  106. data/test/test_one_of.rb +85 -0
  107. data/test/test_ruby_schema.rb +59 -0
  108. data/test/test_schema_loader.rb +74 -0
  109. data/test/test_schema_type_attribute.rb +20 -0
  110. data/test/test_schema_validation.rb +185 -0
  111. data/test/test_stringify.rb +48 -0
  112. data/test/test_uri_related.rb +67 -0
  113. data/test/test_validator.rb +53 -0
  114. metadata +284 -0
@@ -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
+ }
@@ -0,0 +1,150 @@
1
+ {
2
+ "id": "http://json-schema.org/draft-04/schema#",
3
+ "$schema": "http://json-schema.org/draft-04/schema#",
4
+ "description": "Core schema meta-schema",
5
+ "definitions": {
6
+ "schemaArray": {
7
+ "type": "array",
8
+ "minItems": 1,
9
+ "items": { "$ref": "#" }
10
+ },
11
+ "positiveInteger": {
12
+ "type": "integer",
13
+ "minimum": 0
14
+ },
15
+ "positiveIntegerDefault0": {
16
+ "allOf": [ { "$ref": "#/definitions/positiveInteger" }, { "default": 0 } ]
17
+ },
18
+ "simpleTypes": {
19
+ "enum": [ "array", "boolean", "integer", "null", "number", "object", "string" ]
20
+ },
21
+ "stringArray": {
22
+ "type": "array",
23
+ "items": { "type": "string" },
24
+ "minItems": 1,
25
+ "uniqueItems": true
26
+ }
27
+ },
28
+ "type": "object",
29
+ "properties": {
30
+ "id": {
31
+ "type": "string",
32
+ "format": "uri"
33
+ },
34
+ "$schema": {
35
+ "type": "string",
36
+ "format": "uri"
37
+ },
38
+ "title": {
39
+ "type": "string"
40
+ },
41
+ "description": {
42
+ "type": "string"
43
+ },
44
+ "default": {},
45
+ "multipleOf": {
46
+ "type": "number",
47
+ "minimum": 0,
48
+ "exclusiveMinimum": true
49
+ },
50
+ "maximum": {
51
+ "type": "number"
52
+ },
53
+ "exclusiveMaximum": {
54
+ "type": "boolean",
55
+ "default": false
56
+ },
57
+ "minimum": {
58
+ "type": "number"
59
+ },
60
+ "exclusiveMinimum": {
61
+ "type": "boolean",
62
+ "default": false
63
+ },
64
+ "maxLength": { "$ref": "#/definitions/positiveInteger" },
65
+ "minLength": { "$ref": "#/definitions/positiveIntegerDefault0" },
66
+ "pattern": {
67
+ "type": "string",
68
+ "format": "regex"
69
+ },
70
+ "additionalItems": {
71
+ "anyOf": [
72
+ { "type": "boolean" },
73
+ { "$ref": "#" }
74
+ ],
75
+ "default": {}
76
+ },
77
+ "items": {
78
+ "anyOf": [
79
+ { "$ref": "#" },
80
+ { "$ref": "#/definitions/schemaArray" }
81
+ ],
82
+ "default": {}
83
+ },
84
+ "maxItems": { "$ref": "#/definitions/positiveInteger" },
85
+ "minItems": { "$ref": "#/definitions/positiveIntegerDefault0" },
86
+ "uniqueItems": {
87
+ "type": "boolean",
88
+ "default": false
89
+ },
90
+ "maxProperties": { "$ref": "#/definitions/positiveInteger" },
91
+ "minProperties": { "$ref": "#/definitions/positiveIntegerDefault0" },
92
+ "required": { "$ref": "#/definitions/stringArray" },
93
+ "additionalProperties": {
94
+ "anyOf": [
95
+ { "type": "boolean" },
96
+ { "$ref": "#" }
97
+ ],
98
+ "default": {}
99
+ },
100
+ "definitions": {
101
+ "type": "object",
102
+ "additionalProperties": { "$ref": "#" },
103
+ "default": {}
104
+ },
105
+ "properties": {
106
+ "type": "object",
107
+ "additionalProperties": { "$ref": "#" },
108
+ "default": {}
109
+ },
110
+ "patternProperties": {
111
+ "type": "object",
112
+ "additionalProperties": { "$ref": "#" },
113
+ "default": {}
114
+ },
115
+ "dependencies": {
116
+ "type": "object",
117
+ "additionalProperties": {
118
+ "anyOf": [
119
+ { "$ref": "#" },
120
+ { "$ref": "#/definitions/stringArray" }
121
+ ]
122
+ }
123
+ },
124
+ "enum": {
125
+ "type": "array",
126
+ "minItems": 1,
127
+ "uniqueItems": true
128
+ },
129
+ "type": {
130
+ "anyOf": [
131
+ { "$ref": "#/definitions/simpleTypes" },
132
+ {
133
+ "type": "array",
134
+ "items": { "$ref": "#/definitions/simpleTypes" },
135
+ "minItems": 1,
136
+ "uniqueItems": true
137
+ }
138
+ ]
139
+ },
140
+ "allOf": { "$ref": "#/definitions/schemaArray" },
141
+ "anyOf": { "$ref": "#/definitions/schemaArray" },
142
+ "oneOf": { "$ref": "#/definitions/schemaArray" },
143
+ "not": { "$ref": "#" }
144
+ },
145
+ "dependencies": {
146
+ "exclusiveMaximum": [ "maximum" ],
147
+ "exclusiveMinimum": [ "minimum" ]
148
+ },
149
+ "default": {}
150
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "name" : "john"
3
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "names" :
3
+ [ "john"
4
+ , "jane"
5
+ , "jimmy"
6
+ ]
7
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "a" : "poop"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "a" : 5
3
+ }
@@ -0,0 +1,5 @@
1
+ { "links":
2
+ [{ "rel" : ["self"] , "href":"http://api.example.com/api/object/3" }
3
+ ,{ "rel" : ["up"] , "href":"http://api.example.com/api/object" }
4
+ ]
5
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "description": "An Address following the convention of http://microformats.org/wiki/hcard",
3
+ "type": "object",
4
+ "properties": {
5
+ "post-office-box": { "type": "string" },
6
+ "extended-address": { "type": "string" },
7
+ "street-address": { "type": "string" },
8
+ "locality":{ "type": "string" },
9
+ "region": { "type": "string" },
10
+ "postal-code": { "type": "string" },
11
+ "country-name": { "type": "string"}
12
+ },
13
+ "required": ["locality", "region", "country-name"],
14
+ "dependencies": {
15
+ "post-office-box": "street-address",
16
+ "extended-address": "street-address"
17
+ }
18
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "type": "object",
3
+ "properties" : {
4
+ "name" : { "type": "integer" }
5
+ }
6
+ }
@@ -0,0 +1,7 @@
1
+ { "$schema" : "http://json-schema.org/draft-04/schema#",
2
+ "type" : "object",
3
+ "allOf" :
4
+ [ { "$ref" : "all_of_ref_base_schema.json" }
5
+ ]
6
+
7
+ }
@@ -0,0 +1,4 @@
1
+ { "$schema" : "http://json-schema.org/draft-04/schema#"
2
+ , "type" : "string"
3
+ , "pattern" : "jane"
4
+ }
@@ -0,0 +1,4 @@
1
+ { "$schema" : "http://json-schema.org/draft-04/schema#"
2
+ , "type" : "string"
3
+ , "pattern" : "jimmy"
4
+ }
@@ -0,0 +1,4 @@
1
+ { "$schema" : "http://json-schema.org/draft-04/schema#"
2
+ , "type" : "string"
3
+ , "pattern" : "john"
4
+ }
@@ -0,0 +1,15 @@
1
+ { "$schema" : "http://json-schema.org/draft-04/schema#"
2
+ , "type" : "object"
3
+ , "properties" :
4
+ { "names" :
5
+ { "type" : "array"
6
+ , "items" :
7
+ { "anyOf" :
8
+ [ { "$ref" : "any_of_ref_john_schema.json" }
9
+ , { "$ref" : "any_of_ref_jane_schema.json" }
10
+ , { "$ref" : "any_of_ref_jimmy_schema.json" }
11
+ ]
12
+ }
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema#",
3
+ "description": "schema with definition",
4
+ "type": "object",
5
+ "properties": {
6
+ "a": {
7
+ "$ref": "#/definitions/foo"
8
+ }
9
+ },
10
+ "definitions": {
11
+ "foo": {
12
+ "type": "integer"
13
+ }
14
+ }
15
+ }