mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-25 07:16:40 +00:00
add header type schema support for openapi3
This commit is contained in:
parent
a25307dc69
commit
da230a4f3e
@ -157,12 +157,6 @@ module Rswag
|
|||||||
def header(name, attributes)
|
def header(name, attributes)
|
||||||
metadata[:response][:headers] ||= {}
|
metadata[:response][:headers] ||= {}
|
||||||
|
|
||||||
## OA3
|
|
||||||
# if attributes[:type] && attributes[:schema].nil?
|
|
||||||
# attributes[:schema] = { type: attributes[:type] }
|
|
||||||
# attributes.delete(:type)
|
|
||||||
# end
|
|
||||||
|
|
||||||
metadata[:response][:headers][name] = attributes
|
metadata[:response][:headers][name] = attributes
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -127,8 +127,9 @@ module Rswag
|
|||||||
def upgrade_request_type!(metadata)
|
def upgrade_request_type!(metadata)
|
||||||
operation_nodes = metadata[:operation][:parameters] || []
|
operation_nodes = metadata[:operation][:parameters] || []
|
||||||
path_nodes = metadata[:path_item][:parameters] || []
|
path_nodes = metadata[:path_item][:parameters] || []
|
||||||
|
header_node = metadata[:response][:headers] ||= {}
|
||||||
|
|
||||||
(operation_nodes + path_nodes).each do |node|
|
(operation_nodes + path_nodes + [header_node]).each do |node|
|
||||||
if node && node[:type] && node[:schema].nil?
|
if node && node[:type] && node[:schema].nil?
|
||||||
node[:schema] = { type: node[:type] }
|
node[:schema] = { type: node[:type] }
|
||||||
node.delete(:type)
|
node.delete(:type)
|
||||||
|
|||||||
@ -27,20 +27,6 @@ module Rswag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
## OA3
|
|
||||||
# let(:swagger_doc) do
|
|
||||||
# {
|
|
||||||
# components: {
|
|
||||||
# securitySchemes: {
|
|
||||||
# api_key: {
|
|
||||||
# type: :apiKey,
|
|
||||||
# name: 'api_key',
|
|
||||||
# in: :query
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
# end
|
|
||||||
|
|
||||||
let(:metadata) do
|
let(:metadata) do
|
||||||
{
|
{
|
||||||
|
|||||||
@ -28,7 +28,7 @@ module Rswag
|
|||||||
{
|
{
|
||||||
path_item: { template: '/blogs', parameters: [{ type: :string }] },
|
path_item: { template: '/blogs', parameters: [{ type: :string }] },
|
||||||
operation: { verb: :post, summary: 'Creates a blog', parameters: [{ type: :string }] },
|
operation: { verb: :post, summary: 'Creates a blog', parameters: [{ type: :string }] },
|
||||||
response: { code: '201', description: 'blog created' },
|
response: { code: '201', description: 'blog created', headers: { type: :string } },
|
||||||
document: document
|
document: document
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@ -55,7 +55,10 @@ module Rswag
|
|||||||
parameters: [{ type: :string }],
|
parameters: [{ type: :string }],
|
||||||
summary: 'Creates a blog',
|
summary: 'Creates a blog',
|
||||||
responses: {
|
responses: {
|
||||||
'201' => { description: 'blog created' }
|
'201' => {
|
||||||
|
description: 'blog created',
|
||||||
|
headers: { type: :string }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,7 +81,10 @@ module Rswag
|
|||||||
parameters: [{ schema: { type: :string } }],
|
parameters: [{ schema: { type: :string } }],
|
||||||
summary: 'Creates a blog',
|
summary: 'Creates a blog',
|
||||||
responses: {
|
responses: {
|
||||||
'201' => { description: 'blog created' }
|
'201' => {
|
||||||
|
description: 'blog created',
|
||||||
|
headers: { schema: { type: :string } }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user