Sha256: c1a471546518421b13463694ecab89b3b87548c13dfef7b3cae5ee87620324c0

Contents?: true

Size: 1.38 KB

Versions: 6

Compression:

Stored size: 1.38 KB

Contents

# frozen_string_literal: true

# :reek:Attribute
module SwaggerDocsGenerator
  # # Configuration to swagger json file
  #
  # This class it's a DSL class. For customize default json file.
  #
  # @example
  #   SwaggerDocsGenerator.configure do |config|
  #     config.swagger = '2.0.0'
  #   end
  #
  #   SwaggerDocsGenerator.config
  #   => #<SwaggerDocsGenerator::Configuration:0x007f8ae49138d8
  #    @swagger='2.0.0'>
  #
  # @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md
  class Configuration
    # Accessors with default value
    attr_accessor :swagger, :cleanning, :base_path, :compress

    # Accessors without default value
    attr_accessor :schemes, :consumes, :produces, :host, :external_docs,
                  :security, :definitions, :doc_class, :doc_folder

    # Initalize default value (and requried) for json swagger file
    def initialize
      @swagger = '2.0'
      @base_path = '/'
      @cleanning = true
      @compress = false
    end
  end

  class << self
    def configure
      block_given? ? yield(config) : config
    end

    def config
      @config ||= Configuration.new
    end

    def file_base
      File.join(@config.doc_folder, @config.doc_class)
    end

    def file_docs
      Dir[File.join(@config.doc_folder, '*.rb')]
    end

    def temporary_folder
      Rails.root.join('tmp', SwaggerDocsGenerator::GEM)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
swagger_docs_generator-0.4.0 lib/swagger_docs_generator/configuration/configuration.rb
swagger_docs_generator-0.3.6 lib/swagger_docs_generator/configuration/configuration.rb
swagger_docs_generator-0.3.6.pre.34 lib/swagger_docs_generator/configuration/configuration.rb
swagger_docs_generator-0.3.5 lib/swagger_docs_generator/configuration/configuration.rb
swagger_docs_generator-0.3.5.pre.31 lib/swagger_docs_generator/configuration/configuration.rb
swagger_docs_generator-0.3.4.pre.26 lib/swagger_docs_generator/configuration/configuration.rb