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

json-schema-traverse

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-schema-traverse

Traverse JSON Schema passing each schema object to callback

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is json-schema-traverse?

The json-schema-traverse package is used to traverse and process JSON Schemas. It allows you to visit every schema node to analyze or modify the schema. This can be useful for schema analysis, transformation, and enhancement.

What are json-schema-traverse's main functionalities?

Traversing a JSON Schema

This feature allows you to traverse a JSON Schema and execute a callback function at each node. The callback receives information about the current schema node, its path, and its context within the overall schema.

{"schema": {"type": "object", "properties": {"foo": {"type": "string"}, "bar": {"type": "number"}}}, "callback": "(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) => { console.log('Traversing:', jsonPtr); }"}

Modifying a JSON Schema during traversal

This feature allows you to modify the schema nodes during traversal. For example, you can add constraints like 'minLength' to string properties.

{"schema": {"type": "object", "properties": {"foo": {"type": "string"}, "bar": {"type": "number"}}}, "callback": "(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) => { if (schema.type === 'string') { schema.minLength = 1; } }"}

Other packages similar to json-schema-traverse

Keywords

FAQs

Package last updated on 13 Dec 2020

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