Class: JSON::Fuzz::Generator::Keyword::Properties

Inherits:
Object
  • Object
show all
Defined in:
lib/json/fuzz/generator/keyword/properties.rb

Class Method Summary collapse

Class Method Details

.invalid_params(attributes) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/json/fuzz/generator/keyword/properties.rb', line 7

def invalid_params(attributes)
  properties = attributes["members"] || attributes["properties"]
  raise "No properties or members keyword given: #{attributes}" unless properties

  generated_params = []

  properties.each do |key, attribute|
    JSON::Fuzz::Generator.generate(attribute).each do |invalid_param|
      template = JSON::Fuzz::Generator.default_param(attributes)
      generated_params << template.merge(key => invalid_param)
    end
  end

  generated_params
end

.valid_param(attributes) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/json/fuzz/generator/keyword/properties.rb', line 23

def valid_param(attributes)
  properties = attributes["members"] || attributes["properties"]
  raise "No properties or members keyword given: #{attributes}" unless properties

  generated_param = {}

  properties.each do |key, attribute|
    generated_param[key] = JSON::Fuzz::Generator.default_param(attribute)
  end

  generated_param
end