Skip to content

Commit d1f74a9

Browse files
committed
publish: bump version to v10.2.1
1 parent 088cfd4 commit d1f74a9

File tree

6 files changed

+24
-6
lines changed

6 files changed

+24
-6
lines changed

dist/jsonSchemaLibrary.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/module/src/SchemaNode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export const SchemaNodeMethods = {
101101
*/
102102
getNodeRef($ref) {
103103
const node = this;
104-
return node.compileSchema({ $ref }).resolveRef();
104+
return node.compileSchema({ $ref }, "$dynamic").resolveRef();
105105
},
106106
getNodeRoot() {
107107
const node = this;

dist/module/src/compileSchema.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function compileSchema(schema, options = {}) {
3131
resolvers: [],
3232
validators: [],
3333
schema,
34-
// @ts-expect-error self-reference add edlater
34+
// @ts-expect-error self-reference added later
3535
context: {
3636
remotes: {},
3737
dynamicAnchors: {},

dist/module/src/draft2019-09/keywords/$ref.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import splitRef from "../../utils/splitRef";
33
import { omit } from "../../utils/omit";
44
import { isObject } from "../../utils/isObject";
55
import { validateNode } from "../../validateNode";
6-
import { get } from "@sagold/json-pointer";
6+
import { get, split } from "@sagold/json-pointer";
77
import { reduceRef } from "../../keywords/$ref";
88
export const $refKeyword = {
99
id: "$ref",
@@ -175,6 +175,23 @@ export default function getRef(node, $ref = node === null || node === void 0 ? v
175175
return nextNode;
176176
}
177177
}
178+
// resolve by json-pointer (optional dynamicRef)
179+
if (node.context.refs[$remoteHostRef]) {
180+
const parentNode = node.context.refs[$remoteHostRef];
181+
const path = split(fragments[1]);
182+
// @todo add utility to resolve schema-pointer to schema
183+
let currentNode = parentNode;
184+
for (let i = 0; i < path.length; i += 1) {
185+
const property = path[i] === "definitions" ? "$defs" : path[i];
186+
// @ts-expect-error random path
187+
currentNode = currentNode[property];
188+
if (currentNode == null) {
189+
console.error("REF: FAILED RESOLVING ref json-pointer", fragments[1]);
190+
return undefined;
191+
}
192+
}
193+
return currentNode;
194+
}
178195
// console.error("REF: UNFOUND 2", $ref);
179196
return undefined;
180197
}

dist/module/src/keywords/$ref.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,9 @@ export function getRef(node, $ref = node === null || node === void 0 ? void 0 :
204204
// @todo add utility to resolve schema-pointer to schema
205205
let currentNode = parentNode;
206206
for (let i = 0; i < path.length; i += 1) {
207+
const property = path[i] === "definitions" ? "$defs" : path[i];
207208
// @ts-expect-error random path
208-
currentNode = currentNode[path[i]];
209+
currentNode = currentNode[property];
209210
if (currentNode == null) {
210211
console.error("REF: FAILED RESOLVING ref json-pointer", fragments[1]);
211212
return undefined;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "json-schema-library",
3-
"version": "10.2.0",
3+
"version": "10.2.1",
44
"description": "Customizable and hackable json-validator and json-schema utilities for traversal, data generation and validation",
55
"module": "dist/module/index.js",
66
"types": "dist/index.d.ts",

0 commit comments

Comments
 (0)