1.0.0 • Published 8 years ago
loopback-jsonschema-types v1.0.0
loopback-jsonschema-types
Simple module mapping loopbacks built in types to jsonschema types
Installation
npm install loopback-jsonschema-types --save
Usage
Require the module
const types = require('loopback-jsonschema-types')
Then just pass any valid loopback type definition to the module to get back a jsonschema object. https://docs.strongloop.com/display/public/LB/LoopBack+types#LoopBacktypes-Objecttypes
A few examples:
A simple string representation
types('string')
// -> { type: 'string' }
A native javascript type
types(String)
// -> { type: 'string' }
Using the type property (see loopback docs)
types({type: String})
// -> { type: 'string' }
arrays
types([String])
types(['String'])
types({type: [String]})
// -> { type: 'array', items: { type: 'string' } }
Additional information
See extensive tests in the test folder for additional usage information.