Class: Meta::JsonSchema::DynamicSchemaBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/meta/json_schema/builders/dynamic_schema_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ DynamicSchemaBuilder

Returns a new instance of DynamicSchemaBuilder.



8
9
10
11
12
# File 'lib/meta/json_schema/builders/dynamic_schema_builder.rb', line 8

def initialize(options)
  options = options.dup
  @dynamic_schema_options = options.delete(:dynamic_ref)
  @base_options = options
end

Instance Method Details

#to_schemaObject



14
15
16
17
18
19
20
# File 'lib/meta/json_schema/builders/dynamic_schema_builder.rb', line 14

def to_schema
  DynamicSchema.new(
    @dynamic_schema_options[:resolve],
    one_of: @dynamic_schema_options[:one_of] && @dynamic_schema_options[:one_of].map { |schema| RefSchema.new(schema.to_schema) },
    **@base_options
  )
end