forked from RackHD/on-http
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Cleanup errors in API 2.0 swagger definition * Add script to generate documentation in PDF form
- Loading branch information
Brian Parry
committed
Oct 5, 2016
1 parent
e7f34ed
commit 54d0d26
Showing
3 changed files
with
544 additions
and
1,464 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
var yaml = require('js-yaml'); | ||
var fs = require('fs'); | ||
var pdf = require('html-pdf'); | ||
var path = require('path'); | ||
|
||
fs.readFile('static/monorail-2.0.yaml', { encoding: 'utf8'}, function(err, swaggerData) { | ||
if (err) return console.log(err); | ||
|
||
var swaggerDef = yaml.safeLoad(swaggerData); | ||
require('bootprint') | ||
.load(require('bootprint-swagger')) | ||
.build('static/monorail-2.0.yaml', 'build/swagger-doc') | ||
.generate() | ||
.done(function(data) { | ||
var html = fs.readFileSync(data[0], 'utf-8'); | ||
var options = { | ||
base: 'file://' + path.resolve(data[0]), | ||
format: 'Letter' | ||
}; | ||
var pdfFile = 'build/swagger-doc/rackhd-api-' + swaggerDef.info.version + '.pdf'; | ||
|
||
pdf.create(html, options) | ||
.toFile(pdfFile, function(err, res) { | ||
if (err) return console.log(err); | ||
console.log(res); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.