Sha256: 831bb46dbb061a1dd6bfb522f9a14179a59e8f1ab55119ba791c8bcebe7409fa

Contents?: true

Size: 981 Bytes

Versions: 4

Compression:

Stored size: 981 Bytes

Contents

module Rswag
  module Specs

    class Configuration

      def initialize(rspec_config)
        @rspec_config = rspec_config
      end

      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

      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

      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
    end

    class ConfigurationError < StandardError; end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rswag-specs-1.2.0 lib/rswag/specs/configuration.rb
rswag-specs-1.1.0 lib/rswag/specs/configuration.rb
rswag-specs-1.0.3 lib/rswag/specs/configuration.rb
rswag-specs-1.0.2 lib/rswag/specs/configuration.rb