Class: Openapi3Parser::NodeFactory::Fields::Reference

Inherits:
Openapi3Parser::NodeFactory::Field show all
Extended by:
Forwardable
Defined in:
lib/openapi3_parser/node_factory/fields/reference.rb

Defined Under Namespace

Classes: RecursiveResolvedInput

Instance Attribute Summary

Attributes inherited from Openapi3Parser::NodeFactory::Field

#context, #input_type, #validation

Instance Method Summary collapse

Methods inherited from Openapi3Parser::NodeFactory::Field

#data, #default, #errors, #inspect, #nil_input?, #node, #raw_input, #valid?

Constructor Details

#initialize(context, factory) ⇒ Reference

Returns a new instance of Reference.



14
15
16
17
18
19
# File 'lib/openapi3_parser/node_factory/fields/reference.rb', line 14

def initialize(context, factory)
  super(context, input_type: String, validate: :validate)
  @factory = factory
  @reference = context.input
  @resolved_reference = create_resolved_reference
end

Instance Method Details

#referenced_factoryObject



31
32
33
# File 'lib/openapi3_parser/node_factory/fields/reference.rb', line 31

def referenced_factory
  resolved_reference&.factory
end

#resolved_inputObject



21
22
23
24
25
26
27
28
29
# File 'lib/openapi3_parser/node_factory/fields/reference.rb', line 21

def resolved_input
  return unless resolved_reference

  if context.self_referencing?
    RecursiveResolvedInput.new(resolved_reference.factory)
  else
    resolved_reference.resolved_input
  end
end