Class: Plumb::JSONSchemaVisitor

Inherits:
Object
  • Object
show all
Includes:
VisitorHandlers
Defined in:
lib/plumb/json_schema_visitor.rb

Constant Summary collapse

TYPE =
'type'
PROPERTIES =
'properties'
REQUIRED =
'required'
DEFAULT =
'default'
ANY_OF =
'anyOf'
ALL_OF =
'allOf'
NOT =
'not'
ENUM =
'enum'
CONST =
'const'
ITEMS =
'items'
PATTERN =
'pattern'
MINIMUM =
'minimum'
MAXIMUM =
'maximum'
MIN_ITEMS =
'minItems'
MAX_ITEMS =
'maxItems'
MIN_LENGTH =
'minLength'
MAX_LENGTH =
'maxLength'
FORMAT =
'format'
ENVELOPE =
{
  '$schema' => 'https://json-schema.org/draft-08/schema#'
}.freeze

Class Method Summary collapse

Methods included from VisitorHandlers

included, #on_missing_handler, #visit, #visit_children, #visit_name

Class Method Details

.call(node, root: true) ⇒ Object



32
33
34
35
36
37
# File 'lib/plumb/json_schema_visitor.rb', line 32

def self.call(node, root: true)
  data = new.visit(node)
  return data unless root

  ENVELOPE.merge(data)
end