Class: Jsapi::Meta::Schema::Array

Inherits:
Base show all
Defined in:
lib/jsapi/meta/schema/array.rb

Constant Summary

Constants included from Model::Attributes

Model::Attributes::DEFAULT_ARRAY, Model::Attributes::DEFAULT_HASH

Instance Attribute Summary

Attributes inherited from Base

#validations

Instance Method Summary collapse

Methods inherited from Base

#default, #default_value, #deprecated, #description, #enum, #enum=, #examples, #existence, #external_docs, #initialize, #nullable?, #omittable?, #title, #type

Methods included from OpenAPI::Extensions

included

Methods inherited from Model::Base

#initialize, #inspect, #merge!, #reference?, #resolve

Methods included from Model::Attributes

#attribute, #attribute_names

Constructor Details

This class inherits a constructor from Jsapi::Meta::Schema::Base

Instance Method Details

#itemsObject

:attr: items The Schema defining the kind of items.



10
# File 'lib/jsapi/meta/schema/array.rb', line 10

attribute :items, Schema, accessors: %i[reader]

#items=(keywords = {}) ⇒ Object

:nodoc:



22
23
24
25
26
27
28
# File 'lib/jsapi/meta/schema/array.rb', line 22

def items=(keywords = {}) # :nodoc:
  if keywords.key?(:schema)
    keywords = keywords.dup
    keywords[:ref] = keywords.delete(:schema)
  end
  @items = Schema.new(keywords)
end

#max_itemsObject

:attr: max_items The maximum length of an array.



15
# File 'lib/jsapi/meta/schema/array.rb', line 15

attribute :max_items, accessors: %i[reader]

#max_items=(value) ⇒ Object

:nodoc:



30
31
32
33
# File 'lib/jsapi/meta/schema/array.rb', line 30

def max_items=(value) # :nodoc:
  add_validation('max_items', Validation::MaxItems.new(value))
  @max_items = value
end

#min_itemsObject

:attr: min_items The minimum length of an array.



20
# File 'lib/jsapi/meta/schema/array.rb', line 20

attribute :min_items, accessors: %i[reader]

#min_items=(value) ⇒ Object

:nodoc:



35
36
37
38
# File 'lib/jsapi/meta/schema/array.rb', line 35

def min_items=(value) # :nodoc:
  add_validation('min_items', Validation::MinItems.new(value))
  @min_items = value
end

#to_json_schemaObject

:nodoc:



40
41
42
# File 'lib/jsapi/meta/schema/array.rb', line 40

def to_json_schema # :nodoc:
  super.merge(items: items&.to_json_schema || {})
end

#to_openapi(version) ⇒ Object

:nodoc:



44
45
46
# File 'lib/jsapi/meta/schema/array.rb', line 44

def to_openapi(version, *) # :nodoc:
  super.merge(items: items&.to_openapi(version) || {})
end