Skip to content

Commit 1c836f2

Browse files
committed
publish: bump version to v10.0.0
1 parent cd252e1 commit 1c836f2

File tree

11 files changed

+22
-28
lines changed

11 files changed

+22
-28
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/compileSchema.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ function getDraft(drafts, $schema) {
1919
*/
2020
export function compileSchema(schema, options = {}) {
2121
var _a, _b, _c, _d, _e;
22-
/** @todo this option has to be passed to all drafts (remotes) */
2322
let formatAssertion = (_a = options.formatAssertion) !== null && _a !== void 0 ? _a : true;
2423
const drafts = (_b = options.drafts) !== null && _b !== void 0 ? _b : defaultDrafts;
2524
const draft = getDraft(drafts, schema === null || schema === void 0 ? void 0 : schema.$schema);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,5 +128,5 @@ function getRef(node, $ref = node === null || node === void 0 ? void 0 : node.$r
128128
// console.error("REF: UNFOUND 2", $ref);
129129
return undefined;
130130
}
131-
console.error("REF: UNHANDLED", $ref);
131+
console.error("REF: INVALID", $ref);
132132
}

dist/module/src/draft2019-09/keywords/items.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ function validateItems({ node, data, pointer = "#", path }) {
4444
// note: schema is valid when data does not have enough elements as defined by array-list
4545
for (let i = 0; i < Math.min(node.prefixItems.length, data.length); i += 1) {
4646
const itemData = data[i];
47-
// @todo v1 reevaluate: incomplete schema is created here?
4847
const itemNode = node.prefixItems[i];
4948
const result = validateNode(itemNode, itemData, `${pointer}/${i}`, path);
5049
errors.push(...result);

dist/module/src/draft2019-09/methods/getData.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ const TYPE = {
264264
// @ts-expect-error asd
265265
if ((node.items && canResolveRef(node.items, opts)) || (data === null || data === void 0 ? void 0 : data.length) > 0) {
266266
// @attention this should disable cache or break intended behaviour as we reset it after loop
267-
// @todo test recursion of items
268267
// intention: reset cache after each property. last call will add counters
269268
const cache = { ...opts.cache };
270269
for (let i = 0, l = Math.max(minItems, d.length); i < l; i += 1) {

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
// @todo this should be done with every added property in evaluationPath
2-
// @todo this creates a mixed schema, where $defs, etc are not uri-encoded (would be %24defs)
3-
function urlEncodeJsonPointerProperty(property) {
4-
property = property.replace(/~/g, "~0");
5-
property = property.replace(/\//g, "~1");
6-
return encodeURIComponent(property);
7-
}
81
export const $defsKeyword = {
92
id: "$defs",
103
keyword: "$defs",
@@ -25,3 +18,8 @@ export function parseDefs(node) {
2518
});
2619
}
2720
}
21+
function urlEncodeJsonPointerProperty(property) {
22+
property = property.replace(/~/g, "~0");
23+
property = property.replace(/\//g, "~1");
24+
return encodeURIComponent(property);
25+
}

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ function compileNext(referencedNode, evaluationPath = referencedNode.evaluationP
136136
return referencedNode.compileSchema(referencedSchema, `${evaluationPath}/$ref`, referencedNode.schemaLocation);
137137
}
138138
export function getRef(node, $ref = node === null || node === void 0 ? void 0 : node.$ref) {
139-
var _a;
140139
if ($ref == null) {
141140
return node;
142141
}
@@ -166,14 +165,11 @@ export function getRef(node, $ref = node === null || node === void 0 ? void 0 :
166165
return compileNext(node.context.remotes[$ref], node.evaluationPath);
167166
}
168167
if ($ref[0] === "#") {
169-
// @todo there is a bug joining multiple fragments to e.g. #/base#/examples/0
170-
// from "$id": "/base" + $ref "#/examples/0" (in refOfUnknownKeyword spec)
171-
const ref = (_a = $ref.match(/#[^#]*$/)) === null || _a === void 0 ? void 0 : _a.pop(); // sanitize pointer
172168
// support refOfUnknownKeyword
173169
const rootSchema = node.context.rootNode.schema;
174-
const targetSchema = get(rootSchema, ref);
170+
const targetSchema = get(rootSchema, $ref);
175171
if (targetSchema) {
176-
return node.compileSchema(targetSchema, `${node.evaluationPath}/$ref`, ref);
172+
return node.compileSchema(targetSchema, `${node.evaluationPath}/$ref`, $ref);
177173
}
178174
}
179175
// console.error("REF: UNFOUND 1", $ref);

dist/module/src/utils/getSchemaType.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,21 @@ const ARRAY_PROPERTIES = [
4242
*/
4343
export function getSchemaType(node, data) {
4444
const dataType = getTypeOf(data);
45-
// @ts-expect-error boolean schema true
46-
if (node.schema === true) {
45+
const schema = node.schema;
46+
if (schema === true) {
4747
return SCHEMA_TYPES.includes(dataType) ? dataType : undefined;
4848
}
4949
// boolean schema false or invalid schema
50-
if (!isObject(node.schema)) {
50+
if (!isObject(schema)) {
5151
return undefined;
5252
}
53-
const schemaType = node.schema.type;
53+
const schemaType = schema.type;
5454
// type: []
5555
if (Array.isArray(schemaType)) {
5656
if (schemaType.includes(dataType)) {
5757
return dataType;
5858
}
59-
const defaultType = getTypeOf(node.schema.default);
59+
const defaultType = getTypeOf(schema.default);
6060
if (schemaType.includes(defaultType)) {
6161
return defaultType;
6262
}
@@ -67,13 +67,13 @@ export function getSchemaType(node, data) {
6767
return schemaType;
6868
}
6969
// type: undefined, enum: []
70-
if (Array.isArray(node.schema.enum)) {
71-
const schemaEnum = node.schema.enum;
70+
if (Array.isArray(schema.enum)) {
71+
const schemaEnum = schema.enum;
7272
const enumSchemaType = schemaEnum.map((value) => getTypeOf(value)).filter((p, i, l) => l.indexOf(p) === i);
7373
if (enumSchemaType.includes(dataType)) {
7474
return dataType;
7575
}
76-
const defaultType = getTypeOf(node.schema.default);
76+
const defaultType = getTypeOf(schema.default);
7777
if (enumSchemaType.includes(defaultType)) {
7878
return defaultType;
7979
}

dist/module/src/utils/joinId.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ function _joinScope(previous, id) {
1919
return id.replace(trailingHash, "");
2020
}
2121
if (id[0] === "#") {
22+
if (previous[0] === "/") {
23+
return id;
24+
}
2225
return `${previous.replace(idAndPointer, "")}${id.replace(suffixes, "")}`;
2326
}
2427
if (isDomain.test(id)) {

dist/src/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Draft } from "./Draft";
22
import { errors } from "./errors/errors";
33
import { SchemaNode, isSchemaNode, GetNodeOptions } from "./SchemaNode";
4-
export type JsonBooleanSchema = boolean;
4+
export type BooleanSchema = boolean;
55
export interface JsonSchema {
66
[p: string]: any;
77
}

0 commit comments

Comments
 (0)