Class: Jdoc::Link::RequestGenerator
- Inherits:
-
Object
- Object
- Jdoc::Link::RequestGenerator
- Defined in:
- lib/jdoc/link.rb
Class Method Summary collapse
-
.call(schema) ⇒ Hash
Generates example request body from given schema.
Class Method Details
.call(schema) ⇒ Hash
Note:
Not includes properties that have readOnly property
Generates example request body from given schema
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/jdoc/link.rb', line 128 def self.call(schema) schema.properties.inject({}) do |result, (key, value)| if value.data["readOnly"] result else result.merge( key => case when !value.properties.empty? call(value) when !value.data["example"].nil? value.data["example"] when value.type.include?("null") nil else raise ExampleNotFound, "No example found for #{schema.pointer}/#{key}" end ) end end end |