Socket
Socket
Sign inDemoInstall

json-schema-traverse

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    json-schema-traverse

Traverse JSON Schema passing each schema object to callback


Version published
Weekly downloads
84M
decreased by-8.16%
Maintainers
1
Install size
3.42 kB
Created
Weekly downloads
 

Package description

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

Readme

Source

json-schema-traverse

Traverse JSON Schema passing each schema object to callback

Keywords

FAQs

Last updated on 04 Jun 2017

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