diff --git a/rswag-specs/lib/rswag/specs/example_group_helpers.rb b/rswag-specs/lib/rswag/specs/example_group_helpers.rb index 93f1050..c293c63 100644 --- a/rswag-specs/lib/rswag/specs/example_group_helpers.rb +++ b/rswag-specs/lib/rswag/specs/example_group_helpers.rb @@ -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] ||= [] diff --git a/rswag-specs/spec/rswag/specs/example_group_helpers_spec.rb b/rswag-specs/spec/rswag/specs/example_group_helpers_spec.rb index 96d08b0..619a8d7 100644 --- a/rswag-specs/spec/rswag/specs/example_group_helpers_spec.rb +++ b/rswag-specs/spec/rswag/specs/example_group_helpers_spec.rb @@ -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