Skip to content

Commit aa6a972

Browse files
committed
Register endpoint_auth_wrapper middleware only if not yet registered.
1 parent 161c6e3 commit aa6a972

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/grape-swagger.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ def add_swagger_documentation(options = {})
3232
options = { target_class: self }.merge(options)
3333
@target_class = options[:target_class]
3434

35-
use options[:endpoint_auth_wrapper] if !options[:endpoint_auth_wrapper].nil? && options[:endpoint_auth_wrapper].method_defined?(:before)
35+
if !options[:endpoint_auth_wrapper].nil? &&
36+
options[:endpoint_auth_wrapper].method_defined?(:before) &&
37+
!middleware.flatten.include?(options[:endpoint_auth_wrapper])
38+
use options[:endpoint_auth_wrapper]
39+
end
3640

3741
documentation_class.setup(options)
3842
mount(documentation_class)

0 commit comments

Comments
 (0)