Skip to content

Commit 7bb12e6

Browse files
committed
added checks for empty content
1 parent 0e84b91 commit 7bb12e6

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

lib/swagger.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// swagger.js
2+
// version 2.0.13
3+
14
var __bind = function(fn, me){
25
return function(){
36
return fn.apply(me, arguments);
@@ -940,14 +943,10 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
940943
}
941944

942945
responseContentType = null;
943-
if (this.type === "POST" || this.type === "GET" || this.type === "PATCH") {
944-
if (this.opts.responseContentType) {
945-
responseContentType = this.opts.responseContentType;
946-
} else {
947-
responseContentType = "application/json";
948-
}
946+
if (this.opts.responseContentType) {
947+
responseContentType = this.opts.responseContentType;
949948
} else {
950-
responseContentType = null;
949+
responseContentType = "application/json";
951950
}
952951
if (responseContentType && this.operation.produces) {
953952
if (this.operation.produces[responseContentType] === 'undefined') {
@@ -1108,7 +1107,8 @@ JQueryHttpClient.prototype.execute = function(obj) {
11081107
headers: headers
11091108
};
11101109

1111-
if(response._headers["Content-Type"] && response._headers["Content-Type"].indexOf("application/json") == 0 && response.content.data !== "") {
1110+
if(response._headers["Content-Type"] && response._headers["Content-Type"].indexOf("application/json") == 0 &&
1111+
response.content.data && response.content.data !== "") {
11121112
out.obj = JSON.parse(response.responseText);
11131113
}
11141114

@@ -1187,7 +1187,7 @@ ShredHttpClient.prototype.execute = function(obj) {
11871187

11881188
if(contentType != null) {
11891189
if(contentType.indexOf("application/json") == 0) {
1190-
if(response.content.data !== "")
1190+
if(response.content.data && response.content.data !== "")
11911191
out.obj = JSON.parse(response.content.data);
11921192
else
11931193
out.obj = {}
@@ -1302,4 +1302,4 @@ e.SwaggerOperation = SwaggerOperation;
13021302
e.SwaggerModel = SwaggerModel;
13031303
e.SwaggerModelProperty = SwaggerModelProperty;
13041304
e.SwaggerResource = SwaggerResource;
1305-
e.SwaggerApi = SwaggerApi;
1305+
e.SwaggerApi = SwaggerApi;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
}
99
],
1010
"description": "swagger.js is a javascript client for use with swaggering APIs.",
11-
"version": "2.0.12",
11+
"version": "2.0.13",
1212
"homepage": "http://swagger.wordnik.com",
1313
"repository": {
1414
"type": "git",

0 commit comments

Comments
 (0)