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

@stoplight/json-schema-tree

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stoplight/json-schema-tree

<!-- BADGES -->

  • 4.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
34K
decreased by-32.3%
Maintainers
1
Weekly downloads
 
Created
Source

@stoplight/json-schema-tree

Use cases

  • json-schema-viewer
  • json-schema-editor
  • masking

Installation

Supported in modern browsers and Node.JS (>=10.18).

# latest stable
yarn add @stoplight/json-schema-tree

Usage

import { SchemaTree, SchemaNodeKind, isRegularNode } from '@stoplight/json-schema-tree';

const tree = new SchemaTree(mySchema);
const ALLOWED_DEPTH = 2;

tree.walker.hookInto('stepIn', node => tree.walker.depth <= ALLOWED_DEPTH); // if flattening is needed, this might need to be tweaked to account for the scenarios where certain nodes can be merged (i.e. arrays)

tree.walker.hookInto('filter', node => {
  return !isRegularNode(node) || node.types === null || !node.types.includes(SchemaNodeKind.Integer); // if a schema property is of type integer, it won't be included in the tree
});

tree.populate();

tree.root; // populated tree

Contributing

  1. Clone repo.
  2. Create / checkout feature/{name}, chore/{name}, or fix/{name} branch.
  3. Install deps: yarn.
  4. Make your changes.
  5. Run tests: yarn test.prod.
  6. Stage relevant files to git.
  7. Commit: yarn commit. NOTE: Commits that don't follow the conventional format will be rejected. yarn commit creates this format for you, or you can put it together manually and then do a regular git commit.
  8. Push: git push.
  9. Open PR targeting the master branch.

FAQs

Package last updated on 23 Jan 2024

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