Class: Shale::Schema::JSONGenerator::Collection Private
- Inherits:
-
Object
- Object
- Shale::Schema::JSONGenerator::Collection
- Defined in:
- lib/shale/schema/json_generator/collection.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Class representing array type in JSON Schema
Instance Attribute Summary collapse
-
#schema ⇒ Object
readonly
private
Return schema hash.
Instance Method Summary collapse
-
#as_json ⇒ Hash
private
Return JSON Schema fragment as Ruby Hash.
-
#initialize(type, schema: nil) ⇒ Collection
constructor
private
Initialize Collection object.
-
#name ⇒ String
private
Delegate name to wrapped type object.
Constructor Details
#initialize(type, schema: nil) ⇒ Collection
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize Collection object
21 22 23 24 |
# File 'lib/shale/schema/json_generator/collection.rb', line 21 def initialize(type, schema: nil) @type = type @schema = schema end |
Instance Attribute Details
#schema ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return schema hash
13 14 15 |
# File 'lib/shale/schema/json_generator/collection.rb', line 13 def schema @schema end |
Instance Method Details
#as_json ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return JSON Schema fragment as Ruby Hash
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/shale/schema/json_generator/collection.rb', line 40 def as_json schema = @schema || {} { 'type' => 'array', 'items' => @type.as_type, 'minItems' => schema[:min_items], 'maxItems' => schema[:max_items], 'uniqueItems' => schema[:unique], 'minContains' => schema[:min_contains], 'maxContains' => schema[:max_contains], 'description' => schema[:description] }.compact end |
#name ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Delegate name to wrapped type object
31 32 33 |
# File 'lib/shale/schema/json_generator/collection.rb', line 31 def name @type.name end |