项目作者: fastcodejava

项目描述 :
This library is used to generate document from a schema
高级语言: JavaScript
项目地址: git://github.com/fastcodejava/schematodoc.git
创建时间: 2016-10-01T19:51:01Z
项目社区:https://github.com/fastcodejava/schematodoc

开源协议:

下载


schematodoc Document

This library is used to generate document from a schema.
The schema can be in a json file or in a yaml file.
When a json schema is used, we get the documentation for the root key.
When a yaml file is used, we get the documentation for a particular URL and it method.

Use with Node

  1. $ npm install schematodoc

Usage

The module need to be executed from another js file. This module generates the documentation in a particular format.
One can use that to get the document in the desired format.

To execute:

Please do install using npm install schematodoc and create a file test.js in the app root as shown below.

  1. var gen = require('schematodoc');
  2. var inputFile = './api/swagger/swagger.yaml'; //path to yaml file
  3. var url = 'my_url';
  4. var method = 'post';
  5. gen.generateDocFromSwagger(inputFile, url, method, {save: true, outputFile: inputFile});

The generated documentation will be written in the given file.

One can customize the output according to one’s needs. You have to create a function similar to the one : https://github.com/fastcodejava/schematodoc/blob/master/lib/generateOutput.js
and supply the function as shown below :

  1. gen.generateDocFromSwagger(inputFile, url, method, {save: true, outputFile: inputFile}, mygenFunc);
  1. var gen = require('schematodoc');
  2. var inputFile = './api/swagger/swagger.yaml'; //path to yaml file
  3. var url = 'my_url';
  4. var method = 'post';
  5. gen.generateDocFromSwagger(inputFile, url, method, {save: false});

The generated documentation will be written in the console.