Class: Rswag::Ui::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/rswag/ui/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rswag/ui/configuration.rb', line 13

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

Instance Attribute Details

#assets_rootObject (readonly)

Returns the value of attribute assets_root.



11
12
13
# File 'lib/rswag/ui/configuration.rb', line 11

def assets_root
  @assets_root
end

#basic_auth_enabledObject

Returns the value of attribute basic_auth_enabled.



8
9
10
# File 'lib/rswag/ui/configuration.rb', line 8

def basic_auth_enabled
  @basic_auth_enabled
end

#config_objectObject

Returns the value of attribute config_object.



9
10
11
# File 'lib/rswag/ui/configuration.rb', line 9

def config_object
  @config_object
end

#oauth_config_objectObject

Returns the value of attribute oauth_config_object.



10
11
12
# File 'lib/rswag/ui/configuration.rb', line 10

def oauth_config_object
  @oauth_config_object
end

#template_locationsObject (readonly)

Returns the value of attribute template_locations.



7
8
9
# File 'lib/rswag/ui/configuration.rb', line 7

def template_locations
  @template_locations
end

Instance Method Details

#basic_auth_credentials(username, password) ⇒ Object



33
34
35
# File 'lib/rswag/ui/configuration.rb', line 33

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

#get_bindingObject

rubocop:disable Naming/AccessorMethodName



38
39
40
# File 'lib/rswag/ui/configuration.rb', line 38

def get_binding
  binding
end

#swagger_endpoint(url, name) ⇒ Object



28
29
30
31
# File 'lib/rswag/ui/configuration.rb', line 28

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