mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-25 23:32:58 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8e9ab3221 | ||
|
|
26a3bf5079 | ||
|
|
12daacf9a5 | ||
|
|
05e1e2271f | ||
|
|
07ae261e54 | ||
|
|
06d00de992 |
@@ -1 +1 @@
|
||||
2.3.0
|
||||
2.3.1
|
||||
|
||||
1
Gemfile
1
Gemfile
@@ -28,6 +28,7 @@ group :test do
|
||||
gem 'generator_spec'
|
||||
gem 'capybara'
|
||||
gem 'capybara-webkit'
|
||||
gem 'puma'
|
||||
end
|
||||
|
||||
group :assets do
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user