@@ -82,10 +82,10 @@ SwaggerAuthorizations.prototype.remove = function(name) {
8282
8383SwaggerAuthorizations . prototype . apply = function ( obj , authorizations ) {
8484 var status = null ;
85- var key , value , result ;
85+ var key , name , value , result ;
8686
8787 // if the "authorizations" key is undefined, or has an empty array, add all keys
88- if ( typeof authorizations === 'undefined' || Object . keys ( authorizations ) . length == 0 ) {
88+ if ( typeof authorizations === 'undefined' || Object . keys ( authorizations ) . length === 0 ) {
8989 for ( key in this . authz ) {
9090 value = this . authz [ key ] ;
9191 result = value . apply ( obj , authorizations ) ;
@@ -280,6 +280,10 @@ PrimitiveModel.prototype.getMockSignature = function(modelsToIgnore) {
280280 }
281281 return returnVal ;
282282} ;
283+ var addModel = function ( name , model ) {
284+ models [ name ] = model ;
285+ } ;
286+
283287var SwaggerClient = function ( url , options ) {
284288 this . isBuilt = false ;
285289 this . url = null ;
@@ -593,18 +597,18 @@ var Operation = function(parent, scheme, operationId, httpMethod, path, args, de
593597 }
594598 }
595599
600+ var i , model ;
601+
596602 if ( definitions ) {
597603 // add to global models
598604 var key ;
599605 for ( key in this . definitions ) {
600- var model = new Model ( key , definitions [ key ] ) ;
606+ model = new Model ( key , definitions [ key ] ) ;
601607 if ( model ) {
602608 models [ key ] = model ;
603609 }
604610 }
605611 }
606-
607- var i ;
608612 for ( i = 0 ; i < this . parameters . length ; i ++ ) {
609613 var param = this . parameters [ i ] ;
610614 if ( param . type === 'array' ) {
@@ -642,7 +646,7 @@ var Operation = function(parent, scheme, operationId, httpMethod, path, args, de
642646 param . responseClassSignature = param . signature ;
643647 }
644648
645- var defaultResponseCode , response , model , responses = this . responses ;
649+ var defaultResponseCode , response , responses = this . responses ;
646650
647651 if ( responses [ '200' ] ) {
648652 response = responses [ '200' ] ;
@@ -996,9 +1000,9 @@ Operation.prototype.execute = function(arg1, arg2, arg3, arg4, parent) {
9961000 var allHeaders = this . getHeaderParams ( args ) ;
9971001 var contentTypeHeaders = this . setContentTypes ( args , opts ) ;
9981002
999- var headers = { } ;
1000- for ( var attrname in allHeaders ) { headers [ attrname ] = allHeaders [ attrname ] ; }
1001- for ( var attrname in contentTypeHeaders ) { headers [ attrname ] = contentTypeHeaders [ attrname ] ; }
1003+ var headers = { } , attrname ;
1004+ for ( attrname in allHeaders ) { headers [ attrname ] = allHeaders [ attrname ] ; }
1005+ for ( attrname in contentTypeHeaders ) { headers [ attrname ] = contentTypeHeaders [ attrname ] ; }
10021006
10031007 var body = this . getBody ( headers , args ) ;
10041008 var url = this . urlify ( args ) ;
@@ -1440,7 +1444,7 @@ Property.prototype.toString = function() {
14401444 type = '' ;
14411445 }
14421446 else {
1443- this . schema . type ;
1447+ type = this . schema . type ;
14441448 }
14451449
14461450 if ( this . default )
@@ -1501,7 +1505,7 @@ Property.prototype.toString = function() {
15011505
15021506optionHtml = function ( label , value ) {
15031507 return '<tr><td class="optionName">' + label + ':</td><td>' + value + '</td></tr>' ;
1504- }
1508+ } ;
15051509
15061510typeFromJsonSchema = function ( type , format ) {
15071511 var str ;
@@ -1534,7 +1538,7 @@ var cookies = {};
15341538var models = { } ;
15351539
15361540SwaggerClient . prototype . buildFrom1_2Spec = function ( response ) {
1537- if ( response . apiVersion != null ) {
1541+ if ( response . apiVersion !== null ) {
15381542 this . apiVersion = response . apiVersion ;
15391543 }
15401544 this . apis = { } ;
@@ -1588,11 +1592,11 @@ SwaggerClient.prototype.finish = function() {
15881592 this . selfReflect ( ) ;
15891593 this . success ( ) ;
15901594 }
1591- }
1595+ } ;
15921596
15931597SwaggerClient . prototype . buildFrom1_1Spec = function ( response ) {
15941598 log ( 'This API is using a deprecated version of Swagger! Please see http://github.com/wordnik/swagger-core/wiki for more info' ) ;
1595- if ( response . apiVersion != null )
1599+ if ( response . apiVersion !== null )
15961600 this . apiVersion = response . apiVersion ;
15971601 this . apis = { } ;
15981602 this . apisArray = [ ] ;
@@ -1638,7 +1642,7 @@ SwaggerClient.prototype.buildFrom1_1Spec = function (response) {
16381642
16391643SwaggerClient . prototype . convertInfo = function ( resp ) {
16401644 if ( typeof resp == 'object' ) {
1641- var info = { }
1645+ var info = { } ;
16421646
16431647 info . title = resp . title ;
16441648 info . description = resp . description ;
@@ -1667,9 +1671,6 @@ SwaggerClient.prototype.selfReflect = function () {
16671671 }
16681672 this . setConsolidatedModels ( ) ;
16691673 this . ready = true ;
1670- if ( typeof this . success === 'function' ) {
1671- return this . success ( ) ;
1672- }
16731674} ;
16741675
16751676SwaggerClient . prototype . setConsolidatedModels = function ( ) {
@@ -2088,7 +2089,7 @@ var SwaggerOperation = function (nickname, path, method, parameters, summary, no
20882089
20892090 this . path = this . path . replace ( '{format}' , 'json' ) ;
20902091 this . method = this . method . toLowerCase ( ) ;
2091- this . isGetMethod = this . method === 'GET ' ;
2092+ this . isGetMethod = this . method === 'get ' ;
20922093
20932094 var i , j , v ;
20942095 this . resourceName = this . resource . name ;
@@ -2139,17 +2140,17 @@ var SwaggerOperation = function (nickname, path, method, parameters, summary, no
21392140 }
21402141 }
21412142 }
2142- else if ( param . allowableValues != null ) {
2143+ else if ( param . allowableValues ) {
21432144 if ( param . allowableValues . valueType === 'RANGE' )
21442145 param . isRange = true ;
21452146 else
21462147 param . isList = true ;
2147- if ( param . allowableValues != null ) {
2148+ if ( param . allowableValues ) {
21482149 param . allowableValues . descriptiveValues = [ ] ;
21492150 if ( param . allowableValues . values ) {
21502151 for ( j = 0 ; j < param . allowableValues . values . length ; j ++ ) {
21512152 v = param . allowableValues . values [ j ] ;
2152- if ( param . defaultValue != null ) {
2153+ if ( param . defaultValue !== null ) {
21532154 param . allowableValues . descriptiveValues . push ( {
21542155 value : String ( v ) ,
21552156 isDefault : ( v === param . defaultValue )
@@ -2219,7 +2220,7 @@ SwaggerOperation.prototype.getSampleJSON = function (type, models) {
22192220 var isPrimitive , listType , val ;
22202221 listType = this . isListType ( type ) ;
22212222 isPrimitive = ( ( typeof listType !== 'undefined' ) && models [ listType ] ) || ( typeof models [ type ] !== 'undefined' ) ? false : true ;
2222- val = isPrimitive ? void 0 : ( listType != null ? models [ listType ] . createJSONSample ( ) : models [ type ] . createJSONSample ( ) ) ;
2223+ val = isPrimitive ? void 0 : ( listType ? models [ listType ] . createJSONSample ( ) : models [ type ] . createJSONSample ( ) ) ;
22232224 if ( val ) {
22242225 val = listType ? [ val ] : val ;
22252226 if ( typeof val == 'string' )
@@ -2254,7 +2255,7 @@ SwaggerOperation.prototype['do'] = function (args, opts, callback, error) {
22542255 callback = function ( response ) {
22552256 var content ;
22562257 content = null ;
2257- if ( response != null ) {
2258+ if ( response !== null ) {
22582259 content = response . data ;
22592260 } else {
22602261 content = 'no data' ;
@@ -2265,7 +2266,7 @@ SwaggerOperation.prototype['do'] = function (args, opts, callback, error) {
22652266
22662267 params = { } ;
22672268 params . headers = [ ] ;
2268- if ( args . headers != null ) {
2269+ if ( args . headers ) {
22692270 params . headers = args . headers ;
22702271 delete args . headers ;
22712272 }
@@ -2386,7 +2387,7 @@ SwaggerOperation.prototype.urlify = function (args) {
23862387 }
23872388 }
23882389 }
2389- if ( ( queryParams != null ) && queryParams . length > 0 )
2390+ if ( ( queryParams ) && queryParams . length > 0 )
23902391 url += '?' + queryParams ;
23912392 return url ;
23922393} ;
@@ -2595,7 +2596,7 @@ var SwaggerRequest = function (type, url, params, opts, successCallback, errorCa
25952596 }
25962597
25972598 var obj ;
2598- if ( ! ( ( this . headers != null ) && ( this . headers . mock != null ) ) ) {
2599+ if ( ! ( ( this . headers ) && ( this . headers . mock ) ) ) {
25992600 obj = {
26002601 url : this . url ,
26012602 method : this . type ,
@@ -2964,7 +2965,9 @@ e.ApiKeyAuthorization = ApiKeyAuthorization;
29642965e . PasswordAuthorization = PasswordAuthorization ;
29652966e . CookieAuthorization = CookieAuthorization ;
29662967e . SwaggerClient = SwaggerClient ;
2968+ e . SwaggerApi = SwaggerClient ;
29672969e . Operation = Operation ;
29682970e . Model = Model ;
2969- e . models = models ;
2971+ e . addModel = addModel ;
2972+
29702973} ) ( ) ;
0 commit comments