@xschemadev/core 0.1.0 → 0.2.0
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/dist/cli.d.ts +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/ir/nodes.d.ts +24 -4
- package/dist/ir/nodes.d.ts.map +1 -1
- package/dist/parser/collections.d.ts +1 -1
- package/dist/parser/collections.d.ts.map +1 -1
- package/dist/parser/collections.js +35 -16
- package/dist/parser/collections.js.map +1 -1
- package/dist/parser/context.d.ts +5 -10
- package/dist/parser/context.d.ts.map +1 -1
- package/dist/parser/context.js +2 -4
- package/dist/parser/context.js.map +1 -1
- package/dist/parser/index.d.ts +2 -0
- package/dist/parser/index.d.ts.map +1 -1
- package/dist/parser/index.js +91 -80
- package/dist/parser/index.js.map +1 -1
- package/dist/parser/primitives.d.ts.map +1 -1
- package/dist/parser/primitives.js +2 -6
- package/dist/parser/primitives.js.map +1 -1
- package/dist/schema/index.d.ts +1 -3
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +1 -2
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/json-schema.d.ts +3 -4
- package/dist/schema/json-schema.d.ts.map +1 -1
- package/dist/types.d.ts +6 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/code-builder.d.ts +8 -1
- package/dist/utils/code-builder.d.ts.map +1 -1
- package/dist/utils/code-builder.js +20 -3
- package/dist/utils/code-builder.js.map +1 -1
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -2
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/json-pointer.d.ts +6 -6
- package/dist/utils/json-pointer.d.ts.map +1 -1
- package/dist/utils/json-pointer.js +6 -27
- package/dist/utils/json-pointer.js.map +1 -1
- package/package.json +3 -2
- package/dist/schema/normalizer.d.ts +0 -15
- package/dist/schema/normalizer.d.ts.map +0 -1
- package/dist/schema/normalizer.js +0 -203
- package/dist/schema/normalizer.js.map +0 -1
- package/dist/schema/version.d.ts +0 -17
- package/dist/schema/version.d.ts.map +0 -1
- package/dist/schema/version.js +0 -58
- package/dist/schema/version.js.map +0 -1
package/dist/cli.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { ConvertInput, ConvertResult } from "./types.js";
|
|
|
4
4
|
* Reads JSON array of ConvertInput from stdin, calls convert for each, outputs JSON array of ConvertResult.
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
|
-
* ```
|
|
7
|
+
* ```typescript
|
|
8
8
|
* #!/usr/bin/env node
|
|
9
9
|
* import { createAdapterCLI } from "@xschemadev/core";
|
|
10
10
|
* import { convert } from "./index";
|
package/dist/cli.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Reads JSON array of ConvertInput from stdin, calls convert for each, outputs JSON array of ConvertResult.
|
|
4
4
|
*
|
|
5
5
|
* @example
|
|
6
|
-
* ```
|
|
6
|
+
* ```typescript
|
|
7
7
|
* #!/usr/bin/env node
|
|
8
8
|
* import { createAdapterCLI } from "@xschemadev/core";
|
|
9
9
|
* import { convert } from "./index";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
export type {
|
|
1
|
+
export type { ConvertInput, ConvertResult } from "./types.js";
|
|
2
2
|
export { createAdapterCLI } from "./cli.js";
|
|
3
|
-
export type { JSONSchema
|
|
4
|
-
export { detectVersion, supportsRefSiblings, usesBooleanExclusive, normalizeSchema, normalizeDeep, } from "./schema/index.js";
|
|
3
|
+
export type { JSONSchema } from "./schema/index.js";
|
|
5
4
|
export type { SchemaNode, NodeKind, NodeOfKind, StringNode, NumberNode, BooleanNode, NullNode, ObjectNode, ArrayNode, TupleNode, UnionNode, IntersectionNode, OneOfNode, NotNode, LiteralNode, EnumNode, AnyNode, NeverNode, RefNode, ConditionalNode, TypeGuardedNode, NullableNode, TypeGuard, TypeCheck, StringConstraints, NumberConstraints, ArrayConstraints, ContainsConstraint, PropertyDef, PatternPropertyDef, Dependency, PropertyDependency, SchemaDependency, } from "./ir/index.js";
|
|
6
5
|
export { parse, parseSchema, type ParseContext } from "./parser/index.js";
|
|
7
|
-
export { isPrimitive, escapeString, isEmptyObject, getOwnProperty, PROTOTYPE_PROPERTY_NAMES, hasPrototypeProperties,
|
|
6
|
+
export { isPrimitive, escapeString, isEmptyObject, getOwnProperty, PROTOTYPE_PROPERTY_NAMES, hasPrototypeProperties, getRefName, chain, buildUnion, buildIntersection, buildSuperRefine, buildRefine, buildLiteral, buildSafeParseCheck, buildPropertyCheck, sortedStringify, DEEP_SORTED_STRINGIFY_RUNTIME, } from "./utils/index.js";
|
|
8
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAG5C,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGpD,YAAY,EAEV,UAAU,EACV,QAAQ,EACR,UAAU,EAGV,UAAU,EACV,UAAU,EACV,WAAW,EACX,QAAQ,EACR,UAAU,EACV,SAAS,EACT,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,OAAO,EACP,WAAW,EACX,QAAQ,EACR,OAAO,EACP,SAAS,EACT,OAAO,EAEP,eAAe,EACf,eAAe,EACf,YAAY,EACZ,SAAS,EACT,SAAS,EAGT,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAClB,UAAU,EACV,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAG1E,OAAO,EAEL,WAAW,EACX,YAAY,EACZ,aAAa,EACb,cAAc,EACd,wBAAwB,EACxB,sBAAsB,EAGtB,UAAU,EAGV,KAAK,EACL,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,6BAA6B,GAC9B,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { createAdapterCLI } from "./cli.js";
|
|
2
|
-
export { detectVersion, supportsRefSiblings, usesBooleanExclusive, normalizeSchema, normalizeDeep, } from "./schema/index.js";
|
|
3
2
|
// Parser
|
|
4
3
|
export { parse, parseSchema } from "./parser/index.js";
|
|
5
4
|
// Utilities
|
|
@@ -7,7 +6,7 @@ export {
|
|
|
7
6
|
// Primitives
|
|
8
7
|
isPrimitive, escapeString, isEmptyObject, getOwnProperty, PROTOTYPE_PROPERTY_NAMES, hasPrototypeProperties,
|
|
9
8
|
// JSON Pointer
|
|
10
|
-
|
|
9
|
+
getRefName,
|
|
11
10
|
// Code builder
|
|
12
|
-
chain, buildUnion, buildIntersection, buildSuperRefine, buildRefine, buildLiteral, buildSafeParseCheck, buildPropertyCheck, sortedStringify, } from "./utils/index.js";
|
|
11
|
+
chain, buildUnion, buildIntersection, buildSuperRefine, buildRefine, buildLiteral, buildSafeParseCheck, buildPropertyCheck, sortedStringify, DEEP_SORTED_STRINGIFY_RUNTIME, } from "./utils/index.js";
|
|
13
12
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAgD5C,SAAS;AACT,OAAO,EAAE,KAAK,EAAE,WAAW,EAAqB,MAAM,mBAAmB,CAAC;AAE1E,YAAY;AACZ,OAAO;AACL,aAAa;AACb,WAAW,EACX,YAAY,EACZ,aAAa,EACb,cAAc,EACd,wBAAwB,EACxB,sBAAsB;AAEtB,eAAe;AACf,UAAU;AAEV,eAAe;AACf,KAAK,EACL,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,6BAA6B,GAC9B,MAAM,kBAAkB,CAAC"}
|
package/dist/ir/nodes.d.ts
CHANGED
|
@@ -33,18 +33,34 @@ export interface NullNode {
|
|
|
33
33
|
export interface ObjectNode {
|
|
34
34
|
kind: "object";
|
|
35
35
|
properties: Map<string, PropertyDef>;
|
|
36
|
-
|
|
36
|
+
/**
|
|
37
|
+
* additionalProperties - undefined means not specified in schema.
|
|
38
|
+
* Explicitly true means additionalProperties: true was in schema (evaluates extra props).
|
|
39
|
+
* false means additionalProperties: false.
|
|
40
|
+
* SchemaNode means additionalProperties was a schema (evaluates and validates extra props).
|
|
41
|
+
*/
|
|
42
|
+
additionalProperties?: SchemaNode | boolean;
|
|
37
43
|
patternProperties: PatternPropertyDef[];
|
|
38
44
|
propertyNames?: SchemaNode;
|
|
39
45
|
minProperties?: number;
|
|
40
46
|
maxProperties?: number;
|
|
41
47
|
dependencies: Map<string, Dependency>;
|
|
48
|
+
/**
|
|
49
|
+
* unevaluatedProperties - only valid for standalone use (no applicators).
|
|
50
|
+
* Go CLI blocks schemas with unevaluated+applicators, so adapters only see simple cases.
|
|
51
|
+
*/
|
|
52
|
+
unevaluatedProperties?: SchemaNode | false;
|
|
42
53
|
}
|
|
43
54
|
/** Array schema node (homogeneous items) */
|
|
44
55
|
export interface ArrayNode {
|
|
45
56
|
kind: "array";
|
|
46
57
|
items: SchemaNode;
|
|
47
58
|
constraints: ArrayConstraints;
|
|
59
|
+
/**
|
|
60
|
+
* unevaluatedItems - only valid for standalone use (no applicators).
|
|
61
|
+
* Go CLI blocks schemas with unevaluated+applicators, so adapters only see simple cases.
|
|
62
|
+
*/
|
|
63
|
+
unevaluatedItems?: SchemaNode | false;
|
|
48
64
|
}
|
|
49
65
|
/** Tuple schema node (positional items) */
|
|
50
66
|
export interface TupleNode {
|
|
@@ -52,6 +68,11 @@ export interface TupleNode {
|
|
|
52
68
|
prefixItems: SchemaNode[];
|
|
53
69
|
restItems: SchemaNode | false;
|
|
54
70
|
constraints: ArrayConstraints;
|
|
71
|
+
/**
|
|
72
|
+
* unevaluatedItems - only valid for standalone use (no applicators).
|
|
73
|
+
* Go CLI blocks schemas with unevaluated+applicators, so adapters only see simple cases.
|
|
74
|
+
*/
|
|
75
|
+
unevaluatedItems?: SchemaNode | false;
|
|
55
76
|
}
|
|
56
77
|
/** Union schema node (anyOf - at least one must match) */
|
|
57
78
|
export interface UnionNode {
|
|
@@ -91,11 +112,10 @@ export interface AnyNode {
|
|
|
91
112
|
export interface NeverNode {
|
|
92
113
|
kind: "never";
|
|
93
114
|
}
|
|
94
|
-
/** Reference schema node */
|
|
115
|
+
/** Reference schema node — recursive back-edge kept by the processor */
|
|
95
116
|
export interface RefNode {
|
|
96
117
|
kind: "ref";
|
|
97
|
-
|
|
98
|
-
resolved: SchemaNode;
|
|
118
|
+
ref: string;
|
|
99
119
|
}
|
|
100
120
|
/** Conditional schema node (if/then/else) */
|
|
101
121
|
export interface ConditionalNode {
|
package/dist/ir/nodes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../src/ir/nodes.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACX,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAClB,UAAU,EACV,MAAM,kBAAkB,CAAC;AAG1B,YAAY,EACX,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAClB,UAAU,GACV,CAAC;AAEF,yBAAyB;AACzB,MAAM,WAAW,UAAU;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,WAAW,EAAE,iBAAiB,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,4CAA4C;AAC5C,MAAM,WAAW,UAAU;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,WAAW,EAAE,iBAAiB,CAAC;IAC/B,OAAO,EAAE,OAAO,CAAC;CACjB;AAED,0BAA0B;AAC1B,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,SAAS,CAAC;CAChB;AAED,uBAAuB;AACvB,MAAM,WAAW,QAAQ;IACxB,IAAI,EAAE,MAAM,CAAC;CACb;AAED,yBAAyB;AACzB,MAAM,WAAW,UAAU;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACrC,oBAAoB,EAAE,UAAU,GAAG,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../src/ir/nodes.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACX,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAClB,UAAU,EACV,MAAM,kBAAkB,CAAC;AAG1B,YAAY,EACX,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,W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AAU,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,SAAS,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACzB,KAAK,EAAE,SAAS,CAAC;IACjB,MAAM,EAAE,UAAU,CAAC;CACnB;AAED,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEjE;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC5B,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,UAAU,CAAC;CAClB;AAED,kDAAkD;AAClD,MAAM,MAAM,UAAU,GACnB,UAAU,GACV,UAAU,GACV,WAAW,GACX,QAAQ,GACR,UAAU,GACV,SAAS,GACT,SAAS,GACT,SAAS,GACT,gBAAgB,GAChB,SAAS,GACT,OAAO,GACP,WAAW,GACX,QAAQ,GACR,OAAO,GACP,SAAS,GACT,OAAO,GACP,eAAe,GACf,eAAe,GACf,YAAY,CAAC;AAEhB,kDAAkD;AAClD,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,UAAU,CAAC,MAAM,CAAC,IAAI,OAAO,CAC7D,UAAU,EACV;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,CACX,CAAC;AAEF,8BAA8B;AAC9B,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { JSONSchema } from "../schema/json-schema.js";
|
|
5
5
|
import type { ObjectNode, ArrayNode, TupleNode, SchemaNode } from "../ir/nodes.js";
|
|
6
|
-
import type
|
|
6
|
+
import { type ParseContext } from "./context.js";
|
|
7
7
|
type ParseSchemaFn = (schema: JSONSchema | boolean, ctx: ParseContext) => SchemaNode;
|
|
8
8
|
export declare function parseObject(schema: JSONSchema, ctx: ParseContext, parseSchema: ParseSchemaFn): ObjectNode;
|
|
9
9
|
export declare function parseArray(schema: JSONSchema, ctx: ParseContext, parseSchema: ParseSchemaFn): ArrayNode | TupleNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../../src/parser/collections.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EACX,UAAU,EACV,SAAS,EACT,SAAS,EACT,UAAU,EAKV,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../../src/parser/collections.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EACX,UAAU,EACV,SAAS,EACT,SAAS,EACT,UAAU,EAKV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,KAAK,aAAa,GAAG,CACpB,MAAM,EAAE,UAAU,GAAG,OAAO,EAC5B,GAAG,EAAE,YAAY,KACb,UAAU,CAAC;AAEhB,wBAAgB,WAAW,CAC1B,MAAM,EAAE,UAAU,EAClB,GAAG,EAAE,YAAY,EACjB,WAAW,EAAE,aAAa,GACxB,UAAU,CAqIZ;AAED,wBAAgB,UAAU,CACzB,MAAM,EAAE,UAAU,EAClB,GAAG,EAAE,YAAY,EACjB,WAAW,EAAE,aAAa,GACxB,SAAS,GAAG,SAAS,CAkCvB"}
|
|
@@ -49,14 +49,19 @@ export function parseObject(schema, ctx, parseSchema) {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
// Parse additionalProperties
|
|
52
|
-
|
|
52
|
+
// Keep track of whether it was explicitly set to true vs not specified
|
|
53
|
+
let additionalProperties;
|
|
53
54
|
if (schema.additionalProperties === false) {
|
|
54
55
|
additionalProperties = false;
|
|
55
56
|
}
|
|
57
|
+
else if (schema.additionalProperties === true) {
|
|
58
|
+
additionalProperties = true; // Explicitly true
|
|
59
|
+
}
|
|
56
60
|
else if (schema.additionalProperties &&
|
|
57
61
|
typeof schema.additionalProperties === "object") {
|
|
58
62
|
additionalProperties = parseSchema(schema.additionalProperties, ctx);
|
|
59
63
|
}
|
|
64
|
+
// If not specified, leave as undefined (not defaulting to true)
|
|
60
65
|
// Parse propertyNames
|
|
61
66
|
const propertyNames = schema.propertyNames !== undefined
|
|
62
67
|
? parseSchema(schema.propertyNames, ctx)
|
|
@@ -81,22 +86,21 @@ export function parseObject(schema, ctx, parseSchema) {
|
|
|
81
86
|
});
|
|
82
87
|
}
|
|
83
88
|
}
|
|
84
|
-
//
|
|
89
|
+
// Note: legacy dependencies should be normalized by the Go CLI to draft2020-12 format
|
|
90
|
+
// (dependentRequired for property deps, dependentSchemas for schema deps).
|
|
91
|
+
// If we encounter the legacy 'dependencies' keyword, it indicates incomplete bundling.
|
|
85
92
|
if (schema.dependencies) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
}
|
|
93
|
+
throw new Error(`Encountered legacy 'dependencies' keyword - schemas must be normalized to draft2020-12 by the Go CLI. ` +
|
|
94
|
+
`Run the schema through xschema generate to normalize the format.`);
|
|
95
|
+
}
|
|
96
|
+
// Parse unevaluatedProperties (only valid for standalone use - Go CLI blocks applicator combinations)
|
|
97
|
+
let unevaluatedProperties;
|
|
98
|
+
if (schema.unevaluatedProperties === false) {
|
|
99
|
+
unevaluatedProperties = false;
|
|
100
|
+
}
|
|
101
|
+
else if (schema.unevaluatedProperties !== undefined &&
|
|
102
|
+
typeof schema.unevaluatedProperties === "object") {
|
|
103
|
+
unevaluatedProperties = parseSchema(schema.unevaluatedProperties, ctx);
|
|
100
104
|
}
|
|
101
105
|
return {
|
|
102
106
|
kind: "object",
|
|
@@ -107,6 +111,7 @@ export function parseObject(schema, ctx, parseSchema) {
|
|
|
107
111
|
minProperties: schema.minProperties,
|
|
108
112
|
maxProperties: schema.maxProperties,
|
|
109
113
|
dependencies,
|
|
114
|
+
unevaluatedProperties,
|
|
110
115
|
};
|
|
111
116
|
}
|
|
112
117
|
export function parseArray(schema, ctx, parseSchema) {
|
|
@@ -131,12 +136,14 @@ export function parseArray(schema, ctx, parseSchema) {
|
|
|
131
136
|
prefixItems: [],
|
|
132
137
|
restItems: false,
|
|
133
138
|
constraints: buildArrayConstraints(schema, ctx, parseSchema),
|
|
139
|
+
unevaluatedItems: parseUnevaluatedItems(schema, ctx, parseSchema),
|
|
134
140
|
};
|
|
135
141
|
}
|
|
136
142
|
return {
|
|
137
143
|
kind: "array",
|
|
138
144
|
items: itemSchema,
|
|
139
145
|
constraints: buildArrayConstraints(schema, ctx, parseSchema),
|
|
146
|
+
unevaluatedItems: parseUnevaluatedItems(schema, ctx, parseSchema),
|
|
140
147
|
};
|
|
141
148
|
}
|
|
142
149
|
function parseTuple(schema, ctx, parseSchema) {
|
|
@@ -160,6 +167,7 @@ function parseTuple(schema, ctx, parseSchema) {
|
|
|
160
167
|
prefixItems: parsedPrefixItems,
|
|
161
168
|
restItems,
|
|
162
169
|
constraints: buildArrayConstraints(schema, ctx, parseSchema),
|
|
170
|
+
unevaluatedItems: parseUnevaluatedItems(schema, ctx, parseSchema),
|
|
163
171
|
};
|
|
164
172
|
}
|
|
165
173
|
function parseTupleFromItems(schema, ctx, parseSchema) {
|
|
@@ -179,6 +187,7 @@ function parseTupleFromItems(schema, ctx, parseSchema) {
|
|
|
179
187
|
prefixItems: parsedItems,
|
|
180
188
|
restItems,
|
|
181
189
|
constraints: buildArrayConstraints(schema, ctx, parseSchema),
|
|
190
|
+
unevaluatedItems: parseUnevaluatedItems(schema, ctx, parseSchema),
|
|
182
191
|
};
|
|
183
192
|
}
|
|
184
193
|
function buildArrayConstraints(schema, ctx, parseSchema) {
|
|
@@ -197,4 +206,14 @@ function buildArrayConstraints(schema, ctx, parseSchema) {
|
|
|
197
206
|
contains,
|
|
198
207
|
};
|
|
199
208
|
}
|
|
209
|
+
function parseUnevaluatedItems(schema, ctx, parseSchema) {
|
|
210
|
+
if (schema.unevaluatedItems === false) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
if (schema.unevaluatedItems !== undefined &&
|
|
214
|
+
typeof schema.unevaluatedItems === "object") {
|
|
215
|
+
return parseSchema(schema.unevaluatedItems, ctx);
|
|
216
|
+
}
|
|
217
|
+
return undefined;
|
|
218
|
+
}
|
|
200
219
|
//# sourceMappingURL=collections.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collections.js","sourceRoot":"","sources":["../../src/parser/collections.ts"],"names":[],"mappings":"AAAA;;GAEG;AAoBH,MAAM,UAAU,WAAW,CAC1B,MAAkB,EAClB,GAAiB,EACjB,WAA0B;IAE1B,MAAM,UAAU,GAAG,IAAI,GAAG,EAAuB,CAAC;IAClD,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IAEtC,8BAA8B;IAC9B,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QACpC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YACnC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACtB,CAAC;IACF,CAAC;IAED,kEAAkE;IAClE,MAAM,WAAW,GAAG,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC;IAC5C,KAAK,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;QAC7D,IACC,UAAU;YACV,OAAO,UAAU,KAAK,QAAQ;YAC7B,UAAsC,CAAC,QAAQ,KAAK,IAAI,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qB,CAC7B,MAAkB,EAClB,GAAiB,EACjB,WAA0B;IAE1B,IAAI,MAAM,CAAC,gBAAgB,KAAK,KAAK,EAAE,CAAC;QACvC,OAAO,KAAK,CAAC;IACd,CAAC;IACD,IACC,MAAM,CAAC,gBAAgB,KAAK,SAAS;QACrC,OAAO,MAAM,CAAC,gBAAgB,KAAK,QAAQ,EAC1C,CAAC;QACF,OAAO,WAAW,CAAC,MAAM,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC"}
|
package/dist/parser/context.d.ts
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Parser context for tracking state during parsing
|
|
3
3
|
*/
|
|
4
|
-
import type { JSONSchema
|
|
5
|
-
import type { SchemaNode } from "../ir/nodes.js";
|
|
4
|
+
import type { JSONSchema } from "../schema/json-schema.js";
|
|
6
5
|
export interface ParseContext {
|
|
7
|
-
/**
|
|
8
|
-
version: JSONSchemaVersion;
|
|
9
|
-
/** Root schema (for $ref resolution) */
|
|
6
|
+
/** Root schema for $ref resolution */
|
|
10
7
|
rootSchema: JSONSchema;
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
/** Currently processing refs (for circular detection) */
|
|
14
|
-
processing: Set<string>;
|
|
8
|
+
/** Tracks $ref paths currently being resolved (cycle detection) */
|
|
9
|
+
resolving: Set<string>;
|
|
15
10
|
}
|
|
16
|
-
export declare function createContext(rootSchema: JSONSchema
|
|
11
|
+
export declare function createContext(rootSchema: JSONSchema): ParseContext;
|
|
17
12
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/parser/context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/parser/context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE3D,MAAM,WAAW,YAAY;IAC5B,sCAAsC;IACtC,UAAU,EAAE,UAAU,CAAC;IACvB,mEAAmE;IACnE,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACvB;AAED,wBAAgB,aAAa,CAAC,UAAU,EAAE,UAAU,GAAG,YAAY,CAKlE"}
|
package/dist/parser/context.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Parser context for tracking state during parsing
|
|
3
3
|
*/
|
|
4
|
-
export function createContext(rootSchema
|
|
4
|
+
export function createContext(rootSchema) {
|
|
5
5
|
return {
|
|
6
|
-
version,
|
|
7
6
|
rootSchema,
|
|
8
|
-
|
|
9
|
-
processing: new Set(),
|
|
7
|
+
resolving: new Set(),
|
|
10
8
|
};
|
|
11
9
|
}
|
|
12
10
|
//# sourceMappingURL=context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/parser/context.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/parser/context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAWH,MAAM,UAAU,aAAa,CAAC,UAAsB;IACnD,OAAO;QACN,UAAU;QACV,SAAS,EAAE,IAAI,GAAG,EAAE;KACpB,CAAC;AACH,CAAC"}
|
package/dist/parser/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ import { type ParseContext } from "./context.js";
|
|
|
8
8
|
export type { ParseContext } from "./context.js";
|
|
9
9
|
/**
|
|
10
10
|
* Parse a JSON Schema into SchemaNode IR
|
|
11
|
+
* Expects schemas to be pre-normalized to draft2020-12 by the bundler.
|
|
12
|
+
* @param schema The JSON Schema to parse
|
|
11
13
|
*/
|
|
12
14
|
export declare function parse(schema: JSONSchema | boolean): SchemaNode;
|
|
13
15
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,gBAAgB,CAAC;AAG5D,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAYhE,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,GAAG,UAAU,CAQ9D;AAED;;GAEG;AACH,wBAAgB,WAAW,CAC1B,MAAM,EAAE,UAAU,GAAG,OAAO,EAC5B,GAAG,EAAE,YAAY,GACf,UAAU,CA4JZ"}
|
package/dist/parser/index.js
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
* JSON Schema Parser
|
|
3
3
|
* Converts JSON Schema to SchemaNode IR
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
import { normalizeDeep } from "../schema/normalizer.js";
|
|
7
|
-
import { resolveJsonPointer } from "../utils/json-pointer.js";
|
|
5
|
+
// Note: $ref resolution is handled by the Go CLI bundler
|
|
8
6
|
import { isEmptyObject } from "../utils/primitives.js";
|
|
9
7
|
import { createContext } from "./context.js";
|
|
10
8
|
import { parseString, parseNumber } from "./primitives.js";
|
|
@@ -13,16 +11,16 @@ import { parseAllOf, parseAnyOf, parseOneOf, parseNot, parseConditional, } from
|
|
|
13
11
|
import { parseLiteral, parseEnum } from "./values.js";
|
|
14
12
|
/**
|
|
15
13
|
* Parse a JSON Schema into SchemaNode IR
|
|
14
|
+
* Expects schemas to be pre-normalized to draft2020-12 by the bundler.
|
|
15
|
+
* @param schema The JSON Schema to parse
|
|
16
16
|
*/
|
|
17
17
|
export function parse(schema) {
|
|
18
18
|
// Handle boolean schemas at root level
|
|
19
19
|
if (typeof schema === "boolean") {
|
|
20
20
|
return schema ? { kind: "any" } : { kind: "never" };
|
|
21
21
|
}
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const ctx = createContext(normalized, version);
|
|
25
|
-
return parseSchema(normalized, ctx);
|
|
22
|
+
const ctx = createContext(schema);
|
|
23
|
+
return parseSchema(schema, ctx);
|
|
26
24
|
}
|
|
27
25
|
/**
|
|
28
26
|
* Internal schema parser - recursive
|
|
@@ -32,25 +30,20 @@ export function parseSchema(schema, ctx) {
|
|
|
32
30
|
if (typeof schema === "boolean") {
|
|
33
31
|
return schema ? { kind: "any" } : { kind: "never" };
|
|
34
32
|
}
|
|
35
|
-
// Handle
|
|
36
|
-
if (schema.unevaluatedItems !== undefined) {
|
|
37
|
-
throw new Error("unevaluatedItems is not supported");
|
|
38
|
-
}
|
|
39
|
-
if (schema.unevaluatedProperties !== undefined) {
|
|
40
|
-
const hasApplicators = schema.allOf ||
|
|
41
|
-
schema.anyOf ||
|
|
42
|
-
schema.oneOf ||
|
|
43
|
-
schema.if ||
|
|
44
|
-
schema.$ref ||
|
|
45
|
-
schema.dependentSchemas ||
|
|
46
|
-
schema.not;
|
|
47
|
-
if (hasApplicators) {
|
|
48
|
-
throw new Error("unevaluatedProperties with applicators is not supported");
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
// Handle $ref
|
|
33
|
+
// Handle $ref — recursive back-edges left by the processor
|
|
52
34
|
if (schema.$ref) {
|
|
53
|
-
|
|
35
|
+
const ref = schema.$ref;
|
|
36
|
+
if (ctx.resolving.has(ref)) {
|
|
37
|
+
return { kind: "ref", ref };
|
|
38
|
+
}
|
|
39
|
+
const target = resolveJsonPointerInSchema(ref, ctx.rootSchema);
|
|
40
|
+
if (target === undefined) {
|
|
41
|
+
throw new Error(`Encountered unresolvable $ref "${ref}" - schemas must be bundled by the Go CLI before processing.`);
|
|
42
|
+
}
|
|
43
|
+
ctx.resolving.add(ref);
|
|
44
|
+
const result = parseSchema(target, ctx);
|
|
45
|
+
ctx.resolving.delete(ref);
|
|
46
|
+
return result;
|
|
54
47
|
}
|
|
55
48
|
// Handle not - check before composition since { not: {} } = never
|
|
56
49
|
if (schema.not !== undefined) {
|
|
@@ -67,15 +60,42 @@ export function parseSchema(schema, ctx) {
|
|
|
67
60
|
const hasAllOf = schema.allOf && schema.allOf.length > 0;
|
|
68
61
|
const hasAnyOf = schema.anyOf && schema.anyOf.length > 0;
|
|
69
62
|
const hasOneOf = schema.oneOf && schema.oneOf.length > 0;
|
|
70
|
-
// Check for base schema
|
|
63
|
+
// Check for base schema keywords alongside composition operators.
|
|
64
|
+
// If we have base constraints (like additionalProperties/dependencies/etc), they must
|
|
65
|
+
// be intersected with the composition result.
|
|
71
66
|
const hasBaseSchema = schema.type !== undefined ||
|
|
67
|
+
// object keywords
|
|
72
68
|
schema.properties !== undefined ||
|
|
69
|
+
schema.additionalProperties !== undefined ||
|
|
70
|
+
schema.patternProperties !== undefined ||
|
|
71
|
+
schema.required !== undefined ||
|
|
72
|
+
schema.propertyNames !== undefined ||
|
|
73
|
+
schema.minProperties !== undefined ||
|
|
74
|
+
schema.maxProperties !== undefined ||
|
|
75
|
+
schema.dependentRequired !== undefined ||
|
|
76
|
+
schema.dependentSchemas !== undefined ||
|
|
77
|
+
schema.dependencies !== undefined ||
|
|
78
|
+
schema.unevaluatedProperties !== undefined ||
|
|
79
|
+
// array keywords
|
|
73
80
|
schema.items !== undefined ||
|
|
81
|
+
schema.prefixItems !== undefined ||
|
|
82
|
+
schema.additionalItems !== undefined ||
|
|
83
|
+
schema.minItems !== undefined ||
|
|
84
|
+
schema.maxItems !== undefined ||
|
|
85
|
+
schema.uniqueItems !== undefined ||
|
|
86
|
+
schema.contains !== undefined ||
|
|
87
|
+
schema.unevaluatedItems !== undefined ||
|
|
88
|
+
// primitive keywords
|
|
74
89
|
schema.minimum !== undefined ||
|
|
75
90
|
schema.maximum !== undefined ||
|
|
91
|
+
schema.exclusiveMinimum !== undefined ||
|
|
92
|
+
schema.exclusiveMaximum !== undefined ||
|
|
93
|
+
schema.multipleOf !== undefined ||
|
|
76
94
|
schema.minLength !== undefined ||
|
|
77
95
|
schema.maxLength !== undefined ||
|
|
78
96
|
schema.pattern !== undefined ||
|
|
97
|
+
schema.format !== undefined ||
|
|
98
|
+
// value keywords
|
|
79
99
|
schema.enum !== undefined ||
|
|
80
100
|
schema.const !== undefined;
|
|
81
101
|
if (hasAllOf || hasAnyOf || hasOneOf) {
|
|
@@ -94,6 +114,10 @@ export function parseSchema(schema, ctx) {
|
|
|
94
114
|
if (Array.isArray(type)) {
|
|
95
115
|
// Multiple types - create union
|
|
96
116
|
const variants = type.map((t) => {
|
|
117
|
+
// Draft3: type array can contain inline schemas
|
|
118
|
+
if (typeof t === "object" && t !== null) {
|
|
119
|
+
return parseSchema(t, ctx);
|
|
120
|
+
}
|
|
97
121
|
const typeSchema = { ...schema, type: t };
|
|
98
122
|
delete typeSchema.enum;
|
|
99
123
|
return parseSchema(typeSchema, ctx);
|
|
@@ -141,59 +165,42 @@ export function parseSchema(schema, ctx) {
|
|
|
141
165
|
}
|
|
142
166
|
return result;
|
|
143
167
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
const siblingSchema = { ...schema };
|
|
172
|
-
delete siblingSchema.$ref;
|
|
173
|
-
delete siblingSchema.$id;
|
|
174
|
-
delete siblingSchema.$anchor;
|
|
175
|
-
delete siblingSchema.$defs;
|
|
176
|
-
delete siblingSchema.definitions;
|
|
177
|
-
delete siblingSchema.$schema;
|
|
178
|
-
delete siblingSchema.$comment;
|
|
179
|
-
delete siblingSchema.$dynamicRef;
|
|
180
|
-
delete siblingSchema.$dynamicAnchor;
|
|
181
|
-
if (Object.keys(siblingSchema).length > 0) {
|
|
182
|
-
const siblingNode = parseSchema(siblingSchema, ctx);
|
|
183
|
-
return {
|
|
184
|
-
kind: "intersection",
|
|
185
|
-
schemas: [
|
|
186
|
-
{ kind: "ref", path: refPath, resolved: parsed },
|
|
187
|
-
siblingNode,
|
|
188
|
-
],
|
|
189
|
-
};
|
|
168
|
+
/**
|
|
169
|
+
* Resolve a JSON pointer ref against a schema root.
|
|
170
|
+
* Handles "#" (root) and "#/path/to/node" (JSON pointer).
|
|
171
|
+
*/
|
|
172
|
+
function resolveJsonPointerInSchema(ref, root) {
|
|
173
|
+
if (ref === "#")
|
|
174
|
+
return root;
|
|
175
|
+
if (!ref.startsWith("#/"))
|
|
176
|
+
return undefined;
|
|
177
|
+
const segments = ref
|
|
178
|
+
.slice(2)
|
|
179
|
+
.split("/")
|
|
180
|
+
.map((s) => s.replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
181
|
+
let current = root;
|
|
182
|
+
for (const segment of segments) {
|
|
183
|
+
if (current === null || current === undefined)
|
|
184
|
+
return undefined;
|
|
185
|
+
if (typeof current !== "object")
|
|
186
|
+
return undefined;
|
|
187
|
+
if (Array.isArray(current)) {
|
|
188
|
+
const idx = Number(segment);
|
|
189
|
+
if (Number.isNaN(idx) || idx < 0 || idx >= current.length)
|
|
190
|
+
return undefined;
|
|
191
|
+
current = current[idx];
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
current = current[segment];
|
|
190
195
|
}
|
|
191
196
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
+
if (current === undefined)
|
|
198
|
+
return undefined;
|
|
199
|
+
if (typeof current === "boolean")
|
|
200
|
+
return current;
|
|
201
|
+
if (typeof current === "object" && current !== null)
|
|
202
|
+
return current;
|
|
203
|
+
return undefined;
|
|
197
204
|
}
|
|
198
205
|
function parseComposition(schema, ctx, hasBaseSchema) {
|
|
199
206
|
const parts = [];
|
|
@@ -251,16 +258,19 @@ function parseComposition(schema, ctx, hasBaseSchema) {
|
|
|
251
258
|
function parseTypeless(schema, ctx) {
|
|
252
259
|
const guards = [];
|
|
253
260
|
// Check for object keywords
|
|
261
|
+
// Note: required as boolean (draft3 property-level) should NOT trigger object detection
|
|
262
|
+
// Only array-style required (draft4+) indicates schema-level object constraints
|
|
254
263
|
const hasObjectKeywords = schema.properties !== undefined ||
|
|
255
264
|
schema.additionalProperties !== undefined ||
|
|
256
265
|
schema.patternProperties !== undefined ||
|
|
257
|
-
schema.required
|
|
266
|
+
(Array.isArray(schema.required) && schema.required.length > 0) ||
|
|
258
267
|
schema.propertyNames !== undefined ||
|
|
259
268
|
schema.minProperties !== undefined ||
|
|
260
269
|
schema.maxProperties !== undefined ||
|
|
261
270
|
schema.dependentRequired !== undefined ||
|
|
262
271
|
schema.dependentSchemas !== undefined ||
|
|
263
|
-
schema.dependencies !== undefined
|
|
272
|
+
schema.dependencies !== undefined ||
|
|
273
|
+
schema.unevaluatedProperties !== undefined;
|
|
264
274
|
// Check for array keywords
|
|
265
275
|
const hasArrayKeywords = schema.items !== undefined ||
|
|
266
276
|
schema.prefixItems !== undefined ||
|
|
@@ -268,7 +278,8 @@ function parseTypeless(schema, ctx) {
|
|
|
268
278
|
schema.minItems !== undefined ||
|
|
269
279
|
schema.maxItems !== undefined ||
|
|
270
280
|
schema.uniqueItems !== undefined ||
|
|
271
|
-
schema.contains !== undefined
|
|
281
|
+
schema.contains !== undefined ||
|
|
282
|
+
schema.unevaluatedItems !== undefined;
|
|
272
283
|
// Check for numeric keywords
|
|
273
284
|
const hasNumericKeywords = schema.minimum !== undefined ||
|
|
274
285
|
schema.maximum !== undefined ||
|