Sha256: bc6f1e3e65b21fc2f87b76aaad0ee711c269a058ac7e2a91fd7fe78e0c7c760f

Contents?: true

Size: 977 Bytes

Versions: 10

Compression:

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

10 entries across 10 versions & 1 rubygems

Version Path
swaggard-1.5.1 lib/swaggard/swagger/parameters/form.rb
swaggard-1.5.0 lib/swaggard/swagger/parameters/form.rb
swaggard-1.4.0 lib/swaggard/swagger/parameters/form.rb
swaggard-1.3.0 lib/swaggard/swagger/parameters/form.rb
swaggard-1.2.0 lib/swaggard/swagger/parameters/form.rb
swaggard-1.1.1 lib/swaggard/swagger/parameters/form.rb
swaggard-1.1.0 lib/swaggard/swagger/parameters/form.rb
swaggard-1.0.2 lib/swaggard/swagger/parameters/form.rb
swaggard-1.0.1 lib/swaggard/swagger/parameters/form.rb
swaggard-1.0.0 lib/swaggard/swagger/parameters/form.rb