class Openapi3Parser::NodeFactory::Fields::Reference
Attributes
factory[R]
reference[R]
resolved_reference[R]
Public Class Methods
new(context, factory)
click to toggle source
Calls superclass method
Openapi3Parser::NodeFactory::Field::new
# 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
Public Instance Methods
referenced_factory()
click to toggle source
# File lib/openapi3_parser/node_factory/fields/reference.rb, line 31 def referenced_factory resolved_reference&.factory end
resolved_input()
click to toggle source
# 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
Private Instance Methods
build_node(_data, node_context)
click to toggle source
# File lib/openapi3_parser/node_factory/fields/reference.rb, line 39 def build_node(_data, node_context) if resolved_reference.nil? # this shouldn't happen unless dependant code changes raise Openapi3Parser::Error, "can't build node without a resolved reference" end reference_context = Node::Context.resolved_reference( node_context, resolved_reference.factory.context ) resolved_reference.node(reference_context) end
create_resolved_reference()
click to toggle source
# File lib/openapi3_parser/node_factory/fields/reference.rb, line 73 def create_resolved_reference return unless reference_validator.valid? context.resolve_reference(reference, factory, recursive: context.self_referencing?) end
reference_resolves?()
click to toggle source
# File lib/openapi3_parser/node_factory/fields/reference.rb, line 63 def reference_resolves? return true unless referenced_factory.is_a?(NodeFactory::Reference) referenced_factory.resolves? end
reference_validator()
click to toggle source
# File lib/openapi3_parser/node_factory/fields/reference.rb, line 69 def reference_validator @reference_validator ||= Validators::Reference.new(reference) end
validate(validatable)
click to toggle source
# File lib/openapi3_parser/node_factory/fields/reference.rb, line 53 def validate(validatable) if !reference_validator.valid? validatable.add_errors(reference_validator.errors) elsif !reference_resolves? validatable.add_error("Reference doesn't resolve to an object") else validatable.add_errors(resolved_reference&.errors) end end