Class: Openapi3Parser::NodeFactory::ObjectFactory::Validator::CheckInvalidFields

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/openapi3_parser/node_factory/object_factory/validator.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(validator) ⇒ CheckInvalidFields

Returns a new instance of CheckInvalidFields.



77
78
79
# File 'lib/openapi3_parser/node_factory/object_factory/validator.rb', line 77

def initialize(validator)
  @validator = validator
end

Instance Attribute Details

#validatorObject (readonly)

Returns the value of attribute validator.



68
69
70
# File 'lib/openapi3_parser/node_factory/object_factory/validator.rb', line 68

def validator
  @validator
end

Class Method Details

.call(validator) ⇒ Object



73
74
75
# File 'lib/openapi3_parser/node_factory/object_factory/validator.rb', line 73

def self.call(validator)
  new(validator).call
end

Instance Method Details

#callObject



81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/openapi3_parser/node_factory/object_factory/validator.rb', line 81

def call
  factory.data.each do |name, field|
    # references can reference themselves and become in a loop
    next if in_recursive_loop?(field)

    has_factory_errors = handle_factory_checks(name)

    next if has_factory_errors || !field.respond_to?(:errors)

    # We don't add errors when we're building a node as they will
    # be raised when that child node is built
    validatable.add_errors(field.errors) unless raise_on_invalid
  end
end