npm.io
0.2.5 • Published 9 years ago

1tree-schema

Licence
MIT
Version
0.2.5
Deps
2
Vulns
0
Weekly
0
DeprecatedThis package is deprecated

1tree-schema

Converts JSON schema to and from 1tree instances

const SchemaTree = require( '1tree-schema' )
const jsonSchema = require( './test.schema.json' )

const tree = SchemaTree( jsonSchema )

const integerNodes = tree.findAll( n => n.nodeType() === 'integer' )

integerNodes.forEach( n => {
  const value = n.value()

  value.minimum = 1

  n.value( value )
})

const newSchema = tree.toSchema()

console.log( JSON.stringify( newSchema, null, 2 ) )

Keywords