Class: JSON::Fuzz::Generator::Keyword::AdditionalProperties
- Inherits:
-
Object
- Object
- JSON::Fuzz::Generator::Keyword::AdditionalProperties
- Defined in:
- lib/json/fuzz/generator/keyword/additional_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 22 23 24 25 26 27 28 |
# File 'lib/json/fuzz/generator/keyword/additional_properties.rb', line 7 def invalid_params(attributes) attributes = Marshal.load(Marshal.dump(attributes)) additional_properties = attributes.delete("additionalProperties") raise "No additionalProperties keyword given: #{attributes}" if additional_properties.nil? template = JSON::Fuzz::Generator.default_param(attributes) additional_key = nil until (additional_key) key = /\w+/.gen additional_key = key unless template.key?(key) end if additional_properties additional_param = JSON::Fuzz::Generator.generate(additional_properties).sample template[additional_key] = additional_param else template[additional_key] = template[template.keys.sample] end [template] end |
.valid_param(attributes) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/json/fuzz/generator/keyword/additional_properties.rb', line 30 def valid_param(attributes) attributes = Marshal.load(Marshal.dump(attributes)) additional_properties = attributes.delete("additionalProperties") raise "No additionalProperties keyword given: #{attributes}" if additional_properties.nil? template = JSON::Fuzz::Generator.default_param(attributes) if additional_properties additional_param = nil if additional_properties.instance_of?(Hash) additional_param = JSON::Fuzz::Generator.default_param(additional_properties) else additional_param = template[template.keys.sample] end additional_key = nil until (additional_key) key = /\w+/.gen additional_key = key unless template.key?(key) end template[additional_key] = additional_param end template end |