Sha256: d2a41272a3bb93e3358f5e79155d17d234514c05dcb94d1c5b6f0601c5dd148c

Contents?: true

Size: 934 Bytes

Versions: 2

Compression:

Stored size: 934 Bytes

Contents

module OasParser
  class Parameter < AbstractAttribute
    raw_keys :in, :description, :style, :schema,
             :minimum, :maximum, :required, :nullable

    attr_accessor :owner, :raw

    def initialize(owner, raw)
      super(raw['name'])
      @owner = owner
      @raw = raw
    end

    def type
      raw['type'] || (schema ? schema['type'] : nil)
    end

    def format
      raw['format'] || (schema ? schema['format'] : nil)
    end

    def items
      schema['items']
    end

    def example
      raw['example'] || (schema ? schema['example'] : nil)
    end

    def default
      raw['default'] || (schema ? schema['default'] : nil)
    end

    def nullable?
      raw['nullable'] || (schema ? schema['nullable'] : nil )
    end

    def convert_property_schema_to_properties(schema)
      schema.map do |name, definition|
        OasParser::Property.new(self, raw, name, definition)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
oas_parser_reborn-0.25.5 lib/oas_parser_reborn/parameter.rb
oas_parser-0.25.4 lib/oas_parser/parameter.rb