Sha256: 5bf3380464998677036acc89c286345780518f42beedcb6c135232dc63514a4b

Contents?: true

Size: 685 Bytes

Versions: 5

Compression:

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

5 entries across 5 versions & 1 rubygems

Version Path
apiture-0.2.6 lib/apiture/swagger/parameter.rb
apiture-0.2.5 lib/apiture/swagger/parameter.rb
apiture-0.2.4 lib/apiture/swagger/parameter.rb
apiture-0.2.3 lib/apiture/swagger/parameter.rb
apiture-0.2.2 lib/apiture/swagger/parameter.rb