Sha256: 17a4e0c1c74448b222d9a695ce9808578b15eda8e580ede15e4fc0f88383224f

Contents?: true

Size: 1.28 KB

Versions: 9

Compression:

Stored size: 1.28 KB

Contents

require 'ostruct'
require 'rack'

module Rswag
  module Ui
    class Configuration
      attr_reader :template_locations
      attr_accessor :basic_auth_enabled
      attr_accessor :config_object
      attr_accessor :oauth_config_object
      attr_reader :assets_root

      def initialize
        @template_locations = [
          # preffered override location
          "#{Rack::Directory.new('').root}/swagger/index.erb",
          # backwards compatible override location
          "#{Rack::Directory.new('').root}/app/views/rswag/ui/home/index.html.erb",
          # default location
          File.expand_path('../index.erb', __FILE__)
        ]
        @assets_root = File.expand_path('../../../../node_modules/swagger-ui-dist', __FILE__)
        @config_object = {}
        @oauth_config_object = {}
        @basic_auth_enabled = false
      end

      def swagger_endpoint(url, name)
        @config_object[:urls] ||= []
        @config_object[:urls] << { url: url, name: name }
      end

      def basic_auth_credentials(username, password)
        @config_object[:basic_auth] = { username: username, password: password }
      end

      # rubocop:disable Naming/AccessorMethodName
      def get_binding
        binding
      end
      # rubocop:enable Naming/AccessorMethodName
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rswag-ui-2.5.1 lib/rswag/ui/configuration.rb
rswag-ui-2.5.1.rc1 lib/rswag/ui/configuration.rb
rswag-ui-2.5.0 lib/rswag/ui/configuration.rb
rswag-ui-2.5.0.rc1 lib/rswag/ui/configuration.rb
rswag-ui-2.4.0 lib/rswag/ui/configuration.rb
rswag-ui-2.3.3 lib/rswag/ui/configuration.rb
rswag-ui-2.3.2 lib/rswag/ui/configuration.rb
rswag-ui-2.3.1 lib/rswag/ui/configuration.rb
rswag-ui-2.3.0 lib/rswag/ui/configuration.rb