apipie-rails 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +11 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile +1 -1
- data/apipie-rails.gemspec +3 -3
- data/gemfiles/Gemfile.rails50 +10 -0
- data/gemfiles/Gemfile.rails51 +10 -0
- data/lib/apipie/param_description.rb +1 -1
- data/lib/apipie/static_dispatcher.rb +3 -1
- data/lib/apipie/swagger_generator.rb +5 -1
- data/lib/apipie/version.rb +1 -1
- data/spec/dummy/app/controllers/users_controller.rb +6 -0
- data/spec/lib/file_handler_spec.rb +7 -0
- data/spec/lib/swagger/rake_swagger_spec.rb +15 -0
- metadata +9 -9
- data/gemfiles/Gemfile.rails42 +0 -15
- data/gemfiles/Gemfile.rails42.lock +0 -122
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29292cefe596185a3becf01f657a1c8826ea2aa5601e5549926672d1ebaf9309
|
4
|
+
data.tar.gz: 8c1419363f237e7cb8beb61940af1303bdef53a8830e0347f9afbca29d99e32f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87f52d7d548463ec69639b85c7cb9b322b29f711fdd38800365f13bc8963a8a461f840ac8f36300e18236212b088298d90d482a0537d58b857eecbd2b479bdc5
|
7
|
+
data.tar.gz: 895cb9c91976d485ab1442f42895114e15c102cccc8d3b853ea6242de360f7756c5337faa086e4df7b5536079285ab83d259ce21b292c0da7fe766decdaddb32
|
data/.github/workflows/build.yml
CHANGED
@@ -21,16 +21,23 @@ jobs:
|
|
21
21
|
- '3.0'
|
22
22
|
- 3.1
|
23
23
|
gemfile:
|
24
|
-
- Gemfile.
|
24
|
+
- Gemfile.rails50
|
25
|
+
- Gemfile.rails51
|
25
26
|
- Gemfile.rails52 # Min ruby 2.2.2
|
26
27
|
- Gemfile.rails60 # Min ruby 2.5.0
|
27
28
|
- Gemfile.rails61 # Min ruby 2.5.0
|
28
29
|
exclude:
|
29
|
-
- gemfile: Gemfile.
|
30
|
+
- gemfile: Gemfile.rails50
|
30
31
|
ruby: 2.7
|
31
|
-
- gemfile: Gemfile.
|
32
|
+
- gemfile: Gemfile.rails50
|
32
33
|
ruby: '3.0'
|
33
|
-
- gemfile: Gemfile.
|
34
|
+
- gemfile: Gemfile.rails50
|
35
|
+
ruby: 3.1
|
36
|
+
- gemfile: Gemfile.rails51
|
37
|
+
ruby: 2.7
|
38
|
+
- gemfile: Gemfile.rails51
|
39
|
+
ruby: '3.0'
|
40
|
+
- gemfile: Gemfile.rails51
|
34
41
|
ruby: 3.1
|
35
42
|
- gemfile: Gemfile.rails52
|
36
43
|
ruby: 2.7
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
Changelog
|
2
2
|
===========
|
3
3
|
|
4
|
+
## [v0.7.0](https://github.com/Apipie/apipie-rails/tree/v0.7.0) (2022-03-30)
|
5
|
+
[Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.6.0...v0.7.0)
|
6
|
+
* ArgumentError (invalid byte sequence in UTF-8) [#746](https://github.com/Apipie/apipie-rails/pull/746) (David Milanese)
|
7
|
+
* Fix allow_blank does not work [#733](https://github.com/Apipie/apipie-rails/pull/733) (CHEN Song)
|
8
|
+
* Fix schema generation for param descriptions using the array validator in option [#732](https://github.com/Apipie/apipie-rails/pull/732) (Frank Hock)
|
9
|
+
* Remove support for Rails 4 and Ruby <= 2.5 [#747](https://github.com/Apipie/apipie-rails/pull/747) (Mathieu Jobin)
|
10
|
+
|
4
11
|
## [v0.6.0](https://github.com/Apipie/apipie-rails/tree/v0.6.0) (2022-03-29)
|
5
12
|
[Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.5.20...v0.6.0)
|
6
13
|
* Ruby 3.0 fixes [#716](https://github.com/Apipie/apipie-rails/pull/716) (hank-spokeo)
|
data/Gemfile
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Gemfile.rails61
|
1
|
+
./Gemfile.rails61
|
data/apipie-rails.gemspec
CHANGED
@@ -10,14 +10,14 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.homepage = "http://github.com/Apipie/apipie-rails"
|
11
11
|
s.summary = %q{Rails REST API documentation tool}
|
12
12
|
s.description = %q{Rails REST API documentation tool}
|
13
|
-
s.required_ruby_version = '>= 2.
|
13
|
+
s.required_ruby_version = '>= 2.6.0'
|
14
14
|
|
15
15
|
s.files = `git ls-files`.split("\n")
|
16
16
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
|
19
|
-
s.add_dependency "actionpack", ">=
|
20
|
-
s.add_dependency "activesupport", ">=
|
19
|
+
s.add_dependency "actionpack", ">= 5.0"
|
20
|
+
s.add_dependency "activesupport", ">= 5.0"
|
21
21
|
s.add_development_dependency "rspec-rails", "~> 3.0"
|
22
22
|
s.add_development_dependency "sqlite3"
|
23
23
|
s.add_development_dependency "minitest"
|
@@ -0,0 +1,10 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
gemspec path: '..'
|
4
|
+
|
5
|
+
gem 'actionpack', '~> 5.0.0'
|
6
|
+
gem 'activesupport', '~> 5.0.0'
|
7
|
+
gem 'mime-types', '~> 2.99.3'
|
8
|
+
gem 'rails-controller-testing'
|
9
|
+
|
10
|
+
gem 'test_engine', path: '../spec/dummy/components/test_engine', group: :test
|
@@ -0,0 +1,10 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
gemspec path: '..'
|
4
|
+
|
5
|
+
gem 'actionpack', '~> 5.1.0'
|
6
|
+
gem 'activesupport', '~> 5.1.0'
|
7
|
+
gem 'mime-types', '~> 2.99.3'
|
8
|
+
gem 'rails-controller-testing'
|
9
|
+
|
10
|
+
gem 'test_engine', path: '../spec/dummy/components/test_engine', group: :test
|
@@ -117,7 +117,7 @@ module Apipie
|
|
117
117
|
return true if @allow_nil && value.nil?
|
118
118
|
return true if @allow_blank && value.blank?
|
119
119
|
value = normalized_value(value)
|
120
|
-
if (!@allow_nil && value.nil?) || !@validator.valid?(value)
|
120
|
+
if (!@allow_nil && value.nil?) || (!@allow_blank && value.blank?) || !@validator.valid?(value)
|
121
121
|
error = @validator.error
|
122
122
|
error = ParamError.new(error) unless error.is_a? StandardError
|
123
123
|
raise error
|
@@ -9,7 +9,9 @@ module Apipie
|
|
9
9
|
|
10
10
|
def match?(path)
|
11
11
|
# Replace all null bytes
|
12
|
-
path = ::Rack::Utils.unescape(path || '')
|
12
|
+
path = ::Rack::Utils.unescape(path || '')
|
13
|
+
.encode(Encoding::UTF_8, invalid: :replace, replace: '')
|
14
|
+
.gsub(/\x0/, '')
|
13
15
|
|
14
16
|
full_path = path.empty? ? @root : File.join(@root, path)
|
15
17
|
paths = "#{full_path}#{ext}"
|
@@ -476,6 +476,9 @@ module Apipie
|
|
476
476
|
|
477
477
|
if swagger_def[:type] == "array"
|
478
478
|
swagger_def[:items] = {type: "string"}
|
479
|
+
enum = param_desc.options.fetch(:in, [])
|
480
|
+
|
481
|
+
swagger_def[:items][:enum] = enum if enum.any?
|
479
482
|
end
|
480
483
|
|
481
484
|
if swagger_def[:type] == "enum"
|
@@ -504,7 +507,8 @@ module Apipie
|
|
504
507
|
end
|
505
508
|
|
506
509
|
if !in_schema
|
507
|
-
|
510
|
+
# the "name" and "in" keys can only be set on root parameters (non-nested)
|
511
|
+
swagger_def[:in] = @default_value_for_param_in if name.present?
|
508
512
|
swagger_def[:required] = param_desc.required if param_desc.required
|
509
513
|
end
|
510
514
|
|
data/lib/apipie/version.rb
CHANGED
@@ -274,6 +274,12 @@ class UsersController < ApplicationController
|
|
274
274
|
render :plain => 'nothing to see here'
|
275
275
|
end
|
276
276
|
|
277
|
+
api :GET, '/users/in_departments', 'show users from specific departments'
|
278
|
+
param :departments, Array, in: ["finance", "operations", "sales", "marketing", "HR"], default_value: ['sales']
|
279
|
+
def get_in_departments
|
280
|
+
render :plain => 'nothing to see here'
|
281
|
+
end
|
282
|
+
|
277
283
|
api :GET, '/users/desc_from_file', 'desc from file'
|
278
284
|
document 'users/desc_from_file.md'
|
279
285
|
def desc_from_file
|
@@ -14,5 +14,12 @@ describe Apipie::FileHandler do
|
|
14
14
|
it { expect(file_handler.match? path).to be_falsy }
|
15
15
|
it { expect { file_handler.match? path }.to_not raise_error }
|
16
16
|
end
|
17
|
+
|
18
|
+
context 'when the path contans an invalid byte sequence in UTF-8' do
|
19
|
+
let(:path) { "%B6" }
|
20
|
+
|
21
|
+
it { expect(file_handler.match? path).to be_falsy }
|
22
|
+
it { expect { file_handler.match? path }.to_not raise_error }
|
23
|
+
end
|
17
24
|
end
|
18
25
|
end
|
@@ -51,6 +51,17 @@ describe 'rake tasks' do
|
|
51
51
|
expect(param[field]).to eq(value)
|
52
52
|
end
|
53
53
|
|
54
|
+
def expect_array_param_def(http_method, path, param_name, value)
|
55
|
+
params = apidoc_swagger["paths"][path][http_method]["parameters"]
|
56
|
+
param = params.select { |p| p if p["name"] == param_name }[0]
|
57
|
+
|
58
|
+
expect(param['type']).to eq('array')
|
59
|
+
expect(param['items']).to eq(
|
60
|
+
'type' => 'string',
|
61
|
+
'enum' => value
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
54
65
|
def expect_tags_def(http_method, path, value)
|
55
66
|
params = apidoc_swagger["paths"][path][http_method]["tags"]
|
56
67
|
expect(params).to eq(value)
|
@@ -119,6 +130,10 @@ describe 'rake tasks' do
|
|
119
130
|
expect_param_def("get", "/users/by_department", "department", "enum",
|
120
131
|
["finance", "operations", "sales", "marketing", "HR"])
|
121
132
|
|
133
|
+
expect_param_def("get", "/users/in_departments", "departments", "in", "query")
|
134
|
+
expect_array_param_def("get", "/users/in_departments", "departments",
|
135
|
+
["finance", "operations", "sales", "marketing", "HR"])
|
136
|
+
|
122
137
|
expect_tags_def("get", "/twitter_example/{id}/followers", %w[twitter_example following index search])
|
123
138
|
|
124
139
|
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.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Pokorny
|
@@ -17,28 +17,28 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
20
|
+
version: '5.0'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '
|
27
|
+
version: '5.0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: activesupport
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '5.0'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
41
|
+
version: '5.0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rspec-rails
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -211,8 +211,8 @@ files:
|
|
211
211
|
- config/locales/tr.yml
|
212
212
|
- config/locales/zh-CN.yml
|
213
213
|
- config/locales/zh-TW.yml
|
214
|
-
- gemfiles/Gemfile.
|
215
|
-
- gemfiles/Gemfile.
|
214
|
+
- gemfiles/Gemfile.rails50
|
215
|
+
- gemfiles/Gemfile.rails51
|
216
216
|
- gemfiles/Gemfile.rails52
|
217
217
|
- gemfiles/Gemfile.rails60
|
218
218
|
- gemfiles/Gemfile.rails61
|
@@ -350,14 +350,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
350
350
|
requirements:
|
351
351
|
- - ">="
|
352
352
|
- !ruby/object:Gem::Version
|
353
|
-
version: 2.
|
353
|
+
version: 2.6.0
|
354
354
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
355
355
|
requirements:
|
356
356
|
- - ">="
|
357
357
|
- !ruby/object:Gem::Version
|
358
358
|
version: '0'
|
359
359
|
requirements: []
|
360
|
-
rubygems_version: 3.
|
360
|
+
rubygems_version: 3.0.9
|
361
361
|
signing_key:
|
362
362
|
specification_version: 4
|
363
363
|
summary: Rails REST API documentation tool
|
data/gemfiles/Gemfile.rails42
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
gemspec path: '..'
|
4
|
-
|
5
|
-
gem 'actionpack', '~> 4.2.5'
|
6
|
-
gem 'activesupport', '~> 4.2.5'
|
7
|
-
gem 'mime-types', '~> 2.99.3'
|
8
|
-
gem 'sqlite3', '~> 1.3.6'
|
9
|
-
|
10
|
-
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.1.0')
|
11
|
-
gem 'nokogiri', '~> 1.6.8'
|
12
|
-
gem 'rdoc', '~> 4.2.2'
|
13
|
-
end
|
14
|
-
|
15
|
-
gem 'test_engine', path: '../spec/dummy/components/test_engine', group: :test
|
@@ -1,122 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: ../spec/dummy/components/test_engine
|
3
|
-
specs:
|
4
|
-
test_engine (0.0.1)
|
5
|
-
|
6
|
-
PATH
|
7
|
-
remote: ..
|
8
|
-
specs:
|
9
|
-
apipie-rails (0.5.20)
|
10
|
-
actionpack (>= 4.1)
|
11
|
-
activesupport (>= 4.1)
|
12
|
-
|
13
|
-
GEM
|
14
|
-
remote: https://rubygems.org/
|
15
|
-
specs:
|
16
|
-
RedCloth (4.3.2)
|
17
|
-
actionpack (4.2.11.3)
|
18
|
-
actionview (= 4.2.11.3)
|
19
|
-
activesupport (= 4.2.11.3)
|
20
|
-
rack (~> 1.6)
|
21
|
-
rack-test (~> 0.6.2)
|
22
|
-
rails-dom-testing (~> 1.0, >= 1.0.5)
|
23
|
-
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
24
|
-
actionview (4.2.11.3)
|
25
|
-
activesupport (= 4.2.11.3)
|
26
|
-
builder (~> 3.1)
|
27
|
-
erubis (~> 2.7.0)
|
28
|
-
rails-dom-testing (~> 1.0, >= 1.0.5)
|
29
|
-
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
30
|
-
activesupport (4.2.11.3)
|
31
|
-
i18n (~> 0.7)
|
32
|
-
minitest (~> 5.1)
|
33
|
-
thread_safe (~> 0.3, >= 0.3.4)
|
34
|
-
tzinfo (~> 1.1)
|
35
|
-
addressable (2.8.0)
|
36
|
-
public_suffix (>= 2.0.2, < 5.0)
|
37
|
-
builder (3.2.4)
|
38
|
-
concurrent-ruby (1.1.10)
|
39
|
-
crass (1.0.6)
|
40
|
-
diff-lcs (1.5.0)
|
41
|
-
erubis (2.7.0)
|
42
|
-
i18n (0.9.5)
|
43
|
-
concurrent-ruby (~> 1.0)
|
44
|
-
json-schema (2.8.1)
|
45
|
-
addressable (>= 2.4)
|
46
|
-
loofah (2.15.0)
|
47
|
-
crass (~> 1.0.2)
|
48
|
-
nokogiri (>= 1.5.9)
|
49
|
-
maruku (0.7.3)
|
50
|
-
mime-types (2.99.3)
|
51
|
-
mini_portile2 (2.8.0)
|
52
|
-
minitest (5.15.0)
|
53
|
-
nokogiri (1.13.3)
|
54
|
-
mini_portile2 (~> 2.8.0)
|
55
|
-
racc (~> 1.4)
|
56
|
-
psych (4.0.3)
|
57
|
-
stringio
|
58
|
-
public_suffix (4.0.6)
|
59
|
-
racc (1.6.0)
|
60
|
-
rack (1.6.13)
|
61
|
-
rack-test (0.6.3)
|
62
|
-
rack (>= 1.0)
|
63
|
-
rails-deprecated_sanitizer (1.0.4)
|
64
|
-
activesupport (>= 4.2.0.alpha)
|
65
|
-
rails-dom-testing (1.0.9)
|
66
|
-
activesupport (>= 4.2.0, < 5.0)
|
67
|
-
nokogiri (~> 1.6)
|
68
|
-
rails-deprecated_sanitizer (>= 1.0.1)
|
69
|
-
rails-html-sanitizer (1.4.2)
|
70
|
-
loofah (~> 2.3)
|
71
|
-
railties (4.2.11.3)
|
72
|
-
actionpack (= 4.2.11.3)
|
73
|
-
activesupport (= 4.2.11.3)
|
74
|
-
rake (>= 0.8.7)
|
75
|
-
thor (>= 0.18.1, < 2.0)
|
76
|
-
rake (13.0.6)
|
77
|
-
rdoc (6.4.0)
|
78
|
-
psych (>= 4.0.0)
|
79
|
-
rspec-core (3.9.3)
|
80
|
-
rspec-support (~> 3.9.3)
|
81
|
-
rspec-expectations (3.9.4)
|
82
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
83
|
-
rspec-support (~> 3.9.0)
|
84
|
-
rspec-mocks (3.9.1)
|
85
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
86
|
-
rspec-support (~> 3.9.0)
|
87
|
-
rspec-rails (3.9.1)
|
88
|
-
actionpack (>= 3.0)
|
89
|
-
activesupport (>= 3.0)
|
90
|
-
railties (>= 3.0)
|
91
|
-
rspec-core (~> 3.9.0)
|
92
|
-
rspec-expectations (~> 3.9.0)
|
93
|
-
rspec-mocks (~> 3.9.0)
|
94
|
-
rspec-support (~> 3.9.0)
|
95
|
-
rspec-support (3.9.4)
|
96
|
-
sqlite3 (1.3.13)
|
97
|
-
stringio (3.0.1)
|
98
|
-
thor (1.2.1)
|
99
|
-
thread_safe (0.3.6)
|
100
|
-
tzinfo (1.2.9)
|
101
|
-
thread_safe (~> 0.1)
|
102
|
-
|
103
|
-
PLATFORMS
|
104
|
-
ruby
|
105
|
-
|
106
|
-
DEPENDENCIES
|
107
|
-
RedCloth
|
108
|
-
actionpack (~> 4.2.5)
|
109
|
-
activesupport (~> 4.2.5)
|
110
|
-
apipie-rails!
|
111
|
-
json-schema (~> 2.8)
|
112
|
-
maruku
|
113
|
-
mime-types (~> 2.99.3)
|
114
|
-
minitest
|
115
|
-
rake
|
116
|
-
rdoc
|
117
|
-
rspec-rails (~> 3.0)
|
118
|
-
sqlite3 (~> 1.3.6)
|
119
|
-
test_engine!
|
120
|
-
|
121
|
-
BUNDLED WITH
|
122
|
-
1.17.3
|