mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-23 06:16:42 +00:00
add specific test for formData
This commit is contained in:
parent
e53f2ca257
commit
b158f1e164
@ -55,7 +55,7 @@ module Rswag
|
||||
v.each_pair do |_verb, value|
|
||||
is_hash = value.is_a?(Hash)
|
||||
if is_hash && value.dig(:parameters)
|
||||
schema_param = value.dig(:parameters)&.find { |p| p[:in] == :body && p[:schema] }
|
||||
schema_param = value.dig(:parameters)&.find { |p| (p[:in] == :body || p[:in] == :formData) && p[:schema] }
|
||||
mime_list = value.dig(:consumes)
|
||||
if value && schema_param && mime_list
|
||||
value[:requestBody] = { content: {} } unless value.dig(:requestBody, :content)
|
||||
|
||||
@ -240,6 +240,40 @@ module Rswag
|
||||
end
|
||||
end
|
||||
|
||||
context 'with oauth3 formData' do
|
||||
let(:doc_2) do
|
||||
{
|
||||
paths: {
|
||||
'/path/' => {
|
||||
post: {
|
||||
summary: 'Retrieve Nested Paths',
|
||||
tags: ['nested Paths'],
|
||||
produces: ['application/json'],
|
||||
consumes: ['multipart/form-data'],
|
||||
parameters: [{
|
||||
in: :formData,
|
||||
schema: { type: :file }
|
||||
},{
|
||||
in: :headers
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
it 'removes remaining consumes/produces' do
|
||||
expect(doc_2[:paths]['/path/'][:post].keys).to eql([:summary, :tags, :parameters, :requestBody])
|
||||
end
|
||||
|
||||
it 'duplicates params in: :formData to requestBody from consumes list' do
|
||||
expect(doc_2[:paths]['/path/'][:post][:parameters]).to eql([{ in: :headers }])
|
||||
expect(doc_2[:paths]['/path/'][:post][:requestBody]).to eql(content: {
|
||||
'multipart/form-data' => { schema: { type: :file } }
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
after do
|
||||
FileUtils.rm_r(swagger_root) if File.exist?(swagger_root)
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user