mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-25 15:22:56 +00:00
Rename response_examples to examples for consistent DSL
Special handling `examples` invocation with no parameters to avoid overriding the `examples` method of rspec-core ExampleGroup
This commit is contained in:
@@ -113,7 +113,7 @@ module Rswag
|
||||
context "'path' parameter" do
|
||||
before { subject.parameter(name: :id, in: :path) }
|
||||
let(:api_metadata) { { operation: {} } }
|
||||
|
||||
|
||||
it "automatically sets the 'required' flag" do
|
||||
expect(api_metadata[:operation][:parameters]).to match(
|
||||
[ name: :id, in: :path, required: true ]
|
||||
@@ -151,6 +151,25 @@ module Rswag
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#examples(example)' do
|
||||
let(:json_example) do
|
||||
{
|
||||
'application/json' => {
|
||||
foo: 'bar'
|
||||
}
|
||||
}
|
||||
end
|
||||
let(:api_metadata) { { response: {} } }
|
||||
|
||||
before do
|
||||
subject.examples(json_example)
|
||||
end
|
||||
|
||||
it "adds to the 'response examples' metadata" do
|
||||
expect(api_metadata[:response][:examples]).to eq(json_example)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user