mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-22 22:06:43 +00:00
Add a spec for #342 body/required
This commit is contained in:
parent
13a3977c2c
commit
5a60dee838
@ -3,6 +3,10 @@ class StubsController < ApplicationController
|
||||
render plain: 'OK'
|
||||
end
|
||||
|
||||
def create
|
||||
render plain: 'OK'
|
||||
end
|
||||
|
||||
def show
|
||||
render plain: 'OK'
|
||||
end
|
||||
|
||||
@ -181,7 +181,28 @@ RSpec.describe 'Generated OpenApi', type: :request, swagger_doc: 'v3/openapi.jso
|
||||
# TODO: Common Parameters
|
||||
end
|
||||
|
||||
describe 'Request Body'
|
||||
describe 'Request Body' do
|
||||
path '/stubs' do
|
||||
post 'body is required' do
|
||||
tags 'Media Types'
|
||||
consumes 'multipart/form-data'
|
||||
parameter name: :file, :in => :formData, :type => :file, required: true
|
||||
|
||||
let(:file) { Rack::Test::UploadedFile.new(Rails.root.join("spec/fixtures/thumbnail.png")) }
|
||||
|
||||
response '200', 'OK' do
|
||||
run_test!
|
||||
|
||||
it 'declares requestBody is required' do
|
||||
pending "This output is massaged in SwaggerFormatter#stop, and isn't quite ready here to assert"
|
||||
tree = swagger_doc.dig(:paths, "/stubs", :post, :requestBody)
|
||||
expect(tree[:required]).to eq(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Responses'
|
||||
describe 'Data Models (Schemas)'
|
||||
describe 'Examples'
|
||||
|
||||
@ -22,6 +22,30 @@
|
||||
"in": "query"
|
||||
}
|
||||
]
|
||||
},
|
||||
"post": {
|
||||
"summary": "body is required",
|
||||
"tags": [
|
||||
"Media Types"
|
||||
],
|
||||
"parameters": [
|
||||
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"multipart/form-data": {
|
||||
"schema": {
|
||||
"type": "file"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"/stubs/{a_param}": {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user