Class: Openapi3Parser::NodeFactory::Array::ValidNodeBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/openapi3_parser/node_factory/array.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(factory) ⇒ ValidNodeBuilder

Returns a new instance of ValidNodeBuilder.


111
112
113
114
# File 'lib/openapi3_parser/node_factory/array.rb', line 111

def initialize(factory)
  @factory = factory
  @validatable = Validation::Validatable.new(factory)
end

Class Method Details

.data(factory, parent_context) ⇒ Object


107
108
109
# File 'lib/openapi3_parser/node_factory/array.rb', line 107

def self.data(factory, parent_context)
  new(factory).data(parent_context)
end

.errors(factory) ⇒ Object


103
104
105
# File 'lib/openapi3_parser/node_factory/array.rb', line 103

def self.errors(factory)
  new(factory).errors
end

Instance Method Details

#data(parent_context) ⇒ Object


126
127
128
129
130
131
132
133
134
135
136
# File 'lib/openapi3_parser/node_factory/array.rb', line 126

def data(parent_context)
  if factory.use_default?
    return factory.default.nil? ? nil : build_node_data(parent_context)
  end

  TypeChecker.raise_on_invalid_type(factory.context, type: ::Array)
  check_values(raise_on_invalid: true)
  validate(raise_on_invalid: true)

  build_node_data(parent_context)
end

#errorsObject


116
117
118
119
120
121
122
123
124
# File 'lib/openapi3_parser/node_factory/array.rb', line 116

def errors
  return validatable.collection if factory.nil_input?

  TypeChecker.validate_type(validatable, type: ::Array)
  return validatable.collection if validatable.errors.any?

  collate_errors
  validatable.collection
end