Class: Jdoc::Link::ResponseGenerator
- Inherits:
-
Object
- Object
- Jdoc::Link::ResponseGenerator
- Defined in:
- lib/jdoc/link.rb
Class Method Summary collapse
-
.call(properties) ⇒ Hash
Generates example response Hash from given schema.
Class Method Details
.call(properties) ⇒ Hash
Generates example response Hash from given schema
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/jdoc/link.rb', line 213 def self.call(properties) properties.inject({}) do |result, (key, value)| result.merge( key => case when !value.properties.empty? call(value.properties) when !value.data["example"].nil? value.data["example"] when value.type.include?("null") nil when value.type.include?("array") if example = value.items.data["example"] [example] else [call(value.items.properties)] end else raise ExampleNotFound, "No example found for #{value.pointer}" end ) end end |