Class: EasyTalk::Builders::ObjectBuilder

Inherits:
BaseBuilder show all
Extended by:
T::Sig
Defined in:
lib/easy_talk/builders/object_builder.rb

Overview

Builder class for json schema objects.

Constant Summary collapse

VALID_OPTIONS =
{
  properties: { type: T::Hash[T.any(Symbol, String), T.untyped], key: :properties },
  additional_properties: { type: T::Boolean, key: :additionalProperties },
  subschemas: { type: T::Array[T.untyped], key: :subschemas },
  required: { type: T::Array[T.any(Symbol, String)], key: :required },
  defs: { type: T.untyped, key: :$defs },
  allOf: { type: T.untyped, key: :allOf },
  anyOf: { type: T.untyped, key: :anyOf },
  oneOf: { type: T.untyped, key: :oneOf },
  not: { type: T.untyped, key: :not }
}.freeze

Constants inherited from BaseBuilder

BaseBuilder::COMMON_OPTIONS

Instance Attribute Summary collapse

Attributes inherited from BaseBuilder

#name

Instance Method Summary collapse

Methods inherited from BaseBuilder

#build, collection_type?

Constructor Details

#initialize(schema_definition) ⇒ ObjectBuilder

Returns a new instance of ObjectBuilder.



26
27
28
29
30
31
32
# File 'lib/easy_talk/builders/object_builder.rb', line 26

def initialize(schema_definition)
  @schema_definition = schema_definition
  @schema = schema_definition.schema.dup
  @required_properties = []
  name = schema_definition.name ? schema_definition.name.to_sym : :klass
  super(name, { type: 'object' }, options, VALID_OPTIONS)
end

Instance Attribute Details

#schemaObject (readonly)

Returns the value of attribute schema.



11
12
13
# File 'lib/easy_talk/builders/object_builder.rb', line 11

def schema
  @schema
end