4 Commits
1.5.0 ... 1.5.1

Author SHA1 Message Date
domaindrivendev
d91601b02c Merge pull request #87 from BC-THooper/allow_for_undefined_in_parameter_key
Allows for parameters to be defined without the 'in' key defined.
2017-07-31 17:54:43 -07:00
Travis Hooper
037c0e374a Allows for parameters to be defined without the 'in' key defined to allow for parameter 2017-07-31 17:44:43 -05:00
domaindrivendev
8f16492462 Merge pull request #82 from domaindrivendev/per-response-metadata
Allow arbitrary metadata for path/response blocks
2017-07-22 10:33:05 -07:00
domaindrivendev
452d9176cc Allow arbitrary metadata for path/response blocks 2017-07-21 21:19:25 -07:00
2 changed files with 18 additions and 7 deletions

View File

@@ -2,9 +2,9 @@ module Rswag
module Specs
module ExampleGroupHelpers
def path(template, &block)
api_metadata = { path_item: { template: template } }
describe(template, api_metadata, &block)
def path(template, metadata={}, &block)
metadata[:path_item] = { template: template }
describe(template, metadata, &block)
end
[ :get, :post, :patch, :put, :delete, :head ].each do |verb|
@@ -36,7 +36,9 @@ module Rswag
end
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)
metadata[:operation][:parameters] ||= []
@@ -47,9 +49,9 @@ module Rswag
end
end
def response(code, description, &block)
api_metadata = { response: { code: code, description: description } }
context(description, api_metadata, &block)
def response(code, description, metadata={}, &block)
metadata[:response] = { code: code, description: description }
context(description, metadata, &block)
end
def schema(value)

View File

@@ -120,6 +120,15 @@ module Rswag
)
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
describe '#response(code, description)' do