Class: Rswag::Helpers::Schema
- Inherits:
-
Object
- Object
- Rswag::Helpers::Schema
- Defined in:
- lib/rswag/helpers/schema.rb
Direct Known Subclasses
Class Method Summary collapse
Class Method Details
.extract_defaults(hash) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/rswag/helpers/schema.rb', line 25 def extract_defaults(hash) {}.tap do |h| hash.each do |k, v| h[k] = v[:default] || v[:example] end end end |
.request_body(source_hash = nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rswag/helpers/schema.rb', line 7 def request_body(source_hash = nil) source_hash ||= schema if source_hash.keys.include?(:properties) properties = source_hash[:properties] if properties.keys.length == 1 # has nested key nested_key = properties.keys.first { nested_key => request_body(properties[nested_key]) } else extract_defaults(properties) end else extract_defaults(source_hash) end end |