mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-25 07:16:40 +00:00
Adding yaml as option for generator
New installations will get :yaml as it's default with openapi 3 as the version. Old installations will have the key missing and will default to :json with an easy upgrade path.
This commit is contained in:
@@ -6,7 +6,9 @@ module Rswag
|
||||
RSpec.describe Configuration do
|
||||
subject { described_class.new(rspec_config) }
|
||||
|
||||
let(:rspec_config) { OpenStruct.new(swagger_root: swagger_root, swagger_docs: swagger_docs) }
|
||||
let(:rspec_config) do
|
||||
OpenStruct.new(swagger_root: swagger_root, swagger_docs: swagger_docs, swagger_format: swagger_format)
|
||||
end
|
||||
let(:swagger_root) { 'foobar' }
|
||||
let(:swagger_docs) do
|
||||
{
|
||||
@@ -14,6 +16,7 @@ module Rswag
|
||||
'v2/swagger.json' => { info: { title: 'v2' } }
|
||||
}
|
||||
end
|
||||
let(:swagger_format) { :yaml }
|
||||
|
||||
describe '#swagger_root' do
|
||||
let(:response) { subject.swagger_root }
|
||||
@@ -46,6 +49,26 @@ module Rswag
|
||||
end
|
||||
end
|
||||
|
||||
describe '#swagger_format' do
|
||||
let(:response) { subject.swagger_format }
|
||||
|
||||
context 'provided in rspec config' do
|
||||
it { expect(response).to be_an_instance_of(Symbol) }
|
||||
end
|
||||
|
||||
context 'unsupported format provided' do
|
||||
let(:swagger_format) { :xml }
|
||||
|
||||
it { expect { response }.to raise_error ConfigurationError }
|
||||
end
|
||||
|
||||
context 'not provided' do
|
||||
let(:swagger_format) { nil }
|
||||
|
||||
it { expect(response).to eq(:json) }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#get_swagger_doc(tag=nil)' do
|
||||
let(:swagger_doc) { subject.get_swagger_doc(tag) }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user