JSON Schema Walker
Loosely based on CloudFlare's json schema tools
A system that visits all schema objects in a JSON Schema document and makes callbacks before and/or after visiting all of the current schema object's subschemas.
Usage
import { Walker } from "json-schema-walker";
const schema = {
};
const walker = new Walker<T>();
await walker.loadSchema(schema, {
cloneSchema: true,
dereference: false,
dereferenceOptions: {
dereference: {
circular: "ignore",
},
},
});
const convertSchema = (schema) => {
};
await walker.walk(convertSchema, walker.vocabularies.DRAFT_07);
const updatedSchema = walker.rootSchema;
Circular references
Passing the options
{
"dereferenceOptions": {
"dereference": {
"circular": "ignore"
}
}
}
will dereference all non-circular references in your schema.