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
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/jdoc/link.rb', line 261 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 |