Sha256: dbfce93a36947bed9a62e1b717e6c9483fd9b94be26d3b7141841e7ca561e20d

Contents?: true

Size: 638 Bytes

Versions: 1

Compression:

Stored size: 638 Bytes

Contents

# frozen_string_literal: true

# :reek:InstanceVariableAssumption
module SwaggerDocsGenerator
  module Actions
    # Object Schema
    #
    # Parse repsonse and create schema swagger object
    class Schema
      def initialize(&block)
        instance_eval(&block) if block_given?
      end

      def to_hash
        element = { type: @type || 'array' }
        element.merge!(items: { '$ref': @definition }) if @definition.present?
      end

      private

      def type(text)
        @type = text
      end

      def definition(text)
        @definition = '#/definitions/' + text.tr(' ', '_').camelize
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
swagger_docs_generator-0.3.0.pre.18 lib/swagger_docs_generator/parser/actions/schema.rb