Socket
Socket
Sign inDemoInstall

json-schema-walker

Package Overview
Dependencies
6
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    json-schema-walker

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.


Version published
Weekly downloads
11K
decreased by-13.37%
Maintainers
1
Install size
1.03 MB
Created
Weekly downloads
 

Readme

Source

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 = {
  // your json schema
};
const walker = new Walker<T>();
await walker.loadSchema(schema, {
  cloneSchema: true,
  dereference: false,
  dereferenceOptions: {
    dereference: {
      circular: "ignore",
    },
  },
});
const convertSchema = (schema) => {
  // do something with the schema properties
};
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.

FAQs

Last updated on 08 Nov 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc