Merge branch 'develop_2.0' into JSONEditor

Conflicts:
	dist/index.html
	dist/swagger-ui.js
	dist/swagger-ui.min.js
This commit is contained in:
laurent lepinay
2015-03-27 02:15:29 -07:00
23 changed files with 162 additions and 37839 deletions

View File

@@ -1,21 +1,48 @@
'use strict';
SwaggerUi.Views.MainView = Backbone.View.extend({
// TODO: sorters were not used in any place, do we need them?
// sorters = {
// alpha : function(a,b){ return a.path.localeCompare(b.path); },
// method : function(a,b){ return a.method.localeCompare(b.method); },
// },
apisSorter : {
alpha : function(a,b){ return a.name.localeCompare(b.name); }
},
operationsSorters : {
alpha : function(a,b){ return a.path.localeCompare(b.path); },
method : function(a,b){ return a.method.localeCompare(b.method); }
},
initialize: function(opts){
var sorterOption, sorterFn, key, value;
opts = opts || {};
this.router = opts.router;
// Sort APIs
if (opts.swaggerOptions.apisSorter) {
sorterOption = opts.swaggerOptions.apisSorter;
if (_.isFunction(sorterOption)) {
sorterFn = sorterOption;
} else {
sorterFn = this.apisSorter[sorterOption];
}
if (_.isFunction(sorterFn)) {
this.model.apisArray.sort(sorterFn);
}
}
// Sort operations of each API
if (opts.swaggerOptions.operationsSorter) {
sorterOption = opts.swaggerOptions.operationsSorter;
if (_.isFunction(sorterOption)) {
sorterFn = sorterOption;
} else {
sorterFn = this.operationsSorters[sorterOption];
}
if (_.isFunction(sorterFn)) {
for (key in this.model.apisArray) {
this.model.apisArray[key].operationsArray.sort(sorterFn);
}
}
}
// set up the UI for input
this.model.auths = [];
var key, value;
for (key in this.model.securityDefinitions) {
value = this.model.securityDefinitions[key];
@@ -122,4 +149,4 @@ SwaggerUi.Views.MainView = Backbone.View.extend({
clear: function(){
$(this.el).html('');
}
});
});