Gathering detailed insights and metrics for json-schema-traverse
Gathering detailed insights and metrics for json-schema-traverse
Gathering detailed insights and metrics for json-schema-traverse
Gathering detailed insights and metrics for json-schema-traverse
Traverse JSON Schema passing each schema object to callback
npm install json-schema-traverse
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
100 Stars
45 Commits
18 Forks
5 Watching
3 Branches
6 Contributors
Updated on 15 Nov 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-3.5%
21,886,407
Compared to previous day
Last week
3.8%
118,896,963
Compared to previous week
Last month
17.5%
475,003,501
Compared to previous month
Last year
18.3%
4,727,633,477
Compared to previous year
4
Traverse JSON Schema passing each schema object to callback
npm install json-schema-traverse
1const traverse = require('json-schema-traverse'); 2const schema = { 3 properties: { 4 foo: {type: 'string'}, 5 bar: {type: 'integer'} 6 } 7}; 8 9traverse(schema, {cb}); 10// cb is called 3 times with: 11// 1. root schema 12// 2. {type: 'string'} 13// 3. {type: 'integer'} 14 15// Or: 16 17traverse(schema, {cb: {pre, post}}); 18// pre is called 3 times with: 19// 1. root schema 20// 2. {type: 'string'} 21// 3. {type: 'integer'} 22// 23// post is called 3 times with: 24// 1. {type: 'string'} 25// 2. {type: 'integer'} 26// 3. root schema 27
Callback function cb
is called for each schema object (not including draft-06 boolean schemas), including the root schema, in pre-order traversal. Schema references ($ref) are not resolved, they are passed as is. Alternatively, you can pass a {pre, post}
object as cb
, and then pre
will be called before traversing child elements, and post
will be called after all child elements have been traversed.
Callback is passed these parameters:
traverse
objectproperties
, anyOf
, etc.){type: 'string'}
is the root schema{type: 'string'}
the property name is 'foo'
1const traverse = require('json-schema-traverse'); 2const schema = { 3 mySchema: { 4 minimum: 1, 5 maximum: 2 6 } 7}; 8 9traverse(schema, {allKeys: true, cb}); 10// cb is called 2 times with: 11// 1. root schema 12// 2. mySchema
Without option allKeys: true
callback will be called only with root schema.
json-schema-traverse package is a part of Tidelift enterprise subscription - it provides a centralised commercial support to open-source software users, in addition to the support provided by software maintainers.
To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure. Please do NOT report security vulnerability via GitHub issues.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
Found 5/22 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More@json-schema-tools/traverse
This package exports a method that will traverse a JSON-Schema, calling a mutation function for each sub schema found. It is useful for building tools to work with JSON Schemas.
@babel/traverse
The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes
json-schema
JSON Schema validation and specifications
@types/json-schema
TypeScript definitions for json-schema