This commit is contained in:
Tony Tam
2014-08-01 17:15:42 -07:00
parent 2de104aac9
commit c17cc1010f
2 changed files with 69 additions and 14 deletions

73
dist/swagger-ui.js vendored
View File

@@ -1,4 +1,5 @@
// swagger-ui.js // swagger-ui.js
// version 2.0.18
$(function() { $(function() {
// Helper function for vertically aligning DOM elements // Helper function for vertically aligning DOM elements
@@ -67,7 +68,7 @@ log = function(){
log.history = log.history || []; log.history = log.history || [];
log.history.push(arguments); log.history.push(arguments);
if(this.console){ if(this.console){
console.log( Array.prototype.slice.call(arguments) ); console.log( Array.prototype.slice.call(arguments)[0] );
} }
}; };
@@ -311,6 +312,23 @@ function program8(depth0,data) {
}); });
})(); })();
(function() {
var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
templates['oauth_view'] = template(function (Handlebars,depth0,helpers,partials,data) {
this.compilerInfo = [4,'>= 1.0.0'];
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;
buffer += "<div class='auth_button' id='oauth_button'><img class='auth_icon' alt='apply api key' src='images/oauth.jpeg'></div>\n<div class='auth_container' id='oauth_container'>\n <div class='key_input_container'>\n <div class='auth_label'>";
if (stack1 = helpers.keyName) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.keyName; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
+ "</div>\n <div class='auth_submit'><a class='auth_submit_button' id=\"apply_basic_auth\" href=\"#\">apply</a></div>\n </div>\n</div>\n";
return buffer;
});
})();
(function() { (function() {
var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
templates['operation'] = template(function (Handlebars,depth0,helpers,partials,data) { templates['operation'] = template(function (Handlebars,depth0,helpers,partials,data) {
@@ -561,13 +579,22 @@ function program9(depth0,data) {
var buffer = "", stack1; var buffer = "", stack1;
buffer += "\n "; buffer += "\n ";
stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(12, program12, data),fn:self.program(10, program10, data),data:data}); stack1 = helpers['if'].call(depth0, depth0.isFile, {hash:{},inverse:self.program(10, program10, data),fn:self.program(2, program2, data),data:data});
if(stack1 || stack1 === 0) { buffer += stack1; } if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n "; buffer += "\n ";
return buffer; return buffer;
} }
function program10(depth0,data) { function program10(depth0,data) {
var buffer = "", stack1;
buffer += "\n ";
stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(13, program13, data),fn:self.program(11, program11, data),data:data});
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n ";
return buffer;
}
function program11(depth0,data) {
var buffer = "", stack1; var buffer = "", stack1;
buffer += "\n <input class='parameter' minlength='0' name='"; buffer += "\n <input class='parameter' minlength='0' name='";
if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
@@ -581,7 +608,7 @@ function program10(depth0,data) {
return buffer; return buffer;
} }
function program12(depth0,data) { function program13(depth0,data) {
var buffer = "", stack1; var buffer = "", stack1;
buffer += "\n <input class='parameter' minlength='0' name='"; buffer += "\n <input class='parameter' minlength='0' name='";
@@ -1288,7 +1315,8 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
this.showMessage('Finished Loading Resource Information. Rendering Swagger UI...'); this.showMessage('Finished Loading Resource Information. Rendering Swagger UI...');
this.mainView = new MainView({ this.mainView = new MainView({
model: this.api, model: this.api,
el: $('#' + this.dom_id) el: $('#' + this.dom_id),
swaggerOptions: this.options
}).render(); }).render();
this.showMessage(); this.showMessage();
switch (this.options.docExpansion) { switch (this.options.docExpansion) {
@@ -1421,6 +1449,8 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
})(Backbone.View); })(Backbone.View);
MainView = (function(_super) { MainView = (function(_super) {
var sorters;
__extends(MainView, _super); __extends(MainView, _super);
function MainView() { function MainView() {
@@ -1428,7 +1458,33 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
return _ref2; return _ref2;
} }
MainView.prototype.initialize = function() {}; sorters = {
'alpha': function(a, b) {
return a.path.localeCompare(b.path);
},
'method': function(a, b) {
return a.method.localeCompare(b.method);
}
};
MainView.prototype.initialize = function(opts) {
var route, sorter, sorterName, _i, _len, _ref3;
if (opts == null) {
opts = {};
}
if (opts.swaggerOptions.sorter) {
sorterName = opts.swaggerOptions.sorter;
sorter = sorters[sorterName];
_ref3 = this.model.apisArray;
for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
route = _ref3[_i];
route.operationsArray.sort(sorter);
}
if (sorterName === "alpha") {
return this.model.apisArray.sort(sorter);
}
}
};
MainView.prototype.render = function() { MainView.prototype.render = function() {
var counter, id, resource, resources, _i, _len, _ref3; var counter, id, resource, resources, _i, _len, _ref3;
@@ -1540,8 +1596,8 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
OperationView.prototype.mouseEnter = function(e) { OperationView.prototype.mouseEnter = function(e) {
var elem, hgh, pos, scMaxX, scMaxY, scX, scY, wd, x, y; var elem, hgh, pos, scMaxX, scMaxY, scX, scY, wd, x, y;
elem = $(e.currentTarget.parentNode).find('#api_information_panel'); elem = $(e.currentTarget.parentNode).find('#api_information_panel');
x = event.pageX; x = e.pageX;
y = event.pageY; y = e.pageY;
scX = $(window).scrollLeft(); scX = $(window).scrollLeft();
scY = $(window).scrollTop(); scY = $(window).scrollTop();
scMaxX = scX + $(window).width(); scMaxX = scX + $(window).width();
@@ -1746,7 +1802,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) { for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) {
param = _ref6[_j]; param = _ref6[_j];
if (param.paramType === 'form') { if (param.paramType === 'form') {
if (map[param.name] !== void 0) { if (param.type.toLowerCase() !== 'file' && map[param.name] !== void 0) {
bodyParam.append(param.name, map[param.name]); bodyParam.append(param.name, map[param.name]);
} }
} }
@@ -1768,7 +1824,6 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
params += 1; params += 1;
} }
} }
log(bodyParam);
this.invocationUrl = this.model.supportHeaderParams() ? (headerParams = this.model.getHeaderParams(map), this.model.urlify(map, false)) : this.model.urlify(map, true); this.invocationUrl = this.model.supportHeaderParams() ? (headerParams = this.model.getHeaderParams(map), this.model.urlify(map, false)) : this.model.urlify(map, true);
$(".request_url", $(this.el)).html("<pre>" + this.invocationUrl + "</pre>"); $(".request_url", $(this.el)).html("<pre>" + this.invocationUrl + "</pre>");
obj = { obj = {

File diff suppressed because one or more lines are too long