This commit is contained in:
Tony Tam
2014-12-09 22:25:29 -08:00
parent 886145be28
commit f1e394b3c9
2 changed files with 26 additions and 12 deletions

View File

@@ -1,5 +1,5 @@
// swagger-client.js
// version 2.1.0-alpha.3
// version 2.1.0-alpha.4
/**
* Array Model
**/
@@ -936,7 +936,7 @@ Operation.prototype.setContentTypes = function(args, opts) {
}
// if there's a body, need to set the accepts header via requestContentType
if (body && (this.type === 'post' || this.type === 'put' || this.type === 'patch' || this.type === 'delete')) {
if (body && (this.method === 'post' || this.method === 'put' || this.method === 'patch' || this.method === 'delete')) {
if (opts.requestContentType)
consumes = opts.requestContentType;
} else {
@@ -1379,8 +1379,15 @@ JQueryHttpClient.prototype.execute = function(obj) {
if(contentType != null) {
if(contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) {
if(response.responseText && response.responseText !== "")
out.obj = JSON.parse(response.responseText);
if(response.responseText && response.responseText !== "") {
try {
out.obj = JSON.parse(response.content.data);
}
catch (ex) {
// do not set out.obj
log ("unable to parse JSON content");
}
}
else
out.obj = {}
}

View File

@@ -1,5 +1,5 @@
// swagger-client.js
// version 2.1.0-alpha.3
// version 2.1.0-alpha.4
/**
* Array Model
**/
@@ -936,7 +936,7 @@ Operation.prototype.setContentTypes = function(args, opts) {
}
// if there's a body, need to set the accepts header via requestContentType
if (body && (this.type === 'post' || this.type === 'put' || this.type === 'patch' || this.type === 'delete')) {
if (body && (this.method === 'post' || this.method === 'put' || this.method === 'patch' || this.method === 'delete')) {
if (opts.requestContentType)
consumes = opts.requestContentType;
} else {
@@ -1379,8 +1379,15 @@ JQueryHttpClient.prototype.execute = function(obj) {
if(contentType != null) {
if(contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) {
if(response.responseText && response.responseText !== "")
out.obj = JSON.parse(response.responseText);
if(response.responseText && response.responseText !== "") {
try {
out.obj = JSON.parse(response.content.data);
}
catch (ex) {
// do not set out.obj
log ("unable to parse JSON content");
}
}
else
out.obj = {}
}