{"action":"created","issue":{"url":"https://api.github.com/repos/ruby-grape/grape-swagger/issues/493","repository_url":"https://api.github.com/repos/ruby-grape/grape-swagger","labels_url":"https://api.github.com/repos/ruby-grape/grape-swagger/issues/493/labels{/name}","comments_url":"https://api.github.com/repos/ruby-grape/grape-swagger/issues/493/comments","events_url":"https://api.github.com/repos/ruby-grape/grape-swagger/issues/493/events","html_url":"https://github.com/ruby-grape/grape-swagger/pull/493","id":171267459,"number":493,"title":"Swagger UI endpoint authorization.","user":{"login":"texpert","id":2990033,"avatar_url":"https://avatars.githubusercontent.com/u/2990033?v=3","gravatar_id":"","url":"https://api.github.com/users/texpert","html_url":"https://github.com/texpert","followers_url":"https://api.github.com/users/texpert/followers","following_url":"https://api.github.com/users/texpert/following{/other_user}","gists_url":"https://api.github.com/users/texpert/gists{/gist_id}","starred_url":"https://api.github.com/users/texpert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/texpert/subscriptions","organizations_url":"https://api.github.com/users/texpert/orgs","repos_url":"https://api.github.com/users/texpert/repos","events_url":"https://api.github.com/users/texpert/events{/privacy}","received_events_url":"https://api.github.com/users/texpert/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-08-15T21:34:43Z","updated_at":"2016-09-08T14:55:57Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ruby-grape/grape-swagger/pulls/493","html_url":"https://github.com/ruby-grape/grape-swagger/pull/493","diff_url":"https://github.com/ruby-grape/grape-swagger/pull/493.diff","patch_url":"https://github.com/ruby-grape/grape-swagger/pull/493.patch"},"body":"This helps to guard Swagger UI endpoints adding 3 new options to swagger documentation (in my case, using WineBouncer gem and Doorkeeper, but it is configurable):         \r\n\r\n```ruby\r\nendpoint_auth_wrapper: WineBouncer::OAuth2,\r\nswagger_endpoint_guard: \"oauth2 false\",\r\noauth_token: 'doorkeeper_access_token'\r\n```\r\n\r\nTo display the endpoint only for signed admin users, I am using a lambda (I think a few lambdas like this would go to options as well - I will work it later):\r\n\r\n```ruby\r\n  not_admins = lambda { |token=nil| token.nil? || !User.find(token.resource_owner_id).admin? }\r\n\r\n  resource :users, desc: \"Users' operations\" do\r\n    desc 'List users', hidden: not_admins\r\n    oauth2 'admin'\r\n    get do\r\n      render_result User.all\r\n    end\r\n```\r\n\r\nNotes:\r\n- Using with Rails, 'rails' and 'wine_bouncer' gems should be required prior to 'grape-swagger' in boot.rb;\r\n- This works with a fresh PR to WineBouncer which is yet unmerged - https://github.com/antek-drzewiecki/wine_bouncer/pull/64.\r\n"},"comment":{"url":"https://api.github.com/repos/ruby-grape/grape-swagger/issues/comments/245625087","html_url":"https://github.com/ruby-grape/grape-swagger/pull/493#issuecomment-245625087","issue_url":"https://api.github.com/repos/ruby-grape/grape-swagger/issues/493","id":245625087,"user":{"login":"texpert","id":2990033,"avatar_url":"https://avatars.githubusercontent.com/u/2990033?v=3","gravatar_id":"","url":"https://api.github.com/users/texpert","html_url":"https://github.com/texpert","followers_url":"https://api.github.com/users/texpert/followers","following_url":"https://api.github.com/users/texpert/following{/other_user}","gists_url":"https://api.github.com/users/texpert/gists{/gist_id}","starred_url":"https://api.github.com/users/texpert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/texpert/subscriptions","organizations_url":"https://api.github.com/users/texpert/orgs","repos_url":"https://api.github.com/users/texpert/repos","events_url":"https://api.github.com/users/texpert/events{/privacy}","received_events_url":"https://api.github.com/users/texpert/received_events","type":"User","site_admin":false},"created_at":"2016-09-08T14:55:57Z","updated_at":"2016-09-08T14:55:57Z","body":"Done!"}}
{"actor":{"display_login":"texpert"}}