Sha256: bf0e13141b15a214407052a3cb8b71b24805c8277d0112bdfc6daa5ecefe9b51

Contents?: true

Size: 976 Bytes

Versions: 12

Compression:

Stored size: 976 Bytes

Contents

require_relative 'base'

module Swaggard
  module Swagger
    module Parameters
      class Form < Base

        def initialize(string)
          @in = 'formData'
          parse(string)
        end

        private

        # Example: [Array]     status            Filter by status. (e.g. status[]=1&status[]=2&status[]=3)
        # Example: [Array]     status(required)  Filter by status. (e.g. status[]=1&status[]=2&status[]=3)
        # Example: [Integer]   media[media_type_id]                          ID of the desired media type.
        def parse(string)
          data_type, name, required, description = string.match(/\A\[(\w*)\]\s*([\w\[\]]*)(\(required\))?\s*(.*)\Z/).captures
          allow_multiple = name.gsub!('[]', '')

          @name = name
          @description = description
          @data_type = data_type.downcase
          @is_required = required.present?
          @allow_multiple = allow_multiple.present?
        end

      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
swaggard-0.5.4 lib/swaggard/swagger/parameters/form.rb
swaggard-0.5.3 lib/swaggard/swagger/parameters/form.rb
swaggard-0.5.2 lib/swaggard/swagger/parameters/form.rb
swaggard-0.5.1 lib/swaggard/swagger/parameters/form.rb
swaggard-0.5.0 lib/swaggard/swagger/parameters/form.rb
swaggard-0.4.0 lib/swaggard/swagger/parameters/form.rb
swaggard-0.3.0 lib/swaggard/swagger/parameters/form.rb
swaggard-0.2.1 lib/swaggard/swagger/parameters/form.rb
swaggard-0.2.0 lib/swaggard/swagger/parameters/form.rb
swaggard-0.1.1 lib/swaggard/swagger/parameters/form.rb
swaggard-0.1.0 lib/swaggard/swagger/parameters/form.rb
swaggard-0.0.4 lib/swaggard/swagger/parameters/form.rb