Sha256: 6c26d1ece829126d0322b249c8a28637ff9864fe9a0b8059dc4057a9f92c1192

Contents?: true

Size: 610 Bytes

Versions: 4

Compression:

Stored size: 610 Bytes

Contents

require_relative 'type'

module Swaggard
  module Swagger
    class Property
      attr_reader :id, :type, :description

      def initialize(name, type, description = '', required = false, options = [])
        @id = name
        @type = type
        @description = description
        @required = required
        @options = options
      end

      def required?
        @required
      end

      def to_doc
        result = @type.to_doc
        result['description'] = @description if @description.present?
        result['enum'] = @options if @options.present?
        result
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
swaggard-1.5.1 lib/swaggard/swagger/property.rb
swaggard-1.5.0 lib/swaggard/swagger/property.rb
swaggard-1.4.0 lib/swaggard/swagger/property.rb
swaggard-1.3.0 lib/swaggard/swagger/property.rb