Class: JSON::Schema::Array

Inherits:
Leaf
  • Object
show all
Defined in:
lib/json/schema/array.rb

Overview

The JSON::Schema::Array class represents an array value in a JSON schema. It is a subclass of JSON::Schema::Leaf and provides methods that can act as constraints.

Instance Method Summary collapse

Methods inherited from Leaf

#const, #default, #description, #enum, #required, #required?

Constructor Details

#initialize(*items) ⇒ Array

Returns a new instance of Array.



10
11
12
# File 'lib/json/schema/array.rb', line 10

def initialize(*items)
  @items = items
end

Instance Method Details

#to_hObject



14
15
16
# File 'lib/json/schema/array.rb', line 14

def to_h
  super.merge!({type: "array", items:})
end

#to_json(options = {}) ⇒ Object



18
19
20
# File 'lib/json/schema/array.rb', line 18

def to_json(options = {})
  to_h.to_json(options)
end