json-schema-generator
json-schema-generator copied to clipboard
Using the library in the browser?
Hi,
Is it possible to use the library in the browser? If yes, how do I package all the js file into a single for the purpose? Thanks for your help.
Use browserify.
(edit: ./index.js
already exposes ./lib/index.js
nowadays)
I browserified ./index.js
and that exposes the function you'll want. For example, do:
$ npm install -g browserify
$ browserify ./json-schema-generator/index.js -s jsonSchemaGenerator > jsg-browser.js
Then in a page with jsg-browser.js
loaded, use:
var schema = jsonSchemaGenerator({ object: { to: { schemafiy: true } } });
// check:
console.log(JSON.stringify(schema, null, 2));
I just confirmed that this works.
Thank you.
Sent from my iPhone
On Aug 8, 2015, at 7:58 AM, nickyout [email protected] wrote:
Use browserify.
I browserified ./lib/index.js and that exposes the function you'll want. For example, do:
$ npm install -g browserify $ browserify json-schema-generator/lib/index.js -s jsonSchemaGenerator > jsg-browser.js Then in a page with jsg-browser.js loaded, use:
var schema = jsonSchemaGenerator({ object: { to: { schemafiy: true } } }); // check: console.log(JSON.stringify(schema, null, 2)); I just confirmed that this works. The fact that you have to use ./lib/index.js instead of ./index.js is a bit non-intuitive though...
— Reply to this email directly or view it on GitHub.
Sorry @wpoosanguansit - Been very busy. Thanks @nickyout for following up. Perhaps I'll find sometime to have it readily available. Also, good to know it works with Browserify :-)