From 9b4f6f66e66e0ce43cdfece598a52a8f0059450a Mon Sep 17 00:00:00 2001 From: Damien Nozay Date: Mon, 1 Dec 2014 13:55:46 -0800 Subject: [PATCH] Update SwaggerUi.coffee add helpers for collapse/list/expand all operations. --- src/main/coffeescript/SwaggerUi.coffee | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/coffeescript/SwaggerUi.coffee b/src/main/coffeescript/SwaggerUi.coffee index 0c30cfd6..c5cb205d 100644 --- a/src/main/coffeescript/SwaggerUi.coffee +++ b/src/main/coffeescript/SwaggerUi.coffee @@ -66,6 +66,18 @@ class SwaggerUi extends Backbone.Router @api = new SwaggerClient(@options) @api.build() + # collapse all sections + collapseAll:() -> + Docs.collapseEndpointListForResource('') + + # list operations for all sections + listAll:() -> + Docs.collapseOperationsForResource('') + + # expand operations for all sections + expandAll:() -> + Docs.expandOperationsForResource('') + # This is bound to success handler for SwaggerApi # so it gets called when SwaggerApi completes loading render:() -> @@ -73,8 +85,8 @@ class SwaggerUi extends Backbone.Router @mainView = new MainView({model: @api, el: $('#' + @dom_id), swaggerOptions: @options}).render() @showMessage() switch @options.docExpansion - when "full" then Docs.expandOperationsForResource('') - when "list" then Docs.collapseOperationsForResource('') + when "full" then @expandAll() + when "list" then @listAll() @options.onComplete(@api, @) if @options.onComplete setTimeout( =>