Skip to content

Commit

Permalink
fix tags sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob McGuinness committed May 17, 2019
1 parent 04530ad commit e295675
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const schema = Joi.object({
documentationPage: Joi.boolean(),
swaggerUI: Joi.boolean(),
expanded: Joi.string().valid(['none', 'list', 'full']),
sortTags: Joi.string().valid(['alpha', 'default']),
sortTags: Joi.string().valid(['alpha']),
sortEndpoints: Joi.string().valid(['alpha', 'method', 'ordered']),
sortPaths: Joi.string().valid(['unsorted', 'path-method']),
uiCompleteScript: Joi.string().allow(null),
Expand Down
2 changes: 1 addition & 1 deletion optionsreference.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
- `documentationPage`: (boolean) Add documentation page - default: `true`
- `documentationPath`: (string) The path of the documentation page - default: `/documentation`
- `expanded`: (string) If UI is expanded when opened. `none`, `list` or `full` - default: `list`
- `sortTags`: (string) a sort method for `tags` i.e. groups in UI. `alpha`, `default` or `name`
- `sortTags`: (string) a sort method for `tags` i.e. groups in UI. `alpha`
- `alpha`: sort by paths alphanumerically
- `sortEndpoints`: (string) a sort method for endpoints in UI. `alpha`, `method`, `ordered`.
- `alpha`: sort by paths alphanumerically
Expand Down
9 changes: 1 addition & 8 deletions public/extend.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
// sort function for tag groups
var apisSorter = {
alpha: 'alpha',
default: function(a, b) {
if (tags.indexOf(a.name) > -1 && tags.indexOf(b.name) > -1) {
if (tags.indexOf(a.name) < tags.indexOf(b.name)) return -1;
if (tags.indexOf(a.name) > tags.indexOf(b.name)) return 1;
}
return 0;
}
alpha: 'alpha'
};

// sort function for api endpoints within groups
Expand Down
3 changes: 1 addition & 2 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,10 @@
plugins: [SwaggerUIBundle.plugins.DownloadUrl],
layout: 'StandaloneLayout',
docExpansion: "{{hapiSwagger.expanded}}",
apisSorter: apisSorter.{{hapiSwagger.sortTags}},
tagsSorter: apisSorter.{{hapiSwagger.sortTags}},
operationsSorter: operationsSorter.{{hapiSwagger.sortEndpoints}},
}

// Begin Swagger UI call region
var ui = SwaggerUIBundle(swaggerOptions);

window.ui = ui;
Expand Down

0 comments on commit e295675

Please sign in to comment.