6 Commits
1.5.2 ... 1.6.0

Author SHA1 Message Date
domaindrivendev
c8e9ab3221 Add puma to Gemfile to fix integration tests 2018-04-23 16:24:43 -07:00
domaindrivendev
26a3bf5079 avoid metadata mutation in request_factory 2018-04-23 16:00:07 -07:00
Richard Morris
12daacf9a5 Merge pull request #112 from akurashev/master
Fix Authorization header missing and duplicating
2018-04-23 15:49:32 -07:00
Andrey Kurashev
05e1e2271f Fix Authorization header missing and duplicating 2018-02-20 14:49:13 +06:00
domaindrivendev
07ae261e54 Bump ruby patch version 2017-10-21 14:25:12 -07:00
domaindrivendev
06d00de992 Assume symbol for referenced parameter key 2017-09-06 13:38:36 -07:00
5 changed files with 32 additions and 14 deletions

View File

@@ -1 +1 @@
2.3.0
2.3.1

View File

@@ -28,6 +28,7 @@ group :test do
gem 'generator_spec'
gem 'capybara'
gem 'capybara-webkit'
gem 'puma'
end
group :assets do

View File

@@ -29,9 +29,8 @@ module Rswag
path_item_params = metadata[:path_item][:parameters] || []
security_params = derive_security_params(metadata, swagger_doc)
operation_params
.concat(path_item_params)
.concat(security_params)
# NOTE: Use of + instead of concat to avoid mutation of the metadata object
(operation_params + path_item_params + security_params)
.map { |p| p['$ref'] ? resolve_parameter(p['$ref'], swagger_doc) : p }
.uniq { |p| p[:name] }
.reject { |p| p[:required] == false && !example.respond_to?(p[:name]) }
@@ -49,8 +48,8 @@ module Rswag
end
def resolve_parameter(ref, swagger_doc)
key = ref.sub('#/parameters/', '').to_sym
definitions = swagger_doc[:parameters]
key = ref.sub('#/parameters/', '')
raise "Referenced parameter '#{ref}' must be defined" unless definitions && definitions[key]
definitions[key]
end

View File

@@ -235,6 +235,23 @@ module Rswag
expect(request[:headers]).to eq('api_key' => 'foobar')
end
end
context 'in header with auth param already added' do
let(:key_location) { :header }
before do
metadata[:operation][:parameters] = [
{ name: 'q1', in: :query, type: :string },
{ name: 'api_key', in: :header, type: :string }
]
allow(example).to receive(:q1).and_return('foo')
allow(example).to receive(:api_key).and_return('foobar')
end
it 'adds authorization parameter only once' do
expect(request[:headers]).to eq('api_key' => 'foobar')
expect(metadata[:operation][:parameters].size).to eq 2
end
end
end
context 'oauth2' do
@@ -281,7 +298,7 @@ module Rswag
context 'referenced parameters' do
before do
swagger_doc[:parameters] = { 'q1' => { name: 'q1', in: :query, type: :string } }
swagger_doc[:parameters] = { q1: { name: 'q1', in: :query, type: :string } }
metadata[:operation][:parameters] = [ { '$ref' => '#/parameters/q1' } ]
allow(example).to receive(:q1).and_return('foo')
end

View File

@@ -1,3 +1,4 @@
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
@@ -8,16 +9,16 @@
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(version: 20160218212104) do
ActiveRecord::Schema.define(:version => 20160218212104) do
create_table "blogs", force: :cascade do |t|
create_table "blogs", :force => true do |t|
t.string "title"
t.text "content"
t.string "thumbnail"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
end