#254 alphabetical sort of apis and operations under apis
new option sortAlphabetical=true|false
This commit is contained in:
@@ -55,7 +55,7 @@ class SwaggerUi extends Backbone.Router
|
|||||||
# so it gets called when SwaggerApi completes loading
|
# so it gets called when SwaggerApi completes loading
|
||||||
render:() ->
|
render:() ->
|
||||||
@showMessage('Finished Loading Resource Information. Rendering Swagger UI...')
|
@showMessage('Finished Loading Resource Information. Rendering Swagger UI...')
|
||||||
@mainView = new MainView({model: @api, el: $('#' + @dom_id)}).render()
|
@mainView = new MainView({model: @api, el: $('#' + @dom_id), swaggerOptions: @options}).render()
|
||||||
@showMessage()
|
@showMessage()
|
||||||
switch @options.docExpansion
|
switch @options.docExpansion
|
||||||
when "full" then Docs.expandOperationsForResource('')
|
when "full" then Docs.expandOperationsForResource('')
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
class MainView extends Backbone.View
|
class MainView extends Backbone.View
|
||||||
initialize: ->
|
initialize: (opts={}) ->
|
||||||
|
if opts.swaggerOptions.sortAlphabetically == true
|
||||||
|
pathSorter = (a,b) -> return a.path.localeCompare(b.path)
|
||||||
|
# sort apis
|
||||||
|
@model.apisArray.sort pathSorter
|
||||||
|
# sort operations
|
||||||
|
for route in @model.apisArray
|
||||||
|
route.operationsArray.sort pathSorter
|
||||||
|
|
||||||
render: ->
|
render: ->
|
||||||
# Render the outer container for resources
|
# Render the outer container for resources
|
||||||
@@ -10,6 +17,7 @@ class MainView extends Backbone.View
|
|||||||
resources = {}
|
resources = {}
|
||||||
counter = 0
|
counter = 0
|
||||||
for resource in @model.apisArray
|
for resource in @model.apisArray
|
||||||
|
console.info(resource);
|
||||||
id = resource.name
|
id = resource.name
|
||||||
while typeof resources[id] isnt 'undefined'
|
while typeof resources[id] isnt 'undefined'
|
||||||
id = id + "_" + counter
|
id = id + "_" + counter
|
||||||
|
|||||||
@@ -47,7 +47,8 @@
|
|||||||
onFailure: function(data) {
|
onFailure: function(data) {
|
||||||
log("Unable to Load SwaggerUI");
|
log("Unable to Load SwaggerUI");
|
||||||
},
|
},
|
||||||
docExpansion: "none"
|
docExpansion: "none",
|
||||||
|
sortAlphabetically: true
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#input_apiKey').change(function() {
|
$('#input_apiKey').change(function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user