Class: JSONSchemer::Keyword
- Inherits:
-
Object
- Object
- JSONSchemer::Keyword
- Includes:
- Output
- Defined in:
- lib/json_schemer/keyword.rb
Direct Known Subclasses
Draft201909::Vocab::Applicator::AdditionalItems, Draft201909::Vocab::Applicator::Items, Draft201909::Vocab::Applicator::UnevaluatedItems, Draft201909::Vocab::Core::RecursiveAnchor, Draft201909::Vocab::Core::RecursiveRef, Draft202012::Vocab::Applicator::AdditionalProperties, Draft202012::Vocab::Applicator::AllOf, Draft202012::Vocab::Applicator::AnyOf, Draft202012::Vocab::Applicator::Contains, Draft202012::Vocab::Applicator::Dependencies, Draft202012::Vocab::Applicator::DependentSchemas, Draft202012::Vocab::Applicator::Else, Draft202012::Vocab::Applicator::If, Draft202012::Vocab::Applicator::Items, Draft202012::Vocab::Applicator::Not, Draft202012::Vocab::Applicator::OneOf, Draft202012::Vocab::Applicator::PatternProperties, Draft202012::Vocab::Applicator::PrefixItems, Draft202012::Vocab::Applicator::Properties, Draft202012::Vocab::Applicator::PropertyNames, Draft202012::Vocab::Applicator::Then, Draft202012::Vocab::Content::ContentEncoding, Draft202012::Vocab::Content::ContentMediaType, Draft202012::Vocab::Content::ContentSchema, Draft202012::Vocab::Core::Anchor, Draft202012::Vocab::Core::Comment, Draft202012::Vocab::Core::Defs, Draft202012::Vocab::Core::DynamicAnchor, Draft202012::Vocab::Core::DynamicRef, Draft202012::Vocab::Core::Id, Draft202012::Vocab::Core::Ref, Draft202012::Vocab::Core::Schema, Draft202012::Vocab::Core::UnknownKeyword, Draft202012::Vocab::Core::Vocabulary, Draft202012::Vocab::Core::XError, Draft202012::Vocab::FormatAnnotation::Format, Draft202012::Vocab::FormatAssertion::Format, Draft202012::Vocab::MetaData::ReadOnly, Draft202012::Vocab::MetaData::WriteOnly, Draft202012::Vocab::Unevaluated::UnevaluatedItems, Draft202012::Vocab::Unevaluated::UnevaluatedProperties, Draft202012::Vocab::Validation::Const, Draft202012::Vocab::Validation::DependentRequired, Draft202012::Vocab::Validation::Enum, Draft202012::Vocab::Validation::ExclusiveMaximum, Draft202012::Vocab::Validation::ExclusiveMinimum, Draft202012::Vocab::Validation::MaxContains, Draft202012::Vocab::Validation::MaxItems, Draft202012::Vocab::Validation::MaxLength, Draft202012::Vocab::Validation::MaxProperties, Draft202012::Vocab::Validation::Maximum, Draft202012::Vocab::Validation::MinContains, Draft202012::Vocab::Validation::MinItems, Draft202012::Vocab::Validation::MinLength, Draft202012::Vocab::Validation::MinProperties, Draft202012::Vocab::Validation::Minimum, Draft202012::Vocab::Validation::MultipleOf, Draft202012::Vocab::Validation::Pattern, Draft202012::Vocab::Validation::Required, Draft202012::Vocab::Validation::Type, Draft202012::Vocab::Validation::UniqueItems, Draft4::Vocab::Validation::ExclusiveMaximum, Draft4::Vocab::Validation::ExclusiveMinimum, Draft7::Vocab::Validation::AdditionalItems, OpenAPI31::Vocab::Base::Discriminator
Constant Summary
Constants included from Output
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#parsed ⇒ Object
readonly
Returns the value of attribute parsed.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes included from Output
Instance Method Summary collapse
- #absolute_keyword_location ⇒ Object
- #error_key ⇒ Object
- #fetch(key) ⇒ Object
-
#initialize(value, parent, keyword, schema = parent) ⇒ Keyword
constructor
A new instance of Keyword.
- #parsed_schema ⇒ Object
- #schema_pointer ⇒ Object
- #validate(_instance, _instance_location, _keyword_location, _context) ⇒ Object
Methods included from Output
Constructor Details
#initialize(value, parent, keyword, schema = parent) ⇒ Keyword
Returns a new instance of Keyword.
8 9 10 11 12 13 14 15 |
# File 'lib/json_schemer/keyword.rb', line 8 def initialize(value, parent, keyword, schema = parent) @value = value @parent = parent @root = parent.root @keyword = keyword @schema = schema @parsed = parse end |
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
6 7 8 |
# File 'lib/json_schemer/keyword.rb', line 6 def parent @parent end |
#parsed ⇒ Object (readonly)
Returns the value of attribute parsed.
6 7 8 |
# File 'lib/json_schemer/keyword.rb', line 6 def parsed @parsed end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
6 7 8 |
# File 'lib/json_schemer/keyword.rb', line 6 def root @root end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
6 7 8 |
# File 'lib/json_schemer/keyword.rb', line 6 def value @value end |
Instance Method Details
#absolute_keyword_location ⇒ Object
21 22 23 |
# File 'lib/json_schemer/keyword.rb', line 21 def absolute_keyword_location @absolute_keyword_location ||= "#{parent.absolute_keyword_location}/#{fragment_encode(escaped_keyword)}" end |
#error_key ⇒ Object
29 30 31 |
# File 'lib/json_schemer/keyword.rb', line 29 def error_key keyword end |
#fetch(key) ⇒ Object
33 34 35 |
# File 'lib/json_schemer/keyword.rb', line 33 def fetch(key) parsed.fetch(parsed.is_a?(Array) ? key.to_i : key) end |
#parsed_schema ⇒ Object
37 38 39 |
# File 'lib/json_schemer/keyword.rb', line 37 def parsed_schema parsed.is_a?(Schema) ? parsed : nil end |
#schema_pointer ⇒ Object
25 26 27 |
# File 'lib/json_schemer/keyword.rb', line 25 def schema_pointer @schema_pointer ||= "#{parent.schema_pointer}/#{escaped_keyword}" end |
#validate(_instance, _instance_location, _keyword_location, _context) ⇒ Object
17 18 19 |
# File 'lib/json_schemer/keyword.rb', line 17 def validate(_instance, _instance_location, _keyword_location, _context) nil end |