apipie-rails 0.5.14 → 0.5.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: '018d734565f6849bf6c073c6774b2a99082bd6b88f15221999ae80b40c0efacc'
4
- data.tar.gz: 00711a809dbdab171df9f447a3a6e7a8613cc89fa3ec7d632a036b5e2970c83d
2
+ SHA1:
3
+ metadata.gz: a05f50c6c4364f6e0c0ad119a9061f4daef9e2f5
4
+ data.tar.gz: 05ea27245215efd3d2e2d685fa5e82b9de0e17b8
5
5
  SHA512:
6
- metadata.gz: 239806146c1a87920924fcb3ea63d8401edb21aa69b13a1f1305cdd4c2404c05f000cda9684fbdddd785b4124c0dde5540c6eaf78371e3e30172a96af6c54ac5
7
- data.tar.gz: 1a58f612309c9c58c646805dabb64543257e26aa77e0132e8fc7b7d23fbe270008d449e39b00f4e89cc20b4920a044e428721df88c7427d6f114c7a3ee3b2423
6
+ metadata.gz: 07198e0935b6f4c8ea51616153b29578213614de9a783a602d9edf9ebde2223652ddb1482a55a48a0bdb6582423fe4ff6c807412c4bb0529736b5c0d4f3453b4
7
+ data.tar.gz: a4cb3227c448f0f444e6c28972b8d1d6788f011ab3c9bdea8accbf9b41ec614393edff8aafd8c1a521f3a18f05e3eaee767da65cf0f49a2fedfac99f4e046a3a
@@ -1,6 +1,15 @@
1
1
  Changelog
2
2
  ===========
3
3
 
4
+ [v0.5.15](https://github.com/Apipie/apipie-rails/tree/v0.5.15) (2019-01-03)
5
+ --------
6
+ [Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.5.14...v0.5.15)
7
+
8
+
9
+ - Fix authorization of resources [\#655](https://github.com/Apipie/apipie-rails/pull/655) ([NielsKSchjoedt](https://github.com/NielsKSchjoedt))
10
+ - Use configured value when swagger\_content\_type\_input argument is not passed [\#648](https://github.com/Apipie/apipie-rails/pull/648) ([nullnull](https://github.com/nullnull))
11
+ - Fix "ArgumentError: string contains null byte" on malformed stings [\#477](https://github.com/Apipie/apipie-rails/pull/477) ([avokhmin](https://github.com/avokhmin))
12
+
4
13
  v0.5.14
5
14
  -------
6
15
  - HTML escape validator values [\#645](https://github.com/Apipie/apipie-rails/pull/645) ([ekohl](https://github.com/ekohl))
data/Gemfile CHANGED
@@ -1 +1 @@
1
- ./Gemfile.rails50
1
+ Gemfile.rails50
@@ -115,20 +115,30 @@ module Apipie
115
115
 
116
116
  new_doc = { :docs => @doc[:docs].clone }
117
117
 
118
- new_doc[:docs][:resources] = @doc[:docs][:resources].select do |k, v|
119
- if instance_exec(k, nil, v, &Apipie.configuration.authorize)
120
- v[:methods] = v[:methods].select do |h|
121
- instance_exec(k, h[:name], h, &Apipie.configuration.authorize)
122
- end
123
- true
124
- else
125
- false
118
+ new_doc[:docs][:resources] = if @doc[:docs][:resources].kind_of?(Array)
119
+ @doc[:docs][:resources].select do |resource|
120
+ authorize_resource(resource)
121
+ end
122
+ else
123
+ @doc[:docs][:resources].select do |_resource_name, resource|
124
+ authorize_resource(resource)
126
125
  end
127
126
  end
128
127
 
129
128
  new_doc
130
129
  end
131
130
 
131
+ def authorize_resource resource
132
+ if instance_exec(resource[:id], nil, resource, &Apipie.configuration.authorize)
133
+ resource[:methods] = resource[:methods].select do |m|
134
+ instance_exec(resource[:id], m[:name], m, &Apipie.configuration.authorize)
135
+ end
136
+ true
137
+ else
138
+ false
139
+ end
140
+ end
141
+
132
142
  def get_format
133
143
  [:resource, :method, :version].each do |par|
134
144
  next unless params[par]
@@ -106,6 +106,7 @@ module Apipie
106
106
 
107
107
  {
108
108
  :doc_url => doc_url,
109
+ :id => _id,
109
110
  :api_url => api_url,
110
111
  :name => @_name,
111
112
  :short_description => Apipie.app.translate(@_short_description, lang),
@@ -8,9 +8,10 @@ module Apipie
8
8
  end
9
9
 
10
10
  def match?(path)
11
- path = path.dup
11
+ # Replace all null bytes
12
+ path = ::Rack::Utils.unescape(path || '').gsub(/\x0/, '')
12
13
 
13
- full_path = path.empty? ? @root : File.join(@root, ::Rack::Utils.unescape(path))
14
+ full_path = path.empty? ? @root : File.join(@root, path)
14
15
  paths = "#{full_path}#{ext}"
15
16
 
16
17
  matches = Dir[paths]
@@ -1,3 +1,3 @@
1
1
  module Apipie
2
- VERSION = '0.5.14'
2
+ VERSION = '0.5.15'
3
3
  end
@@ -191,7 +191,7 @@ namespace :apipie do
191
191
 
192
192
  def generate_swagger_using_args(args, out)
193
193
  args.with_defaults(:version => Apipie.configuration.default_version,
194
- :swagger_content_type_input => :form_data,
194
+ :swagger_content_type_input => Apipie.configuration.swagger_content_type_input || :form_data,
195
195
  :filename_suffix => nil)
196
196
  Apipie.configuration.swagger_content_type_input = args[:swagger_content_type_input].to_sym
197
197
  count = 0
@@ -0,0 +1,18 @@
1
+ require "spec_helper"
2
+
3
+ describe Apipie::FileHandler do
4
+
5
+ describe "match?" do
6
+ let(:file_handler) { Apipie::FileHandler.new File.dirname(__FILE__) }
7
+
8
+ it { expect(file_handler.match? 'file_handler_spec.rb').to be_truthy }
9
+ it { expect(file_handler.match? 'foo.bar').to be_falsy }
10
+
11
+ context 'path contains null bytes' do
12
+ let(:path) { "foo%00.bar" }
13
+
14
+ it { expect(file_handler.match? path).to be_falsy }
15
+ it { expect { file_handler.match? path }.to_not raise_error }
16
+ end
17
+ end
18
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apipie-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.14
4
+ version: 0.5.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Pokorny
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-11-16 00:00:00.000000000 Z
12
+ date: 2019-01-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -299,6 +299,7 @@ files:
299
299
  - spec/lib/extractor/extractor_spec.rb
300
300
  - spec/lib/extractor/middleware_spec.rb
301
301
  - spec/lib/extractor/writer_spec.rb
302
+ - spec/lib/file_handler_spec.rb
302
303
  - spec/lib/method_description_spec.rb
303
304
  - spec/lib/param_description_spec.rb
304
305
  - spec/lib/param_group_spec.rb
@@ -331,7 +332,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
331
332
  version: '0'
332
333
  requirements: []
333
334
  rubyforge_project:
334
- rubygems_version: 2.7.6
335
+ rubygems_version: 2.5.1
335
336
  signing_key:
336
337
  specification_version: 4
337
338
  summary: Rails REST API documentation tool
@@ -395,6 +396,7 @@ test_files:
395
396
  - spec/lib/extractor/extractor_spec.rb
396
397
  - spec/lib/extractor/middleware_spec.rb
397
398
  - spec/lib/extractor/writer_spec.rb
399
+ - spec/lib/file_handler_spec.rb
398
400
  - spec/lib/method_description_spec.rb
399
401
  - spec/lib/param_description_spec.rb
400
402
  - spec/lib/param_group_spec.rb