provide option sorter=[alpha|method]
This commit is contained in:
@@ -59,6 +59,7 @@ To use swagger-ui you should take a look at the [source of swagger-ui html page]
|
|||||||
* *dom_id parameter* is the the id of a dom element inside which SwaggerUi will put the user interface for swagger
|
* *dom_id parameter* is the the id of a dom element inside which SwaggerUi will put the user interface for swagger
|
||||||
* *booleanValues* SwaggerUI renders boolean data types as a dropdown. By default it provides a 'true' and 'false' string as the possible choices. You can use this parameter to change the values in dropdown to be something else, for example 0 and 1 by setting booleanValues to new Array(0, 1)
|
* *booleanValues* SwaggerUI renders boolean data types as a dropdown. By default it provides a 'true' and 'false' string as the possible choices. You can use this parameter to change the values in dropdown to be something else, for example 0 and 1 by setting booleanValues to new Array(0, 1)
|
||||||
* *docExpansion* controls how the API listing is displayed. It can be set to 'none' (default), 'list' (shows operations for each resource), or 'full' (fully expanded: shows operations and their details)
|
* *docExpansion* controls how the API listing is displayed. It can be set to 'none' (default), 'list' (shows operations for each resource), or 'full' (fully expanded: shows operations and their details)
|
||||||
|
* *sorter* apply a sort to the API list. It can be 'alpha' (sort paths alphanumerically) or 'method' (sort operations by HTTP method). Default is the order returned by the server unchanged.
|
||||||
* *onComplete* is a callback function parameter which can be passed to be notified of when SwaggerUI has completed rendering successfully.
|
* *onComplete* is a callback function parameter which can be passed to be notified of when SwaggerUI has completed rendering successfully.
|
||||||
* *onFailure* is a callback function parameter which can be passed to be notified of when SwaggerUI encountered a failure was unable to render.
|
* *onFailure* is a callback function parameter which can be passed to be notified of when SwaggerUI encountered a failure was unable to render.
|
||||||
* All other parameters are explained in greater detail below
|
* All other parameters are explained in greater detail below
|
||||||
|
|||||||
@@ -1,13 +1,18 @@
|
|||||||
class MainView extends Backbone.View
|
class MainView extends Backbone.View
|
||||||
initialize: (opts={}) ->
|
sorters = {
|
||||||
if opts.swaggerOptions.sortAlphabetically == true
|
'alpha' : (a,b) -> return a.path.localeCompare(b.path),
|
||||||
pathSorter = (a,b) -> return a.path.localeCompare(b.path)
|
'method' : (a,b) -> return a.method.localeCompare(b.method),
|
||||||
# sort apis
|
}
|
||||||
@model.apisArray.sort pathSorter
|
|
||||||
# sort operations
|
|
||||||
for route in @model.apisArray
|
|
||||||
route.operationsArray.sort pathSorter
|
|
||||||
|
|
||||||
|
initialize: (opts={}) ->
|
||||||
|
if opts.swaggerOptions.sorter
|
||||||
|
sorterName = opts.swaggerOptions.sorter
|
||||||
|
sorter = sorters[sorterName]
|
||||||
|
for route in @model.apisArray
|
||||||
|
route.operationsArray.sort sorter
|
||||||
|
if (sorterName == "alpha") # sort top level paths if alpha
|
||||||
|
@model.apisArray.sort sorter
|
||||||
|
|
||||||
render: ->
|
render: ->
|
||||||
# Render the outer container for resources
|
# Render the outer container for resources
|
||||||
$(@el).html(Handlebars.templates.main(@model))
|
$(@el).html(Handlebars.templates.main(@model))
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
log("Unable to Load SwaggerUI");
|
log("Unable to Load SwaggerUI");
|
||||||
},
|
},
|
||||||
docExpansion: "none",
|
docExpansion: "none",
|
||||||
sortAlphabetically: true
|
sorter : "alpha"
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#input_apiKey').change(function() {
|
$('#input_apiKey').change(function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user