4.0.0 • Published 11 months ago
@stoplight/json-schema-tree v4.0.0
@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
- Clone repo.
- Create / checkout
feature/{name}
,chore/{name}
, orfix/{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 regulargit commit
. - Push:
git push
. - Open PR targeting the
master
branch.
4.0.0
11 months ago
3.0.0
1 year ago
2.3.0
1 year ago
2.3.1
1 year ago
2.2.5
1 year ago
2.2.4
1 year ago
2.2.3
2 years ago
2.2.2
2 years ago
2.2.1
3 years ago
2.2.0
3 years ago
2.1.3
3 years ago
2.1.2
3 years ago
2.1.1
3 years ago
1.1.0-beta.1
4 years ago
2.1.0
4 years ago
2.0.1
4 years ago
2.0.0
4 years ago
1.1.3
4 years ago
1.1.1
4 years ago
1.0.1-beta.1
4 years ago
1.1.2
4 years ago
1.1.0
4 years ago
1.0.0
4 years ago
1.0.0-beta.6
4 years ago
1.0.0-beta.5
4 years ago
1.0.0-beta.4
4 years ago
1.0.0-beta.3
4 years ago
1.0.0-beta.2
4 years ago
1.0.0-beta.1
4 years ago