From cc90876dfac2b0a6ce8e90a69fe59c8fa64ed25b Mon Sep 17 00:00:00 2001 From: richie Date: Mon, 11 Jul 2016 13:04:29 -0700 Subject: [PATCH] Handle trailing slashes when building discovery paths --- app/controllers/swagger_rails/swagger_ui_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/swagger_rails/swagger_ui_controller.rb b/app/controllers/swagger_rails/swagger_ui_controller.rb index 820e344..dc055a7 100644 --- a/app/controllers/swagger_rails/swagger_ui_controller.rb +++ b/app/controllers/swagger_rails/swagger_ui_controller.rb @@ -9,12 +9,14 @@ module SwaggerRails def index swagger_root = SwaggerRails.config.resolve_swagger_root(request.env) + swagger_root.concat('/') unless swagger_root.end_with?('/') + swagger_filenames = Dir["#{swagger_root}/**/*.json"] @discovery_paths = Hash[ swagger_filenames.map do |filename| [ - filename.sub(swagger_root, root_path), + filename.sub(swagger_root, root_path.chomp('/')), load_json(filename)["info"]["title"] ] end