Package Exports
- jsonschema-nodewalker
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (jsonschema-nodewalker) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Traverse JSON Schema from bottom up. Allows altering of structure or reformatting
to match other schema formats, even if the structure is immutable, as values
return in onNode
callback will be placed at the node's position in a newly
formatted structure.
Given the following schema:
const SCHEMA = {
type: 'object',
properties: {
title: {
type: 'string'
},
actors: {
type: 'array',
items: {
type: 'object',
properties: {
name: {
type: 'string'
},
gender: {
type: 'string'
}
}
}
}
}
};
$ npm install --save jsonschema-nodewalker
const walkNodes = require('jsonschema-nodewalker');
To simply walk the nodes, we call:
walkNodes(SCHEMA, (node, meta) => {
// `node` will contain the schema node we're currently on
// `meta` will contain metadata about the current node, such as whether it is
// required, whether it is an array item, as well as the structures that its
// children returned from their onNode functions.
});