Pārlūkot izejas kodu

added exception handling, updated client

bubble
Tony Tam pirms 10 gadiem
vecāks
revīzija
b0eff2d78b
6 mainītis faili ar 30 papildinājumiem un 7 dzēšanām
  1. +0
    -1
      dist/index.html
  2. +7
    -1
      dist/lib/swagger-client.js
  3. +9
    -2
      dist/swagger-ui.js
  4. +1
    -1
      dist/swagger-ui.min.js
  5. +7
    -1
      lib/swagger-client.js
  6. +6
    -1
      src/main/coffeescript/view/OperationView.coffee

+ 0
- 1
dist/index.html Parādīt failu

@@ -22,7 +22,6 @@
<!-- enabling this will enable oauth2 implicit scope support -->
<script src='lib/swagger-oauth.js' type='text/javascript'></script>
<script src='spec.js' type='text/javascript'></script>
<script type="text/javascript">
$(function () {
var url = window.location.search.match(/url=([^&]+)/);


+ 7
- 1
dist/lib/swagger-client.js Parādīt failu

@@ -673,6 +673,7 @@ Operation.prototype.execute = function(arg1, arg2, arg3, arg4, parent) {
var obj = {
url: url,
method: this.method,
body: args.body,
useJQuery: this.useJQuery,
headers: headers,
on: {
@@ -1318,7 +1319,12 @@ ShredHttpClient.prototype.execute = function(obj) {
if(contentType != null) {
if(contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) {
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
out.obj = {}
}


+ 9
- 2
dist/swagger-ui.js Parādīt failu

@@ -2080,7 +2080,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
};

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) {
content = response.data;
url = response.url;
@@ -2094,7 +2094,14 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
code = $('<code />').text("no content");
pre = $('<pre class="json" />').append(code);
} 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);
} else if (contentType === "application/xml" || /\+xml$/.test(contentType)) {
code = $('<code />').text(this.formatXml(content));


+ 1
- 1
dist/swagger-ui.min.js
Failā izmaiņas netiks attēlotas, jo tās ir par lielu
Parādīt failu


+ 7
- 1
lib/swagger-client.js Parādīt failu

@@ -673,6 +673,7 @@ Operation.prototype.execute = function(arg1, arg2, arg3, arg4, parent) {
var obj = {
url: url,
method: this.method,
body: args.body,
useJQuery: this.useJQuery,
headers: headers,
on: {
@@ -1318,7 +1319,12 @@ ShredHttpClient.prototype.execute = function(obj) {
if(contentType != null) {
if(contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) {
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
out.obj = {}
}


+ 6
- 1
src/main/coffeescript/view/OperationView.coffee Parādīt failu

@@ -366,7 +366,12 @@ class OperationView extends Backbone.View
code = $('<code />').text("no content")
pre = $('<pre class="json" />').append(code)
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)
else if contentType is "application/xml" || /\+xml$/.test(contentType)
code = $('<code />').text(@formatXml(content))


Notiek ielāde…
Atcelt
Saglabāt