forked from OAI/OpenAPI-Specification
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
Latest commit
48 lines (39 loc) · 1.33 KB
/
Copy pathgulpfile.js
File metadata and controls
48 lines (39 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
vargulp=require('gulp');
varjsonlint=require("gulp-jsonlint");
vargulpyaml=require('gulp-yaml');
varext_replace=require('gulp-ext-replace');
varmap=require('map-stream');
varYAML=require('json2yaml');
vargutil=require('gulp-util');
varexitCode=0;
varjson_paths={
examples: 'examples/**/*.json',
models: 'fixtures/v2.0/json/models/**/*.json',
resources: 'fixtures/v2.0/json/resources/**/*.json',
responses: 'fixtures/v2.0/json/responses/**/*.json'
// What are the other files in fixtures/v2.0/json/*.json
};
gulp.task('lint',function(){
returngulp.src(['./**/*.json','!./node_modules/**/*.json'])
.pipe(jsonlint())
.pipe(jsonlint.reporter());
// YAML linting/formatting?
});
gulp.task('yaml2json',function(){
gulp.src('./fixtures/v2.0/yaml/**.yaml')
.pipe(gulpyaml({pretty: true}))
.pipe(gulp.dest('./fixtures/v2.0/json'));
gulp.src(json_paths.examples)
.pipe(gulpyaml({pretty: true}))
.pipe(gulp.dest('examples/'));
});
gulp.task('json2yaml',function(){
returngulp.src('./fixtures/v2.0/json/**/*.json')
.pipe(map(function(file,cb){
data=JSON.parse(file.contents);
file.contents=newBuffer(String(YAML.stringify(data)));
cb(null,file);
}))
.pipe(ext_replace('.yaml'))
.pipe(gulp.dest('fixtures/v2.0/yaml'));
});