@@ -350,8 +350,8 @@ SwaggerResource.prototype.addModels = function(models) {
350350 }
351351 }
352352 var output = [ ] ;
353- for ( var i = 0 ; i < this . modelsArray ; i ++ ) {
354- model = this . modelsArray [ _i ] ;
353+ for ( var i = 0 ; i < this . modelsArray . length ; i ++ ) {
354+ model = this . modelsArray [ i ] ;
355355 output . push ( model . setReferencedModels ( this . models ) ) ;
356356 }
357357 return output ;
@@ -450,7 +450,7 @@ var SwaggerModel = function(modelName, obj) {
450450
451451SwaggerModel . prototype . setReferencedModels = function ( allModels ) {
452452 var results = [ ] ;
453- for ( i = 0 ; i < this . properties . length ; i ++ ) {
453+ for ( var i = 0 ; i < this . properties . length ; i ++ ) {
454454 var property = this . properties [ i ] ;
455455 var type = property . type || property . dataType ;
456456 if ( allModels [ type ] != null )
@@ -465,7 +465,7 @@ SwaggerModel.prototype.setReferencedModels = function(allModels) {
465465
466466SwaggerModel . prototype . getMockSignature = function ( modelsToIgnore ) {
467467 var propertiesStr = [ ] ;
468- for ( i = 0 ; i < this . properties . length ; i ++ ) {
468+ for ( var i = 0 ; i < this . properties . length ; i ++ ) {
469469 prop = this . properties [ i ] ;
470470 propertiesStr . push ( prop . toString ( ) ) ;
471471 }
@@ -480,7 +480,7 @@ SwaggerModel.prototype.getMockSignature = function(modelsToIgnore) {
480480 modelsToIgnore = [ ] ;
481481 modelsToIgnore . push ( this ) ;
482482
483- for ( i = 0 ; i < this . properties . length ; i ++ ) {
483+ for ( var i = 0 ; i < this . properties . length ; i ++ ) {
484484 prop = this . properties [ i ] ;
485485 if ( ( prop . refModel != null ) && modelsToIgnore . indexOf ( prop . refModel ) === - 1 ) {
486486 returnVal = returnVal + ( '<br>' + prop . refModel . getMockSignature ( modelsToIgnore ) ) ;
@@ -493,7 +493,7 @@ SwaggerModel.prototype.createJSONSample = function(modelsToIgnore) {
493493 var result = { } ;
494494 var modelsToIgnore = ( modelsToIgnore || [ ] )
495495 modelsToIgnore . push ( this . name ) ;
496- for ( i = 0 ; i < this . properties . length ; i ++ ) {
496+ for ( var i = 0 ; i < this . properties . length ; i ++ ) {
497497 prop = this . properties [ i ] ;
498498 result [ prop . name ] = prop . getSampleValue ( modelsToIgnore ) ;
499499 }
@@ -534,7 +534,7 @@ var SwaggerModelProperty = function(name, obj) {
534534
535535SwaggerModelProperty . prototype . getSampleValue = function ( modelsToIgnore ) {
536536 var result ;
537- if ( ( this . refModel != null ) && ( modelsToIgnore [ this . refModel . name ] === ' undefined' ) ) {
537+ if ( ( this . refModel != null ) && ( modelsToIgnore [ this . refModel . name ] === undefined ) ) {
538538 result = this . refModel . createJSONSample ( modelsToIgnore ) ;
539539 } else {
540540 if ( this . isCollection ) {
@@ -615,7 +615,7 @@ var SwaggerOperation = function(nickname, path, method, parameters, summary, not
615615 this . responseSampleJSON = this . getSampleJSON ( this . type , this . resource . models ) ;
616616 }
617617
618- for ( i = 0 ; i < this . parameters . length ; i ++ ) {
618+ for ( var i = 0 ; i < this . parameters . length ; i ++ ) {
619619 var param = this . parameters [ i ] ;
620620 // might take this away
621621 param . name = param . name || param . type || param . dataType ;
@@ -763,7 +763,7 @@ SwaggerOperation.prototype["do"] = function(args, opts, callback, error) {
763763 }
764764
765765 var possibleParams = [ ] ;
766- for ( i = 0 ; i < this . parameters . length ; i ++ ) {
766+ for ( var i = 0 ; i < this . parameters . length ; i ++ ) {
767767 var param = this . parameters [ i ] ;
768768 if ( param . paramType === 'header' ) {
769769 if ( args [ param . name ] )
@@ -806,7 +806,7 @@ SwaggerOperation.prototype.pathXml = function() {
806806SwaggerOperation . prototype . urlify = function ( args ) {
807807 var url = this . resource . basePath + this . pathJson ( ) ;
808808 var params = this . parameters ;
809- for ( i = 0 ; i < params . length ; i ++ ) {
809+ for ( var i = 0 ; i < params . length ; i ++ ) {
810810 var param = params [ i ] ;
811811 if ( param . paramType === 'path' ) {
812812 if ( args [ param . name ] ) {
@@ -821,7 +821,7 @@ SwaggerOperation.prototype.urlify = function(args) {
821821 }
822822
823823 var queryParams = "" ;
824- for ( i = 0 ; i < params . length ; i ++ ) {
824+ for ( var i = 0 ; i < params . length ; i ++ ) {
825825 var param = params [ i ] ;
826826 if ( param . paramType === 'query' ) {
827827 if ( queryParams !== '' )
@@ -853,7 +853,7 @@ SwaggerOperation.prototype.getHeaderParams = function(args) {
853853SwaggerOperation . prototype . getMatchingParams = function ( paramTypes , args ) {
854854 var matchingParams = { } ;
855855 var params = this . parameters ;
856- for ( i = 0 ; i < params . length ; i ++ ) {
856+ for ( var i = 0 ; i < params . length ; i ++ ) {
857857 param = params [ i ] ;
858858 if ( args && args [ param . name ] )
859859 matchingParams [ param . name ] = args [ param . name ] ;
@@ -869,7 +869,7 @@ SwaggerOperation.prototype.getMatchingParams = function(paramTypes, args) {
869869SwaggerOperation . prototype . help = function ( ) {
870870 var msg = "" ;
871871 var params = this . parameters ;
872- for ( i = 0 ; i < params . length ; i ++ ) {
872+ for ( var i = 0 ; i < params . length ; i ++ ) {
873873 var param = params [ i ] ;
874874 if ( msg !== "" )
875875 msg += "\n" ;
@@ -908,7 +908,7 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
908908 var params = this . operation . parameters ;
909909
910910
911- for ( i = 0 ; i < params . length ; i ++ ) {
911+ for ( var i = 0 ; i < params . length ; i ++ ) {
912912 var param = params [ i ] ;
913913 if ( param . paramType === "form" )
914914 formParams . push ( param ) ;
@@ -958,7 +958,7 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
958958 var possibleParams = { } ;
959959 var values = { } ;
960960
961- for ( i = 0 ; i < formParams . length ; i ++ ) {
961+ for ( var i = 0 ; i < formParams . length ; i ++ ) {
962962 var param = formParams [ i ] ;
963963 values [ param . name ] = param ;
964964 }
@@ -1095,7 +1095,7 @@ JQueryHttpClient.prototype.execute = function(obj) {
10951095 headers = { } ;
10961096 headerArray = response . getAllResponseHeaders ( ) . split ( ":" ) ;
10971097
1098- for ( i = 0 ; i < headerArray . length / 2 ; i ++ )
1098+ for ( var i = 0 ; i < headerArray . length / 2 ; i ++ )
10991099 headers [ headerArray [ i ] = headerArray [ i + 1 ] ] ;
11001100
11011101 out = {
@@ -1107,9 +1107,15 @@ JQueryHttpClient.prototype.execute = function(obj) {
11071107 headers : headers
11081108 } ;
11091109
1110- if ( response . _headers [ "Content-Type" ] && response . _headers [ "Content-Type" ] . indexOf ( "application/json" ) == 0 &&
1111- response . content . data && response . content . data !== "" ) {
1112- out . obj = JSON . parse ( response . responseText ) ;
1110+ var contentType = ( response . _headers [ "content-type" ] || response . _headers [ "Content-Type" ] || null )
1111+
1112+ if ( contentType != null ) {
1113+ if ( contentType . indexOf ( "application/json" ) == 0 || contentType . indexOf ( "+json" ) > 0 ) {
1114+ if ( response . responseText && response . responseText !== "" )
1115+ out . obj = JSON . parse ( response . responseText ) ;
1116+ else
1117+ out . obj = { }
1118+ }
11131119 }
11141120
11151121 if ( response . status >= 200 && response . status < 300 )
@@ -1186,7 +1192,7 @@ ShredHttpClient.prototype.execute = function(obj) {
11861192 var contentType = ( response . _headers [ "content-type" ] || response . _headers [ "Content-Type" ] || null )
11871193
11881194 if ( contentType != null ) {
1189- if ( contentType . indexOf ( "application/json" ) == 0 ) {
1195+ if ( contentType . indexOf ( "application/json" ) == 0 || contentType . indexOf ( "+json" ) > 0 ) {
11901196 if ( response . content . data && response . content . data !== "" )
11911197 out . obj = JSON . parse ( response . content . data ) ;
11921198 else
0 commit comments