Skip to content

Commit

Permalink
Register endpoint_auth_wrapper middleware only if not yet registered.
Browse files Browse the repository at this point in the history
  • Loading branch information
texpert committed Aug 22, 2016
1 parent 30c2cc9 commit 59cf1a9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/grape-swagger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 59cf1a9

Please sign in to comment.