mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-22 22:06:43 +00:00
This will allow to describe multipart in a short way, like JSON payload:
Before:
put 'Creates a blog with thumbnail' do
consumes 'multipart/form-data'
parameter name: :title, in: :formData, type: :string, required: true
parameter name: :content, in: :formData, type: :string, required: true
parameter name: :file, in: :formData, type: :file, required: true
let(:blog) { FactoryBot.build(:blog) }
let(:title) { blog.title }
let(:content) { blog.content }
let(:file) { blog.file }
...
end
After:
put 'Creates a blog with thumbnail' do
consumes 'multipart/form-data'
parameter name: :blog, in: :formData, schema: { '$ref' => '#/definitions/blog' }
let(:blog) { FactoryBot.attributes_for(:blog) }
...
end
Your mileage may vary but you can always choose the best option.
14 lines
495 B
Ruby
14 lines
495 B
Ruby
require 'rails_helper'
|
|
|
|
RSpec.feature 'swagger-ui', js: true do
|
|
|
|
scenario 'browsing api-docs' do
|
|
visit '/api-docs'
|
|
|
|
expect(page).to have_content('GET /blogs Searches blogs', normalize_ws: true)
|
|
expect(page).to have_content('POST /blogs Creates a blog', normalize_ws: true)
|
|
expect(page).to have_content('POST /blogs/multipart Creates a blog using multipart', normalize_ws: true)
|
|
expect(page).to have_content('GET /blogs/{id} Retrieves a blog', normalize_ws: true)
|
|
end
|
|
end
|