mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-25 07:16:40 +00:00
Adds fix for multiple files to be marked in request_body_multipart
This commit is contained in:
parent
6467ce6543
commit
6a4cc8de8d
@ -106,12 +106,11 @@ module OpenApi
|
|||||||
request_body(description: description, content: content_hash)
|
request_body(description: description, content: content_hash)
|
||||||
|
|
||||||
schema.extend(Hashie::Extensions::DeepLocate)
|
schema.extend(Hashie::Extensions::DeepLocate)
|
||||||
file_properties = schema.deep_locate -> (_k, v, _obj) { v == :binary }
|
file_properties = schema.deep_locate ->(_k, v, _obj) { v == :binary }
|
||||||
|
|
||||||
hash_locator = []
|
hash_locator = []
|
||||||
|
|
||||||
file_properties.each do |match|
|
file_properties.each do |match|
|
||||||
hash_match = schema.deep_locate -> (_k, v, _obj) { v == match }
|
hash_match = schema.deep_locate ->(_k, v, _obj) { v == match }
|
||||||
hash_locator.concat(hash_match) unless hash_match.empty?
|
hash_locator.concat(hash_match) unless hash_match.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -119,11 +118,19 @@ module OpenApi
|
|||||||
locator.select { |_k,v| file_properties.include?(v) }
|
locator.select { |_k,v| file_properties.include?(v) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
existing_keys = []
|
||||||
property_hashes.each do |property_hash|
|
property_hashes.each do |property_hash|
|
||||||
file_name = property_hash.keys.first
|
property_hash.keys.each do |k|
|
||||||
|
if existing_keys.include?(k)
|
||||||
|
next
|
||||||
|
else
|
||||||
|
file_name = k
|
||||||
|
existing_keys << k
|
||||||
parameter name: file_name, in: :formData, type: :file, required: true
|
parameter name: file_name, in: :formData, type: :file, required: true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def parameter(attributes)
|
def parameter(attributes)
|
||||||
if attributes[:in] && attributes[:in].to_sym == :path
|
if attributes[:in] && attributes[:in].to_sym == :path
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user