apipie-rails 0.9.2 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rubocop-challenger.yml +1 -1
- data/.github/workflows/rubocop.yml +20 -0
- data/.rubocop.yml +21 -0
- data/.rubocop_todo.yml +222 -610
- data/CHANGELOG.md +16 -1
- data/README.rst +20 -0
- data/apipie-rails.gemspec +4 -0
- data/app/controllers/apipie/apipies_controller.rb +2 -2
- data/app/helpers/apipie_helper.rb +1 -1
- data/app/views/apipie/apipies/_deprecation.html.erb +16 -0
- data/app/views/apipie/apipies/_params.html.erb +7 -1
- data/config/locales/en.yml +7 -0
- data/lib/apipie/apipie_module.rb +2 -2
- data/lib/apipie/application.rb +16 -8
- data/lib/apipie/configuration.rb +13 -2
- data/lib/apipie/dsl_definition.rb +6 -6
- data/lib/apipie/error_description.rb +1 -1
- data/lib/apipie/errors.rb +2 -16
- data/lib/apipie/extractor/collector.rb +1 -1
- data/lib/apipie/extractor/recorder.rb +2 -2
- data/lib/apipie/extractor.rb +2 -2
- data/lib/apipie/generator/swagger/operation_id.rb +1 -1
- data/lib/apipie/helpers.rb +3 -3
- data/lib/apipie/markup.rb +9 -8
- data/lib/apipie/method_description.rb +1 -1
- data/lib/apipie/param_description/deprecation.rb +24 -0
- data/lib/apipie/param_description.rb +38 -11
- data/lib/apipie/resource_description.rb +10 -7
- data/lib/apipie/response_description.rb +1 -1
- data/lib/apipie/response_description_adapter.rb +3 -3
- data/lib/apipie/routing.rb +1 -1
- data/lib/apipie/rspec/response_validation_helper.rb +1 -1
- data/lib/apipie/swagger_generator.rb +6 -6
- data/lib/apipie/validator.rb +9 -10
- data/lib/apipie/version.rb +1 -1
- data/lib/apipie-rails.rb +1 -0
- data/lib/tasks/apipie.rake +11 -10
- data/spec/controllers/users_controller_spec.rb +8 -1
- data/spec/dummy/config.ru +1 -1
- data/spec/{controllers → lib/apipie}/apipies_controller_spec.rb +6 -2
- data/spec/lib/apipie/application_spec.rb +53 -0
- data/spec/lib/apipie/configuration_spec.rb +23 -0
- data/spec/lib/apipie/extractor/recorder_spec.rb +40 -0
- data/spec/lib/{generator → apipie/generator}/swagger/context_spec.rb +1 -0
- data/spec/lib/{method_description_spec.rb → apipie/method_description_spec.rb} +4 -4
- data/spec/lib/apipie/no_documented_method_spec.rb +17 -0
- data/spec/lib/apipie/param_description/deprecation_spec.rb +31 -0
- data/spec/lib/{param_description_spec.rb → apipie/param_description_spec.rb} +81 -1
- data/spec/lib/apipie/resource_description_spec.rb +91 -0
- data/spec/lib/apipie/response_does_not_match_swagger_schema_spec.rb +35 -0
- data/spec/lib/rake_spec.rb +1 -1
- data/spec/lib/swagger/rake_swagger_spec.rb +2 -2
- data/spec/lib/swagger/swagger_dsl_spec.rb +11 -5
- data/spec/spec_helper.rb +3 -3
- metadata +79 -29
- data/spec/lib/application_spec.rb +0 -49
- data/spec/lib/resource_description_spec.rb +0 -48
- /data/spec/{lib/swagger/response_validation_spec.rb → controllers/pets_controller_spec.rb} +0 -0
- /data/spec/lib/{extractor → apipie/extractor/recorder}/middleware_spec.rb +0 -0
- /data/spec/lib/{extractor → apipie/extractor}/writer_spec.rb +0 -0
- /data/spec/lib/{extractor → apipie}/extractor_spec.rb +0 -0
- /data/spec/lib/{file_handler_spec.rb → apipie/file_handler_spec.rb} +0 -0
- /data/spec/lib/{generator → apipie/generator}/swagger/operation_id_spec.rb +0 -0
- /data/spec/lib/{generator → apipie/generator}/swagger/param_description/builder_spec.rb +0 -0
- /data/spec/lib/{generator → apipie/generator}/swagger/param_description/composite_spec.rb +0 -0
- /data/spec/lib/{generator → apipie/generator}/swagger/param_description/description_spec.rb +0 -0
- /data/spec/lib/{generator → apipie/generator}/swagger/param_description/in_spec.rb +0 -0
- /data/spec/lib/{generator → apipie/generator}/swagger/param_description/name_spec.rb +0 -0
- /data/spec/lib/{generator → apipie/generator}/swagger/param_description/type_spec.rb +0 -0
- /data/spec/lib/{generator → apipie/generator}/swagger/param_description_spec.rb +0 -0
- /data/spec/lib/{generator → apipie/generator}/swagger/type_extractor_spec.rb +0 -0
- /data/spec/lib/{generator → apipie/generator}/swagger/warning_spec.rb +0 -0
- /data/spec/lib/{generator → apipie/generator}/swagger/warning_writer_spec.rb +0 -0
- /data/spec/lib/{method_description → apipie/method_description}/apis_service_spec.rb +0 -0
- /data/spec/lib/{param_group_spec.rb → apipie/param_group_spec.rb} +0 -0
- /data/spec/lib/{validator_spec.rb → apipie/validator_spec.rb} +0 -0
- /data/spec/{controllers → test_engine}/memes_controller_spec.rb +0 -0
@@ -0,0 +1,91 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Apipie::ResourceDescription do
|
4
|
+
let(:resource_description) do
|
5
|
+
Apipie::ResourceDescription.new(controller, id, dsl_data)
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:controller) { ApplicationController }
|
9
|
+
let(:id) { 'dummy' }
|
10
|
+
let(:dsl_data) { ActionController::Base.send(:_apipie_dsl_data_init) }
|
11
|
+
|
12
|
+
describe '#_methods' do
|
13
|
+
subject(:methods) { resource_description._methods }
|
14
|
+
|
15
|
+
context 'when has method descriptions' do
|
16
|
+
before do
|
17
|
+
resource_description.add_method_description(
|
18
|
+
Apipie::MethodDescription.new(:a, resource_description, dsl_data)
|
19
|
+
)
|
20
|
+
resource_description.add_method_description(
|
21
|
+
Apipie::MethodDescription.new(:b, resource_description, dsl_data)
|
22
|
+
)
|
23
|
+
resource_description.add_method_description(
|
24
|
+
Apipie::MethodDescription.new(:c, resource_description, dsl_data)
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should be ordered' do
|
29
|
+
expect(methods.keys).to eq([:a, :b, :c])
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#to_json' do
|
35
|
+
let(:json_data) { resource_description.to_json }
|
36
|
+
|
37
|
+
describe 'metadata' do
|
38
|
+
subject { json_data[:metadata] }
|
39
|
+
|
40
|
+
it { is_expected.to be_nil }
|
41
|
+
|
42
|
+
context 'when meta data are provided' do
|
43
|
+
let(:meta) { { length: 32, weight: '830g' } }
|
44
|
+
let(:dsl_data) { super().update({ meta: meta }) }
|
45
|
+
|
46
|
+
it { is_expected.to eq(meta) }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe 'methods' do
|
51
|
+
subject(:methods_as_json) { json_data[:methods] }
|
52
|
+
|
53
|
+
context 'when has method descriptions' do
|
54
|
+
before do
|
55
|
+
resource_description.add_method_description(
|
56
|
+
Apipie::MethodDescription.new(:a, resource_description, dsl_data)
|
57
|
+
)
|
58
|
+
resource_description.add_method_description(
|
59
|
+
Apipie::MethodDescription.new(:b, resource_description, dsl_data)
|
60
|
+
)
|
61
|
+
resource_description.add_method_description(
|
62
|
+
Apipie::MethodDescription.new(:c, resource_description, dsl_data)
|
63
|
+
)
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should be ordered' do
|
67
|
+
expect(methods_as_json.map { |h| h[:name] }).to eq(['a', 'b', 'c'])
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe 'name' do
|
74
|
+
subject { resource_description.name }
|
75
|
+
|
76
|
+
it { is_expected.to eq('Dummy') }
|
77
|
+
|
78
|
+
context 'when given id contains dashes' do
|
79
|
+
let(:id) { 'some-nested-resource' }
|
80
|
+
|
81
|
+
it { is_expected.to eq('Some::Nested::Resource') }
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'when resource_name is given' do
|
85
|
+
let(:resource_name) { 'Some-Resource' }
|
86
|
+
let(:dsl_data) { super().merge!(resource_name: 'Some-Resource') }
|
87
|
+
|
88
|
+
it { is_expected.to eq(resource_name) }
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Apipie::ResponseDoesNotMatchSwaggerSchema do
|
4
|
+
let(:error) do
|
5
|
+
described_class.new(
|
6
|
+
controller_name,
|
7
|
+
method_name,
|
8
|
+
response_code,
|
9
|
+
error_messages,
|
10
|
+
schema,
|
11
|
+
returned_object
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:controller_name) { 'UserController' }
|
16
|
+
let(:method_name) { 'index' }
|
17
|
+
let(:response_code) { 200 }
|
18
|
+
let(:error_messages) { [] }
|
19
|
+
let(:schema) { {} }
|
20
|
+
let(:returned_object) { {} }
|
21
|
+
|
22
|
+
describe '#to_s' do
|
23
|
+
subject { error.to_s }
|
24
|
+
|
25
|
+
let(:error_message) do
|
26
|
+
<<~HEREDOC.chomp
|
27
|
+
Response does not match swagger schema (#{controller_name}##{method_name} #{response_code}): #{error_messages}
|
28
|
+
Schema: #{JSON(schema)}
|
29
|
+
Returned object: #{returned_object}
|
30
|
+
HEREDOC
|
31
|
+
end
|
32
|
+
|
33
|
+
it { is_expected.to eq(error_message) }
|
34
|
+
end
|
35
|
+
end
|
data/spec/lib/rake_spec.rb
CHANGED
@@ -37,11 +37,11 @@ describe 'rake tasks' do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
let(:doc_output) do
|
40
|
-
File.join(
|
40
|
+
File.join(Rails.root, doc_path, 'apidoc')
|
41
41
|
end
|
42
42
|
|
43
43
|
let(:ref_output) do
|
44
|
-
File.join(
|
44
|
+
File.join(Rails.root, doc_path, 'apidoc_ref')
|
45
45
|
end
|
46
46
|
|
47
47
|
|
@@ -24,20 +24,20 @@ describe "Swagger Responses" do
|
|
24
24
|
schema
|
25
25
|
end
|
26
26
|
|
27
|
-
def swagger_response_for(path, code=200, method='get')
|
27
|
+
def swagger_response_for(path, code = 200, method = 'get')
|
28
28
|
response = swagger[:paths][path][method][:responses][code]
|
29
29
|
response[:schema] = resolve_refs(response[:schema])
|
30
30
|
response
|
31
31
|
end
|
32
32
|
|
33
|
-
def swagger_params_for(path, method='get')
|
33
|
+
def swagger_params_for(path, method = 'get')
|
34
34
|
swagger[:paths][path][method][:parameters]
|
35
35
|
end
|
36
36
|
|
37
|
-
def swagger_param_by_name(param_name, path, method='get')
|
37
|
+
def swagger_param_by_name(param_name, path, method = 'get')
|
38
38
|
params = swagger_params_for(path, method)
|
39
39
|
matching = params.select{|p| p[:name] == param_name }
|
40
|
-
raise "multiple params named [#{param_name}] in swagger definition for [#{method
|
40
|
+
raise "multiple params named [#{param_name}] in swagger definition for [#{method} #{path}]" if matching.length > 1
|
41
41
|
|
42
42
|
nil if matching.length == 0
|
43
43
|
|
@@ -72,7 +72,7 @@ describe "Swagger Responses" do
|
|
72
72
|
deep_match?(actual, expected)
|
73
73
|
end
|
74
74
|
|
75
|
-
def deep_match?(actual, expected, breadcrumb=[])
|
75
|
+
def deep_match?(actual, expected, breadcrumb = [])
|
76
76
|
pending_params = actual.params_ordered.dup
|
77
77
|
expected.each do |expected_param|
|
78
78
|
expected_param_name = expected_param.is_a?(Hash) ? expected_param.keys.first : expected_param
|
@@ -338,6 +338,7 @@ describe "Swagger Responses" do
|
|
338
338
|
|
339
339
|
expect(returns_obj).to match_field_structure([:pet_name, :animal_type])
|
340
340
|
end
|
341
|
+
|
341
342
|
it 'should have the 201 response described in the swagger' do
|
342
343
|
response = swagger_response_for('/pets/{id}/extra_info', 201)
|
343
344
|
expect(response[:description]).to eq("Found a pet")
|
@@ -359,6 +360,7 @@ describe "Swagger Responses" do
|
|
359
360
|
{:pet_measurements => [:weight, :height, :num_legs]}
|
360
361
|
])
|
361
362
|
end
|
363
|
+
|
362
364
|
it 'should have the 202 response described in the swagger' do
|
363
365
|
response = swagger_response_for('/pets/{id}/extra_info', 202)
|
364
366
|
expect(response[:description]).to eq('Accepted')
|
@@ -388,6 +390,7 @@ describe "Swagger Responses" do
|
|
388
390
|
{:additional_histories => [:did_visit_vet, :avg_meals_per_day]}
|
389
391
|
])
|
390
392
|
end
|
393
|
+
|
391
394
|
it 'should have the 203 response described in the swagger' do
|
392
395
|
response = swagger_response_for('/pets/{id}/extra_info', 203)
|
393
396
|
expect(response[:description]).to eq('Non-Authoritative Information')
|
@@ -424,6 +427,7 @@ describe "Swagger Responses" do
|
|
424
427
|
|
425
428
|
expect(returns_obj).to match_field_structure([:int_array, :enum_array])
|
426
429
|
end
|
430
|
+
|
427
431
|
it 'should have the 204 response described in the swagger' do
|
428
432
|
response = swagger_response_for('/pets/{id}/extra_info', 204)
|
429
433
|
|
@@ -444,6 +448,7 @@ describe "Swagger Responses" do
|
|
444
448
|
:num_fleas
|
445
449
|
])
|
446
450
|
end
|
451
|
+
|
447
452
|
it 'should have the 422 response described in the swagger' do
|
448
453
|
response = swagger_response_for('/pets/{id}/extra_info', 422)
|
449
454
|
expect(response[:description]).to eq('Fleas were discovered on the pet')
|
@@ -568,6 +573,7 @@ describe "Swagger Responses" do
|
|
568
573
|
{:pet_measurements => [:weight, :height, :num_legs]}
|
569
574
|
])
|
570
575
|
end
|
576
|
+
|
571
577
|
it 'should have the 200 response described in the swagger' do
|
572
578
|
response = swagger_response_for('/pets_with_measurements_described_as_class/{id}', 200)
|
573
579
|
expect(response[:description]).to eq('measurements of the pet')
|
data/spec/spec_helper.rb
CHANGED
@@ -24,7 +24,7 @@ require 'test_engine'
|
|
24
24
|
#
|
25
25
|
# will verify that the selected response schema includes a required string field called 'pet_name'
|
26
26
|
#
|
27
|
-
RSpec::Matchers.define :have_field do |name, type, opts={}|
|
27
|
+
RSpec::Matchers.define :have_field do |name, type, opts = {}|
|
28
28
|
def fail(msg)
|
29
29
|
@fail_message = msg
|
30
30
|
false
|
@@ -55,14 +55,14 @@ 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', __dir__)].each {|f| require f}
|
58
|
+
Dir[File.expand_path('support/**/*.rb', __dir__)].sort.each {|f| require f}
|
59
59
|
|
60
60
|
RSpec.configure do |config|
|
61
61
|
|
62
62
|
config.mock_with :rspec
|
63
63
|
|
64
64
|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
65
|
-
config.fixture_path = "#{
|
65
|
+
config.fixture_path = "#{Rails.root}/spec/fixtures"
|
66
66
|
|
67
67
|
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
68
68
|
# examples within a transaction, remove the following line or assign false
|
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.9.
|
4
|
+
version: 0.9.4
|
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: 2023-
|
12
|
+
date: 2023-04-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|
@@ -123,6 +123,48 @@ dependencies:
|
|
123
123
|
- - ">="
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: rubocop-rails
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: rubocop-rspec
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
- !ruby/object:Gem::Dependency
|
155
|
+
name: rubocop-performance
|
156
|
+
requirement: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
type: :development
|
162
|
+
prerelease: false
|
163
|
+
version_requirements: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
126
168
|
- !ruby/object:Gem::Dependency
|
127
169
|
name: simplecov
|
128
170
|
requirement: !ruby/object:Gem::Requirement
|
@@ -161,6 +203,7 @@ extra_rdoc_files: []
|
|
161
203
|
files:
|
162
204
|
- ".github/workflows/build.yml"
|
163
205
|
- ".github/workflows/rubocop-challenger.yml"
|
206
|
+
- ".github/workflows/rubocop.yml"
|
164
207
|
- ".gitignore"
|
165
208
|
- ".rspec"
|
166
209
|
- ".rubocop.yml"
|
@@ -184,6 +227,7 @@ files:
|
|
184
227
|
- app/public/apipie/stylesheets/bundled/bootstrap-responsive.min.css
|
185
228
|
- app/public/apipie/stylesheets/bundled/bootstrap.min.css
|
186
229
|
- app/public/apipie/stylesheets/bundled/prettify.css
|
230
|
+
- app/views/apipie/apipies/_deprecation.html.erb
|
187
231
|
- app/views/apipie/apipies/_disqus.html.erb
|
188
232
|
- app/views/apipie/apipies/_errors.html.erb
|
189
233
|
- app/views/apipie/apipies/_headers.html.erb
|
@@ -256,6 +300,7 @@ files:
|
|
256
300
|
- lib/apipie/method_description/apis_service.rb
|
257
301
|
- lib/apipie/middleware/checksum_in_headers.rb
|
258
302
|
- lib/apipie/param_description.rb
|
303
|
+
- lib/apipie/param_description/deprecation.rb
|
259
304
|
- lib/apipie/railtie.rb
|
260
305
|
- lib/apipie/resource_description.rb
|
261
306
|
- lib/apipie/response_description.rb
|
@@ -281,11 +326,10 @@ files:
|
|
281
326
|
- spec/controllers/api/v1/architectures_controller_spec.rb
|
282
327
|
- spec/controllers/api/v2/architectures_controller_spec.rb
|
283
328
|
- spec/controllers/api/v2/nested/resources_controller_spec.rb
|
284
|
-
- spec/controllers/apipies_controller_spec.rb
|
285
329
|
- spec/controllers/concerns_controller_spec.rb
|
286
330
|
- spec/controllers/extended_controller_spec.rb
|
287
331
|
- spec/controllers/included_param_group_controller_spec.rb
|
288
|
-
- spec/controllers/
|
332
|
+
- spec/controllers/pets_controller_spec.rb
|
289
333
|
- spec/controllers/users_controller_spec.rb
|
290
334
|
- spec/dummy/Rakefile
|
291
335
|
- spec/dummy/app/controllers/api/base_controller.rb
|
@@ -344,38 +388,44 @@ files:
|
|
344
388
|
- spec/dummy/public/favicon.ico
|
345
389
|
- spec/dummy/public/stylesheets/.gitkeep
|
346
390
|
- spec/dummy/script/rails
|
347
|
-
- spec/lib/
|
348
|
-
- spec/lib/
|
349
|
-
- spec/lib/
|
350
|
-
- spec/lib/extractor/
|
351
|
-
- spec/lib/
|
352
|
-
- spec/lib/
|
353
|
-
- spec/lib/
|
354
|
-
- spec/lib/
|
355
|
-
- spec/lib/generator/swagger/
|
356
|
-
- spec/lib/generator/swagger/
|
357
|
-
- spec/lib/generator/swagger/param_description/
|
358
|
-
- spec/lib/generator/swagger/param_description/
|
359
|
-
- spec/lib/generator/swagger/param_description/
|
360
|
-
- spec/lib/generator/swagger/
|
361
|
-
- spec/lib/generator/swagger/
|
362
|
-
- spec/lib/generator/swagger/
|
363
|
-
- spec/lib/generator/swagger/
|
364
|
-
- spec/lib/
|
365
|
-
- spec/lib/
|
366
|
-
- spec/lib/
|
367
|
-
- spec/lib/
|
391
|
+
- spec/lib/apipie/apipies_controller_spec.rb
|
392
|
+
- spec/lib/apipie/application_spec.rb
|
393
|
+
- spec/lib/apipie/configuration_spec.rb
|
394
|
+
- spec/lib/apipie/extractor/recorder/middleware_spec.rb
|
395
|
+
- spec/lib/apipie/extractor/recorder_spec.rb
|
396
|
+
- spec/lib/apipie/extractor/writer_spec.rb
|
397
|
+
- spec/lib/apipie/extractor_spec.rb
|
398
|
+
- spec/lib/apipie/file_handler_spec.rb
|
399
|
+
- spec/lib/apipie/generator/swagger/context_spec.rb
|
400
|
+
- spec/lib/apipie/generator/swagger/operation_id_spec.rb
|
401
|
+
- spec/lib/apipie/generator/swagger/param_description/builder_spec.rb
|
402
|
+
- spec/lib/apipie/generator/swagger/param_description/composite_spec.rb
|
403
|
+
- spec/lib/apipie/generator/swagger/param_description/description_spec.rb
|
404
|
+
- spec/lib/apipie/generator/swagger/param_description/in_spec.rb
|
405
|
+
- spec/lib/apipie/generator/swagger/param_description/name_spec.rb
|
406
|
+
- spec/lib/apipie/generator/swagger/param_description/type_spec.rb
|
407
|
+
- spec/lib/apipie/generator/swagger/param_description_spec.rb
|
408
|
+
- spec/lib/apipie/generator/swagger/type_extractor_spec.rb
|
409
|
+
- spec/lib/apipie/generator/swagger/warning_spec.rb
|
410
|
+
- spec/lib/apipie/generator/swagger/warning_writer_spec.rb
|
411
|
+
- spec/lib/apipie/method_description/apis_service_spec.rb
|
412
|
+
- spec/lib/apipie/method_description_spec.rb
|
413
|
+
- spec/lib/apipie/no_documented_method_spec.rb
|
414
|
+
- spec/lib/apipie/param_description/deprecation_spec.rb
|
415
|
+
- spec/lib/apipie/param_description_spec.rb
|
416
|
+
- spec/lib/apipie/param_group_spec.rb
|
417
|
+
- spec/lib/apipie/resource_description_spec.rb
|
418
|
+
- spec/lib/apipie/response_does_not_match_swagger_schema_spec.rb
|
419
|
+
- spec/lib/apipie/validator_spec.rb
|
368
420
|
- spec/lib/rake_spec.rb
|
369
|
-
- spec/lib/resource_description_spec.rb
|
370
421
|
- spec/lib/swagger/openapi_2_0_schema.json
|
371
422
|
- spec/lib/swagger/rake_swagger_spec.rb
|
372
|
-
- spec/lib/swagger/response_validation_spec.rb
|
373
423
|
- spec/lib/swagger/swagger_dsl_spec.rb
|
374
|
-
- spec/lib/validator_spec.rb
|
375
424
|
- spec/lib/validators/array_validator_spec.rb
|
376
425
|
- spec/spec_helper.rb
|
377
426
|
- spec/support/custom_bool_validator.rb
|
378
427
|
- spec/support/rake.rb
|
428
|
+
- spec/test_engine/memes_controller_spec.rb
|
379
429
|
homepage: http://github.com/Apipie/apipie-rails
|
380
430
|
licenses: []
|
381
431
|
metadata: {}
|
@@ -394,7 +444,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
394
444
|
- !ruby/object:Gem::Version
|
395
445
|
version: '0'
|
396
446
|
requirements: []
|
397
|
-
rubygems_version: 3.
|
447
|
+
rubygems_version: 3.1.6
|
398
448
|
signing_key:
|
399
449
|
specification_version: 4
|
400
450
|
summary: Rails REST API documentation tool
|
@@ -1,49 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Apipie::Application do
|
4
|
-
|
5
|
-
describe "api_controllers_paths" do
|
6
|
-
before { Apipie.configuration.api_controllers_matcher = [File.join(Rails.root, "app", "controllers", "**","*.rb"), File.join(Rails.root, "lib", "**","*.rb")] }
|
7
|
-
|
8
|
-
it "should support receiving array as parameter" do
|
9
|
-
expect { Apipie.api_controllers_paths}.
|
10
|
-
not_to raise_error
|
11
|
-
end
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "get_resource_name" do
|
17
|
-
subject {Apipie.get_resource_name(Api::V2::Nested::ArchitecturesController)}
|
18
|
-
|
19
|
-
context "with namespaced_resources enabled" do
|
20
|
-
before { Apipie.configuration.namespaced_resources = true }
|
21
|
-
context "with a defined base url" do
|
22
|
-
|
23
|
-
it "should not overwrite the parent resource" do
|
24
|
-
is_expected.not_to eq(Apipie.get_resource_name(Api::V2::ArchitecturesController))
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
context "with an undefined base url" do
|
30
|
-
before {allow(Apipie.app).to receive(:get_base_url).and_return(nil)}
|
31
|
-
|
32
|
-
it "should not raise an error" do
|
33
|
-
expect { Apipie.get_resource_name(Api::V2::ArchitecturesController) }.
|
34
|
-
not_to raise_error
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
after { Apipie.configuration.namespaced_resources = false }
|
39
|
-
end
|
40
|
-
|
41
|
-
context "with namespaced_resources enabled" do
|
42
|
-
before { Apipie.configuration.namespaced_resources = false }
|
43
|
-
|
44
|
-
it "should overwrite the the parent" do
|
45
|
-
is_expected.to eq(Apipie.get_resource_name(Api::V2::ArchitecturesController))
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Apipie::ResourceDescription do
|
4
|
-
|
5
|
-
let(:dsl_data) { ActionController::Base.send(:_apipie_dsl_data_init) }
|
6
|
-
|
7
|
-
describe "metadata" do
|
8
|
-
|
9
|
-
it "should return nil when no metadata is provided" do
|
10
|
-
resource = Apipie::ResourceDescription.new(ApplicationController, "dummy", dsl_data)
|
11
|
-
expect(resource.to_json[:metadata]).to eq(nil)
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should return the metadata" do
|
15
|
-
meta = {
|
16
|
-
:lenght => 32,
|
17
|
-
:weight => '830g'
|
18
|
-
}
|
19
|
-
resource = Apipie::ResourceDescription.new(ApplicationController, "dummy", dsl_data.update(:meta => meta))
|
20
|
-
expect(resource.to_json[:metadata]).to eq(meta)
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
describe "methods descriptions" do
|
26
|
-
|
27
|
-
before(:each) do
|
28
|
-
@resource = Apipie::ResourceDescription.new(ApplicationController, "dummy")
|
29
|
-
a = Apipie::MethodDescription.new(:a, @resource, dsl_data)
|
30
|
-
b = Apipie::MethodDescription.new(:b, @resource, dsl_data)
|
31
|
-
c = Apipie::MethodDescription.new(:c, @resource, dsl_data)
|
32
|
-
@resource.add_method_description(a)
|
33
|
-
@resource.add_method_description(b)
|
34
|
-
@resource.add_method_description(c)
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should be ordered" do
|
38
|
-
expect(@resource._methods.keys).to eq([:a, :b, :c])
|
39
|
-
expect(@resource.to_json[:methods].map{|h| h[:name]}).to eq(['a', 'b', 'c'])
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should be still ordered" do
|
43
|
-
expect(@resource._methods.keys).to eq([:a, :b, :c])
|
44
|
-
expect(@resource.to_json[:methods].map{|h| h[:name]}).to eq(['a', 'b', 'c'])
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|