Sha256: 43b421f43e972aea8cd4f1d360ba4e4192024e1b290e46b5f3dbe3eea132f5d9

Contents?: true

Size: 823 Bytes

Versions: 13

Compression:

Stored size: 823 Bytes

Contents

module OasRails
  module Spec
    class Parameter
      include Specable
      include Hashable

      STYLE_DEFAULTS = { query: 'form', path: 'simple', header: 'simple', cookie: 'form' }.freeze

      attr_accessor :name, :style, :description, :required, :schema
      attr_reader :in

      def initialize(specification)
        @specification = specification
        @name = ""
        @in = ""
        @description = ""
        @required = false
        @style = ""
        @schema = { type: 'string' }
      end

      def in=(value)
        @in = value
        @style = STYLE_DEFAULTS[@in.to_sym]
        @required = true if value == "path"
      end

      def required?
        @in == 'path'
      end

      def oas_fields
        [:name, :in, :description, :required, :schema, :style]
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
oas_rails-0.9.0 lib/oas_rails/spec/parameter.rb
oas_rails-0.8.4 lib/oas_rails/spec/parameter.rb
oas_rails-0.8.3 lib/oas_rails/spec/parameter.rb
oas_rails-0.8.2 lib/oas_rails/spec/parameter.rb
oas_rails-0.8.1 lib/oas_rails/spec/parameter.rb
oas_rails-0.8.0 lib/oas_rails/spec/parameter.rb
oas_rails-0.7.0 lib/oas_rails/spec/parameter.rb
oas_rails-0.6.0 lib/oas_rails/spec/parameter.rb
oas_rails-0.5.0 lib/oas_rails/spec/parameter.rb
oas_rails-0.4.5 lib/oas_rails/spec/parameter.rb
oas_rails-0.4.4 lib/oas_rails/spec/parameter.rb
oas_rails-0.4.3 lib/oas_rails/spec/parameter.rb
oas_rails-0.4.2 lib/oas_rails/spec/parameter.rb