json-schema-walker
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -6,3 +6,3 @@ import type { JSONSchema } from "@apidevtools/json-schema-ref-parser"; | ||
declare type IVocabulary = Record<string, any>; | ||
interface Options<T extends InputSchema> { | ||
interface Options { | ||
cloneSchema?: boolean; | ||
@@ -18,3 +18,3 @@ dereference?: boolean; | ||
constructor(); | ||
loadSchema: (schema: T, options?: Options<T>) => Promise<void>; | ||
loadSchema: (schema: T, options?: Options) => Promise<void>; | ||
walk: (processor: ProcessorFunction<T>, vocabulary: IVocabulary) => Promise<void>; | ||
@@ -21,0 +21,0 @@ private cleanupVisited; |
@@ -72,3 +72,3 @@ "use strict"; | ||
for (const entry of Object.values(schema)) { | ||
if (typeof entry === "object" && null !== entry && entry[visited]) { | ||
if (entry && typeof entry === "object" && entry[visited]) { | ||
delete entry[visited]; | ||
@@ -103,3 +103,3 @@ this.cleanupVisited(entry); | ||
this.processSchemaKey = (schema, keyword) => { | ||
if (typeof schema[keyword] !== "object") { | ||
if (!schema[keyword] || typeof schema[keyword] !== "object") { | ||
return; | ||
@@ -116,3 +116,4 @@ } | ||
for (const prop of Object.getOwnPropertyNames(schema[keyword])) { | ||
if (typeof schema[keyword][prop] === "object") { | ||
const schemaElem = schema[keyword][prop]; | ||
if (typeof schemaElem === "object" && schemaElem) { | ||
this.applyUserProcessor(schema[keyword], prop); | ||
@@ -124,3 +125,4 @@ } | ||
for (const prop of Object.getOwnPropertyNames(schema[keyword])) { | ||
if (typeof schema[keyword][prop] === "object") { | ||
const schemaElem = schema[keyword][prop]; | ||
if (schemaElem && typeof schemaElem === "object") { | ||
this.applyUserProcessor(schema[keyword], prop); | ||
@@ -127,0 +129,0 @@ } |
@@ -6,3 +6,3 @@ import type { JSONSchema } from "@apidevtools/json-schema-ref-parser"; | ||
declare type IVocabulary = Record<string, any>; | ||
interface Options<T extends InputSchema> { | ||
interface Options { | ||
cloneSchema?: boolean; | ||
@@ -18,3 +18,3 @@ dereference?: boolean; | ||
constructor(); | ||
loadSchema: (schema: T, options?: Options<T>) => Promise<void>; | ||
loadSchema: (schema: T, options?: Options) => Promise<void>; | ||
walk: (processor: ProcessorFunction<T>, vocabulary: IVocabulary) => Promise<void>; | ||
@@ -21,0 +21,0 @@ private cleanupVisited; |
@@ -57,3 +57,3 @@ import clone from "clone"; | ||
for (const entry of Object.values(schema)) { | ||
if (typeof entry === "object" && null !== entry && entry[visited]) { | ||
if (entry && typeof entry === "object" && entry[visited]) { | ||
delete entry[visited]; | ||
@@ -88,3 +88,3 @@ this.cleanupVisited(entry); | ||
this.processSchemaKey = (schema, keyword) => { | ||
if (typeof schema[keyword] !== "object") { | ||
if (!schema[keyword] || typeof schema[keyword] !== "object") { | ||
return; | ||
@@ -101,3 +101,4 @@ } | ||
for (const prop of Object.getOwnPropertyNames(schema[keyword])) { | ||
if (typeof schema[keyword][prop] === "object") { | ||
const schemaElem = schema[keyword][prop]; | ||
if (typeof schemaElem === "object" && schemaElem) { | ||
this.applyUserProcessor(schema[keyword], prop); | ||
@@ -109,3 +110,4 @@ } | ||
for (const prop of Object.getOwnPropertyNames(schema[keyword])) { | ||
if (typeof schema[keyword][prop] === "object") { | ||
const schemaElem = schema[keyword][prop]; | ||
if (schemaElem && typeof schemaElem === "object") { | ||
this.applyUserProcessor(schema[keyword], prop); | ||
@@ -112,0 +114,0 @@ } |
{ | ||
"name": "json-schema-walker", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "A system that visits all schema objects in a JSON Schema document and makes callbacks before visiting all of the current schema object's subschemas.", | ||
@@ -5,0 +5,0 @@ "types": "dist/mjs/index.d.ts", |
24697
510