mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-25 23:32:58 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d91601b02c | ||
|
|
037c0e374a | ||
|
|
8f16492462 | ||
|
|
452d9176cc |
@@ -2,9 +2,9 @@ module Rswag
|
|||||||
module Specs
|
module Specs
|
||||||
module ExampleGroupHelpers
|
module ExampleGroupHelpers
|
||||||
|
|
||||||
def path(template, &block)
|
def path(template, metadata={}, &block)
|
||||||
api_metadata = { path_item: { template: template } }
|
metadata[:path_item] = { template: template }
|
||||||
describe(template, api_metadata, &block)
|
describe(template, metadata, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
[ :get, :post, :patch, :put, :delete, :head ].each do |verb|
|
[ :get, :post, :patch, :put, :delete, :head ].each do |verb|
|
||||||
@@ -36,7 +36,9 @@ module Rswag
|
|||||||
end
|
end
|
||||||
|
|
||||||
def parameter(attributes)
|
def parameter(attributes)
|
||||||
attributes[:required] = true if attributes[:in].to_sym == :path
|
if attributes[:in] && attributes[:in].to_sym == :path
|
||||||
|
attributes[:required] = true
|
||||||
|
end
|
||||||
|
|
||||||
if metadata.has_key?(:operation)
|
if metadata.has_key?(:operation)
|
||||||
metadata[:operation][:parameters] ||= []
|
metadata[:operation][:parameters] ||= []
|
||||||
@@ -47,9 +49,9 @@ module Rswag
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def response(code, description, &block)
|
def response(code, description, metadata={}, &block)
|
||||||
api_metadata = { response: { code: code, description: description } }
|
metadata[:response] = { code: code, description: description }
|
||||||
context(description, api_metadata, &block)
|
context(description, metadata, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
def schema(value)
|
def schema(value)
|
||||||
|
|||||||
@@ -120,6 +120,15 @@ module Rswag
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "when 'in' parameter key is not defined" do
|
||||||
|
before { subject.parameter(name: :id) }
|
||||||
|
let(:api_metadata) { { operation: {} } }
|
||||||
|
|
||||||
|
it "does not require the 'in' parameter key" do
|
||||||
|
expect(api_metadata[:operation][:parameters]).to match([ name: :id ])
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#response(code, description)' do
|
describe '#response(code, description)' do
|
||||||
|
|||||||
Reference in New Issue
Block a user