json-schema-library 11.3.0 → 11.3.1
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/bowtie/bowtie.test.ts +80 -0
- package/bowtie/package.json +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/jlib.js +1 -1
- package/dist/remotes/index.d.cts +1 -1
- package/dist/remotes/index.d.mts +1 -1
- package/dist/{types-B2wwNWyo.d.cts → types-DVyFDxCv.d.mts} +2 -1
- package/dist/{types-BhTU1l2h.d.mts → types-ZgoQMSny.d.cts} +2 -1
- package/package.json +1 -1
- package/src/SchemaNode.ts +3 -1
- package/src/compileSchema.ts +1 -0
package/dist/remotes/index.d.cts
CHANGED
package/dist/remotes/index.d.mts
CHANGED
|
@@ -232,7 +232,8 @@ declare const errors: {
|
|
|
232
232
|
declare function isSchemaNode(value: unknown): value is SchemaNode;
|
|
233
233
|
declare function isReduceable(node: SchemaNode): boolean;
|
|
234
234
|
type Context = {
|
|
235
|
-
/** root node of this JSON Schema */rootNode: SchemaNode; /**
|
|
235
|
+
/** root node of this JSON Schema */rootNode: SchemaNode; /** Fallback _draft_ version in case no _draft_ is specified by `schema.$schema` */
|
|
236
|
+
draft?: string; /** available draft configurations */
|
|
236
237
|
drafts: Draft[]; /** [SHARED ACROSS REMOTES] root nodes of registered remote JSON Schema, stored by id/url */
|
|
237
238
|
remotes: Record<string, SchemaNode>; /** references stored by fully resolved schema-$id + local-pointer */
|
|
238
239
|
refs: Record<string, SchemaNode>; /** anchors stored by fully resolved schema-$id + $anchor */
|
|
@@ -232,7 +232,8 @@ declare const errors: {
|
|
|
232
232
|
declare function isSchemaNode(value: unknown): value is SchemaNode;
|
|
233
233
|
declare function isReduceable(node: SchemaNode): boolean;
|
|
234
234
|
type Context = {
|
|
235
|
-
/** root node of this JSON Schema */rootNode: SchemaNode; /**
|
|
235
|
+
/** root node of this JSON Schema */rootNode: SchemaNode; /** Fallback _draft_ version in case no _draft_ is specified by `schema.$schema` */
|
|
236
|
+
draft?: string; /** available draft configurations */
|
|
236
237
|
drafts: Draft[]; /** [SHARED ACROSS REMOTES] root nodes of registered remote JSON Schema, stored by id/url */
|
|
237
238
|
remotes: Record<string, SchemaNode>; /** references stored by fully resolved schema-$id + local-pointer */
|
|
238
239
|
refs: Record<string, SchemaNode>; /** anchors stored by fully resolved schema-$id + $anchor */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json-schema-library",
|
|
3
|
-
"version": "11.3.
|
|
3
|
+
"version": "11.3.1",
|
|
4
4
|
"description": "Customizable and hackable json-validator and json-schema utilities for traversal, data generation and validation",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
package/src/SchemaNode.ts
CHANGED
|
@@ -70,6 +70,8 @@ function getDraft(drafts: Draft[], $schema: string) {
|
|
|
70
70
|
export type Context = {
|
|
71
71
|
/** root node of this JSON Schema */
|
|
72
72
|
rootNode: SchemaNode;
|
|
73
|
+
/** Fallback _draft_ version in case no _draft_ is specified by `schema.$schema` */
|
|
74
|
+
draft?: string;
|
|
73
75
|
/** available draft configurations */
|
|
74
76
|
drafts: Draft[];
|
|
75
77
|
/** [SHARED ACROSS REMOTES] root nodes of registered remote JSON Schema, stored by id/url */
|
|
@@ -551,7 +553,7 @@ export const SchemaNodeMethods = {
|
|
|
551
553
|
|
|
552
554
|
const node = this as SchemaNode;
|
|
553
555
|
const { context } = node;
|
|
554
|
-
const schemaId = isJsonSchema(schema) ? schema.$schema : undefined;
|
|
556
|
+
const schemaId = isJsonSchema(schema) ? (node.context.draft ?? schema.$schema) : undefined;
|
|
555
557
|
const draft = getDraft(context.drafts, schemaId ?? context.rootNode.schema?.$schema);
|
|
556
558
|
|
|
557
559
|
const remoteNode: SchemaNode = {
|
package/src/compileSchema.ts
CHANGED
|
@@ -116,6 +116,7 @@ export function compileSchema(schema: JsonSchema | BooleanSchema, options: Compi
|
|
|
116
116
|
anchors: {},
|
|
117
117
|
refs: {},
|
|
118
118
|
...copy(pick(draft, "methods", "keywords", "version", "formats", "errors")),
|
|
119
|
+
draft: options.draft,
|
|
119
120
|
getDataDefaultOptions: options.getDataDefaultOptions,
|
|
120
121
|
withSchemaAnnotations: options.withSchemaAnnotations ?? false,
|
|
121
122
|
throwOnInvalidRef: options.throwOnInvalidRef ?? false,
|