Add upgrades for consumes and produces in content with schemas

This commit is contained in:
Greg Myers
2020-03-26 23:37:00 +00:00
parent c739228c89
commit 405ccca494
5 changed files with 43 additions and 30 deletions

View File

@@ -154,16 +154,8 @@ module Rswag
before { subject.schema(type: 'object') }
let(:api_metadata) { { response: {} } }
context 'swagger 2.0' do
it "adds to the 'response' metadata" do
expect(api_metadata[:response][:schema]).to match(type: 'object')
end
end
context 'openapi 3.0' do
it "adds to the 'response' metadata" do
expect(api_metadata[:response][:content]['application/json'][:schema]).to match(type: 'object')
end
it "adds to the 'response' metadata" do
expect(api_metadata[:response][:schema]).to match(type: 'object')
end
end

View File

@@ -26,7 +26,7 @@ module Rswag
{
path_item: { template: '/blogs', parameters: [{ type: :string }] },
operation: { verb: :post, summary: 'Creates a blog', parameters: [{ type: :string }] },
response: { code: '201', description: 'blog created', headers: { type: :string } },
response: { code: '201', description: 'blog created', headers: { type: :string }, schema: { '$ref' => '#/definitions/blog' } },
document: document
}
end
@@ -57,7 +57,8 @@ module Rswag
responses: {
'201' => {
description: 'blog created',
headers: { type: :string }
headers: { type: :string },
schema: { '$ref' => '#/definitions/blog' }
}
}
}
@@ -74,6 +75,7 @@ module Rswag
basePath: '/foo',
schemes: ['http', 'https'],
host: 'api.example.com',
produces: ['application/vnd.my_mime', 'application/json'],
components: {
securitySchemes: {
my_oauth: {
@@ -95,6 +97,14 @@ module Rswag
summary: 'Creates a blog',
responses: {
'201' => {
content: {
'application/vnd.my_mime' => {
schema: { '$ref' => '#/definitions/blog' }
},
'application/json' => {
schema: { '$ref' => '#/definitions/blog' }
}
},
description: 'blog created',
headers: { schema: { type: :string } }
}