mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-22 22:06:43 +00:00
Move path metadata into 'path_item' hash
This commit is contained in:
parent
b81b2927be
commit
de09df59e1
@ -2,9 +2,9 @@ module Rswag
|
|||||||
module Specs
|
module Specs
|
||||||
module ExampleGroupHelpers
|
module ExampleGroupHelpers
|
||||||
|
|
||||||
def path(path, &block)
|
def path(template, &block)
|
||||||
api_metadata = { path: path}
|
api_metadata = { path_item: { template: template } }
|
||||||
describe(path, api_metadata, &block)
|
describe(template, api_metadata, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
[ :get, :post, :patch, :put, :delete, :head ].each do |verb|
|
[ :get, :post, :patch, :put, :delete, :head ].each do |verb|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ module Rswag
|
|||||||
end
|
end
|
||||||
|
|
||||||
def build_fullpath(example)
|
def build_fullpath(example)
|
||||||
@api_metadata[:path].dup.tap do |t|
|
@api_metadata[:path_item][:template].dup.tap do |t|
|
||||||
t.prepend(@global_metadata[:basePath] || '')
|
t.prepend(@global_metadata[:basePath] || '')
|
||||||
parameters_in(:path).each { |p| t.gsub!("{#{p[:name]}}", example.send(p[:name]).to_s) }
|
parameters_in(:path).each { |p| t.gsub!("{#{p[:name]}}", example.send(p[:name]).to_s) }
|
||||||
t.concat(build_query_string(example))
|
t.concat(build_query_string(example))
|
||||||
|
|||||||
@ -56,7 +56,7 @@ module Rswag
|
|||||||
|
|
||||||
{
|
{
|
||||||
paths: {
|
paths: {
|
||||||
metadata[:path] => {
|
metadata[:path_item][:template] => {
|
||||||
verb => operation
|
verb => operation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,7 @@ module Rswag
|
|||||||
|
|
||||||
it "delegates to 'describe' with 'path' metadata" do
|
it "delegates to 'describe' with 'path' metadata" do
|
||||||
expect(subject).to have_received(:describe).with(
|
expect(subject).to have_received(:describe).with(
|
||||||
'/blogs', path: '/blogs'
|
'/blogs', path_item: { template: '/blogs' }
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -16,7 +16,7 @@ module Rswag
|
|||||||
end
|
end
|
||||||
let(:api_metadata) do
|
let(:api_metadata) do
|
||||||
{
|
{
|
||||||
path: '/blogs/{blog_id}/comments/{id}',
|
path_item: { template: '/blogs/{blog_id}/comments/{id}' },
|
||||||
operation: {
|
operation: {
|
||||||
verb: :put,
|
verb: :put,
|
||||||
summary: 'Updates a blog',
|
summary: 'Updates a blog',
|
||||||
|
|||||||
@ -12,7 +12,7 @@ module Rswag
|
|||||||
end
|
end
|
||||||
let(:api_metadata) do
|
let(:api_metadata) do
|
||||||
{
|
{
|
||||||
path: '/blogs/{blog_id}/comments/{id}',
|
path_item: { template: '/blogs/{blog_id}/comments/{id}' },
|
||||||
operation: {
|
operation: {
|
||||||
verb: :put,
|
verb: :put,
|
||||||
summary: 'Updates a blog',
|
summary: 'Updates a blog',
|
||||||
|
|||||||
@ -24,7 +24,7 @@ module Rswag
|
|||||||
let(:notification) { OpenStruct.new(group: OpenStruct.new(metadata: api_metadata)) }
|
let(:notification) { OpenStruct.new(group: OpenStruct.new(metadata: api_metadata)) }
|
||||||
let(:api_metadata) do
|
let(:api_metadata) do
|
||||||
{
|
{
|
||||||
path: '/blogs',
|
path_item: { template: '/blogs' },
|
||||||
operation: { verb: :post, summary: 'Creates a blog' },
|
operation: { verb: :post, summary: 'Creates a blog' },
|
||||||
response: { code: '201', description: 'blog created' }
|
response: { code: '201', description: 'blog created' }
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user