Sha256: 691a84ce91f92266d19c6fed26adaaa142ef421573486730524605257980632a

Contents?: true

Size: 738 Bytes

Versions: 2

Compression:

Stored size: 738 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, :in, :style, :description, :required, :schema

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

      def default_from_in
        STYLE_DEFAULTS[@in.to_sym]
      end

      def required?
        @in == 'path'
      end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
oas_rails-0.4.1 lib/oas_rails/spec/parameter.rb
oas_rails-0.4.0 lib/oas_rails/spec/parameter.rb