Class: Swagalicious::Configuration

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

Instance Method Summary collapse

Constructor Details

#initialize(rspec_config) ⇒ Configuration

Returns a new instance of Configuration.



5
6
7
# File 'lib/swagalicious/configuration.rb', line 5

def initialize(rspec_config)
  @rspec_config = rspec_config
end

Instance Method Details

#get_swagger_doc(name) ⇒ Object

Raises:



41
42
43
44
45
46
# File 'lib/swagalicious/configuration.rb', line 41

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

#get_swagger_doc_version(name) ⇒ Object



48
49
50
51
# File 'lib/swagalicious/configuration.rb', line 48

def get_swagger_doc_version(name)
  doc = get_swagger_doc(name)
  doc[:openapi] || doc[:swagger]
end

#swagger_docsObject



18
19
20
21
22
23
24
25
# File 'lib/swagalicious/configuration.rb', line 18

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



27
28
29
30
31
# File 'lib/swagalicious/configuration.rb', line 27

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

#swagger_formatObject



33
34
35
36
37
38
39
# File 'lib/swagalicious/configuration.rb', line 33

def swagger_format
  @swagger_format ||= begin
                        @rspec_config.swagger_format = :json if @rspec_config.swagger_format.nil? || @rspec_config.swagger_format.empty?
                        raise ConfigurationError, "Unknown swagger_format '#{@rspec_config.swagger_format}'" unless [:json, :yaml].include?(@rspec_config.swagger_format)
                        @rspec_config.swagger_format
                      end
end

#swagger_rootObject



9
10
11
12
13
14
15
16
# File 'lib/swagalicious/configuration.rb', line 9

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