Class: OpenApi::Rswag::Specs::Configuration

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

Instance Method Summary collapse

Constructor Details

#initialize(rspec_config) ⇒ Configuration

Returns a new instance of Configuration.



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

def initialize(rspec_config)
  @rspec_config = rspec_config
end

Instance Method Details

#get_swagger_doc(name) ⇒ Object

Raises:



37
38
39
40
41
42
# File 'lib/open_api/rswag/specs/configuration.rb', line 37

def get_swagger_doc(name)
  return swagger_docs.values.first if name.nil?
  raise ConfigurationError, "Unknown swagger_doc '#{name}'" unless swagger_docs[name]

  swagger_docs[name]
end

#swagger_docsObject



21
22
23
24
25
26
27
28
29
# File 'lib/open_api/rswag/specs/configuration.rb', line 21

def swagger_docs
  @swagger_docs ||= begin
    if @rspec_config.swagger_docs.nil? || @rspec_config.swagger_docs.empty?
      raise ConfigurationError, 'No swagger_docs defined. See swagger_helper.rb'
    end

    @rspec_config.swagger_docs
  end
end

#swagger_dry_runObject



31
32
33
34
35
# File 'lib/open_api/rswag/specs/configuration.rb', line 31

def swagger_dry_run
  @swagger_dry_run ||= begin
    @rspec_config.swagger_dry_run.nil? || @rspec_config.swagger_dry_run
  end
end

#swagger_rootObject



11
12
13
14
15
16
17
18
19
# File 'lib/open_api/rswag/specs/configuration.rb', line 11

def swagger_root
  @swagger_root ||= begin
    if @rspec_config.swagger_root.nil?
      raise ConfigurationError, 'No swagger_root provided. See swagger_helper.rb'
    end

    @rspec_config.swagger_root
  end
end