Class: JSONSchemer::OpenAPI31::Vocab::Base::AllOf

Inherits:
Draft202012::Vocab::Applicator::AllOf show all
Defined in:
lib/json_schemer/openapi31/vocab/base.rb

Constant Summary

Constants included from JSONSchemer::Output

JSONSchemer::Output::FRAGMENT_ENCODE_REGEX

Instance Attribute Summary collapse

Attributes inherited from Keyword

#parent, #parsed, #root, #value

Attributes included from JSONSchemer::Output

#keyword, #schema

Instance Method Summary collapse

Methods inherited from Draft202012::Vocab::Applicator::AllOf

#error, #parse

Methods inherited from Keyword

#absolute_keyword_location, #error_key, #fetch, #initialize, #parsed_schema, #schema_pointer

Methods included from JSONSchemer::Output

#x_error

Constructor Details

This class inherits a constructor from JSONSchemer::Keyword

Instance Attribute Details

#skip_ref_onceObject

Returns the value of attribute skip_ref_once.



7
8
9
# File 'lib/json_schemer/openapi31/vocab/base.rb', line 7

def skip_ref_once
  @skip_ref_once
end

Instance Method Details

#validate(instance, instance_location, keyword_location, context) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/json_schemer/openapi31/vocab/base.rb', line 9

def validate(instance, instance_location, keyword_location, context)
  nested = []
  parsed.each_with_index do |subschema, index|
    if ref_schema = subschema.parsed['$ref']&.ref_schema
      next if skip_ref_once == ref_schema.absolute_keyword_location
      ref_schema.parsed['discriminator']&.skip_ref_once = schema.absolute_keyword_location
    end
    nested << subschema.validate_instance(instance, instance_location, join_location(keyword_location, index.to_s), context)
  end
  result(instance, instance_location, keyword_location, nested.all?(&:valid), nested)
ensure
  self.skip_ref_once = nil
end