@stoplight/json-schema-tree
Use cases
- json-schema-viewer
- json-schema-editor
- masking
Installation
Supported in modern browsers and Node.JS (>=10.18).
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);
tree.walker.hookInto('filter', node => {
return !isRegularNode(node) || node.types === null || !node.types.includes(SchemaNodeKind.Integer);
});
tree.populate();
tree.root;
Contributing
- Clone repo.
- Create / checkout
feature/{name}
, chore/{name}
, or fix/{name}
branch.
- Install deps:
yarn
.
- Make your changes.
- Run tests:
yarn test.prod
.
- Stage relevant files to git.
- 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
.
- Push:
git push
.
- Open PR targeting the
master
branch.