From 0667fd172131640be7b9e4757e5fa13df9b3e1c4 Mon Sep 17 00:00:00 2001 From: Samuel Reed Date: Mon, 7 Sep 2015 21:55:53 -0500 Subject: [PATCH] Sort APIs and operations. Sorts APIs alphabetically. Sorts operations alphabetically then by method. --- public/lib/loadSwaggerUI.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/public/lib/loadSwaggerUI.js b/public/lib/loadSwaggerUI.js index 1d4a53d..0b24cd5 100644 --- a/public/lib/loadSwaggerUI.js +++ b/public/lib/loadSwaggerUI.js @@ -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);