@@ -17,8 +17,18 @@ npm install --save jsdoc-to-json-schema
1717``` js
1818var toJsonSchema = require (' jsdoc-to-json-schema' );
1919
20- // generate a JSON schema for product.js
20+ // OPTION 1: generate a JSON schema for product.js and save it to disk
2121toJsonSchema (' ./example/product.js' , ' ./example/product.schema.json' );
22+
23+ // OPTION 2: generate a JSON schema and return it as an object
24+ toJsonSchema (' ./example/product.js' ).then (function (schema ){
25+ // do something with it
26+ });
27+
28+ // OPTION 3: generate a JSON schema, save it to disk and return it as an object
29+ toJsonSchema (' ./example/product.js' , ' ./example/product.schema.json' ).then (function (schema ){
30+ // do something with it
31+ });
2232```
2333
2434### Using this module via the command line
@@ -41,7 +51,7 @@ var toJsonSchema = require('../lib/jsdoc-to-json-schema.js');
4151// create an express route
4252app .get (' /' , function (req , res ){
4353
44- // return JSON schema generated from person.js script comments
54+ // pipe schema directly to the response stream
4555 toJsonSchema (' ./examples/person.js' , res);
4656});
4757
@@ -55,7 +65,7 @@ For use with express consider the dedicated express middleware project [express-
5565
5666### Input * (singleton)*
5767
58- JavaScript file containing jsDoc * @schema * tags used to specify the JSON schema output.
68+ JavaScript file containing jsDoc @schema tags used to define the JSON schema:
5969
6070``` js
6171/**
@@ -134,7 +144,7 @@ var Person = {
134144
135145### Input * (instance)*
136146
137- JavaScript file containing jsDoc * @schema * tags used to specify the JSON schema output.
147+ JavaScript file containing jsDoc @schema tags used to define the JSON schema:
138148
139149``` js
140150/**
0 commit comments