apipie-rails 0.8.2 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build.yml +7 -0
  3. data/.github/workflows/rubocop-challenger.yml +28 -0
  4. data/.rubocop.yml +37 -0
  5. data/.rubocop_todo.yml +1991 -0
  6. data/CHANGELOG.md +19 -0
  7. data/README.rst +4 -4
  8. data/Rakefile +0 -5
  9. data/apipie-rails.gemspec +10 -7
  10. data/app/controllers/apipie/apipies_controller.rb +1 -1
  11. data/lib/apipie/application.rb +4 -4
  12. data/lib/apipie/dsl_definition.rb +4 -4
  13. data/lib/apipie/extractor/writer.rb +4 -4
  14. data/lib/apipie/generator/generator.rb +2 -0
  15. data/lib/apipie/generator/swagger/swagger.rb +2 -0
  16. data/lib/apipie/generator/swagger/type.rb +16 -0
  17. data/lib/apipie/generator/swagger/type_extractor.rb +70 -0
  18. data/lib/apipie/generator/swagger/warning.rb +77 -0
  19. data/lib/apipie/generator/swagger/warning_writer.rb +48 -0
  20. data/lib/apipie/method_description/api.rb +12 -0
  21. data/lib/apipie/method_description/apis_service.rb +82 -0
  22. data/lib/apipie/method_description.rb +3 -48
  23. data/lib/apipie/resource_description.rb +1 -1
  24. data/lib/apipie/swagger_generator.rb +76 -81
  25. data/lib/apipie/validator.rb +4 -0
  26. data/lib/apipie/version.rb +1 -1
  27. data/lib/apipie-rails.rb +9 -1
  28. data/lib/generators/apipie/install/install_generator.rb +1 -1
  29. data/lib/generators/apipie/views_generator.rb +1 -1
  30. data/lib/tasks/apipie.rake +4 -4
  31. data/spec/controllers/apipies_controller_spec.rb +2 -2
  32. data/spec/controllers/users_controller_spec.rb +1 -1
  33. data/spec/dummy/Rakefile +1 -1
  34. data/spec/dummy/app/controllers/users_controller.rb +1 -1
  35. data/spec/dummy/components/test_engine/test_engine.gemspec +1 -1
  36. data/spec/dummy/config/application.rb +1 -1
  37. data/spec/dummy/config/boot.rb +2 -2
  38. data/spec/dummy/config/environment.rb +1 -1
  39. data/spec/dummy/config/initializers/apipie.rb +2 -2
  40. data/spec/dummy/config/routes.rb +1 -0
  41. data/spec/dummy/config.ru +1 -1
  42. data/spec/dummy/script/rails +2 -2
  43. data/spec/lib/application_spec.rb +1 -1
  44. data/spec/lib/extractor/writer_spec.rb +8 -6
  45. data/spec/lib/generator/swagger/type_extractor_spec.rb +61 -0
  46. data/spec/lib/generator/swagger/warning_spec.rb +51 -0
  47. data/spec/lib/generator/swagger/warning_writer_spec.rb +59 -0
  48. data/spec/lib/method_description/apis_service_spec.rb +60 -0
  49. data/spec/lib/param_description_spec.rb +4 -4
  50. data/spec/lib/rake_spec.rb +2 -4
  51. data/spec/lib/swagger/rake_swagger_spec.rb +4 -4
  52. data/spec/lib/validator_spec.rb +1 -1
  53. data/spec/spec_helper.rb +4 -4
  54. metadata +39 -38
@@ -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
@@ -374,7 +374,7 @@ describe Apipie::ParamDescription do
374
374
 
375
375
  subject do
376
376
  Apipie::ParamDescription.new(method_desc, :param, Hash) do
377
- param :answer, Fixnum
377
+ param :answer, Integer
378
378
  end
379
379
  end
380
380
 
@@ -392,7 +392,7 @@ describe Apipie::ParamDescription do
392
392
 
393
393
  subject do
394
394
  Apipie::ParamDescription.new(method_desc, :param, Array) do
395
- param :answer, Fixnum
395
+ param :answer, Integer
396
396
  end
397
397
  end
398
398
 
@@ -422,9 +422,9 @@ describe Apipie::ParamDescription do
422
422
 
423
423
  describe "Array with classes" do
424
424
  it "should be valid for objects included in class array" do
425
- param = Apipie::ParamDescription.new(method_desc, :param, [Fixnum, String])
425
+ param = Apipie::ParamDescription.new(method_desc, :param, [Integer, String])
426
426
  expect { param.validate("1") }.not_to raise_error
427
- expect { param.validate(Fixnum) }.to raise_error(Apipie::ParamInvalid)
427
+ expect { param.validate(Integer) }.to raise_error(Apipie::ParamInvalid)
428
428
  end
429
429
  end
430
430
 
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe 'rake tasks' do
4
4
  include_context "rake"
5
5
 
6
- let(:doc_path) { "user_specified_doc_path" }
6
+ let(:doc_path) { 'tmp/user_specified_doc_path' }
7
7
 
8
8
  before do
9
9
  Apipie.configuration.doc_path = doc_path
@@ -49,9 +49,7 @@ describe 'rake tasks' do
49
49
  end
50
50
 
51
51
  describe 'apipie:cache' do
52
- let(:cache_output) do
53
- File.join(::Rails.root, 'public', 'apipie-cache')
54
- end
52
+ let(:cache_output) { Apipie.configuration.cache_dir }
55
53
 
56
54
  let(:apidoc_html) do
57
55
  File.read("#{cache_output}.html")
@@ -1,14 +1,14 @@
1
1
  require 'spec_helper'
2
2
  require "json-schema"
3
3
 
4
- require File.expand_path("../../../dummy/app/controllers/twitter_example_controller.rb", __FILE__)
5
- require File.expand_path("../../../dummy/app/controllers/users_controller.rb", __FILE__)
6
- require File.expand_path("../../../dummy/app/controllers/pets_controller.rb", __FILE__)
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) { "user_specified_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
@@ -69,7 +69,7 @@ describe Apipie::Validator do
69
69
 
70
70
  describe 'ArrayClassValidator' do
71
71
  it "should validate by object class" do
72
- validator = Apipie::Validator::ArrayClassValidator.new(params_desc, [Fixnum, String])
72
+ validator = Apipie::Validator::ArrayClassValidator.new(params_desc, [Integer, String])
73
73
  expect(validator.validate("1")).to be_truthy
74
74
  expect(validator.validate(1)).to be_truthy
75
75
  expect(validator.validate({ 1 => 1 })).to be_falsey
data/spec/spec_helper.rb CHANGED
@@ -6,8 +6,8 @@ SimpleCov.minimum_coverage 89
6
6
  SimpleCov.start
7
7
 
8
8
  ENV["RAILS_ENV"] ||= 'test'
9
- APIPIE_ROOT = File.expand_path('../..', __FILE__)
10
- require File.expand_path("../dummy/config/environment", __FILE__)
9
+ APIPIE_ROOT = File.expand_path('..', __dir__)
10
+ require File.expand_path('dummy/config/environment', __dir__)
11
11
 
12
12
  require 'rspec/rails'
13
13
 
@@ -55,7 +55,7 @@ end
55
55
 
56
56
  # Requires supporting ruby files with custom matchers and macros, etc,
57
57
  # in spec/support/ and its subdirectories.
58
- Dir[File.expand_path("../support/**/*.rb", __FILE__)].each {|f| require f}
58
+ Dir[File.expand_path('support/**/*.rb', __dir__)].each {|f| require f}
59
59
 
60
60
  RSpec.configure do |config|
61
61
 
@@ -86,4 +86,4 @@ RSpec.configure do |config|
86
86
  config.infer_spec_type_from_file_location!
87
87
  end
88
88
 
89
- require 'action_controller/test_case.rb'
89
+ require 'action_controller/test_case'
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.8.2
4
+ version: 0.9.1
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: 2022-09-02 00:00:00.000000000 Z
12
+ date: 2023-01-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -40,21 +40,7 @@ dependencies:
40
40
  - !ruby/object:Gem::Version
41
41
  version: '5.0'
42
42
  - !ruby/object:Gem::Dependency
43
- name: rspec-rails
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - "~>"
47
- - !ruby/object:Gem::Version
48
- version: '3.0'
49
- type: :development
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - "~>"
54
- - !ruby/object:Gem::Version
55
- version: '3.0'
56
- - !ruby/object:Gem::Dependency
57
- name: sqlite3
43
+ name: maruku
58
44
  requirement: !ruby/object:Gem::Requirement
59
45
  requirements:
60
46
  - - ">="
@@ -68,7 +54,7 @@ dependencies:
68
54
  - !ruby/object:Gem::Version
69
55
  version: '0'
70
56
  - !ruby/object:Gem::Dependency
71
- name: minitest
57
+ name: RedCloth
72
58
  requirement: !ruby/object:Gem::Requirement
73
59
  requirements:
74
60
  - - ">="
@@ -82,33 +68,33 @@ dependencies:
82
68
  - !ruby/object:Gem::Version
83
69
  version: '0'
84
70
  - !ruby/object:Gem::Dependency
85
- name: maruku
71
+ name: json-schema
86
72
  requirement: !ruby/object:Gem::Requirement
87
73
  requirements:
88
- - - ">="
74
+ - - "~>"
89
75
  - !ruby/object:Gem::Version
90
- version: '0'
76
+ version: '2.8'
91
77
  type: :development
92
78
  prerelease: false
93
79
  version_requirements: !ruby/object:Gem::Requirement
94
80
  requirements:
95
- - - ">="
81
+ - - "~>"
96
82
  - !ruby/object:Gem::Version
97
- version: '0'
83
+ version: '2.8'
98
84
  - !ruby/object:Gem::Dependency
99
- name: RedCloth
85
+ name: rspec-rails
100
86
  requirement: !ruby/object:Gem::Requirement
101
87
  requirements:
102
- - - ">="
88
+ - - "~>"
103
89
  - !ruby/object:Gem::Version
104
- version: '0'
90
+ version: '3.0'
105
91
  type: :development
106
92
  prerelease: false
107
93
  version_requirements: !ruby/object:Gem::Requirement
108
94
  requirements:
109
- - - ">="
95
+ - - "~>"
110
96
  - !ruby/object:Gem::Version
111
- version: '0'
97
+ version: '3.0'
112
98
  - !ruby/object:Gem::Dependency
113
99
  name: rake
114
100
  requirement: !ruby/object:Gem::Requirement
@@ -124,7 +110,7 @@ dependencies:
124
110
  - !ruby/object:Gem::Version
125
111
  version: '0'
126
112
  - !ruby/object:Gem::Dependency
127
- name: rdoc
113
+ name: rubocop_challenger
128
114
  requirement: !ruby/object:Gem::Requirement
129
115
  requirements:
130
116
  - - ">="
@@ -152,19 +138,19 @@ dependencies:
152
138
  - !ruby/object:Gem::Version
153
139
  version: '0'
154
140
  - !ruby/object:Gem::Dependency
155
- name: json-schema
141
+ name: sqlite3
156
142
  requirement: !ruby/object:Gem::Requirement
157
143
  requirements:
158
- - - "~>"
144
+ - - ">="
159
145
  - !ruby/object:Gem::Version
160
- version: '2.8'
146
+ version: '0'
161
147
  type: :development
162
148
  prerelease: false
163
149
  version_requirements: !ruby/object:Gem::Requirement
164
150
  requirements:
165
- - - "~>"
151
+ - - ">="
166
152
  - !ruby/object:Gem::Version
167
- version: '2.8'
153
+ version: '0'
168
154
  description: Rails REST API documentation tool
169
155
  email:
170
156
  - pajkycz@gmail.com
@@ -174,8 +160,11 @@ extensions: []
174
160
  extra_rdoc_files: []
175
161
  files:
176
162
  - ".github/workflows/build.yml"
163
+ - ".github/workflows/rubocop-challenger.yml"
177
164
  - ".gitignore"
178
165
  - ".rspec"
166
+ - ".rubocop.yml"
167
+ - ".rubocop_todo.yml"
179
168
  - APACHE-LICENSE-2.0
180
169
  - CHANGELOG.md
181
170
  - MIT-LICENSE
@@ -245,9 +234,17 @@ files:
245
234
  - lib/apipie/extractor/collector.rb
246
235
  - lib/apipie/extractor/recorder.rb
247
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
248
243
  - lib/apipie/helpers.rb
249
244
  - lib/apipie/markup.rb
250
245
  - lib/apipie/method_description.rb
246
+ - lib/apipie/method_description/api.rb
247
+ - lib/apipie/method_description/apis_service.rb
251
248
  - lib/apipie/middleware/checksum_in_headers.rb
252
249
  - lib/apipie/param_description.rb
253
250
  - lib/apipie/railtie.rb
@@ -343,6 +340,10 @@ files:
343
340
  - spec/lib/extractor/middleware_spec.rb
344
341
  - spec/lib/extractor/writer_spec.rb
345
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
346
347
  - spec/lib/method_description_spec.rb
347
348
  - spec/lib/param_description_spec.rb
348
349
  - spec/lib/param_group_spec.rb
@@ -360,7 +361,7 @@ files:
360
361
  homepage: http://github.com/Apipie/apipie-rails
361
362
  licenses: []
362
363
  metadata: {}
363
- post_install_message:
364
+ post_install_message:
364
365
  rdoc_options: []
365
366
  require_paths:
366
367
  - lib
@@ -375,8 +376,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
375
376
  - !ruby/object:Gem::Version
376
377
  version: '0'
377
378
  requirements: []
378
- rubygems_version: 3.3.5
379
- signing_key:
379
+ rubygems_version: 3.3.26
380
+ signing_key:
380
381
  specification_version: 4
381
382
  summary: Rails REST API documentation tool
382
383
  test_files: []