Class: Eazypi::Schema::Array

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

Overview

Array schema for JSON

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(item_schema) ⇒ Array

Returns a new instance of Array.



9
10
11
# File 'lib/eazypi/schema/array.rb', line 9

def initialize(item_schema)
  @item_schema = item_schema
end

Instance Attribute Details

#item_schemaObject (readonly)

Returns the value of attribute item_schema.



7
8
9
# File 'lib/eazypi/schema/array.rb', line 7

def item_schema
  @item_schema
end

Instance Method Details

#==(other) ⇒ Object



26
27
28
29
30
# File 'lib/eazypi/schema/array.rb', line 26

def ==(other)
  return false unless other.is_a?(Array)

  other.instance_variable_get(:@item_schema) == @item_schema
end

#collect_components(schemas: nil, **kwargs) ⇒ Object



13
14
15
16
17
# File 'lib/eazypi/schema/array.rb', line 13

def collect_components(schemas: nil, **kwargs)
  schemas&.call(@item_schema)

  @item_schema.collect_components(schemas: schemas, **kwargs)
end

#to_openapi_specObject



19
20
21
22
23
24
# File 'lib/eazypi/schema/array.rb', line 19

def to_openapi_spec
  {
    "type" => "array",
    "items" => item_schema.to_openapi_spec
  }
end