class Jfuzz::SchemaFuzzer
Attributes
property_fuzzer[R]
schema_path[R]
Public Class Methods
new(schema_path)
click to toggle source
# File lib/jfuzz/schema_fuzzer.rb, line 9 def initialize(schema_path) @schema_path = schema_path @property_fuzzer = PropertyFuzzer.new end
Public Instance Methods
fuzz()
click to toggle source
# File lib/jfuzz/schema_fuzzer.rb, line 14 def fuzz raise "Schema path cannot be nil or empty" if schema_path.to_s.nil? schema_contents = File.read(schema_path) schema = JSON.parse(schema_contents) fuzzed = property_fuzzer.fuzz_property(schema) json_schema = JsonSchema.parse!(schema) is_valid, validation_errors = json_schema.validate(fuzzed) unless is_valid raise "Error in the report validation. Produced invalid JSON file " \ "according to JSON schema #{schema_path}. " \ "Validation errors: #{validation_errors}" end fuzzed end