Gulp plugin to resolve $ref references (local+file+http) and bundle into a single json schema
$ npm install --save-dev gulp-jsonschema-deref
var gulp = require('gulp');
var jsonschemaDeref = require('gulp-jsonschema-deref');
var schemaFiles = '*.schema.json',
definitionsFiles = 'definitions/' + schemaFiles, // (optional)
buildFolder = 'build';
gulp.task('resolve-schema', function() {
var stream = gulp.src( schemaFiles )
.pipe( jsonschemaDeref() )
.pipe( gulp.dest(buildFolder) );
return stream;
});
gulp.task('watch-schema', function() {
var watcher = gulp.watch( [schemaFiles,definitionsFiles], ['resolve-schema']);
watcher.on('change', function(event) {
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
});
});
gulp.task('default', ['resolve-schema','watch-schema']);
Currently, dependant on json-schema-ref-parser
see: dereference
MIT © oori