188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
# File 'lib/praxis/types/multipart_array.rb', line 188
def self.describe_attributes(shallow=true, example: nil)
self.attributes.each_with_object({}) do |(part_name, part_attribute), parts|
sub_example = example.part(part_name) if example
if sub_example && self.multiple.include?(part_name)
sub_example = sub_example.first
end
sub_hash = part_attribute.describe(shallow, example: sub_example)
if (options = sub_hash.delete(:options))
sub_hash[:options] = {}
if self.multiple.include?(part_name)
sub_hash[:options][:multiple] = true
end
if (payload_attribute = options.delete :payload_attribute)
if (required = payload_attribute.options[:required])
sub_hash[:options][:required] = true
end
end
end
sub_hash[:type] = MultipartPart.describe(shallow, example: sub_example, options: part_attribute.options)
parts[part_name] = sub_hash
end
end
|