Debian Codegraph @

t/additional-tests-draft2019-09/ref.json

raw
1 [
2 {
3 "description": "order of evaluation: $id and $ref",
4 "schema": {
5 "$comment": "$id must be evaluated before $ref to get the proper $ref destination",
6 "$id": "/ref1/base.json",
7 "$ref": "int.json",
8 "$defs": {
9 "bigint": {
10 "$comment": "canonical uri: /ref1/int.json",
11 "$id": "int.json",
12 "maximum": 10
13 },
14 "smallint": {
15 "$comment": "canonical uri: /int.json",
16 "$id": "/int.json",
17 "maximum": 2
18 }
19 }
20 },
21 "tests": [
22 {
23 "description": "data is valid against first definition",
24 "data": 5,
25 "valid": true
26 },
27 {
28 "description": "data is invalid against first definition",
29 "data": 50,
30 "valid": false
31 }
32 ]
33 },
34 {
35 "description": "order of evaluation: $id and $anchor and $ref",
36 "schema": {
37 "$comment": "$id must be evaluated before $ref to get the proper $ref destination",
38 "$id": "/ref2/base.json",
39 "$ref": "#bigint",
40 "$defs": {
41 "bigint": {
42 "$comment": "canonical uri: /ref2/base.json#/$defs/bigint; another valid uri for this location: /ref2/base.json#bigint",
43 "$anchor": "bigint",
44 "maximum": 10
45 },
46 "smallint": {
47 "$comment": "canonical uri: /ref2; other valid uris for this location: /ref2/#bigint, /refs2/base.json#/$defs/smallint",
48 "$id": "/ref2/",
49 "$anchor": "bigint",
50 "maximum": 2
51 }
52 }
53 },
54 "tests": [
55 {
56 "description": "data is valid against first definition",
57 "data": 5,
58 "valid": true
59 },
60 {
61 "description": "data is invalid against first definition",
62 "data": 50,
63 "valid": false
64 }
65 ]
66 },
67 {
68 "description": "naive replacement of $ref with its destination is not correct",
69 "schema": {
70 "$defs": {
71 "a_string": { "type": "string" }
72 },
73 "enum": [
74 { "$ref": "#/$defs/a_string" }
75 ]
76 },
77 "tests": [
78 {
79 "description": "do not evaluate the $ref inside the enum",
80 "data": "this is a string",
81 "valid": false
82 },
83 {
84 "description": "match the enum exactly",
85 "data": { "$ref": "#/$defs/a_string" },
86 "valid": true
87 }
88 ]
89 },
90 {
91 "description": "invalid $ref: invalid anchor fragment",
92 "schema": {
93 "$defs": {
94 "foo": {
95 "$ref": "https://foo.com/bar.json#-not-an-anchor"
96 }
97 }
98 },
99 "tests": [
100 {
101 "description": "an invalid anchor fragment",
102 "data": 1,
103 "valid": false
104 }
105 ]
106 },
107 {
108 "description": "invalid $ref: invalid json-pointer fragment",
109 "schema": {
110 "$defs": {
111 "foo": {
112 "$ref": "https://foo.com/bar.json#/~2/not/json/pointer"
113 }
114 }
115 },
116 "tests": [
117 {
118 "description": "an invalid json-pointer fragment",
119 "data": 1,
120 "valid": false
121 }
122 ]
123 },
124 {
125 "description": "base URI change - change folder in subschema with path from root",
126 "comment": "based on test suite draft7/refRemote.json 'base URI change - change folder in subschema'",
127 "schema": {
128 "$id": "http://localhost:1234/scope_change_defs.json",
129 "type" : "object",
130 "properties": {
131 "list": { "$ref": "#/$defs/baz/$defs/bar" }
132 },
133 "$defs": {
134 "folderInteger": {
135 "$id": "baseUriChangeFolderInSubschema/folderInteger.json",
136 "type": "integer"
137 },
138 "baz": {
139 "$id": "baseUriChangeFolderInSubschema/",
140 "$defs": {
141 "bar": {
142 "type": "array",
143 "items": { "$ref": "folderInteger.json" }
144 }
145 }
146 }
147 }
148 },
149 "tests": [
150 {
151 "description": "number is valid",
152 "data": {"list": [1]},
153 "valid": true
154 },
155 {
156 "description": "string is invalid",
157 "data": {"list": ["a"]},
158 "valid": false
159 }
160 ]
161 }
162 ]