require "mountapi/schema/base" module Mountapi module Schema # Schema implementation for Array class Array include Base # @param [Object] value the inbound value for this schema # # cast the inbound value and it's items # in case of array we already expect an array. (from rack Query parser) def cast(array) raise_cast_error(array) unless array.is_a?(::Array) array.to_a.map do |item| Schema.build(open_api_schema.items).cast(item) end end # for array we also transform items to json_schema def self.to_json_schema(key_name, value) if key_name == "items" value = Schema.build(value).to_json_schema end { key_name => value } end end end end