Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using the library in the browser? #11

Open
wpoosanguansit opened this issue Jul 13, 2015 · 3 comments
Open

Using the library in the browser? #11

wpoosanguansit opened this issue Jul 13, 2015 · 3 comments

Comments

@wpoosanguansit
Copy link

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.

@nickyout
Copy link
Contributor

nickyout commented Aug 8, 2015

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.

@wpoosanguansit
Copy link
Author

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.

@krg7880
Copy link
Owner

krg7880 commented Aug 11, 2015

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 :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants