jsdoc-to-schema
v0.1.0
Published
Utility to produce OpenAPI compliant JSON schemas from JSDoc comments
Downloads
2
Readme
JSDoc to Schema
This package provides a CLI tool for generating JSON schemas for models based on JSDoc style comments.
This package is in it's early stages, and currently only supports parsing of JavaScript and TypeScript models (not full API documentation).
Installation
To use the CLI tool:npm install -g jsdoc-to-schema
To use the package in another application:npm install --save jsdoc-to-schema
Usage
CLI
You can see help for using the CLI by running:jsdoc-to-schema help
To parse files:jsdoc-to-schema parse --file myClass.js
To parse a directory:jsdoc-to-schema parse --dir ./models
Specify either the --file
or --dir
parameter, not both.
Both parameter values can be comma separated lists to handle multiple files or directories with one command.
Module
Require the module:const jsDocToSchema = require('jsdoc-to-schema/src/cmds/parse');
You can then run the parse method by passing in the arguments:
jsDocToSchema.handle({
output: 'schema.json',
file: undefined,
dir: './models'
});