Sha256: b831c1f1eee79b9421b52ef1052276a729227698fc2123f024969ae880fc8d1d

Contents?: true

Size: 816 Bytes

Versions: 3

Compression:

Stored size: 816 Bytes

Contents

# frozen_string_literal: true

module HenshinBelt
  module Extension
    def oauth2(*scopes)
      scopes = Doorkeeper.configuration.default_scopes.all if scopes.all? { |x| x.nil? }
      if respond_to?(:route_setting) # >= grape-0.10.0
        description = route_setting(:description) || route_setting(:description, {})
      else
        description = @last_description ||= {}
      end
      # case WineBouncer.configuration.auth_strategy
      # when :default
      description[:auth] = { scopes: scopes }
      # when :swagger
      description[:authorizations] = { oauth2: scopes.map { |x| { scope: x } } }
      # end
    end

    # Grape::API::Instance is defined in grape 1.2.0 or above
    grape_api = defined?(Grape::API::Instance) ? Grape::API::Instance : Grape::API
    grape_api.extend self
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
henshin-belt-0.0.3 lib/henshin_belt/extension.rb
henshin-belt-0.0.2 lib/henshin_belt/extension.rb
henshin-belt-0.0.1 lib/henshin_belt/extension.rb