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
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
# File 'lib/jdoc/link.rb', line 273 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 |