@@ -12,24 +12,13 @@ var parser = Promise.promisifyAll(require("swagger-parser"));
12
12
var yaml = Promise . promisifyAll ( require ( "js-yaml" ) ) ;
13
13
var _ = Promise . promisifyAll ( require ( "lodash" ) ) ;
14
14
15
-
16
15
function getSpecPromise ( file ) {
17
- return parser . parseAsync ( file )
18
- . spread ( function ( api , metadata ) {
19
- return api ;
20
- } ) . catch ( function ( e ) {
21
- console . error ( "unable to read swagger file\n" + e )
22
- process . exit ( 1 ) ;
23
- } ) ;
16
+ return parser . parseAsync ( file , { } ) ;
24
17
}
25
18
26
19
function getCheckStylePromise ( file ) {
27
20
return fs . readFileAsync ( file )
28
- . then ( yaml . safeLoad )
29
- . catch ( function ( e ) {
30
- console . error ( "unable to read checkstyle\n" + e )
31
- process . exit ( 1 ) ;
32
- } ) ;
21
+ . then ( yaml . safeLoad ) ;
33
22
}
34
23
35
24
function getSchema ( checkStyle ) {
@@ -45,6 +34,7 @@ function getSchema(checkStyle) {
45
34
var parameterKeys = {
46
35
'in' : Joi . string ( ) . valid ( 'query' , 'header' ) ,
47
36
format : Joi . string ( ) ,
37
+ $ref : Joi . string ( ) ,
48
38
type : Joi . string ( ) ,
49
39
description : Joi . string ( ) ,
50
40
required : Joi . boolean ( ) ,
@@ -61,11 +51,11 @@ function getSchema(checkStyle) {
61
51
version : Joi . string ( )
62
52
} ) ,
63
53
host : joiRegex ( checkStyle . host ) ,
64
- scheme : joiRegex ( checkStyle . schemes ) ,
54
+ scheme : joiRegex ( checkStyle . scheme ) ,
65
55
basePath : joiRegex ( checkStyle . basePath ) ,
66
56
produces : Joi . array ( ) . items ( joiRegex ( checkStyle . produces ) ) ,
67
57
consumes : Joi . array ( ) . items ( joiRegex ( checkStyle . consumes ) ) ,
68
- schemes : Joi . array ( ) . items ( joiRegex ( checkStyle . schemes ) ) ,
58
+ schemes : Joi . array ( ) . items ( joiRegex ( checkStyle . scheme ) ) ,
69
59
paths : Joi . object ( ) . pattern ( pathConvention ,
70
60
Joi . object ( ) . pattern ( verbs , Joi . object ( ) . keys ( {
71
61
summary : Joi . any ( ) ,
@@ -94,8 +84,8 @@ function validate(checkStyleFile, specFile, callback) {
94
84
} ) . spread ( function ( spec , schema , callback ) {
95
85
return Joi . validate ( spec , schema ) ;
96
86
} ) . then ( function ( result ) {
97
- callback ( result , null ) ;
87
+ callback ( null , result ) ;
98
88
} ) . catch ( function ( e ) {
99
- callback ( null , e ) ;
89
+ callback ( e ) ;
100
90
} ) ;
101
91
}
0 commit comments