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.
@@ -1,4 +1,4 @@
1
- import { c as JsonSchema } from "../types-B2wwNWyo.cjs";
1
+ import { c as JsonSchema } from "../types-ZgoQMSny.cjs";
2
2
 
3
3
  //#region remotes/index.d.ts
4
4
  /** JSON Schema meta-schemata */
@@ -1,4 +1,4 @@
1
- import { c as JsonSchema } from "../types-BhTU1l2h.mjs";
1
+ import { c as JsonSchema } from "../types-DVyFDxCv.mjs";
2
2
 
3
3
  //#region remotes/index.d.ts
4
4
  /** JSON Schema meta-schemata */
@@ -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; /** available draft configurations */
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; /** available draft configurations */
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.0",
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 = {
@@ -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,