Skip to content

Commit b2ec981

Browse files
committed
Add ability to sort the routes alphabetically
1 parent 454d0ab commit b2ec981

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/rspec_api_documentation/configuration.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ def self.add_setting(name, opts = {})
8181
add_setting :response_headers_to_include, :default => nil
8282
add_setting :html_embedded_css_file, :default => nil
8383

84+
# sorting
85+
add_setting :sort_routes, :default => false
86+
8487
# renamed to request_body_formatter. here for backwards compatibility
8588
add_setting :post_body_formatter, :default => nil
8689

lib/rspec_api_documentation/views/api_blueprint_index.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def sections
3838
end
3939

4040
section.merge({
41-
routes: routes
41+
routes: @configuration.sort_routes ? routes.sort_by { |r| r[:route_name] } : routes
4242
})
4343
end
4444
end

0 commit comments

Comments
 (0)