fix for #770
This commit is contained in:
15
dist/lib/swagger-client.js
vendored
15
dist/lib/swagger-client.js
vendored
@@ -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 = {}
|
||||
}
|
||||
|
||||
@@ -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 = {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user