1
1
// swagger-client.js
2
- // version 2.1.0-alpha.3
2
+ // version 2.1.0-alpha.4
3
3
/**
4
4
* Array Model
5
5
**/
@@ -936,7 +936,7 @@ Operation.prototype.setContentTypes = function(args, opts) {
936
936
}
937
937
938
938
// if there's a body, need to set the accepts header via requestContentType
939
- if ( body && ( this . type === 'post' || this . type === 'put' || this . type === 'patch' || this . type === 'delete' ) ) {
939
+ if ( body && ( this . method === 'post' || this . method === 'put' || this . method === 'patch' || this . method === 'delete' ) ) {
940
940
if ( opts . requestContentType )
941
941
consumes = opts . requestContentType ;
942
942
} else {
@@ -1350,7 +1350,7 @@ JQueryHttpClient.prototype.execute = function(obj) {
1350
1350
obj . data = obj . body ;
1351
1351
obj . complete = function ( response , textStatus , opts ) {
1352
1352
var headers = { } ,
1353
- headerArray = response . getAllResponseHeaders ( ) . split ( "\n" ) ;
1353
+ headerArray = response . getAllResponseHeaders ( ) . split ( "\n" ) ;
1354
1354
1355
1355
for ( var i = 0 ; i < headerArray . length ; i ++ ) {
1356
1356
var toSplit = headerArray [ i ] . trim ( ) ;
@@ -1363,7 +1363,7 @@ JQueryHttpClient.prototype.execute = function(obj) {
1363
1363
continue ;
1364
1364
}
1365
1365
var name = toSplit . substring ( 0 , separator ) . trim ( ) ,
1366
- value = toSplit . substring ( separator + 1 ) . trim ( ) ;
1366
+ value = toSplit . substring ( separator + 1 ) . trim ( ) ;
1367
1367
headers [ name ] = value ;
1368
1368
}
1369
1369
@@ -1379,8 +1379,15 @@ JQueryHttpClient.prototype.execute = function(obj) {
1379
1379
1380
1380
if ( contentType != null ) {
1381
1381
if ( contentType . indexOf ( "application/json" ) == 0 || contentType . indexOf ( "+json" ) > 0 ) {
1382
- if ( response . responseText && response . responseText !== "" )
1383
- out . obj = JSON . parse ( response . responseText ) ;
1382
+ if ( response . responseText && response . responseText !== "" ) {
1383
+ try {
1384
+ out . obj = JSON . parse ( response . content . data ) ;
1385
+ }
1386
+ catch ( ex ) {
1387
+ // do not set out.obj
1388
+ log ( "unable to parse JSON content" ) ;
1389
+ }
1390
+ }
1384
1391
else
1385
1392
out . obj = { }
1386
1393
}
0 commit comments