Class: SchemaTest::Collection
- Inherits:
-
Property::Object
- Object
- Property
- Property::Object
- SchemaTest::Collection
- Defined in:
- lib/schema_test/collection.rb
Constant Summary
Constants inherited from Property::Object
Property::Object::SHORTHAND_ATTRIBUTES, Property::Object::TYPES
Instance Attribute Summary
Attributes inherited from Property::Object
Attributes inherited from Property
#description, #name, #optional, #type
Instance Method Summary collapse
- #as_json_schema(domain: SchemaTest.configuration.domain) ⇒ Object
-
#initialize(name, of_name, version: nil, description: nil) ⇒ Collection
constructor
A new instance of Collection.
Methods inherited from Property::Object
#==, #array, #as_structure, #json_schema_type, #object, #properties, #resolve
Methods inherited from Property
#==, #as_structure, #json_schema_format, #json_schema_type, #optional!, #optional?
Constructor Details
#initialize(name, of_name, version: nil, description: nil) ⇒ Collection
Returns a new instance of Collection.
5 6 7 8 9 |
# File 'lib/schema_test/collection.rb', line 5 def initialize(name, of_name, version: nil, description: nil) super(name, version: version, description: description) @item_type = lookup_object(of_name, version) SchemaTest::Definition.register(self) end |
Instance Method Details
#as_json_schema(domain: SchemaTest.configuration.domain) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/schema_test/collection.rb', line 11 def as_json_schema(domain: SchemaTest.configuration.domain) id_part = version ? "v#{version}/#{name}" : name { '$schema' => SchemaTest::SCHEMA_VERSION, '$id' => "http://#{domain}/#{id_part}.json", 'title' => name.to_s, 'type' => 'array', 'items' => @item_type.as_json_schema(false), 'minItems' => 1 } end |