Creates html or PDF from a Swagger JSON file.
npm install
node ./index.js "path to your Swagger.json file"
or add the html
parameter for html format:
node ./index.js "path to your Swagger.json file" html
Also supports combining several Swagger JSON files into 1 output file:
node ./index.js "file1.json,file2.json,file3.json"
Swagger-to-PDF supports calling the functionality from within your own node application:
npm install swagger-to-pdf
npm install phantom-html2pdf
Then, in your code:
const swaggerConverter = require('swagger-to-pdf').converter;
const swaggerJSON = JSON.parse(fs.readFileSync(filename.trim(), 'utf8'));
// Optional: pass in custom CSS overrides
const customCss = fs.readFileSync(cssFilename.trim(), 'utf8'));
const html = converter.convertTopdf(swaggerJSON.document || swaggerJSON, customCss);
- Automatic chapter # generation
- Updated API to enable integration in other apps
- Re-organization and modularization of code
- Added option to obtain (intermediate) html result
- Added option to include custom CSS
- Added generation of bookmark links for TOC
- Introduction of ES6 syntax
These are the current plans:
-
Cleanup Code
- Replace consecutive
html +=
assignments - Remove inline styling by smarter css
- Convert string html to JSX
- Replace consecutive
-
Unit testing
-
Additional options for mark up
- phantom-html2pdf
If you've got value out of this and have ideas, please send pull requests.