json_schemer 0.2.9 → 0.2.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (235) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +2 -2
  3. data/json_schemer.gemspec +1 -1
  4. data/lib/json_schemer/version.rb +1 -1
  5. metadata +3 -234
  6. data/JSON-Schema-Test-Suite/.gitignore +0 -1
  7. data/JSON-Schema-Test-Suite/.travis.yml +0 -8
  8. data/JSON-Schema-Test-Suite/LICENSE +0 -19
  9. data/JSON-Schema-Test-Suite/README.md +0 -181
  10. data/JSON-Schema-Test-Suite/bin/jsonschema_suite +0 -298
  11. data/JSON-Schema-Test-Suite/index.js +0 -45
  12. data/JSON-Schema-Test-Suite/package.json +0 -28
  13. data/JSON-Schema-Test-Suite/remotes/folder/folderInteger.json +0 -3
  14. data/JSON-Schema-Test-Suite/remotes/integer.json +0 -3
  15. data/JSON-Schema-Test-Suite/remotes/name-defs.json +0 -15
  16. data/JSON-Schema-Test-Suite/remotes/name.json +0 -15
  17. data/JSON-Schema-Test-Suite/remotes/subSchemas.json +0 -8
  18. data/JSON-Schema-Test-Suite/test-schema.json +0 -59
  19. data/JSON-Schema-Test-Suite/tests/draft2019-09/additionalItems.json +0 -87
  20. data/JSON-Schema-Test-Suite/tests/draft2019-09/additionalProperties.json +0 -133
  21. data/JSON-Schema-Test-Suite/tests/draft2019-09/allOf.json +0 -218
  22. data/JSON-Schema-Test-Suite/tests/draft2019-09/anchor.json +0 -87
  23. data/JSON-Schema-Test-Suite/tests/draft2019-09/anyOf.json +0 -189
  24. data/JSON-Schema-Test-Suite/tests/draft2019-09/boolean_schema.json +0 -104
  25. data/JSON-Schema-Test-Suite/tests/draft2019-09/const.json +0 -170
  26. data/JSON-Schema-Test-Suite/tests/draft2019-09/contains.json +0 -95
  27. data/JSON-Schema-Test-Suite/tests/draft2019-09/default.json +0 -49
  28. data/JSON-Schema-Test-Suite/tests/draft2019-09/defs.json +0 -24
  29. data/JSON-Schema-Test-Suite/tests/draft2019-09/dependencies.json +0 -268
  30. data/JSON-Schema-Test-Suite/tests/draft2019-09/enum.json +0 -179
  31. data/JSON-Schema-Test-Suite/tests/draft2019-09/exclusiveMaximum.json +0 -30
  32. data/JSON-Schema-Test-Suite/tests/draft2019-09/exclusiveMinimum.json +0 -30
  33. data/JSON-Schema-Test-Suite/tests/draft2019-09/format.json +0 -614
  34. data/JSON-Schema-Test-Suite/tests/draft2019-09/if-then-else.json +0 -188
  35. data/JSON-Schema-Test-Suite/tests/draft2019-09/items.json +0 -250
  36. data/JSON-Schema-Test-Suite/tests/draft2019-09/maxItems.json +0 -28
  37. data/JSON-Schema-Test-Suite/tests/draft2019-09/maxLength.json +0 -33
  38. data/JSON-Schema-Test-Suite/tests/draft2019-09/maxProperties.json +0 -38
  39. data/JSON-Schema-Test-Suite/tests/draft2019-09/maximum.json +0 -28
  40. data/JSON-Schema-Test-Suite/tests/draft2019-09/minItems.json +0 -28
  41. data/JSON-Schema-Test-Suite/tests/draft2019-09/minLength.json +0 -33
  42. data/JSON-Schema-Test-Suite/tests/draft2019-09/minProperties.json +0 -38
  43. data/JSON-Schema-Test-Suite/tests/draft2019-09/minimum.json +0 -59
  44. data/JSON-Schema-Test-Suite/tests/draft2019-09/multipleOf.json +0 -60
  45. data/JSON-Schema-Test-Suite/tests/draft2019-09/not.json +0 -117
  46. data/JSON-Schema-Test-Suite/tests/draft2019-09/oneOf.json +0 -206
  47. data/JSON-Schema-Test-Suite/tests/draft2019-09/optional/bignum.json +0 -105
  48. data/JSON-Schema-Test-Suite/tests/draft2019-09/optional/content.json +0 -77
  49. data/JSON-Schema-Test-Suite/tests/draft2019-09/optional/ecmascript-regex.json +0 -213
  50. data/JSON-Schema-Test-Suite/tests/draft2019-09/optional/format/date-time.json +0 -53
  51. data/JSON-Schema-Test-Suite/tests/draft2019-09/optional/format/date.json +0 -23
  52. data/JSON-Schema-Test-Suite/tests/draft2019-09/optional/format/email.json +0 -18
  53. data/JSON-Schema-Test-Suite/tests/draft2019-09/optional/format/hostname.json +0 -33
  54. data/JSON-Schema-Test-Suite/tests/draft2019-09/optional/format/idn-email.json +0 -18
  55. data/JSON-Schema-Test-Suite/tests/draft2019-09/optional/format/idn-hostname.json +0 -28
  56. data/JSON-Schema-Test-Suite/tests/draft2019-09/optional/format/ipv4.json +0 -33
  57. data/JSON-Schema-Test-Suite/tests/draft2019-09/optional/format/ipv6.json +0 -28
  58. data/JSON-Schema-Test-Suite/tests/draft2019-09/optional/format/iri-reference.json +0 -43
  59. data/JSON-Schema-Test-Suite/tests/draft2019-09/optional/format/iri.json +0 -53
  60. data/JSON-Schema-Test-Suite/tests/draft2019-09/optional/format/json-pointer.json +0 -168
  61. data/JSON-Schema-Test-Suite/tests/draft2019-09/optional/format/regex.json +0 -18
  62. data/JSON-Schema-Test-Suite/tests/draft2019-09/optional/format/relative-json-pointer.json +0 -33
  63. data/JSON-Schema-Test-Suite/tests/draft2019-09/optional/format/time.json +0 -23
  64. data/JSON-Schema-Test-Suite/tests/draft2019-09/optional/format/uri-reference.json +0 -43
  65. data/JSON-Schema-Test-Suite/tests/draft2019-09/optional/format/uri-template.json +0 -28
  66. data/JSON-Schema-Test-Suite/tests/draft2019-09/optional/format/uri.json +0 -103
  67. data/JSON-Schema-Test-Suite/tests/draft2019-09/optional/zeroTerminatedFloats.json +0 -15
  68. data/JSON-Schema-Test-Suite/tests/draft2019-09/pattern.json +0 -34
  69. data/JSON-Schema-Test-Suite/tests/draft2019-09/patternProperties.json +0 -151
  70. data/JSON-Schema-Test-Suite/tests/draft2019-09/properties.json +0 -167
  71. data/JSON-Schema-Test-Suite/tests/draft2019-09/propertyNames.json +0 -78
  72. data/JSON-Schema-Test-Suite/tests/draft2019-09/ref.json +0 -359
  73. data/JSON-Schema-Test-Suite/tests/draft2019-09/refRemote.json +0 -167
  74. data/JSON-Schema-Test-Suite/tests/draft2019-09/required.json +0 -105
  75. data/JSON-Schema-Test-Suite/tests/draft2019-09/type.json +0 -464
  76. data/JSON-Schema-Test-Suite/tests/draft2019-09/uniqueItems.json +0 -173
  77. data/JSON-Schema-Test-Suite/tests/draft3/additionalItems.json +0 -82
  78. data/JSON-Schema-Test-Suite/tests/draft3/additionalProperties.json +0 -133
  79. data/JSON-Schema-Test-Suite/tests/draft3/default.json +0 -49
  80. data/JSON-Schema-Test-Suite/tests/draft3/dependencies.json +0 -118
  81. data/JSON-Schema-Test-Suite/tests/draft3/disallow.json +0 -80
  82. data/JSON-Schema-Test-Suite/tests/draft3/divisibleBy.json +0 -60
  83. data/JSON-Schema-Test-Suite/tests/draft3/enum.json +0 -71
  84. data/JSON-Schema-Test-Suite/tests/draft3/extends.json +0 -94
  85. data/JSON-Schema-Test-Suite/tests/draft3/format.json +0 -362
  86. data/JSON-Schema-Test-Suite/tests/draft3/items.json +0 -46
  87. data/JSON-Schema-Test-Suite/tests/draft3/maxItems.json +0 -28
  88. data/JSON-Schema-Test-Suite/tests/draft3/maxLength.json +0 -33
  89. data/JSON-Schema-Test-Suite/tests/draft3/maximum.json +0 -42
  90. data/JSON-Schema-Test-Suite/tests/draft3/minItems.json +0 -28
  91. data/JSON-Schema-Test-Suite/tests/draft3/minLength.json +0 -33
  92. data/JSON-Schema-Test-Suite/tests/draft3/minimum.json +0 -73
  93. data/JSON-Schema-Test-Suite/tests/draft3/optional/bignum.json +0 -107
  94. data/JSON-Schema-Test-Suite/tests/draft3/optional/ecmascript-regex.json +0 -18
  95. data/JSON-Schema-Test-Suite/tests/draft3/optional/format.json +0 -227
  96. data/JSON-Schema-Test-Suite/tests/draft3/optional/zeroTerminatedFloats.json +0 -15
  97. data/JSON-Schema-Test-Suite/tests/draft3/pattern.json +0 -34
  98. data/JSON-Schema-Test-Suite/tests/draft3/patternProperties.json +0 -115
  99. data/JSON-Schema-Test-Suite/tests/draft3/properties.json +0 -97
  100. data/JSON-Schema-Test-Suite/tests/draft3/ref.json +0 -192
  101. data/JSON-Schema-Test-Suite/tests/draft3/refRemote.json +0 -74
  102. data/JSON-Schema-Test-Suite/tests/draft3/required.json +0 -53
  103. data/JSON-Schema-Test-Suite/tests/draft3/type.json +0 -489
  104. data/JSON-Schema-Test-Suite/tests/draft3/uniqueItems.json +0 -163
  105. data/JSON-Schema-Test-Suite/tests/draft4/additionalItems.json +0 -87
  106. data/JSON-Schema-Test-Suite/tests/draft4/additionalProperties.json +0 -133
  107. data/JSON-Schema-Test-Suite/tests/draft4/allOf.json +0 -185
  108. data/JSON-Schema-Test-Suite/tests/draft4/anyOf.json +0 -156
  109. data/JSON-Schema-Test-Suite/tests/draft4/default.json +0 -49
  110. data/JSON-Schema-Test-Suite/tests/draft4/definitions.json +0 -32
  111. data/JSON-Schema-Test-Suite/tests/draft4/dependencies.json +0 -194
  112. data/JSON-Schema-Test-Suite/tests/draft4/enum.json +0 -179
  113. data/JSON-Schema-Test-Suite/tests/draft4/format.json +0 -218
  114. data/JSON-Schema-Test-Suite/tests/draft4/items.json +0 -195
  115. data/JSON-Schema-Test-Suite/tests/draft4/maxItems.json +0 -28
  116. data/JSON-Schema-Test-Suite/tests/draft4/maxLength.json +0 -33
  117. data/JSON-Schema-Test-Suite/tests/draft4/maxProperties.json +0 -38
  118. data/JSON-Schema-Test-Suite/tests/draft4/maximum.json +0 -73
  119. data/JSON-Schema-Test-Suite/tests/draft4/minItems.json +0 -28
  120. data/JSON-Schema-Test-Suite/tests/draft4/minLength.json +0 -33
  121. data/JSON-Schema-Test-Suite/tests/draft4/minProperties.json +0 -38
  122. data/JSON-Schema-Test-Suite/tests/draft4/minimum.json +0 -104
  123. data/JSON-Schema-Test-Suite/tests/draft4/multipleOf.json +0 -60
  124. data/JSON-Schema-Test-Suite/tests/draft4/not.json +0 -96
  125. data/JSON-Schema-Test-Suite/tests/draft4/oneOf.json +0 -162
  126. data/JSON-Schema-Test-Suite/tests/draft4/optional/bignum.json +0 -107
  127. data/JSON-Schema-Test-Suite/tests/draft4/optional/ecmascript-regex.json +0 -213
  128. data/JSON-Schema-Test-Suite/tests/draft4/optional/format.json +0 -253
  129. data/JSON-Schema-Test-Suite/tests/draft4/optional/zeroTerminatedFloats.json +0 -15
  130. data/JSON-Schema-Test-Suite/tests/draft4/pattern.json +0 -34
  131. data/JSON-Schema-Test-Suite/tests/draft4/patternProperties.json +0 -120
  132. data/JSON-Schema-Test-Suite/tests/draft4/properties.json +0 -136
  133. data/JSON-Schema-Test-Suite/tests/draft4/ref.json +0 -411
  134. data/JSON-Schema-Test-Suite/tests/draft4/refRemote.json +0 -171
  135. data/JSON-Schema-Test-Suite/tests/draft4/required.json +0 -89
  136. data/JSON-Schema-Test-Suite/tests/draft4/type.json +0 -464
  137. data/JSON-Schema-Test-Suite/tests/draft4/uniqueItems.json +0 -173
  138. data/JSON-Schema-Test-Suite/tests/draft6/additionalItems.json +0 -87
  139. data/JSON-Schema-Test-Suite/tests/draft6/additionalProperties.json +0 -133
  140. data/JSON-Schema-Test-Suite/tests/draft6/allOf.json +0 -218
  141. data/JSON-Schema-Test-Suite/tests/draft6/anyOf.json +0 -189
  142. data/JSON-Schema-Test-Suite/tests/draft6/boolean_schema.json +0 -104
  143. data/JSON-Schema-Test-Suite/tests/draft6/const.json +0 -170
  144. data/JSON-Schema-Test-Suite/tests/draft6/contains.json +0 -100
  145. data/JSON-Schema-Test-Suite/tests/draft6/default.json +0 -49
  146. data/JSON-Schema-Test-Suite/tests/draft6/definitions.json +0 -32
  147. data/JSON-Schema-Test-Suite/tests/draft6/dependencies.json +0 -268
  148. data/JSON-Schema-Test-Suite/tests/draft6/enum.json +0 -179
  149. data/JSON-Schema-Test-Suite/tests/draft6/exclusiveMaximum.json +0 -30
  150. data/JSON-Schema-Test-Suite/tests/draft6/exclusiveMinimum.json +0 -30
  151. data/JSON-Schema-Test-Suite/tests/draft6/format.json +0 -326
  152. data/JSON-Schema-Test-Suite/tests/draft6/items.json +0 -250
  153. data/JSON-Schema-Test-Suite/tests/draft6/maxItems.json +0 -28
  154. data/JSON-Schema-Test-Suite/tests/draft6/maxLength.json +0 -33
  155. data/JSON-Schema-Test-Suite/tests/draft6/maxProperties.json +0 -38
  156. data/JSON-Schema-Test-Suite/tests/draft6/maximum.json +0 -28
  157. data/JSON-Schema-Test-Suite/tests/draft6/minItems.json +0 -28
  158. data/JSON-Schema-Test-Suite/tests/draft6/minLength.json +0 -33
  159. data/JSON-Schema-Test-Suite/tests/draft6/minProperties.json +0 -38
  160. data/JSON-Schema-Test-Suite/tests/draft6/minimum.json +0 -59
  161. data/JSON-Schema-Test-Suite/tests/draft6/multipleOf.json +0 -60
  162. data/JSON-Schema-Test-Suite/tests/draft6/not.json +0 -117
  163. data/JSON-Schema-Test-Suite/tests/draft6/oneOf.json +0 -206
  164. data/JSON-Schema-Test-Suite/tests/draft6/optional/bignum.json +0 -105
  165. data/JSON-Schema-Test-Suite/tests/draft6/optional/ecmascript-regex.json +0 -213
  166. data/JSON-Schema-Test-Suite/tests/draft6/optional/format.json +0 -491
  167. data/JSON-Schema-Test-Suite/tests/draft6/optional/zeroTerminatedFloats.json +0 -15
  168. data/JSON-Schema-Test-Suite/tests/draft6/pattern.json +0 -34
  169. data/JSON-Schema-Test-Suite/tests/draft6/patternProperties.json +0 -151
  170. data/JSON-Schema-Test-Suite/tests/draft6/properties.json +0 -167
  171. data/JSON-Schema-Test-Suite/tests/draft6/propertyNames.json +0 -78
  172. data/JSON-Schema-Test-Suite/tests/draft6/ref.json +0 -443
  173. data/JSON-Schema-Test-Suite/tests/draft6/refRemote.json +0 -171
  174. data/JSON-Schema-Test-Suite/tests/draft6/required.json +0 -105
  175. data/JSON-Schema-Test-Suite/tests/draft6/type.json +0 -464
  176. data/JSON-Schema-Test-Suite/tests/draft6/uniqueItems.json +0 -173
  177. data/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json +0 -87
  178. data/JSON-Schema-Test-Suite/tests/draft7/additionalProperties.json +0 -133
  179. data/JSON-Schema-Test-Suite/tests/draft7/allOf.json +0 -218
  180. data/JSON-Schema-Test-Suite/tests/draft7/anyOf.json +0 -189
  181. data/JSON-Schema-Test-Suite/tests/draft7/boolean_schema.json +0 -104
  182. data/JSON-Schema-Test-Suite/tests/draft7/const.json +0 -170
  183. data/JSON-Schema-Test-Suite/tests/draft7/contains.json +0 -100
  184. data/JSON-Schema-Test-Suite/tests/draft7/default.json +0 -49
  185. data/JSON-Schema-Test-Suite/tests/draft7/definitions.json +0 -32
  186. data/JSON-Schema-Test-Suite/tests/draft7/dependencies.json +0 -268
  187. data/JSON-Schema-Test-Suite/tests/draft7/enum.json +0 -179
  188. data/JSON-Schema-Test-Suite/tests/draft7/exclusiveMaximum.json +0 -30
  189. data/JSON-Schema-Test-Suite/tests/draft7/exclusiveMinimum.json +0 -30
  190. data/JSON-Schema-Test-Suite/tests/draft7/format.json +0 -614
  191. data/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json +0 -188
  192. data/JSON-Schema-Test-Suite/tests/draft7/items.json +0 -250
  193. data/JSON-Schema-Test-Suite/tests/draft7/maxItems.json +0 -28
  194. data/JSON-Schema-Test-Suite/tests/draft7/maxLength.json +0 -33
  195. data/JSON-Schema-Test-Suite/tests/draft7/maxProperties.json +0 -38
  196. data/JSON-Schema-Test-Suite/tests/draft7/maximum.json +0 -28
  197. data/JSON-Schema-Test-Suite/tests/draft7/minItems.json +0 -28
  198. data/JSON-Schema-Test-Suite/tests/draft7/minLength.json +0 -33
  199. data/JSON-Schema-Test-Suite/tests/draft7/minProperties.json +0 -38
  200. data/JSON-Schema-Test-Suite/tests/draft7/minimum.json +0 -59
  201. data/JSON-Schema-Test-Suite/tests/draft7/multipleOf.json +0 -60
  202. data/JSON-Schema-Test-Suite/tests/draft7/not.json +0 -117
  203. data/JSON-Schema-Test-Suite/tests/draft7/oneOf.json +0 -206
  204. data/JSON-Schema-Test-Suite/tests/draft7/optional/bignum.json +0 -105
  205. data/JSON-Schema-Test-Suite/tests/draft7/optional/content.json +0 -77
  206. data/JSON-Schema-Test-Suite/tests/draft7/optional/ecmascript-regex.json +0 -213
  207. data/JSON-Schema-Test-Suite/tests/draft7/optional/format/date-time.json +0 -53
  208. data/JSON-Schema-Test-Suite/tests/draft7/optional/format/date.json +0 -23
  209. data/JSON-Schema-Test-Suite/tests/draft7/optional/format/email.json +0 -18
  210. data/JSON-Schema-Test-Suite/tests/draft7/optional/format/hostname.json +0 -33
  211. data/JSON-Schema-Test-Suite/tests/draft7/optional/format/idn-email.json +0 -18
  212. data/JSON-Schema-Test-Suite/tests/draft7/optional/format/idn-hostname.json +0 -28
  213. data/JSON-Schema-Test-Suite/tests/draft7/optional/format/ipv4.json +0 -33
  214. data/JSON-Schema-Test-Suite/tests/draft7/optional/format/ipv6.json +0 -28
  215. data/JSON-Schema-Test-Suite/tests/draft7/optional/format/iri-reference.json +0 -43
  216. data/JSON-Schema-Test-Suite/tests/draft7/optional/format/iri.json +0 -53
  217. data/JSON-Schema-Test-Suite/tests/draft7/optional/format/json-pointer.json +0 -168
  218. data/JSON-Schema-Test-Suite/tests/draft7/optional/format/regex.json +0 -18
  219. data/JSON-Schema-Test-Suite/tests/draft7/optional/format/relative-json-pointer.json +0 -33
  220. data/JSON-Schema-Test-Suite/tests/draft7/optional/format/time.json +0 -23
  221. data/JSON-Schema-Test-Suite/tests/draft7/optional/format/uri-reference.json +0 -43
  222. data/JSON-Schema-Test-Suite/tests/draft7/optional/format/uri-template.json +0 -28
  223. data/JSON-Schema-Test-Suite/tests/draft7/optional/format/uri.json +0 -103
  224. data/JSON-Schema-Test-Suite/tests/draft7/optional/zeroTerminatedFloats.json +0 -15
  225. data/JSON-Schema-Test-Suite/tests/draft7/pattern.json +0 -34
  226. data/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json +0 -151
  227. data/JSON-Schema-Test-Suite/tests/draft7/properties.json +0 -167
  228. data/JSON-Schema-Test-Suite/tests/draft7/propertyNames.json +0 -78
  229. data/JSON-Schema-Test-Suite/tests/draft7/ref.json +0 -443
  230. data/JSON-Schema-Test-Suite/tests/draft7/refRemote.json +0 -171
  231. data/JSON-Schema-Test-Suite/tests/draft7/required.json +0 -105
  232. data/JSON-Schema-Test-Suite/tests/draft7/type.json +0 -464
  233. data/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json +0 -173
  234. data/JSON-Schema-Test-Suite/tests/latest +0 -1
  235. data/JSON-Schema-Test-Suite/tox.ini +0 -9
@@ -1,298 +0,0 @@
1
- #! /usr/bin/env python3
2
- from __future__ import print_function
3
- from pprint import pformat
4
- import argparse
5
- import errno
6
- import fnmatch
7
- import json
8
- import os
9
- import random
10
- import shutil
11
- import sys
12
- import textwrap
13
- import unittest
14
- import warnings
15
-
16
- if getattr(unittest, "skipIf", None) is None:
17
- unittest.skipIf = lambda cond, msg : lambda fn : fn
18
-
19
- try:
20
- import jsonschema
21
- except ImportError:
22
- jsonschema = None
23
- else:
24
- validators = getattr(
25
- jsonschema.validators, "validators", jsonschema.validators
26
- )
27
-
28
-
29
- ROOT_DIR = os.path.abspath(
30
- os.path.join(os.path.dirname(__file__), os.pardir).rstrip("__pycache__"),
31
- )
32
- SUITE_ROOT_DIR = os.path.join(ROOT_DIR, "tests")
33
-
34
- REMOTES = {
35
- "integer.json": {u"type": u"integer"},
36
- "name.json": {
37
- u"type": "string",
38
- u"definitions": {
39
- u"orNull": {u"anyOf": [{u"type": u"null"}, {u"$ref": u"#"}]},
40
- },
41
- },
42
- "name-defs.json": {
43
- u"type": "string",
44
- u"$defs": {
45
- u"orNull": {u"anyOf": [{u"type": u"null"}, {u"$ref": u"#"}]},
46
- },
47
- },
48
- "subSchemas.json": {
49
- u"integer": {u"type": u"integer"},
50
- u"refToInteger": {u"$ref": u"#/integer"},
51
- },
52
- "folder/folderInteger.json": {u"type": u"integer"}
53
- }
54
- REMOTES_DIR = os.path.join(ROOT_DIR, "remotes")
55
-
56
- with open(os.path.join(ROOT_DIR, "test-schema.json")) as schema:
57
- TESTSUITE_SCHEMA = json.load(schema)
58
-
59
- def files(paths):
60
- for path in paths:
61
- with open(path) as test_file:
62
- yield json.load(test_file)
63
-
64
-
65
- def groups(paths):
66
- for test_file in files(paths):
67
- for group in test_file:
68
- yield group
69
-
70
-
71
- def cases(paths):
72
- for test_group in groups(paths):
73
- for test in test_group["tests"]:
74
- test["schema"] = test_group["schema"]
75
- yield test
76
-
77
-
78
- def collect(root_dir):
79
- for root, dirs, files in os.walk(root_dir):
80
- for filename in fnmatch.filter(files, "*.json"):
81
- yield os.path.join(root, filename)
82
-
83
-
84
- class SanityTests(unittest.TestCase):
85
- @classmethod
86
- def setUpClass(cls):
87
- print("Looking for tests in %s" % SUITE_ROOT_DIR)
88
- cls.test_files = list(collect(SUITE_ROOT_DIR))
89
- print("Found %s test files" % len(cls.test_files))
90
- assert cls.test_files, "Didn't find the test files!"
91
-
92
- def test_all_files_are_valid_json(self):
93
- for path in self.test_files:
94
- with open(path) as test_file:
95
- try:
96
- json.load(test_file)
97
- except ValueError as error:
98
- self.fail("%s contains invalid JSON (%s)" % (path, error))
99
-
100
- def test_all_descriptions_have_reasonable_length(self):
101
- for case in cases(self.test_files):
102
- description = case["description"]
103
- self.assertLess(
104
- len(description),
105
- 70,
106
- "%r is too long! (keep it to less than 70 chars)" % (
107
- description,
108
- ),
109
- )
110
-
111
- def test_all_descriptions_are_unique(self):
112
- for group in groups(self.test_files):
113
- descriptions = set(test["description"] for test in group["tests"])
114
- self.assertEqual(
115
- len(descriptions),
116
- len(group["tests"]),
117
- "%r contains a duplicate description" % (group,)
118
- )
119
-
120
- @unittest.skipIf(jsonschema is None, "Validation library not present!")
121
- def test_all_schemas_are_valid(self):
122
- for schema in os.listdir(SUITE_ROOT_DIR):
123
- schema_validator = validators.get(schema)
124
- if schema_validator is not None:
125
- test_files = collect(os.path.join(SUITE_ROOT_DIR, schema))
126
- for case in cases(test_files):
127
- try:
128
- schema_validator.check_schema(case["schema"])
129
- except jsonschema.SchemaError as error:
130
- self.fail("%s contains an invalid schema (%s)" %
131
- (case, error))
132
- else:
133
- warnings.warn("No schema validator for %s" % schema)
134
-
135
- @unittest.skipIf(jsonschema is None, "Validation library not present!")
136
- def test_suites_are_valid(self):
137
- validator = jsonschema.Draft4Validator(TESTSUITE_SCHEMA)
138
- for tests in files(self.test_files):
139
- try:
140
- validator.validate(tests)
141
- except jsonschema.ValidationError as error:
142
- self.fail(str(error))
143
-
144
- def test_remote_schemas_are_updated(self):
145
- files = {}
146
- for parent, _, paths in os.walk(REMOTES_DIR):
147
- for path in paths:
148
- absolute_path = os.path.join(parent, path)
149
- with open(absolute_path) as schema_file:
150
- files[absolute_path] = json.load(schema_file)
151
-
152
- expected = {
153
- os.path.join(REMOTES_DIR, path): contents
154
- for path, contents in REMOTES.items()
155
- }
156
-
157
- missing = set(files).symmetric_difference(expected)
158
- changed = {
159
- path
160
- for path, contents in expected.items()
161
- if path in files
162
- and contents != files[path]
163
- }
164
-
165
- self.assertEqual(
166
- files,
167
- expected,
168
- msg=textwrap.dedent(
169
- """
170
- Remotes in the remotes/ directory do not match those in the
171
- ``jsonschema_suite`` Python script.
172
-
173
- Unfortunately for the minute, each remote file is duplicated in
174
- two places.""" + ("""
175
-
176
- Only present in one location:
177
-
178
- {}""".format("\n".join(missing)) if missing else "") + ("""
179
-
180
- Conflicting between the two:
181
-
182
- {}""".format("\n".join(changed)) if changed else "")
183
- )
184
- )
185
-
186
-
187
- def main(arguments):
188
- if arguments.command == "check":
189
- suite = unittest.TestLoader().loadTestsFromTestCase(SanityTests)
190
- result = unittest.TextTestRunner(verbosity=2).run(suite)
191
- sys.exit(not result.wasSuccessful())
192
- elif arguments.command == "flatten":
193
- selected_cases = [case for case in cases(collect(arguments.version))]
194
-
195
- if arguments.randomize:
196
- random.shuffle(selected_cases)
197
-
198
- json.dump(selected_cases, sys.stdout, indent=4, sort_keys=True)
199
- elif arguments.command == "remotes":
200
- json.dump(REMOTES, sys.stdout, indent=4, sort_keys=True)
201
- elif arguments.command == "dump_remotes":
202
- if arguments.update:
203
- shutil.rmtree(arguments.out_dir, ignore_errors=True)
204
-
205
- try:
206
- os.makedirs(arguments.out_dir)
207
- except OSError as e:
208
- if e.errno == errno.EEXIST:
209
- print("%s already exists. Aborting." % arguments.out_dir)
210
- sys.exit(1)
211
- raise
212
-
213
- for url, schema in REMOTES.items():
214
- filepath = os.path.join(arguments.out_dir, url)
215
-
216
- try:
217
- os.makedirs(os.path.dirname(filepath))
218
- except OSError as e:
219
- if e.errno != errno.EEXIST:
220
- raise
221
-
222
- with open(filepath, "w") as out_file:
223
- json.dump(schema, out_file, indent=4, sort_keys=True)
224
- out_file.write("\n")
225
- elif arguments.command == "serve":
226
- try:
227
- from flask import Flask, jsonify
228
- except ImportError:
229
- print(textwrap.dedent("""
230
- The Flask library is required to serve the remote schemas.
231
-
232
- You can install it by running `pip install Flask`.
233
-
234
- Alternatively, see the `jsonschema_suite remotes` or
235
- `jsonschema_suite dump_remotes` commands to create static files
236
- that can be served with your own web server.
237
- """.strip("\n")))
238
- sys.exit(1)
239
-
240
- app = Flask(__name__)
241
-
242
- @app.route("/<path:path>")
243
- def serve_path(path):
244
- if path in REMOTES:
245
- return jsonify(REMOTES[path])
246
- return "Document does not exist.", 404
247
-
248
- app.run(port=1234)
249
-
250
-
251
- parser = argparse.ArgumentParser(
252
- description="JSON Schema Test Suite utilities",
253
- )
254
- subparsers = parser.add_subparsers(help="utility commands", dest="command")
255
-
256
- check = subparsers.add_parser("check", help="Sanity check the test suite.")
257
-
258
- flatten = subparsers.add_parser(
259
- "flatten",
260
- help="Output a flattened file containing a selected version's test cases."
261
- )
262
- flatten.add_argument(
263
- "--randomize",
264
- action="store_true",
265
- help="Randomize the order of the outputted cases.",
266
- )
267
- flatten.add_argument(
268
- "version", help="The directory containing the version to output",
269
- )
270
-
271
- remotes = subparsers.add_parser(
272
- "remotes",
273
- help="Output the expected URLs and their associated schemas for remote "
274
- "ref tests as a JSON object."
275
- )
276
-
277
- dump_remotes = subparsers.add_parser(
278
- "dump_remotes", help="Dump the remote ref schemas into a file tree",
279
- )
280
- dump_remotes.add_argument(
281
- "--update",
282
- action="store_true",
283
- help="Update the remotes in an existing directory.",
284
- )
285
- dump_remotes.add_argument(
286
- "--out-dir",
287
- default=REMOTES_DIR,
288
- type=os.path.abspath,
289
- help="The output directory to create as the root of the file tree",
290
- )
291
-
292
- serve = subparsers.add_parser(
293
- "serve",
294
- help="Start a webserver to serve schemas used by remote ref tests."
295
- )
296
-
297
- if __name__ == "__main__":
298
- main(parser.parse_args())
@@ -1,45 +0,0 @@
1
- 'use strict';
2
-
3
- const Ajv = require('ajv');
4
- const jsonSchemaTest = require('json-schema-test');
5
- const assert = require('assert');
6
-
7
- const refs = {
8
- 'http://localhost:1234/integer.json': require('./remotes/integer.json'),
9
- 'http://localhost:1234/subSchemas.json': require('./remotes/subSchemas.json'),
10
- 'http://localhost:1234/folder/folderInteger.json': require('./remotes/folder/folderInteger.json'),
11
- 'http://localhost:1234/name.json': require('./remotes/name.json'),
12
- 'http://localhost:1234/name-defs.json': require('./remotes/name-defs.json')
13
- };
14
-
15
- const SKIP = {
16
- 4: ['optional/zeroTerminatedFloats'],
17
- 7: [
18
- 'format/idn-email',
19
- 'format/idn-hostname',
20
- 'format/iri',
21
- 'format/iri-reference',
22
- 'optional/content'
23
- ]
24
- };
25
-
26
- [4, 6, 7].forEach((draft) => {
27
- let ajv;
28
- if (draft == 7) {
29
- ajv = new Ajv({format: 'full'});
30
- } else {
31
- const schemaId = draft == 4 ? 'id' : '$id';
32
- ajv = new Ajv({format: 'full', meta: false, schemaId});
33
- ajv.addMetaSchema(require(`ajv/lib/refs/json-schema-draft-0${draft}.json`));
34
- ajv._opts.defaultMeta = `http://json-schema.org/draft-0${draft}/schema#`;
35
- }
36
- for (const uri in refs) ajv.addSchema(refs[uri], uri);
37
-
38
- jsonSchemaTest(ajv, {
39
- description: `Test suite draft-0${draft}`,
40
- suites: {tests: `./tests/draft${draft}/{**/,}*.json`},
41
- skip: SKIP[draft],
42
- cwd: __dirname,
43
- hideFolder: 'tests/'
44
- });
45
- });
@@ -1,28 +0,0 @@
1
- {
2
- "name": "json-schema-test-suite",
3
- "version": "0.1.0",
4
- "description": "A language agnostic test suite for the JSON Schema specifications",
5
- "main": "index.js",
6
- "scripts": {
7
- "test": "mocha index.js -R spec"
8
- },
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/json-schema-org/JSON-Schema-Test-Suite.git"
12
- },
13
- "keywords": [
14
- "json-schema",
15
- "tests"
16
- ],
17
- "author": "http://json-schema.org",
18
- "license": "MIT",
19
- "bugs": {
20
- "url": "https://github.com/json-schema-org/JSON-Schema-Test-Suite/issues"
21
- },
22
- "homepage": "https://github.com/json-schema-org/JSON-Schema-Test-Suite#readme",
23
- "devDependencies": {
24
- "ajv": "^6.0.0-rc.1",
25
- "json-schema-test": "^2.0.0",
26
- "mocha": "^3.2.0"
27
- }
28
- }
@@ -1,3 +0,0 @@
1
- {
2
- "type": "integer"
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "type": "integer"
3
- }
@@ -1,15 +0,0 @@
1
- {
2
- "$defs": {
3
- "orNull": {
4
- "anyOf": [
5
- {
6
- "type": "null"
7
- },
8
- {
9
- "$ref": "#"
10
- }
11
- ]
12
- }
13
- },
14
- "type": "string"
15
- }
@@ -1,15 +0,0 @@
1
- {
2
- "definitions": {
3
- "orNull": {
4
- "anyOf": [
5
- {
6
- "type": "null"
7
- },
8
- {
9
- "$ref": "#"
10
- }
11
- ]
12
- }
13
- },
14
- "type": "string"
15
- }
@@ -1,8 +0,0 @@
1
- {
2
- "integer": {
3
- "type": "integer"
4
- },
5
- "refToInteger": {
6
- "$ref": "#/integer"
7
- }
8
- }
@@ -1,59 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-04/schema#",
3
- "definitions": {
4
- "outputItem": {
5
- "type": "object",
6
- "properties": {
7
- "valid": {"type": "boolean"},
8
- "keywordLocation": {"type": "string"},
9
- "absoluteKeywordLocation": {
10
- "type": "string",
11
- "format": "uri"
12
- },
13
- "instanceLocation": {"type": "string"},
14
- "annotations": {
15
- "type": "array",
16
- "items": {"$ref": "#/definitions/outputItem"}
17
- },
18
- "errors": {
19
- "type": "array",
20
- "items": {"$ref": "#/definitions/outputItem"}
21
- }
22
- }
23
- }
24
- },
25
- "type": "array",
26
- "items": {
27
- "type": "object",
28
- "required": ["description", "schema", "tests"],
29
- "properties": {
30
- "description": {"type": "string"},
31
- "schema": {},
32
- "tests": {
33
- "type": "array",
34
- "items": {
35
- "type": "object",
36
- "required": ["description", "data", "valid"],
37
- "properties": {
38
- "description": {"type": "string"},
39
- "data": {},
40
- "valid": {"type": "boolean"},
41
- "output": {
42
- "type": "object",
43
- "properties": {
44
- "basic": {"$ref": "#/definitions/outputItem"},
45
- "detailed": {"$ref": "#/definitions/outputItem"},
46
- "verbose": {"$ref": "#/definitions/outputItem"}
47
- },
48
- "required": ["basic", "detailed", "verbose"]
49
- }
50
- },
51
- "additionalProperties": false
52
- },
53
- "minItems": 1
54
- }
55
- },
56
- "additionalProperties": false,
57
- "minItems": 1
58
- }
59
- }