@@ -65,15 +65,15 @@ var getViewForSwagger2 = function(opts, type){
65
65
}
66
66
var secureTypes = [ ] ;
67
67
if ( swagger . securityDefinitions !== undefined || op . security !== undefined ) {
68
- var mergedSecurity = _ . merge ( [ ] , swagger . security , op . security ) . map ( function ( security ) {
69
- return Object . keys ( security ) ;
68
+ var mergedSecurity = _ . merge ( [ ] , swagger . security , op . security ) . map ( function ( security ) {
69
+ return Object . keys ( security ) ;
70
70
} ) ;
71
- if ( swagger . securityDefinitions ) {
72
- for ( var sk in swagger . securityDefinitions ) {
71
+ if ( swagger . securityDefinitions ) {
72
+ for ( var sk in swagger . securityDefinitions ) {
73
73
if ( mergedSecurity . join ( ',' ) . indexOf ( sk ) !== - 1 ) {
74
- secureTypes . push ( swagger . securityDefinitions [ sk ] . type ) ;
74
+ secureTypes . push ( swagger . securityDefinitions [ sk ] . type ) ;
75
75
}
76
- }
76
+ }
77
77
}
78
78
}
79
79
var methodName = ( op . operationId ? normalizeName ( op . operationId ) : getPathToMethodName ( opts , m , path ) ) ;
@@ -101,22 +101,22 @@ var getViewForSwagger2 = function(opts, type){
101
101
summary : op . description || op . summary ,
102
102
externalDocs : op . externalDocs ,
103
103
isSecure : swagger . security !== undefined || op . security !== undefined ,
104
- isSecureToken : secureTypes . indexOf ( 'oauth2' ) !== - 1 ,
105
- isSecureApiKey : secureTypes . indexOf ( 'apiKey' ) !== - 1 ,
106
- isSecureBasic : secureTypes . indexOf ( 'basic' ) !== - 1 ,
104
+ isSecureToken : secureTypes . indexOf ( 'oauth2' ) !== - 1 ,
105
+ isSecureApiKey : secureTypes . indexOf ( 'apiKey' ) !== - 1 ,
106
+ isSecureBasic : secureTypes . indexOf ( 'basic' ) !== - 1 ,
107
107
parameters : [ ] ,
108
108
headers : [ ]
109
109
} ;
110
- if ( method . isSecure && method . isSecureToken ) {
111
- data . isSecureToken = method . isSecureToken ;
112
- }
113
- if ( method . isSecure && method . isSecureApiKey ) {
114
- data . isSecureApiKey = method . isSecureApiKey ;
115
- }
116
- if ( method . isSecure && method . isSecureBasic ) {
117
- data . isSecureBasic = method . isSecureBasic ;
118
- }
119
- var produces = op . produces || swagger . produces ;
110
+ if ( method . isSecure && method . isSecureToken ) {
111
+ data . isSecureToken = method . isSecureToken ;
112
+ }
113
+ if ( method . isSecure && method . isSecureApiKey ) {
114
+ data . isSecureApiKey = method . isSecureApiKey ;
115
+ }
116
+ if ( method . isSecure && method . isSecureBasic ) {
117
+ data . isSecureBasic = method . isSecureBasic ;
118
+ }
119
+ var produces = op . produces || swagger . produces ;
120
120
if ( produces ) {
121
121
method . headers . push ( {
122
122
name : 'Accept' ,
@@ -277,31 +277,30 @@ var getCode = function(opts, type) {
277
277
}
278
278
279
279
var source = Mustache . render ( opts . template . class , data , opts . template ) ;
280
- var lintOptions = {
281
- node : type === 'node' || type === 'custom' ,
282
- browser : type === 'angular' || type === 'custom' || type === 'react' ,
283
- undef : true ,
284
- strict : true ,
285
- trailing : true ,
286
- smarttabs : true ,
287
- maxerr : 999
288
- } ;
289
- if ( opts . esnext ) {
290
- lintOptions . esnext = true ;
291
- }
292
280
293
- if ( type === 'typescript' ) {
281
+ if ( type === 'typescript' ) {
294
282
opts . lint = false ;
295
283
}
296
284
297
- if ( opts . lint === undefined || opts . lint === true ) {
285
+ if ( opts . lint || opts . lint === undefined ) {
286
+ var lintOptions = _ . merge ( {
287
+ node : type === 'node' || type === 'custom' ,
288
+ browser : type === 'angular' || type === 'custom' || type === 'react' ,
289
+ undef : true ,
290
+ strict : true ,
291
+ trailing : true ,
292
+ smarttabs : true ,
293
+ esnext = Boolean ( opts . next ) ,
294
+ maxerr : 999
295
+ } , _ . isObject ( opts . lint ) ? opts . lint : { } ) ;
298
296
lint ( source , lintOptions ) ;
299
297
lint . errors . forEach ( function ( error ) {
300
298
if ( error . code [ 0 ] === 'E' ) {
301
299
throw new Error ( error . reason + ' in ' + error . evidence + ' (' + error . code + ')' ) ;
302
300
}
303
301
} ) ;
304
302
}
303
+
305
304
if ( opts . beautify === undefined || opts . beautify === true ) {
306
305
return beautify ( source , { indent_size : 4 , max_preserve_newlines : 2 } ) ;
307
306
} else {
0 commit comments