@@ -22,7 +22,6 @@ | |||||
<!-- enabling this will enable oauth2 implicit scope support --> | <!-- enabling this will enable oauth2 implicit scope support --> | ||||
<script src='lib/swagger-oauth.js' type='text/javascript'></script> | <script src='lib/swagger-oauth.js' type='text/javascript'></script> | ||||
<script src='spec.js' type='text/javascript'></script> | |||||
<script type="text/javascript"> | <script type="text/javascript"> | ||||
$(function () { | $(function () { | ||||
var url = window.location.search.match(/url=([^&]+)/); | var url = window.location.search.match(/url=([^&]+)/); | ||||
@@ -673,6 +673,7 @@ Operation.prototype.execute = function(arg1, arg2, arg3, arg4, parent) { | |||||
var obj = { | var obj = { | ||||
url: url, | url: url, | ||||
method: this.method, | method: this.method, | ||||
body: args.body, | |||||
useJQuery: this.useJQuery, | useJQuery: this.useJQuery, | ||||
headers: headers, | headers: headers, | ||||
on: { | on: { | ||||
@@ -1318,7 +1319,12 @@ ShredHttpClient.prototype.execute = function(obj) { | |||||
if(contentType != null) { | if(contentType != null) { | ||||
if(contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) { | if(contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) { | ||||
if(response.content.data && response.content.data !== "") | if(response.content.data && response.content.data !== "") | ||||
out.obj = JSON.parse(response.content.data); | |||||
try{ | |||||
out.obj = JSON.parse(response.content.data); | |||||
} | |||||
catch (e) { | |||||
// unable to parse | |||||
} | |||||
else | else | ||||
out.obj = {} | out.obj = {} | ||||
} | } | ||||
@@ -2080,7 +2080,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; | |||||
}; | }; | ||||
OperationView.prototype.showStatus = function(response) { | OperationView.prototype.showStatus = function(response) { | ||||
var code, content, contentType, headers, opts, pre, response_body, response_body_el, url; | |||||
var code, content, contentType, e, headers, json, opts, pre, response_body, response_body_el, url; | |||||
if (response.content === void 0) { | if (response.content === void 0) { | ||||
content = response.data; | content = response.data; | ||||
url = response.url; | url = response.url; | ||||
@@ -2094,7 +2094,14 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; | |||||
code = $('<code />').text("no content"); | code = $('<code />').text("no content"); | ||||
pre = $('<pre class="json" />').append(code); | pre = $('<pre class="json" />').append(code); | ||||
} else if (contentType === "application/json" || /\+json$/.test(contentType)) { | } else if (contentType === "application/json" || /\+json$/.test(contentType)) { | ||||
code = $('<code />').text(JSON.stringify(JSON.parse(content), null, " ")); | |||||
json = null; | |||||
try { | |||||
json = JSON.stringify(JSON.stringify(JSON.parse(content), null, " ")); | |||||
} catch (_error) { | |||||
e = _error; | |||||
json = "can't parse JSON. Raw result:\n\n" + content; | |||||
} | |||||
code = $('<code />').text(json); | |||||
pre = $('<pre class="json" />').append(code); | pre = $('<pre class="json" />').append(code); | ||||
} else if (contentType === "application/xml" || /\+xml$/.test(contentType)) { | } else if (contentType === "application/xml" || /\+xml$/.test(contentType)) { | ||||
code = $('<code />').text(this.formatXml(content)); | code = $('<code />').text(this.formatXml(content)); | ||||
@@ -673,6 +673,7 @@ Operation.prototype.execute = function(arg1, arg2, arg3, arg4, parent) { | |||||
var obj = { | var obj = { | ||||
url: url, | url: url, | ||||
method: this.method, | method: this.method, | ||||
body: args.body, | |||||
useJQuery: this.useJQuery, | useJQuery: this.useJQuery, | ||||
headers: headers, | headers: headers, | ||||
on: { | on: { | ||||
@@ -1318,7 +1319,12 @@ ShredHttpClient.prototype.execute = function(obj) { | |||||
if(contentType != null) { | if(contentType != null) { | ||||
if(contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) { | if(contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) { | ||||
if(response.content.data && response.content.data !== "") | if(response.content.data && response.content.data !== "") | ||||
out.obj = JSON.parse(response.content.data); | |||||
try{ | |||||
out.obj = JSON.parse(response.content.data); | |||||
} | |||||
catch (e) { | |||||
// unable to parse | |||||
} | |||||
else | else | ||||
out.obj = {} | out.obj = {} | ||||
} | } | ||||
@@ -366,7 +366,12 @@ class OperationView extends Backbone.View | |||||
code = $('<code />').text("no content") | code = $('<code />').text("no content") | ||||
pre = $('<pre class="json" />').append(code) | pre = $('<pre class="json" />').append(code) | ||||
else if contentType is "application/json" || /\+json$/.test(contentType) | else if contentType is "application/json" || /\+json$/.test(contentType) | ||||
code = $('<code />').text(JSON.stringify(JSON.parse(content), null, " ")) | |||||
json = null | |||||
try | |||||
json = JSON.stringify(JSON.stringify(JSON.parse(content), null, " ")) | |||||
catch e | |||||
json = "can't parse JSON. Raw result:\n\n" + content | |||||
code = $('<code />').text(json) | |||||
pre = $('<pre class="json" />').append(code) | pre = $('<pre class="json" />').append(code) | ||||
else if contentType is "application/xml" || /\+xml$/.test(contentType) | else if contentType is "application/xml" || /\+xml$/.test(contentType) | ||||
code = $('<code />').text(@formatXml(content)) | code = $('<code />').text(@formatXml(content)) | ||||