json-schema-library 11.2.0 → 11.3.1
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.
- package/CHANGELOG.md +5 -0
- package/bowtie/BOWTIE.md +4 -4
- package/bowtie/Dockerfile +1 -1
- package/bowtie/{bowtie.ts → bowtie-jlib.ts} +11 -17
- package/bowtie/bowtie.test.ts +287 -16
- package/bowtie/package.json +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +76 -5
- package/dist/index.d.mts +76 -5
- package/dist/index.mjs +1 -1
- package/dist/jlib.js +2 -2
- package/dist/remotes/index.d.cts +1 -1
- package/dist/remotes/index.d.mts +1 -1
- package/dist/{types-B2wwNWyo.d.cts → types-DVyFDxCv.d.mts} +2 -1
- package/dist/{types-BhTU1l2h.d.mts → types-ZgoQMSny.d.cts} +2 -1
- package/package.json +2 -2
- package/src/SchemaNode.ts +3 -1
- package/src/compileSchema.test.ts +52 -0
- package/src/compileSchema.ts +52 -4
- package/src/draft04.ts +2 -2
- package/src/draft06.ts +2 -2
- package/src/draft07.ts +2 -2
- package/src/draft2019-09/keywords/$ref.ts +4 -14
- package/src/draft2019.ts +1 -1
- package/src/draft2020.ts +1 -1
- package/src/keywords/$ref.ts +3 -4
- package/src/keywords/oneOf.test.ts +3 -3
- package/src/settings.ts +27 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
## Changelog
|
|
2
2
|
|
|
3
|
+
### v11.3.0
|
|
4
|
+
|
|
5
|
+
- added option 'draft' as fallback for a missing `$schema` id
|
|
6
|
+
- added properties to merge when resolvinf a $ref to `settings.PROPERTIES_TO_MERGE`
|
|
7
|
+
|
|
3
8
|
### v11.2.0
|
|
4
9
|
|
|
5
10
|
- introduced `throwOnInvalidRef` to abort validation when a $ref cannot be resolved
|
package/bowtie/BOWTIE.md
CHANGED
|
@@ -27,14 +27,14 @@ echo '{"cmd":"stop"}' | docker run -i jlib
|
|
|
27
27
|
bowtie smoke -i localhost/jlib
|
|
28
28
|
bowtie suite -i localhost/jlib https://github.com/json-schema-org/JSON-Schema-Test-Suite/blob/main/tests/draft7/type.json | bowtie summary --show failures
|
|
29
29
|
|
|
30
|
-
bowtie suite -i localhost/jlib https://github.com/json-schema-org/JSON-Schema-Test-Suite/tree/main/tests/
|
|
31
|
-
bowtie suite -i localhost/jlib https://github.com/json-schema-org/JSON-Schema-Test-Suite/tree/main/tests/
|
|
32
|
-
bowtie suite -i localhost/jlib https://github.com/json-schema-org/JSON-Schema-Test-Suite/tree/main/tests/draft2020-12 > draft2020-12.json
|
|
33
|
-
|
|
30
|
+
bowtie suite -i localhost/jlib https://github.com/json-schema-org/JSON-Schema-Test-Suite/tree/main/tests/draft4 | bowtie summary --show failures
|
|
31
|
+
bowtie suite -i localhost/jlib https://github.com/json-schema-org/JSON-Schema-Test-Suite/tree/main/tests/draft6 | bowtie summary --show failures
|
|
34
32
|
bowtie suite -i localhost/jlib https://github.com/json-schema-org/JSON-Schema-Test-Suite/tree/main/tests/draft7 | bowtie summary --show failures
|
|
35
33
|
bowtie suite -i localhost/jlib https://github.com/json-schema-org/JSON-Schema-Test-Suite/tree/main/tests/draft2019-09 | bowtie summary --show failures
|
|
36
34
|
bowtie suite -i localhost/jlib https://github.com/json-schema-org/JSON-Schema-Test-Suite/tree/main/tests/draft2020-12 | bowtie summary --show failures
|
|
37
35
|
|
|
36
|
+
bowtie suite -i localhost/jlib https://github.com/json-schema-org/JSON-Schema-Test-Suite/tree/main/tests/draft7 > draft7.json
|
|
37
|
+
|
|
38
38
|
**Fails**
|
|
39
39
|
bowtie suite $(bowtie filter-implementations | sed 's/^/-i /') https://github.com/json-schema-org/JSON-Schema-Test-Suite/tree/main/tests/draft2020-12 >draft2020-12.json
|
|
40
40
|
|
package/bowtie/Dockerfile
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
let state: "started" | "dialect" | "testing" | "stopped" = "stopped";
|
|
20
20
|
/** current JSON Schema draft version to test */
|
|
21
21
|
let dialect: Dialect;
|
|
22
|
+
/** all meta-schemata added as remtoes */
|
|
22
23
|
let remote: SchemaNode;
|
|
23
24
|
|
|
24
25
|
const cmds: CommandMap = {
|
|
@@ -26,6 +27,7 @@ const cmds: CommandMap = {
|
|
|
26
27
|
console.assert(args.version === 1, { args });
|
|
27
28
|
console.assert(state === "stopped");
|
|
28
29
|
state = "started";
|
|
30
|
+
|
|
29
31
|
return {
|
|
30
32
|
version: 1,
|
|
31
33
|
implementation: {
|
|
@@ -53,32 +55,23 @@ const cmds: CommandMap = {
|
|
|
53
55
|
dialect: async (args) => {
|
|
54
56
|
console.assert(state === "started");
|
|
55
57
|
state = "dialect";
|
|
56
|
-
dialect = args.dialect;
|
|
57
|
-
|
|
58
|
-
const node = compileSchema({ $schema: dialect });
|
|
59
|
-
remotes.forEach((schema) => {
|
|
60
|
-
node.addRemoteSchema(schema.$id ?? schema.id, schema);
|
|
61
|
-
});
|
|
62
|
-
remote = node;
|
|
63
58
|
|
|
59
|
+
dialect = args.dialect;
|
|
60
|
+
remote = compileSchema({ $schema: dialect });
|
|
61
|
+
remotes.forEach((schema) => remote.addRemoteSchema(schema.$id ?? schema.id, schema));
|
|
64
62
|
return { ok: true };
|
|
65
63
|
},
|
|
66
64
|
|
|
67
65
|
run: async (args) => {
|
|
68
66
|
console.assert(state === "dialect" || state === "testing");
|
|
69
67
|
state = "testing";
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// compile schema
|
|
75
|
-
const node = compileSchema(schema, { remote, formatAssertion: false });
|
|
76
|
-
// add remote schemata
|
|
77
|
-
for (const id in registry) {
|
|
78
|
-
node.addRemoteSchema(id, registry[id]);
|
|
68
|
+
|
|
69
|
+
const node = compileSchema(args.case.schema, { remote, draft: dialect, formatAssertion: false });
|
|
70
|
+
for (const id in args.case.registry) {
|
|
71
|
+
node.addRemoteSchema(id, args.case.registry[id]);
|
|
79
72
|
}
|
|
80
73
|
// run test cases and collect results to be sent back to bowtie
|
|
81
|
-
const results: RunCmdResponse["results"] = tests.map((test) => {
|
|
74
|
+
const results: RunCmdResponse["results"] = args.case.tests.map((test) => {
|
|
82
75
|
try {
|
|
83
76
|
return { valid: node.validate(test.instance).valid };
|
|
84
77
|
} catch (e) {
|
|
@@ -92,6 +85,7 @@ const cmds: CommandMap = {
|
|
|
92
85
|
stop: async (_, stdio) => {
|
|
93
86
|
console.assert(state === "testing");
|
|
94
87
|
state = "stopped";
|
|
88
|
+
|
|
95
89
|
if (process.env.JLIB_TEST_RUN !== "true") {
|
|
96
90
|
stdio?.close();
|
|
97
91
|
process.exit(0);
|
package/bowtie/bowtie.test.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { strict as assert } from "node:assert";
|
|
|
2
2
|
import { compileSchema } from "../src/compileSchema";
|
|
3
3
|
import { remotes } from "json-schema-library/remotes";
|
|
4
4
|
import { JsonSchema } from "../src/types";
|
|
5
|
-
import { runCommand } from "./bowtie";
|
|
5
|
+
import { runCommand } from "./bowtie-jlib";
|
|
6
6
|
import { ErrorResponse, RunCmdResponse } from "./bowtie-api";
|
|
7
7
|
|
|
8
8
|
const isRunCmdResponse = (value: unknown): value is RunCmdResponse =>
|
|
@@ -14,6 +14,86 @@ const isErrorResponse = (value: unknown): value is ErrorResponse =>
|
|
|
14
14
|
const remote = compileSchema({ $id: "draft2020-12" });
|
|
15
15
|
remotes.map((schema: JsonSchema) => remote.addRemoteSchema(schema.$id ?? schema.id, schema));
|
|
16
16
|
|
|
17
|
+
describe("bowtie (draft4)", async () => {
|
|
18
|
+
before(async () => {
|
|
19
|
+
await runCommand({ cmd: "start", version: 1 });
|
|
20
|
+
await runCommand({ cmd: "dialect", dialect: "http://json-schema.org/draft-04/schema#" });
|
|
21
|
+
});
|
|
22
|
+
after(async () => runCommand({ cmd: "stop" }));
|
|
23
|
+
|
|
24
|
+
const registry = {
|
|
25
|
+
"http://localhost:1234/draft4/name.json": {
|
|
26
|
+
definitions: { orNull: { anyOf: [{ type: "null" }, { $ref: "#" }] } },
|
|
27
|
+
type: "string"
|
|
28
|
+
},
|
|
29
|
+
"http://localhost:1234/v1/nested-absolute-ref-to-string.json": {
|
|
30
|
+
$defs: { bar: { $id: "http://localhost:1234/v1/the-nested-id.json", type: "string" } },
|
|
31
|
+
$ref: "http://localhost:1234/v1/the-nested-id.json"
|
|
32
|
+
},
|
|
33
|
+
"http://localhost:1234/nested/string.json": { type: "string" },
|
|
34
|
+
"http://localhost:1234/baseUriChange/folderInteger.json": { type: "integer" },
|
|
35
|
+
"http://localhost:1234/draft4/subSchemas.json": {
|
|
36
|
+
definitions: { integer: { type: "integer" }, refToInteger: { $ref: "#/definitions/integer" } }
|
|
37
|
+
},
|
|
38
|
+
"http://localhost:1234/v1/different-id-ref-string.json": {
|
|
39
|
+
$id: "http://localhost:1234/v1/real-id-ref-string.json",
|
|
40
|
+
$defs: { bar: { type: "string" } },
|
|
41
|
+
$ref: "#/$defs/bar"
|
|
42
|
+
},
|
|
43
|
+
"http://localhost:1234/v1/urn-ref-string.json": {
|
|
44
|
+
$id: "urn:uuid:feebdaed-ffff-0000-ff01-0000deadbeef",
|
|
45
|
+
$defs: { bar: { type: "string" } },
|
|
46
|
+
$ref: "#/$defs/bar"
|
|
47
|
+
},
|
|
48
|
+
"http://localhost:1234/integer.json": { type: "integer" },
|
|
49
|
+
"http://localhost:1234/nested/foo-ref-string.json": {
|
|
50
|
+
type: "object",
|
|
51
|
+
properties: { foo: { $ref: "string.json" } }
|
|
52
|
+
},
|
|
53
|
+
"http://localhost:1234/baseUriChangeFolder/folderInteger.json": { type: "integer" },
|
|
54
|
+
"http://localhost:1234/draft4/locationIndependentIdentifier.json": {
|
|
55
|
+
definitions: { refToInteger: { $ref: "#foo" }, A: { id: "#foo", type: "integer" } }
|
|
56
|
+
},
|
|
57
|
+
"http://localhost:1234/baseUriChangeFolderInSubschema/folderInteger.json": { type: "integer" }
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
it("Location-independent identifier in remote ref - additional items match schema", async () => {
|
|
61
|
+
const response = await runCommand({
|
|
62
|
+
cmd: "run",
|
|
63
|
+
seq: 1,
|
|
64
|
+
case: {
|
|
65
|
+
description: "Location-independent identifier in remote ref",
|
|
66
|
+
schema: {
|
|
67
|
+
$ref: "http://localhost:1234/draft4/locationIndependentIdentifier.json#/definitions/refToInteger"
|
|
68
|
+
},
|
|
69
|
+
registry,
|
|
70
|
+
tests: [{ description: "integer is valid", instance: 1, valid: true }]
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
assert(isRunCmdResponse(response));
|
|
74
|
+
assert(!isErrorResponse(response.results[0]));
|
|
75
|
+
assert.equal(response.results[0].valid, true);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("Location-independent identifier in remote ref - additional items do not match schema", async () => {
|
|
79
|
+
const response = await runCommand({
|
|
80
|
+
cmd: "run",
|
|
81
|
+
seq: 1,
|
|
82
|
+
case: {
|
|
83
|
+
description: "Location-independent identifier in remote ref",
|
|
84
|
+
schema: {
|
|
85
|
+
$ref: "http://localhost:1234/draft4/locationIndependentIdentifier.json#/definitions/refToInteger"
|
|
86
|
+
},
|
|
87
|
+
registry,
|
|
88
|
+
tests: [{ description: "string is invalid", instance: "foo", valid: false }]
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
assert(isRunCmdResponse(response));
|
|
92
|
+
assert(!isErrorResponse(response.results[0]));
|
|
93
|
+
assert.equal(response.results[0].valid, false);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
17
97
|
describe("bowtie (draft7)", async () => {
|
|
18
98
|
before(async () => {
|
|
19
99
|
await runCommand({ cmd: "start", version: 1 });
|
|
@@ -54,23 +134,214 @@ describe("bowtie (draft7)", async () => {
|
|
|
54
134
|
});
|
|
55
135
|
});
|
|
56
136
|
|
|
57
|
-
describe("bowtie (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
137
|
+
describe("bowtie (2019-09)", () => {
|
|
138
|
+
const testCase = {
|
|
139
|
+
description: "schema that uses custom metaschema with with no validation vocabulary",
|
|
140
|
+
schema: {
|
|
141
|
+
$id: "https://schema/using/no/validation",
|
|
142
|
+
$schema: "http://localhost:1234/draft2019-09/metaschema-no-validation.json",
|
|
143
|
+
properties: { badProperty: false, numberProperty: { minimum: 10 } }
|
|
144
|
+
},
|
|
145
|
+
registry: {
|
|
146
|
+
"http://localhost:1234/draft2019-09/integer.json": {
|
|
147
|
+
$schema: "https://json-schema.org/draft/2019-09/schema",
|
|
148
|
+
type: "integer"
|
|
149
|
+
},
|
|
150
|
+
"http://localhost:1234/draft2019-09/dependentRequired.json": {
|
|
151
|
+
$id: "http://localhost:1234/draft2019-09/dependentRequired.json",
|
|
152
|
+
$schema: "https://json-schema.org/draft/2019-09/schema",
|
|
153
|
+
dependentRequired: { foo: ["bar"] }
|
|
154
|
+
},
|
|
155
|
+
"http://localhost:1234/draft2019-09/detached-ref.json": {
|
|
156
|
+
$id: "http://localhost:1234/draft2019-09/detached-ref.json",
|
|
157
|
+
$schema: "https://json-schema.org/draft/2019-09/schema",
|
|
158
|
+
$defs: { foo: { $ref: "#detached" }, detached: { $anchor: "detached", type: "integer" } }
|
|
159
|
+
},
|
|
160
|
+
"http://localhost:1234/integer.json": { type: "integer" },
|
|
161
|
+
"http://localhost:1234/draft2019-09/nested/foo-ref-string.json": {
|
|
162
|
+
$schema: "https://json-schema.org/draft/2019-09/schema",
|
|
163
|
+
type: "object",
|
|
164
|
+
properties: { foo: { $ref: "string.json" } }
|
|
165
|
+
},
|
|
166
|
+
"http://localhost:1234/draft2019-09/urn-ref-string.json": {
|
|
167
|
+
$id: "urn:uuid:feebdaed-ffff-0000-2019-0900deadbeef",
|
|
168
|
+
$defs: { bar: { type: "string" } },
|
|
169
|
+
$ref: "#/$defs/bar"
|
|
170
|
+
},
|
|
171
|
+
"http://localhost:1234/draft2019-09/locationIndependentIdentifier.json": {
|
|
172
|
+
$schema: "https://json-schema.org/draft/2019-09/schema",
|
|
173
|
+
$defs: { refToInteger: { $ref: "#foo" }, A: { $anchor: "foo", type: "integer" } }
|
|
174
|
+
},
|
|
175
|
+
"http://localhost:1234/baseUriChangeFolder/folderInteger.json": { type: "integer" },
|
|
176
|
+
"http://localhost:1234/draft2019-09/baseUriChange/folderInteger.json": {
|
|
177
|
+
$schema: "https://json-schema.org/draft/2019-09/schema",
|
|
178
|
+
type: "integer"
|
|
179
|
+
},
|
|
180
|
+
"http://localhost:1234/draft2019-09/ref-and-defs.json": {
|
|
181
|
+
$schema: "https://json-schema.org/draft/2019-09/schema",
|
|
182
|
+
$id: "http://localhost:1234/draft2019-09/ref-and-defs.json",
|
|
183
|
+
$defs: { inner: { properties: { bar: { type: "string" } } } },
|
|
184
|
+
$ref: "#/$defs/inner"
|
|
185
|
+
},
|
|
186
|
+
"http://localhost:1234/baseUriChangeFolderInSubschema/folderInteger.json": { type: "integer" },
|
|
187
|
+
"http://localhost:1234/draft2019-09/baseUriChangeFolder/folderInteger.json": {
|
|
188
|
+
$schema: "https://json-schema.org/draft/2019-09/schema",
|
|
189
|
+
type: "integer"
|
|
190
|
+
},
|
|
191
|
+
"http://localhost:1234/nested/foo-ref-string.json": {
|
|
192
|
+
type: "object",
|
|
193
|
+
properties: { foo: { $ref: "string.json" } }
|
|
194
|
+
},
|
|
195
|
+
"http://localhost:1234/nested/string.json": { type: "string" },
|
|
196
|
+
"http://localhost:1234/draft2019-09/baseUriChangeFolderInSubschema/folderInteger.json": {
|
|
197
|
+
$schema: "https://json-schema.org/draft/2019-09/schema",
|
|
198
|
+
type: "integer"
|
|
199
|
+
},
|
|
200
|
+
"http://localhost:1234/draft2019-09/name-defs.json": {
|
|
201
|
+
$schema: "https://json-schema.org/draft/2019-09/schema",
|
|
202
|
+
$defs: { orNull: { anyOf: [{ type: "null" }, { $ref: "#" }] } },
|
|
203
|
+
type: "string"
|
|
204
|
+
},
|
|
205
|
+
"http://localhost:1234/v1/different-id-ref-string.json": {
|
|
206
|
+
$id: "http://localhost:1234/v1/real-id-ref-string.json",
|
|
207
|
+
$defs: { bar: { type: "string" } },
|
|
208
|
+
$ref: "#/$defs/bar"
|
|
209
|
+
},
|
|
210
|
+
"http://localhost:1234/v1/nested-absolute-ref-to-string.json": {
|
|
211
|
+
$defs: { bar: { $id: "http://localhost:1234/v1/the-nested-id.json", type: "string" } },
|
|
212
|
+
$ref: "http://localhost:1234/v1/the-nested-id.json"
|
|
213
|
+
},
|
|
214
|
+
"http://localhost:1234/v1/urn-ref-string.json": {
|
|
215
|
+
$id: "urn:uuid:feebdaed-ffff-0000-ff01-0000deadbeef",
|
|
216
|
+
$defs: { bar: { type: "string" } },
|
|
217
|
+
$ref: "#/$defs/bar"
|
|
218
|
+
},
|
|
219
|
+
"http://localhost:1234/draft2019-09/ignore-prefixItems.json": {
|
|
220
|
+
$id: "http://localhost:1234/draft2019-09/ignore-prefixItems.json",
|
|
221
|
+
$schema: "https://json-schema.org/draft/2019-09/schema",
|
|
222
|
+
prefixItems: [{ type: "string" }]
|
|
223
|
+
},
|
|
224
|
+
"http://localhost:1234/draft2019-09/subSchemas.json": {
|
|
225
|
+
$schema: "https://json-schema.org/draft/2019-09/schema",
|
|
226
|
+
$defs: { integer: { type: "integer" }, refToInteger: { $ref: "#/$defs/integer" } }
|
|
227
|
+
},
|
|
228
|
+
"http://localhost:1234/draft2019-09/nested-absolute-ref-to-string.json": {
|
|
229
|
+
$defs: { bar: { $id: "http://localhost:1234/draft2019-09/the-nested-id.json", type: "string" } },
|
|
230
|
+
$ref: "http://localhost:1234/draft2019-09/the-nested-id.json"
|
|
231
|
+
},
|
|
232
|
+
"http://localhost:1234/draft2019-09/nested/string.json": {
|
|
233
|
+
$schema: "https://json-schema.org/draft/2019-09/schema",
|
|
234
|
+
type: "string"
|
|
235
|
+
},
|
|
236
|
+
"http://localhost:1234/draft2019-09/metaschema-optional-vocabulary.json": {
|
|
237
|
+
$schema: "https://json-schema.org/draft/2019-09/schema",
|
|
238
|
+
$id: "http://localhost:1234/draft2019-09/metaschema-optional-vocabulary.json",
|
|
239
|
+
$vocabulary: {
|
|
240
|
+
"https://json-schema.org/draft/2019-09/vocab/validation": true,
|
|
241
|
+
"https://json-schema.org/draft/2019-09/vocab/core": true,
|
|
242
|
+
"http://localhost:1234/draft/2019-09/vocab/custom": false
|
|
243
|
+
},
|
|
244
|
+
$recursiveAnchor: true,
|
|
245
|
+
allOf: [
|
|
246
|
+
{ $ref: "https://json-schema.org/draft/2019-09/meta/validation" },
|
|
247
|
+
{ $ref: "https://json-schema.org/draft/2019-09/meta/core" }
|
|
248
|
+
]
|
|
249
|
+
},
|
|
250
|
+
"http://localhost:1234/draft2019-09/different-id-ref-string.json": {
|
|
251
|
+
$id: "http://localhost:1234/draft2019-09/real-id-ref-string.json",
|
|
252
|
+
$defs: { bar: { type: "string" } },
|
|
253
|
+
$ref: "#/$defs/bar"
|
|
254
|
+
},
|
|
255
|
+
"http://localhost:1234/draft2019-09/extendible-dynamic-ref.json": {
|
|
256
|
+
description: "extendible array",
|
|
257
|
+
$schema: "https://json-schema.org/draft/2019-09/schema",
|
|
258
|
+
$id: "http://localhost:1234/draft2019-09/extendible-dynamic-ref.json",
|
|
259
|
+
type: "object",
|
|
260
|
+
properties: { elements: { type: "array", items: { $dynamicRef: "#elements" } } },
|
|
261
|
+
required: ["elements"],
|
|
262
|
+
additionalProperties: false,
|
|
263
|
+
$defs: { elements: { $dynamicAnchor: "elements" } }
|
|
264
|
+
},
|
|
265
|
+
"http://localhost:1234/draft2019-09/metaschema-no-validation.json": {
|
|
266
|
+
$schema: "https://json-schema.org/draft/2019-09/schema",
|
|
267
|
+
$id: "http://localhost:1234/draft2019-09/metaschema-no-validation.json",
|
|
268
|
+
$vocabulary: {
|
|
269
|
+
"https://json-schema.org/draft/2019-09/vocab/applicator": true,
|
|
270
|
+
"https://json-schema.org/draft/2019-09/vocab/core": true
|
|
271
|
+
},
|
|
272
|
+
$recursiveAnchor: true,
|
|
273
|
+
allOf: [
|
|
274
|
+
{ $ref: "https://json-schema.org/draft/2019-09/meta/applicator" },
|
|
275
|
+
{ $ref: "https://json-schema.org/draft/2019-09/meta/core" }
|
|
276
|
+
]
|
|
277
|
+
},
|
|
278
|
+
"http://localhost:1234/baseUriChange/folderInteger.json": { type: "integer" }
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
before(async () => {
|
|
283
|
+
await runCommand({ cmd: "start", version: 1 });
|
|
284
|
+
await runCommand({ cmd: "dialect", dialect: "https://json-schema.org/draft/2019-09/schema" });
|
|
285
|
+
});
|
|
286
|
+
after(async () => runCommand({ cmd: "stop" }));
|
|
66
287
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
288
|
+
it(`${testCase.description} - applicator vocabulary still works`, async () => {
|
|
289
|
+
const response = await runCommand({
|
|
290
|
+
cmd: "run",
|
|
291
|
+
seq: 1,
|
|
292
|
+
case: {
|
|
293
|
+
...testCase,
|
|
294
|
+
tests: [
|
|
295
|
+
{
|
|
296
|
+
description: "applicator vocabulary still works",
|
|
297
|
+
instance: { badProperty: "this property should not exist" },
|
|
298
|
+
valid: false
|
|
299
|
+
}
|
|
300
|
+
]
|
|
301
|
+
}
|
|
70
302
|
});
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
303
|
+
assert(isRunCmdResponse(response));
|
|
304
|
+
assert(!isErrorResponse(response.results[0]));
|
|
305
|
+
assert.equal(response.results[0].valid, false);
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
it(`${testCase.description} - no validation: valid number`, async () => {
|
|
309
|
+
const response = await runCommand({
|
|
310
|
+
cmd: "run",
|
|
311
|
+
seq: 1,
|
|
312
|
+
case: {
|
|
313
|
+
...testCase,
|
|
314
|
+
tests: [
|
|
315
|
+
{
|
|
316
|
+
description: "no validation: valid number",
|
|
317
|
+
instance: { numberProperty: 20 },
|
|
318
|
+
valid: true
|
|
319
|
+
}
|
|
320
|
+
]
|
|
321
|
+
}
|
|
74
322
|
});
|
|
323
|
+
assert(isRunCmdResponse(response));
|
|
324
|
+
assert(!isErrorResponse(response.results[0]));
|
|
325
|
+
assert.equal(response.results[0].valid, true);
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
it(`${testCase.description} - no validation: invalid number, but it still validates`, async () => {
|
|
329
|
+
const response = await runCommand({
|
|
330
|
+
cmd: "run",
|
|
331
|
+
seq: 1,
|
|
332
|
+
case: {
|
|
333
|
+
...testCase,
|
|
334
|
+
tests: [
|
|
335
|
+
{
|
|
336
|
+
description: "no validation: invalid number, but it still validates",
|
|
337
|
+
instance: { numberProperty: 1 },
|
|
338
|
+
valid: true
|
|
339
|
+
}
|
|
340
|
+
]
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
assert(isRunCmdResponse(response));
|
|
344
|
+
assert(!isErrorResponse(response.results[0]));
|
|
345
|
+
assert.equal(response.results[0].valid, true);
|
|
75
346
|
});
|
|
76
347
|
});
|