Class: JSONSchemer::Draft201909::Vocab::Core::RecursiveRef
- Inherits:
-
Keyword
- Object
- Keyword
- JSONSchemer::Draft201909::Vocab::Core::RecursiveRef
show all
- Defined in:
- lib/json_schemer/draft201909/vocab/core.rb
Constant Summary
Constants included
from Output
Output::FRAGMENT_ENCODE_REGEX
Instance Attribute Summary
Attributes inherited from Keyword
#parent, #parsed, #root, #value
Attributes included from Output
#keyword, #schema
Instance Method Summary
collapse
Methods inherited from Keyword
#absolute_keyword_location, #error_key, #fetch, #initialize, #parsed_schema, #schema_pointer
Methods included from Output
#x_error
Instance Method Details
#recursive_anchor ⇒ Object
22
23
24
25
|
# File 'lib/json_schemer/draft201909/vocab/core.rb', line 22
def recursive_anchor
return @recursive_anchor if defined?(@recursive_anchor)
@recursive_anchor = (ref_schema.parsed['$recursiveAnchor']&.parsed == true)
end
|
#ref_schema ⇒ Object
18
19
20
|
# File 'lib/json_schemer/draft201909/vocab/core.rb', line 18
def ref_schema
@ref_schema ||= root.resolve_ref(ref_uri)
end
|
#ref_uri ⇒ Object
14
15
16
|
# File 'lib/json_schemer/draft201909/vocab/core.rb', line 14
def ref_uri
@ref_uri ||= URI.join(schema.base_uri, value)
end
|
#validate(instance, instance_location, keyword_location, context) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/json_schemer/draft201909/vocab/core.rb', line 27
def validate(instance, instance_location, keyword_location, context)
schema = ref_schema
if recursive_anchor
context.dynamic_scope.each do |ancestor|
if ancestor.root.resources.fetch(:dynamic).key?(ancestor.base_uri)
schema = ancestor.root.resources.fetch(:dynamic).fetch(ancestor.base_uri)
break
end
end
end
schema.validate_instance(instance, instance_location, keyword_location, context)
end
|