apipie-rails 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/rubocop-challenger.yml +28 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +37 -0
- data/.rubocop_todo.yml +2001 -0
- data/CHANGELOG.md +24 -0
- data/README.rst +45 -2
- data/Rakefile +0 -5
- data/apipie-rails.gemspec +11 -7
- data/lib/apipie/dsl_definition.rb +3 -3
- data/lib/apipie/extractor/writer.rb +2 -2
- data/lib/apipie/generator/generator.rb +2 -0
- data/lib/apipie/generator/swagger/swagger.rb +2 -0
- data/lib/apipie/generator/swagger/type.rb +16 -0
- data/lib/apipie/generator/swagger/type_extractor.rb +70 -0
- data/lib/apipie/generator/swagger/warning.rb +77 -0
- data/lib/apipie/generator/swagger/warning_writer.rb +48 -0
- data/lib/apipie/method_description/api.rb +12 -0
- data/lib/apipie/method_description/apis_service.rb +82 -0
- data/lib/apipie/method_description.rb +1 -46
- data/lib/apipie/param_description.rb +1 -1
- data/lib/apipie/swagger_generator.rb +76 -81
- data/lib/apipie/validator.rb +13 -0
- data/lib/apipie/version.rb +1 -1
- data/lib/apipie-rails.rb +9 -1
- data/lib/generators/apipie/install/install_generator.rb +1 -1
- data/lib/generators/apipie/views_generator.rb +1 -1
- data/lib/tasks/apipie.rake +2 -2
- data/spec/controllers/included_param_group_controller_spec.rb +13 -0
- data/spec/dummy/Rakefile +1 -1
- data/spec/dummy/app/controllers/included_param_group_controller.rb +19 -0
- data/spec/dummy/app/helpers/random_param_group.rb +8 -0
- data/spec/dummy/components/test_engine/test_engine.gemspec +1 -1
- data/spec/dummy/config/application.rb +1 -1
- data/spec/dummy/config/boot.rb +2 -2
- data/spec/dummy/config/environment.rb +1 -1
- data/spec/dummy/config/routes.rb +1 -0
- data/spec/dummy/config.ru +1 -1
- data/spec/dummy/script/rails +2 -2
- data/spec/lib/application_spec.rb +1 -1
- data/spec/lib/extractor/writer_spec.rb +7 -5
- data/spec/lib/generator/swagger/type_extractor_spec.rb +61 -0
- data/spec/lib/generator/swagger/warning_spec.rb +51 -0
- data/spec/lib/generator/swagger/warning_writer_spec.rb +59 -0
- data/spec/lib/method_description/apis_service_spec.rb +60 -0
- data/spec/lib/param_description_spec.rb +18 -0
- data/spec/lib/rake_spec.rb +1 -1
- data/spec/lib/swagger/rake_swagger_spec.rb +4 -4
- data/spec/spec_helper.rb +8 -4
- data/spec/support/custom_bool_validator.rb +17 -0
- metadata +49 -30
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Apipie::MethodDescription::ApisService do
|
4
|
+
let(:resource) {}
|
5
|
+
let(:controller_action) {}
|
6
|
+
let(:api_args) { [] }
|
7
|
+
let(:dsl) { { api_args: api_args } }
|
8
|
+
let(:service) { described_class.new(resource, controller_action, dsl) }
|
9
|
+
|
10
|
+
describe '#call' do
|
11
|
+
subject { service.call }
|
12
|
+
|
13
|
+
it { is_expected.to eq(api_args) }
|
14
|
+
|
15
|
+
context 'when api_from_routes is given' do
|
16
|
+
let(:controller) { UsersController }
|
17
|
+
let(:controller_action) { :show }
|
18
|
+
let(:resource) { Apipie::ResourceDescription.new(controller, 'dummy') }
|
19
|
+
let(:short_description) { 'Short description' }
|
20
|
+
|
21
|
+
let(:dsl) do
|
22
|
+
super().merge({
|
23
|
+
api_from_routes: {
|
24
|
+
desc: short_description,
|
25
|
+
options: {}
|
26
|
+
}
|
27
|
+
})
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'returns an array of Apipie::MethodDescription::Api' do
|
31
|
+
expect(subject).to all(be_an_instance_of(Apipie::MethodDescription::Api))
|
32
|
+
expect(subject.count).to eq(1)
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'Apipie::MethodDescription::Api' do
|
36
|
+
subject { service.call.first }
|
37
|
+
|
38
|
+
it 'has the correct values' do
|
39
|
+
expect(subject.short_description).to eq(short_description)
|
40
|
+
expect(subject.path).to eq('/api/users/:id')
|
41
|
+
expect(subject.from_routes).to eq(true)
|
42
|
+
expect(subject.options).to eq({ from_routes: true })
|
43
|
+
end
|
44
|
+
|
45
|
+
context "when it's from concern" do
|
46
|
+
let(:controller) { ConcernsController }
|
47
|
+
let(:controller_action) { :custom }
|
48
|
+
let(:dsl) { super().merge(from_concern: true ) }
|
49
|
+
|
50
|
+
it 'has the correct values' do
|
51
|
+
expect(subject.short_description).to eq(short_description)
|
52
|
+
expect(subject.path).to eq('/api/concern_resources/custom')
|
53
|
+
expect(subject.from_routes).to eq(true)
|
54
|
+
expect(subject.options).to eq({ from_routes: true })
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -157,11 +157,29 @@ describe Apipie::ParamDescription do
|
|
157
157
|
expect { Apipie::ParamDescription.new(method_desc, :param, :boolean).validate(false) }.to_not raise_error
|
158
158
|
end
|
159
159
|
|
160
|
+
it "should still not throw an exception when passed false with explicit allow_blank: false" do
|
161
|
+
expect { Apipie::ParamDescription.new(method_desc, :param, :boolean, allow_blank: false).validate(false) }.to_not raise_error
|
162
|
+
end
|
163
|
+
|
160
164
|
it "should throw an exception when passed an empty value" do
|
161
165
|
expect { Apipie::ParamDescription.new(method_desc, :param, :boolean).validate('') }.to raise_error(Apipie::ParamInvalid)
|
162
166
|
end
|
163
167
|
end
|
164
168
|
|
169
|
+
context "when the parameter is a custom type with ignore_allow_blank? returning true" do
|
170
|
+
it "should not throw an exception when passed a blank but valid value" do
|
171
|
+
expect { Apipie::ParamDescription.new(method_desc, :param, :custom_bool).validate(false) }.to_not raise_error
|
172
|
+
end
|
173
|
+
|
174
|
+
it "should still not throw an exception when passed false with explicit allow_blank: false" do
|
175
|
+
expect { Apipie::ParamDescription.new(method_desc, :param, :custom_bool, allow_blank: false).validate(false) }.to_not raise_error
|
176
|
+
end
|
177
|
+
|
178
|
+
it "should throw an exception when passed an invalid but blank value" do
|
179
|
+
expect { Apipie::ParamDescription.new(method_desc, :param, :custom_bool).validate("") }.to raise_error(Apipie::ParamInvalid)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
165
183
|
context 'when the parameter is a string' do
|
166
184
|
context 'when allow_blank is specified as true' do
|
167
185
|
it "should throw an exception when passed an empty value" do
|
data/spec/lib/rake_spec.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require "json-schema"
|
3
3
|
|
4
|
-
require File.expand_path(
|
5
|
-
require File.expand_path(
|
6
|
-
require File.expand_path(
|
4
|
+
require File.expand_path('../../dummy/app/controllers/twitter_example_controller.rb', __dir__)
|
5
|
+
require File.expand_path('../../dummy/app/controllers/users_controller.rb', __dir__)
|
6
|
+
require File.expand_path('../../dummy/app/controllers/pets_controller.rb', __dir__)
|
7
7
|
|
8
8
|
describe 'rake tasks' do
|
9
9
|
include_context "rake"
|
10
10
|
|
11
|
-
let(:doc_path) {
|
11
|
+
let(:doc_path) { 'tmp/user_specified_doc_path' }
|
12
12
|
|
13
13
|
before do
|
14
14
|
Apipie.configuration.doc_path = doc_path
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'bundler/setup'
|
3
3
|
|
4
|
+
require 'simplecov'
|
5
|
+
SimpleCov.minimum_coverage 89
|
6
|
+
SimpleCov.start
|
7
|
+
|
4
8
|
ENV["RAILS_ENV"] ||= 'test'
|
5
|
-
APIPIE_ROOT = File.expand_path('
|
6
|
-
require File.expand_path(
|
9
|
+
APIPIE_ROOT = File.expand_path('..', __dir__)
|
10
|
+
require File.expand_path('dummy/config/environment', __dir__)
|
7
11
|
|
8
12
|
require 'rspec/rails'
|
9
13
|
|
@@ -51,7 +55,7 @@ end
|
|
51
55
|
|
52
56
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
53
57
|
# in spec/support/ and its subdirectories.
|
54
|
-
Dir[File.expand_path(
|
58
|
+
Dir[File.expand_path('support/**/*.rb', __dir__)].each {|f| require f}
|
55
59
|
|
56
60
|
RSpec.configure do |config|
|
57
61
|
|
@@ -82,4 +86,4 @@ RSpec.configure do |config|
|
|
82
86
|
config.infer_spec_type_from_file_location!
|
83
87
|
end
|
84
88
|
|
85
|
-
require 'action_controller/test_case
|
89
|
+
require 'action_controller/test_case'
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class CustomBoolValidator < Apipie::Validator::BaseValidator
|
2
|
+
def validate(value)
|
3
|
+
value.in?([true, false])
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.build(param_description, argument, options, block)
|
7
|
+
new(param_description) if argument == :custom_bool
|
8
|
+
end
|
9
|
+
|
10
|
+
def description
|
11
|
+
"Must be a boolean."
|
12
|
+
end
|
13
|
+
|
14
|
+
def ignore_allow_blank?
|
15
|
+
true
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apipie-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Pokorny
|
8
8
|
- Ivan Necas
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-01-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|
@@ -40,21 +40,21 @@ dependencies:
|
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '5.0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
43
|
+
name: maruku
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - "
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
48
|
+
version: '0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - "
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
55
|
+
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
57
|
+
name: RedCloth
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - ">="
|
@@ -68,35 +68,35 @@ dependencies:
|
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
|
-
name:
|
71
|
+
name: json-schema
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- - "
|
74
|
+
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: '
|
76
|
+
version: '2.8'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- - "
|
81
|
+
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: '
|
83
|
+
version: '2.8'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
|
-
name:
|
85
|
+
name: rspec-rails
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- - "
|
88
|
+
- - "~>"
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: '0'
|
90
|
+
version: '3.0'
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- - "
|
95
|
+
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: '0'
|
97
|
+
version: '3.0'
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
|
-
name:
|
99
|
+
name: rake
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
102
|
- - ">="
|
@@ -110,7 +110,7 @@ dependencies:
|
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
|
-
name:
|
113
|
+
name: rubocop_challenger
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
116
|
- - ">="
|
@@ -124,7 +124,7 @@ dependencies:
|
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
|
-
name:
|
127
|
+
name: simplecov
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
129
129
|
requirements:
|
130
130
|
- - ">="
|
@@ -138,19 +138,19 @@ dependencies:
|
|
138
138
|
- !ruby/object:Gem::Version
|
139
139
|
version: '0'
|
140
140
|
- !ruby/object:Gem::Dependency
|
141
|
-
name:
|
141
|
+
name: sqlite3
|
142
142
|
requirement: !ruby/object:Gem::Requirement
|
143
143
|
requirements:
|
144
|
-
- - "
|
144
|
+
- - ">="
|
145
145
|
- !ruby/object:Gem::Version
|
146
|
-
version: '
|
146
|
+
version: '0'
|
147
147
|
type: :development
|
148
148
|
prerelease: false
|
149
149
|
version_requirements: !ruby/object:Gem::Requirement
|
150
150
|
requirements:
|
151
|
-
- - "
|
151
|
+
- - ">="
|
152
152
|
- !ruby/object:Gem::Version
|
153
|
-
version: '
|
153
|
+
version: '0'
|
154
154
|
description: Rails REST API documentation tool
|
155
155
|
email:
|
156
156
|
- pajkycz@gmail.com
|
@@ -160,8 +160,11 @@ extensions: []
|
|
160
160
|
extra_rdoc_files: []
|
161
161
|
files:
|
162
162
|
- ".github/workflows/build.yml"
|
163
|
+
- ".github/workflows/rubocop-challenger.yml"
|
163
164
|
- ".gitignore"
|
164
165
|
- ".rspec"
|
166
|
+
- ".rubocop.yml"
|
167
|
+
- ".rubocop_todo.yml"
|
165
168
|
- APACHE-LICENSE-2.0
|
166
169
|
- CHANGELOG.md
|
167
170
|
- MIT-LICENSE
|
@@ -231,9 +234,17 @@ files:
|
|
231
234
|
- lib/apipie/extractor/collector.rb
|
232
235
|
- lib/apipie/extractor/recorder.rb
|
233
236
|
- lib/apipie/extractor/writer.rb
|
237
|
+
- lib/apipie/generator/generator.rb
|
238
|
+
- lib/apipie/generator/swagger/swagger.rb
|
239
|
+
- lib/apipie/generator/swagger/type.rb
|
240
|
+
- lib/apipie/generator/swagger/type_extractor.rb
|
241
|
+
- lib/apipie/generator/swagger/warning.rb
|
242
|
+
- lib/apipie/generator/swagger/warning_writer.rb
|
234
243
|
- lib/apipie/helpers.rb
|
235
244
|
- lib/apipie/markup.rb
|
236
245
|
- lib/apipie/method_description.rb
|
246
|
+
- lib/apipie/method_description/api.rb
|
247
|
+
- lib/apipie/method_description/apis_service.rb
|
237
248
|
- lib/apipie/middleware/checksum_in_headers.rb
|
238
249
|
- lib/apipie/param_description.rb
|
239
250
|
- lib/apipie/railtie.rb
|
@@ -264,6 +275,7 @@ files:
|
|
264
275
|
- spec/controllers/apipies_controller_spec.rb
|
265
276
|
- spec/controllers/concerns_controller_spec.rb
|
266
277
|
- spec/controllers/extended_controller_spec.rb
|
278
|
+
- spec/controllers/included_param_group_controller_spec.rb
|
267
279
|
- spec/controllers/memes_controller_spec.rb
|
268
280
|
- spec/controllers/users_controller_spec.rb
|
269
281
|
- spec/dummy/Rakefile
|
@@ -279,6 +291,7 @@ files:
|
|
279
291
|
- spec/dummy/app/controllers/extended_controller.rb
|
280
292
|
- spec/dummy/app/controllers/extending_concern.rb
|
281
293
|
- spec/dummy/app/controllers/files_controller.rb
|
294
|
+
- spec/dummy/app/controllers/included_param_group_controller.rb
|
282
295
|
- spec/dummy/app/controllers/overridden_concerns_controller.rb
|
283
296
|
- spec/dummy/app/controllers/pets_controller.rb
|
284
297
|
- spec/dummy/app/controllers/pets_using_auto_views_controller.rb
|
@@ -288,6 +301,7 @@ files:
|
|
288
301
|
- spec/dummy/app/controllers/tagged_dogs_controller.rb
|
289
302
|
- spec/dummy/app/controllers/twitter_example_controller.rb
|
290
303
|
- spec/dummy/app/controllers/users_controller.rb
|
304
|
+
- spec/dummy/app/helpers/random_param_group.rb
|
291
305
|
- spec/dummy/app/views/layouts/application.html.erb
|
292
306
|
- spec/dummy/components/test_engine/Gemfile
|
293
307
|
- spec/dummy/components/test_engine/app/controllers/test_engine/application_controller.rb
|
@@ -326,6 +340,10 @@ files:
|
|
326
340
|
- spec/lib/extractor/middleware_spec.rb
|
327
341
|
- spec/lib/extractor/writer_spec.rb
|
328
342
|
- spec/lib/file_handler_spec.rb
|
343
|
+
- spec/lib/generator/swagger/type_extractor_spec.rb
|
344
|
+
- spec/lib/generator/swagger/warning_spec.rb
|
345
|
+
- spec/lib/generator/swagger/warning_writer_spec.rb
|
346
|
+
- spec/lib/method_description/apis_service_spec.rb
|
329
347
|
- spec/lib/method_description_spec.rb
|
330
348
|
- spec/lib/param_description_spec.rb
|
331
349
|
- spec/lib/param_group_spec.rb
|
@@ -338,11 +356,12 @@ files:
|
|
338
356
|
- spec/lib/validator_spec.rb
|
339
357
|
- spec/lib/validators/array_validator_spec.rb
|
340
358
|
- spec/spec_helper.rb
|
359
|
+
- spec/support/custom_bool_validator.rb
|
341
360
|
- spec/support/rake.rb
|
342
361
|
homepage: http://github.com/Apipie/apipie-rails
|
343
362
|
licenses: []
|
344
363
|
metadata: {}
|
345
|
-
post_install_message:
|
364
|
+
post_install_message:
|
346
365
|
rdoc_options: []
|
347
366
|
require_paths:
|
348
367
|
- lib
|
@@ -357,8 +376,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
357
376
|
- !ruby/object:Gem::Version
|
358
377
|
version: '0'
|
359
378
|
requirements: []
|
360
|
-
rubygems_version: 3.
|
361
|
-
signing_key:
|
379
|
+
rubygems_version: 3.3.26
|
380
|
+
signing_key:
|
362
381
|
specification_version: 4
|
363
382
|
summary: Rails REST API documentation tool
|
364
383
|
test_files: []
|