Module: Prmd::Verification

Defined in:
lib/prmd/commands/verify.rb

Overview

Schema Verification

Constant Summary collapse

SCHEMAS =

These schemas are listed manually and in order because they reference each other.

[
  'schema.json',
  'hyper-schema.json',
  'interagent-hyper-schema.json'
]

Class Method Summary collapse

Class Method Details

.add_schema(store, file) ⇒ Object


27
28
29
30
31
32
# File 'lib/prmd/commands/verify.rb', line 27

def self.add_schema(store, file)
  data = JSON.parse(File.read(file))
  schema = JsonSchema::Parser.new.parse!(data)
  schema.expand_references!(store: store)
  store.add_schema(schema)
end

.verify(schema_data, custom_schema: nil) ⇒ Array<String>

Verfies that a given schema is valid

Parameters:

  • schema_data (Hash)

Returns:

  • (Array<String>)

    errors from failed verification


78
79
80
81
82
83
84
85
# File 'lib/prmd/commands/verify.rb', line 78

def self.verify(schema_data, custom_schema: nil)
  @custom_schema = custom_schema
  a = verify_schema(schema_data)
  return a unless a.empty?
  b = verify_parsable(schema_data)
  return b unless b.empty?
  []
end