Created
August 10, 2015 18:47
-
-
Save glen-84/f1bdda0bbe9c32da0d3f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var gulp = require("gulp"); | |
var browserSync = require("browser-sync").create(); | |
var swagger = require("swagger-parser"); | |
var fs = require("fs"); | |
gulp.task("serve", function() { | |
browserSync.init({ | |
open: false, | |
server: { | |
baseDir: "./", | |
middleware: function (req, res, next) { | |
res.setHeader("Access-Control-Allow-Origin", "*"); | |
next(); | |
} | |
} | |
}); | |
}); | |
gulp.task("watch", function() { | |
gulp.watch("**/*.yaml", ["build"]); | |
}); | |
gulp.task("build", function() { | |
swagger.dereference("swagger.yaml", function(err, api) { | |
if (err) { | |
console.log(err); | |
} else { | |
fs.writeFileSync("swagger.json", JSON.stringify(api)); | |
} | |
}); | |
}); | |
gulp.task("default", ["serve", "watch"]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment