Sha256: 44f35e3f35d53d8394c55f139bd21c8e32e87ea7cc68063e98cc74143c18027d

Contents?: true

Size: 684 Bytes

Versions: 2

Compression:

Stored size: 684 Bytes

Contents

require 'apiture/swagger/data_type_field'

module Apiture
  module Swagger
    class Parameter < DataTypeField
      VALID_TYPES = %w(
        string
        number
        integer
        boolean
        array
        file
      )

      attribute :name
      attribute :in, symbolize: true
      attribute :description
      attribute :required, type: :boolean
      attribute :schema

      def schema?
        !!schema
      end

      def validate
        if self.in.nil?
          errors << "in attribute is required"
        end
        if self.in == :path && !required?
          errors << "Path parameters must be defined as required"
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
apiture-0.2.1 lib/apiture/swagger/parameter.rb
apiture-0.2.0 lib/apiture/swagger/parameter.rb