Class: Meta::JsonSchema::ArraySchema

Inherits:
BaseSchema show all
Extended by:
Forwardable
Defined in:
lib/meta/json_schema/schemas/array_schema.rb

Instance Attribute Summary collapse

Attributes inherited from BaseSchema

#options

Instance Method Summary collapse

Methods inherited from BaseSchema

#defined_scopes, #filter, #filter?, #find_schema, #if?, #scoped, #staged, #to_schema, #value?

Constructor Details

#initialize(items, options = {}) ⇒ ArraySchema

Returns a new instance of ArraySchema.



10
11
12
13
14
# File 'lib/meta/json_schema/schemas/array_schema.rb', line 10

def initialize(items, options = {})
  super(options)

  @items = items
end

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items.



8
9
10
# File 'lib/meta/json_schema/schemas/array_schema.rb', line 8

def items
  @items
end

Instance Method Details

#to_schema_doc(**user_options) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/meta/json_schema/schemas/array_schema.rb', line 16

def to_schema_doc(**user_options)
  stage_options = options

  schema = {
    type: 'array',
    items: @items ? @items.to_schema_doc(**user_options) : {}
  }
  schema[:description] = stage_options[:description] if stage_options[:description]
  schema
end