Sort APIs and operations.

Sorts APIs alphabetically.
Sorts operations alphabetically then by method.
This commit is contained in:
Samuel Reed 2015-09-07 21:55:53 -05:00
parent 9d20fe8b7d
commit 0667fd1721
1 changed files with 8 additions and 1 deletions

View File

@ -16,6 +16,7 @@ $(function() {
var accessToken;
function loadSwaggerUi(config) {
var methodOrder = ['get', 'head', 'options', 'put', 'post', 'delete'];
window.swaggerUi = new SwaggerUi({
url: config.url || '/swagger/resources',
apiKey: '',
@ -48,7 +49,13 @@ $(function() {
},
docExpansion: 'none',
highlightSizeThreshold: 16384,
sorter: 'alpha'
apisSorter: 'alpha',
operationsSorter: function(a, b) {
var pathCompare = a.path.localeCompare(b.path);
return pathCompare !== 0 ?
pathCompare :
methodOrder.indexOf(a.method) - methodOrder.indexOf(b.method);
}
});
$('#explore').click(setAccessToken);