|
1 | 1 | // swagger-ui.js |
2 | | -// version 2.0.17 |
| 2 | +// version 2.0.18 |
3 | 3 | $(function() { |
4 | 4 |
|
5 | 5 | // Helper function for vertically aligning DOM elements |
@@ -1298,7 +1298,8 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; |
1298 | 1298 | this.showMessage('Finished Loading Resource Information. Rendering Swagger UI...'); |
1299 | 1299 | this.mainView = new MainView({ |
1300 | 1300 | model: this.api, |
1301 | | - el: $('#' + this.dom_id) |
| 1301 | + el: $('#' + this.dom_id), |
| 1302 | + swaggerOptions: this.options |
1302 | 1303 | }).render(); |
1303 | 1304 | this.showMessage(); |
1304 | 1305 | switch (this.options.docExpansion) { |
@@ -1443,14 +1444,42 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; |
1443 | 1444 | })(Backbone.View); |
1444 | 1445 |
|
1445 | 1446 | MainView = (function(_super) { |
| 1447 | + var sorters; |
| 1448 | + |
1446 | 1449 | __extends(MainView, _super); |
1447 | 1450 |
|
1448 | 1451 | function MainView() { |
1449 | 1452 | _ref2 = MainView.__super__.constructor.apply(this, arguments); |
1450 | 1453 | return _ref2; |
1451 | 1454 | } |
1452 | 1455 |
|
1453 | | - MainView.prototype.initialize = function() {}; |
| 1456 | + sorters = { |
| 1457 | + 'alpha': function(a, b) { |
| 1458 | + return a.path.localeCompare(b.path); |
| 1459 | + }, |
| 1460 | + 'method': function(a, b) { |
| 1461 | + return a.method.localeCompare(b.method); |
| 1462 | + } |
| 1463 | + }; |
| 1464 | + |
| 1465 | + MainView.prototype.initialize = function(opts) { |
| 1466 | + var route, sorter, sorterName, _i, _len, _ref3; |
| 1467 | + if (opts == null) { |
| 1468 | + opts = {}; |
| 1469 | + } |
| 1470 | + if (opts.swaggerOptions.sorter) { |
| 1471 | + sorterName = opts.swaggerOptions.sorter; |
| 1472 | + sorter = sorters[sorterName]; |
| 1473 | + _ref3 = this.model.apisArray; |
| 1474 | + for (_i = 0, _len = _ref3.length; _i < _len; _i++) { |
| 1475 | + route = _ref3[_i]; |
| 1476 | + route.operationsArray.sort(sorter); |
| 1477 | + } |
| 1478 | + if (sorterName === "alpha") { |
| 1479 | + return this.model.apisArray.sort(sorter); |
| 1480 | + } |
| 1481 | + } |
| 1482 | + }; |
1454 | 1483 |
|
1455 | 1484 | MainView.prototype.render = function() { |
1456 | 1485 | var counter, id, resource, resources, _i, _len, _ref3; |
@@ -1563,8 +1592,8 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; |
1563 | 1592 | OperationView.prototype.mouseEnter = function(e) { |
1564 | 1593 | var elem, hgh, pos, scMaxX, scMaxY, scX, scY, wd, x, y; |
1565 | 1594 | elem = $(e.currentTarget.parentNode).find('#api_information_panel'); |
1566 | | - x = event.pageX; |
1567 | | - y = event.pageY; |
| 1595 | + x = e.pageX; |
| 1596 | + y = e.pageY; |
1568 | 1597 | scX = $(window).scrollLeft(); |
1569 | 1598 | scY = $(window).scrollTop(); |
1570 | 1599 | scMaxX = scX + $(window).width(); |
@@ -1992,7 +2021,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; |
1992 | 2021 | $(".request_url", $(this.el)).html("<pre>" + url + "</pre>"); |
1993 | 2022 | $(".response_code", $(this.el)).html("<pre>" + response.status + "</pre>"); |
1994 | 2023 | $(".response_body", $(this.el)).html(response_body); |
1995 | | - $(".response_headers", $(this.el)).html("<pre>" + JSON.stringify(response.headers, null, " ").replace(/\n/g, "<br>") + "</pre>"); |
| 2024 | + $(".response_headers", $(this.el)).html("<pre>" + _.escape(JSON.stringify(response.headers, null, " ")).replace(/\n/g, "<br>") + "</pre>"); |
1996 | 2025 | $(".response", $(this.el)).slideDown(); |
1997 | 2026 | $(".response_hider", $(this.el)).show(); |
1998 | 2027 | $(".response_throbber", $(this.el)).hide(); |
@@ -2200,9 +2229,9 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; |
2200 | 2229 | var template; |
2201 | 2230 | template = this.template(); |
2202 | 2231 | $(this.el).html(template(this.model)); |
2203 | | - this.switchToDescription(); |
2204 | | - $('.description-link', $(this.el)).removeClass('selected'); |
2205 | | - $(".description", $(this.el)).hide(); |
| 2232 | + this.switchToSnippet(); |
| 2233 | + $('.snippet-link', $(this.el)).removeClass('selected'); |
| 2234 | + $(".snippet", $(this.el)).hide(); |
2206 | 2235 | this.isParam = this.model.isParam; |
2207 | 2236 | if (this.isParam) { |
2208 | 2237 | $('.notice', $(this.el)).text('Click to set as parameter value'); |
|
0 commit comments