Sha256: 1d2ddf0163fd1aefadb30258b9002c9ad11e78cdc245795447ea2e2fa9922955

Contents?: true

Size: 1.34 KB

Versions: 7

Compression:

Stored size: 1.34 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

    # 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
    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

7 entries across 7 versions & 1 rubygems

Version Path
swagger_docs_generator-0.3.4 lib/swagger_docs_generator/configuration/configuration.rb
swagger_docs_generator-0.3.4.pre.23 lib/swagger_docs_generator/configuration/configuration.rb
swagger_docs_generator-0.3.3 lib/swagger_docs_generator/configuration/configuration.rb
swagger_docs_generator-0.3.2 lib/swagger_docs_generator/configuration/configuration.rb
swagger_docs_generator-0.3.1 lib/swagger_docs_generator/configuration/configuration.rb
swagger_docs_generator-0.3.0.pre.19 lib/swagger_docs_generator/configuration/configuration.rb
swagger_docs_generator-0.3.0.pre.18 lib/swagger_docs_generator/configuration/configuration.rb