class Openapi3Parser::NodeFactory::Reference

Attributes

factory[R]

Public Class Methods

new(context, factory) click to toggle source
# File lib/openapi3_parser/node_factory/reference.rb, line 12
def initialize(context, factory)
  @factory = factory
  super(context)
end

Public Instance Methods

errors() click to toggle source
# File lib/openapi3_parser/node_factory/reference.rb, line 35
def errors
  if in_recursive_loop?
    @errors ||= Validation::ErrorCollection.new
  else
    super
  end
end
in_recursive_loop?() click to toggle source
# File lib/openapi3_parser/node_factory/reference.rb, line 17
def in_recursive_loop?
  data["$ref"].self_referencing?
end
referenced_factory() click to toggle source
# File lib/openapi3_parser/node_factory/reference.rb, line 21
def referenced_factory
  data["$ref"].referenced_factory
end
resolves?(control_factory = nil) click to toggle source
# File lib/openapi3_parser/node_factory/reference.rb, line 25
def resolves?(control_factory = nil)
  control_factory ||= self

  return true unless referenced_factory.is_a?(Reference)
  # recursive loop of references that never references an object
  return false if referenced_factory == control_factory

  referenced_factory.resolves?(control_factory)
end

Private Instance Methods

build_node(node_context) click to toggle source
# File lib/openapi3_parser/node_factory/reference.rb, line 45
def build_node(node_context)
  TypeChecker.raise_on_invalid_type(context, type: ::Hash)
  ObjectFactory::Validator.call(self, raise_on_invalid: true)
  data["$ref"].node(node_context)
end
build_resolved_input() click to toggle source
# File lib/openapi3_parser/node_factory/reference.rb, line 55
def build_resolved_input
  data["$ref"].resolved_input
end
ref_factory(context) click to toggle source
# File lib/openapi3_parser/node_factory/reference.rb, line 51
def ref_factory(context)
  NodeFactory::Fields::Reference.new(context, factory)
end