Skip to content

Commit 43621f6

Browse files
The guard method should not just pass the second item as a string.
If you want to use the guard method as instructed in the readme, you will actually pass the string “false” to the oauth2 method, iso actually passing `false`. As this is a user added string, we should just instance_eval it. This is clearly made to be used with wine_bouncer, but in the current implementation I so no way possible to actually pass false (so make wine_bouncer see this as public iso the scope :false)
1 parent 6c5e386 commit 43621f6

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
#### Fixes
1111

12+
* [#562](https://github.com/ruby-grape/grape-swagger/pull/562): The guard method should allow regular object methods as arguments - [@tim-vandecasteele](https://github.com/tim-vandecasteele).
13+
1214
* Your contribution here.
1315

1416
### 0.25.3 (December 18, 2016)

lib/grape-swagger/doc_methods.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def setup(options)
4343
end
4444
end
4545

46-
send(guard.split.first.to_sym, *guard.split(/[\s,]+/).drop(1)) unless guard.nil?
46+
instance_eval(guard) unless guard.nil?
4747

4848
output_path_definitions = proc do |combi_routes, endpoint|
4949
output = endpoint.swagger_object(

spec/swagger_v2/guarded_endpoint_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ def before
3636
context.protected_endpoint = context.options[:route_options][:auth].present?
3737

3838
return unless context.protected_endpoint?
39-
scopes = context.options[:route_options][:auth][:scopes].map(&:to_sym)
40-
authorize!(*scopes) unless scopes.include? :false
39+
scopes = context.options[:route_options][:auth][:scopes]
40+
authorize!(*scopes) unless scopes.include? false
4141
context.access_token = env['HTTP_AUTHORIZATION']
4242
end
4343
end

0 commit comments

Comments
 (0)