Skip to content

Commit 088cfd4

Browse files
committed
fix: scope issue using getNodeRef
1 parent 9df62d0 commit 088cfd4

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/SchemaNode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ export const SchemaNodeMethods = {
276276
*/
277277
getNodeRef($ref: string): SchemaNode | undefined {
278278
const node = this as SchemaNode;
279-
return node.compileSchema({ $ref }).resolveRef();
279+
return node.compileSchema({ $ref }, "$dynamic").resolveRef();
280280
},
281281

282282
getNodeRoot() {

src/tests/issues/issue79.csn.ref-resolution.test.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { strict as assert } from "assert";
22
import { compileSchema } from "../../compileSchema";
33
import CSNSchema from "./csn-interop-effective.schema.json";
44

5-
describe.only("issue#79 - csn ref resolution from defintions", () => {
5+
describe("issue#79 - csn ref resolution from defintions", () => {
66
it("should compile as draft-07", () => {
77
const node = compileSchema(CSNSchema);
88
assert.equal(node.getDraftVersion(), "draft-07");
@@ -13,16 +13,27 @@ describe.only("issue#79 - csn ref resolution from defintions", () => {
1313
assert(node.$defs?.["@EndUserText.label"] != null);
1414
});
1515

16-
it.skip("should resolve $ref '#/$defs/@EndUserText.label'", () => {
16+
it("should resolve $ref '#/$defs/@EndUserText.label'", () => {
1717
const node = compileSchema(CSNSchema);
1818
const childSchema = node.getNodeRef("#/$defs/@EndUserText.label");
1919
assert(childSchema != null);
2020
});
2121

22-
it.skip("should resolve $ref '#/definitions/@EndUserText.label'", () => {
22+
it("should resolve uri-encoded $ref '#/%24defs/%40EndUserText.label'", () => {
23+
const node = compileSchema(CSNSchema);
24+
const childSchema = node.getNodeRef("#/%24defs/%40EndUserText.label");
25+
assert(childSchema != null);
26+
});
27+
28+
it("should resolve $ref '#/definitions/@EndUserText.label'", () => {
2329
const node = compileSchema(CSNSchema);
2430
const childSchema = node.getNodeRef("#/definitions/@EndUserText.label");
25-
console.log("childSchema", childSchema);
31+
assert(childSchema != null);
32+
});
33+
34+
it("should resolve uri-encoded $ref '#/definitions/%40EndUserText.label'", () => {
35+
const node = compileSchema(CSNSchema);
36+
const childSchema = node.getNodeRef("#/definitions/%40EndUserText.label");
2637
assert(childSchema != null);
2738
});
2839

0 commit comments

Comments
 (0)