Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

json-schema-walker

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

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.

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
18K
increased by0.93%
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 08 Nov 2023

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc