-
-
Notifications
You must be signed in to change notification settings - Fork 887
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: reference resolution issue with base URI change, fixes #1414
- Loading branch information
1 parent
0b7567b
commit c91e8ba
Showing
2 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import _Ajv from "../ajv" | ||
import assert = require("assert") | ||
|
||
const schema1 = { | ||
$id: "one", | ||
type: "object", | ||
properties: { | ||
foo: {$ref: "#/definitions/foo"}, | ||
}, | ||
definitions: { | ||
foo: {$ref: "two"}, | ||
}, | ||
} | ||
|
||
const schema2 = { | ||
$id: "two", | ||
type: "object", | ||
properties: { | ||
bar: {$ref: "#/definitions/bar"}, | ||
}, | ||
definitions: { | ||
bar: {type: "string"}, | ||
}, | ||
} | ||
|
||
describe("issue 1414: base URI change", () => { | ||
it("should compile schema", () => { | ||
const ajv = new _Ajv() | ||
ajv.addSchema(schema2) | ||
const validate = ajv.compile(schema1) | ||
assert.strictEqual(typeof validate, "function") | ||
assert.strictEqual(validate({foo: {bar: 1}}), false) | ||
assert.strictEqual(validate({foo: {bar: "1"}}), true) | ||
}) | ||
}) |