Skip to content

Commit 0e84b91

Browse files
committed
cleaned up content-type detection
1 parent 2f9ebe1 commit 0e84b91

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

lib/swagger.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -281,12 +281,13 @@ var SwaggerResource = function(resourceObj, api) {
281281
accept: "application/json"
282282
},
283283
on: {
284-
error: function(response) {
285-
return _this.api.fail("Unable to read api '" + _this.name + "' from path " + _this.url + " (server returned " + response.statusText + ")");
286-
},
287284
response: function(response) {
288285
var responseObj = response.obj;
289286
return _this.addApiDeclaration(responseObj);
287+
},
288+
error: function(response) {
289+
return _this.api.fail("Unable to read api '" +
290+
_this.name + "' from path " + _this.url + " (server returned " + response.statusText + ")");
290291
}
291292
}
292293
};
@@ -552,7 +553,7 @@ SwaggerModelProperty.prototype.toSampleValue = function(value) {
552553
result = 0;
553554
} else if (value === "boolean") {
554555
result = false;
555-
} else if (value === "double") {
556+
} else if (value === "double" || value === "number") {
556557
result = 0.0;
557558
} else if (value === "string") {
558559
result = "";
@@ -563,9 +564,8 @@ SwaggerModelProperty.prototype.toSampleValue = function(value) {
563564
};
564565

565566
SwaggerModelProperty.prototype.toString = function() {
566-
var req, str;
567-
req = this.required ? 'propReq' : 'propOpt';
568-
str = '<span class="propName ' + req + '">' + this.name + '</span> (<span class="propType">' + this.dataTypeWithRef + '</span>';
567+
var req = this.required ? 'propReq' : 'propOpt';
568+
var str = '<span class="propName ' + req + '">' + this.name + '</span> (<span class="propType">' + this.dataTypeWithRef + '</span>';
569569
if (!this.required) {
570570
str += ', <span class="propOptKey">optional</span>';
571571
}
@@ -580,8 +580,7 @@ SwaggerModelProperty.prototype.toString = function() {
580580
};
581581

582582
var SwaggerOperation = function(nickname, path, method, parameters, summary, notes, type, responseMessages, resource, consumes, produces, authorizations) {
583-
var parameter, v, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3,
584-
_this = this;
583+
var _this = this;
585584

586585
var errors = [];
587586
this.nickname = (nickname||errors.push("SwaggerOperations must have a nickname."));
@@ -1184,8 +1183,10 @@ ShredHttpClient.prototype.execute = function(obj) {
11841183
data: response.content.data
11851184
};
11861185

1187-
if(response._headers["Content-Type"]) {
1188-
if(response._headers["Content-Type"].indexOf("application/json") == 0) {
1186+
var contentType = (response._headers["content-type"]||response._headers["Content-Type"]||null)
1187+
1188+
if(contentType != null) {
1189+
if(contentType.indexOf("application/json") == 0) {
11891190
if(response.content.data !== "")
11901191
out.obj = JSON.parse(response.content.data);
11911192
else

0 commit comments

Comments
 (0)