Class: JSON::SchemaDsl::Entity
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- JSON::SchemaDsl::Entity
- Includes:
- AstNode
- Defined in:
- lib/json/schema_dsl/entity.rb
Overview
The basic entity type for json schemas.
This is mostly used in cases where you don’t exactly know what type a property will have, for example if the property is an ‘anyOf` of different types.
Internally it is used as the superclass of all other types.
Class Method Summary collapse
-
.required_type ⇒ Object
nodoc.
Instance Method Summary collapse
-
#to_h ⇒ Hash<Symbol, Object>
Returns this entity as a hash and all children and properties as simple values.
Methods included from AstNode
Class Method Details
Instance Method Details
#to_h ⇒ Hash<Symbol, Object>
Returns this entity as a hash and all children and properties as simple values. This structure is used to render the eventual schema by the renderer.
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/json/schema_dsl/entity.rb', line 41 def to_h super.transform_values do |v| is_array = v.is_a?(::Array) if (is_array ? v.first : v).respond_to?(:to_h) is_array ? v.map(&:to_h) : v.to_h else v end end end |