From aa6a9726d1397323071b46d48286c61c6bc78d44 Mon Sep 17 00:00:00 2001 From: texpert Date: Mon, 22 Aug 2016 18:56:09 +0300 Subject: [PATCH] Register endpoint_auth_wrapper middleware only if not yet registered. --- lib/grape-swagger.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/grape-swagger.rb b/lib/grape-swagger.rb index 5647e01b..0eac1aa8 100644 --- a/lib/grape-swagger.rb +++ b/lib/grape-swagger.rb @@ -32,7 +32,11 @@ def add_swagger_documentation(options = {}) options = { target_class: self }.merge(options) @target_class = options[:target_class] - use options[:endpoint_auth_wrapper] if !options[:endpoint_auth_wrapper].nil? && options[:endpoint_auth_wrapper].method_defined?(:before) + if !options[:endpoint_auth_wrapper].nil? && + options[:endpoint_auth_wrapper].method_defined?(:before) && + !middleware.flatten.include?(options[:endpoint_auth_wrapper]) + use options[:endpoint_auth_wrapper] + end documentation_class.setup(options) mount(documentation_class)