apipie-rails 0.5.19 → 1.3.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 +31 -0
- data/.github/workflows/rubocop-challenger.yml +28 -0
- data/.github/workflows/rubocop.yml +18 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +128 -0
- data/.rubocop_todo.yml +2056 -0
- data/.vscode/settings.json +3 -0
- data/CHANGELOG.md +161 -0
- data/Gemfile +20 -0
- data/README.rst +117 -23
- data/Rakefile +0 -5
- data/apipie-rails.gemspec +18 -9
- data/app/controllers/apipie/apipies_controller.rb +14 -29
- data/app/helpers/apipie_helper.rb +1 -1
- data/app/public/apipie/javascripts/bundled/bootstrap-collapse.js +70 -41
- data/app/public/apipie/javascripts/bundled/bootstrap.js +1033 -479
- data/app/public/apipie/javascripts/bundled/jquery.js +5 -5
- data/app/public/apipie/stylesheets/bundled/bootstrap-responsive.min.css +9 -12
- data/app/public/apipie/stylesheets/bundled/bootstrap.min.css +9 -689
- 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 +8 -0
- data/config/locales/ko.yml +31 -0
- data/gemfiles/Gemfile.tools +9 -0
- data/lib/apipie/apipie_module.rb +7 -7
- data/lib/apipie/application.rb +132 -97
- data/lib/apipie/configuration.rb +43 -33
- data/lib/apipie/dsl_definition.rb +44 -33
- data/lib/apipie/error_description.rb +3 -3
- data/lib/apipie/errors.rb +17 -17
- data/lib/apipie/extractor/collector.rb +5 -6
- data/lib/apipie/extractor/recorder.rb +35 -8
- data/lib/apipie/extractor/writer.rb +15 -15
- data/lib/apipie/extractor.rb +6 -9
- data/lib/apipie/generator/config.rb +12 -0
- data/lib/apipie/generator/generator.rb +2 -0
- data/lib/apipie/generator/swagger/computed_interface_id.rb +23 -0
- data/lib/apipie/generator/swagger/config.rb +80 -0
- data/lib/apipie/generator/swagger/context.rb +38 -0
- data/lib/apipie/generator/swagger/method_description/api_decorator.rb +20 -0
- data/lib/apipie/generator/swagger/method_description/api_schema_service.rb +89 -0
- data/lib/apipie/generator/swagger/method_description/decorator.rb +22 -0
- data/lib/apipie/generator/swagger/method_description/parameters_service.rb +139 -0
- data/lib/apipie/generator/swagger/method_description/response_schema_service.rb +46 -0
- data/lib/apipie/generator/swagger/method_description/response_service.rb +58 -0
- data/lib/apipie/generator/swagger/method_description.rb +2 -0
- data/lib/apipie/generator/swagger/operation_id.rb +51 -0
- data/lib/apipie/generator/swagger/param_description/builder.rb +114 -0
- data/lib/apipie/generator/swagger/param_description/composite.rb +119 -0
- data/lib/apipie/generator/swagger/param_description/description.rb +15 -0
- data/lib/apipie/generator/swagger/param_description/in.rb +37 -0
- data/lib/apipie/generator/swagger/param_description/name.rb +18 -0
- data/lib/apipie/generator/swagger/param_description/path_params_composite.rb +61 -0
- data/lib/apipie/generator/swagger/param_description/referenced_composite.rb +36 -0
- data/lib/apipie/generator/swagger/param_description/type.rb +128 -0
- data/lib/apipie/generator/swagger/param_description.rb +18 -0
- data/lib/apipie/generator/swagger/path_decorator.rb +36 -0
- data/lib/apipie/generator/swagger/referenced_definitions.rb +17 -0
- data/lib/apipie/generator/swagger/resource_description_collection.rb +30 -0
- data/lib/apipie/generator/swagger/resource_description_composite.rb +56 -0
- data/lib/apipie/generator/swagger/schema.rb +63 -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 +51 -0
- data/lib/apipie/generator/swagger/warning.rb +74 -0
- data/lib/apipie/generator/swagger/warning_writer.rb +54 -0
- data/lib/apipie/helpers.rb +3 -3
- data/lib/apipie/markup.rb +9 -8
- 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 +12 -56
- data/lib/apipie/param_description/deprecation.rb +24 -0
- data/lib/apipie/param_description.rb +57 -24
- data/lib/apipie/resource_description.rb +42 -14
- data/lib/apipie/response_description.rb +3 -3
- data/lib/apipie/response_description_adapter.rb +12 -10
- data/lib/apipie/routing.rb +1 -1
- data/lib/apipie/rspec/response_validation_helper.rb +3 -3
- data/lib/apipie/static_dispatcher.rb +10 -2
- data/lib/apipie/swagger_generator.rb +28 -691
- data/lib/apipie/validator.rb +41 -11
- data/lib/apipie/version.rb +1 -1
- data/lib/apipie-rails.rb +36 -5
- data/lib/generators/apipie/install/install_generator.rb +1 -1
- data/lib/generators/apipie/views_generator.rb +1 -1
- data/lib/tasks/apipie.rake +37 -32
- data/rel-eng/gem_release.ipynb +41 -9
- data/spec/controllers/api/v2/architectures_controller_spec.rb +10 -3
- data/spec/controllers/api/v2/empty_middle_controller_spec.rb +23 -0
- data/spec/controllers/api/v2/nested/resources_controller_spec.rb +18 -2
- data/spec/controllers/api/v2/sub/footguns_controller_spec.rb +19 -0
- data/spec/controllers/included_param_group_controller_spec.rb +13 -0
- data/spec/{lib/swagger/response_validation_spec.rb → controllers/pets_controller_spec.rb} +26 -32
- data/spec/controllers/users_controller_spec.rb +47 -6
- data/spec/dummy/Rakefile +1 -1
- data/spec/dummy/app/controllers/api/v2/architectures_controller.rb +2 -1
- data/spec/dummy/app/controllers/api/v2/base_controller.rb +6 -0
- data/spec/dummy/app/controllers/api/v2/empty_middle_controller.rb +14 -0
- data/spec/dummy/app/controllers/api/v2/nested/resources_controller.rb +2 -2
- data/spec/dummy/app/controllers/api/v2/sub/footguns_controller.rb +30 -0
- data/spec/dummy/app/controllers/concerns_controller.rb +1 -1
- data/spec/dummy/app/controllers/{concerns/extending_concern.rb → extending_concern.rb} +0 -2
- data/spec/dummy/app/controllers/included_param_group_controller.rb +19 -0
- data/spec/dummy/app/controllers/overridden_concerns_controller.rb +2 -2
- data/spec/dummy/app/controllers/pets_controller.rb +5 -5
- data/spec/dummy/app/controllers/pets_using_self_describing_classes_controller.rb +2 -2
- data/spec/dummy/app/controllers/{concerns/sample_controller.rb → sample_controller.rb} +0 -2
- data/spec/dummy/app/controllers/twitter_example_controller.rb +2 -2
- data/spec/dummy/app/controllers/users_controller.rb +17 -5
- 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 +2 -5
- data/spec/dummy/config/boot.rb +2 -2
- data/spec/dummy/config/environment.rb +1 -1
- data/spec/dummy/config/environments/development.rb +0 -3
- data/spec/dummy/config/environments/production.rb +0 -3
- data/spec/dummy/config/environments/test.rb +0 -5
- data/spec/dummy/config/initializers/apipie.rb +2 -2
- data/spec/dummy/config/routes.rb +8 -0
- data/spec/dummy/config.ru +1 -1
- data/spec/dummy/script/rails +2 -2
- data/spec/{controllers → lib/apipie}/apipies_controller_spec.rb +95 -23
- data/spec/lib/apipie/application_spec.rb +62 -0
- data/spec/lib/apipie/configuration_spec.rb +38 -0
- data/spec/lib/apipie/extractor/collector_spec.rb +57 -0
- data/spec/lib/apipie/extractor/recorder_spec.rb +77 -0
- data/spec/lib/{extractor → apipie/extractor}/writer_spec.rb +8 -6
- data/spec/lib/{extractor → apipie}/extractor_spec.rb +1 -1
- data/spec/lib/{file_handler_spec.rb → apipie/file_handler_spec.rb} +7 -0
- data/spec/lib/apipie/generator/swagger/config_spec.rb +19 -0
- data/spec/lib/apipie/generator/swagger/context_spec.rb +56 -0
- data/spec/lib/apipie/generator/swagger/method_description/api_schema_service_spec.rb +119 -0
- data/spec/lib/apipie/generator/swagger/method_description/response_schema_service_spec.rb +105 -0
- data/spec/lib/apipie/generator/swagger/operation_id_spec.rb +63 -0
- data/spec/lib/apipie/generator/swagger/param_description/builder_spec.rb +215 -0
- data/spec/lib/apipie/generator/swagger/param_description/composite_spec.rb +95 -0
- data/spec/lib/apipie/generator/swagger/param_description/description_spec.rb +79 -0
- data/spec/lib/apipie/generator/swagger/param_description/in_spec.rb +86 -0
- data/spec/lib/apipie/generator/swagger/param_description/name_spec.rb +81 -0
- data/spec/lib/apipie/generator/swagger/param_description/type_spec.rb +183 -0
- data/spec/lib/apipie/generator/swagger/param_description_spec.rb +28 -0
- data/spec/lib/apipie/generator/swagger/path_decorator_spec.rb +57 -0
- data/spec/lib/apipie/generator/swagger/referenced_definitions_spec.rb +35 -0
- data/spec/lib/apipie/generator/swagger/resource_description_composite_spec.rb +37 -0
- data/spec/lib/apipie/generator/swagger/resource_descriptions_collection_spec.rb +57 -0
- data/spec/lib/apipie/generator/swagger/schema_spec.rb +89 -0
- data/spec/lib/apipie/generator/swagger/type_extractor_spec.rb +38 -0
- data/spec/lib/apipie/generator/swagger/warning_spec.rb +51 -0
- data/spec/lib/apipie/generator/swagger/warning_writer_spec.rb +71 -0
- data/spec/lib/apipie/method_description/apis_service_spec.rb +60 -0
- data/spec/lib/apipie/method_description_spec.rb +133 -0
- 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} +332 -6
- data/spec/lib/{param_group_spec.rb → apipie/param_group_spec.rb} +6 -5
- 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/apipie/swagger_generator_spec.rb +94 -0
- data/spec/lib/{validator_spec.rb → apipie/validator_spec.rb} +48 -12
- data/spec/lib/rake_spec.rb +3 -5
- data/spec/lib/swagger/openapi_2_0_schema.json +8 -1
- data/spec/lib/swagger/rake_swagger_spec.rb +30 -10
- data/spec/lib/swagger/swagger_dsl_spec.rb +18 -12
- data/spec/lib/validators/array_validator_spec.rb +1 -1
- data/spec/spec_helper.rb +10 -32
- data/spec/support/custom_bool_validator.rb +17 -0
- data/spec/{controllers → test_engine}/memes_controller_spec.rb +1 -1
- metadata +173 -125
- data/.travis.yml +0 -41
- data/Gemfile +0 -1
- data/Gemfile.rails41 +0 -7
- data/Gemfile.rails42 +0 -14
- data/Gemfile.rails50 +0 -9
- data/Gemfile.rails51 +0 -9
- data/Gemfile.rails60 +0 -10
- data/Gemfile.rails61 +0 -10
- data/spec/lib/application_spec.rb +0 -49
- data/spec/lib/method_description_spec.rb +0 -98
- data/spec/lib/resource_description_spec.rb +0 -48
- /data/spec/lib/{extractor → apipie/extractor/recorder}/middleware_spec.rb +0 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Apipie::Generator::Swagger::Warning do
|
4
|
+
let(:code) { Apipie::Generator::Swagger::Warning::MISSING_METHOD_SUMMARY_CODE }
|
5
|
+
let(:method_id) { 'Examples#index' }
|
6
|
+
let(:info_message) { 'Something went wrong' }
|
7
|
+
|
8
|
+
let(:warning) { described_class.new(code, info_message, method_id) }
|
9
|
+
|
10
|
+
describe '#id' do
|
11
|
+
subject { warning.id }
|
12
|
+
|
13
|
+
it { is_expected.to eq("#{method_id}#{code}#{info_message}") }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#warning_message' do
|
17
|
+
subject { warning.warning_message }
|
18
|
+
|
19
|
+
it { is_expected.to eq("WARNING (#{code}): [#{method_id}] -- #{info_message}\n") }
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#warn' do
|
23
|
+
subject { warning.warn }
|
24
|
+
|
25
|
+
it 'outputs the warning' do
|
26
|
+
expect { subject }.to output(warning.warning_message).to_stderr
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#warn_through_writer' do
|
31
|
+
subject { warning.warn }
|
32
|
+
|
33
|
+
it 'outputs the warning' do
|
34
|
+
expect { subject }.to output(warning.warning_message).to_stderr
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '.for_code' do
|
39
|
+
subject { described_class.for_code(code, method_id) }
|
40
|
+
|
41
|
+
it { is_expected.to be_an_instance_of(described_class)}
|
42
|
+
|
43
|
+
context 'when code is invalid' do
|
44
|
+
let(:code) { 12345 }
|
45
|
+
|
46
|
+
it 'raises an argument error' do
|
47
|
+
expect { subject }.to raise_error(ArgumentError)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Apipie::Generator::Swagger::WarningWriter do
|
4
|
+
let(:writer) { described_class.clone.instance }
|
5
|
+
|
6
|
+
let(:warning) do
|
7
|
+
Apipie::Generator::Swagger::Warning.for_code(
|
8
|
+
Apipie::Generator::Swagger::Warning::PARAM_IGNORED_IN_FORM_DATA_CODE,
|
9
|
+
'SampleController#action',
|
10
|
+
{ parameter: 'some-param' }
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
before do
|
15
|
+
Apipie.configuration.generator.swagger.suppress_warnings = false
|
16
|
+
Singleton.__init__(described_class)
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#warn' do
|
20
|
+
subject { writer.warn(warning) }
|
21
|
+
|
22
|
+
it 'outputs the warning' do
|
23
|
+
expect { subject }.to output(warning.warning_message).to_stderr
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'when Apipie.configuration.generator.swagger.suppress_warnings is true' do
|
27
|
+
before { Apipie.configuration.generator.swagger.suppress_warnings = true }
|
28
|
+
|
29
|
+
it { is_expected.to be_falsey }
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'when Apipie.configuration.generator.swagger.suppress_warnings includes warning code' do
|
33
|
+
before do
|
34
|
+
Apipie.configuration.generator.swagger.suppress_warnings =
|
35
|
+
Array(Apipie::Generator::Swagger::Warning::PARAM_IGNORED_IN_FORM_DATA_CODE)
|
36
|
+
end
|
37
|
+
|
38
|
+
it { is_expected.to be_falsey }
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'when a warning already been logged' do
|
42
|
+
before { writer.warn(warning) }
|
43
|
+
|
44
|
+
it { is_expected.to be_falsey }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#issued_warnings?' do
|
49
|
+
subject { writer.issued_warnings? }
|
50
|
+
|
51
|
+
it { is_expected.to be_falsey }
|
52
|
+
|
53
|
+
context 'when a warning already been logged' do
|
54
|
+
before { writer.warn(warning) }
|
55
|
+
|
56
|
+
it { is_expected.to be_truthy }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#clear!' do
|
61
|
+
subject { writer.clear! }
|
62
|
+
|
63
|
+
context 'when writer has issued warnings' do
|
64
|
+
before { writer.warn(warning) }
|
65
|
+
|
66
|
+
it 'removes issued warnings' do
|
67
|
+
expect { subject }.to change(writer, :issued_warnings?).from(true).to(false)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -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
|
@@ -0,0 +1,133 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Apipie::MethodDescription do
|
4
|
+
let(:dsl_data) { ActionController::Base.send(:_apipie_dsl_data_init) }
|
5
|
+
let(:deprecated_resource_description) { false }
|
6
|
+
let(:method_description_method) { :some_method }
|
7
|
+
|
8
|
+
let(:resource_description_dsl) do
|
9
|
+
ActionController::Base.send(:_apipie_dsl_data_init).merge(
|
10
|
+
{
|
11
|
+
deprecated: deprecated_resource_description
|
12
|
+
}
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:resource_description) do
|
17
|
+
Apipie::ResourceDescription.new(
|
18
|
+
ApplicationController,
|
19
|
+
'dummy',
|
20
|
+
resource_description_dsl
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
let(:method_description) do
|
25
|
+
Apipie::MethodDescription.new(
|
26
|
+
method_description_method,
|
27
|
+
resource_description,
|
28
|
+
dsl_data
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#to_json' do
|
33
|
+
describe 'metadata' do
|
34
|
+
subject { method_description.to_json[:metadata] }
|
35
|
+
|
36
|
+
it { is_expected.to be_nil }
|
37
|
+
|
38
|
+
context 'when meta are given' do
|
39
|
+
let(:meta) { { length: 32, weight: '830g' } }
|
40
|
+
let(:dsl_data) { super().merge(meta: meta) }
|
41
|
+
|
42
|
+
it { is_expected.to eq(meta) }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe 'params' do
|
47
|
+
subject(:json_params) { method_description.to_json[:params].map { |h| h[:name] } }
|
48
|
+
|
49
|
+
let(:dsl_data) do
|
50
|
+
super().merge(
|
51
|
+
{
|
52
|
+
params: [
|
53
|
+
[:a, String, nil, {}, nil],
|
54
|
+
[:b, String, nil, {}, nil],
|
55
|
+
[:c, String, nil, {}, nil]
|
56
|
+
]
|
57
|
+
}
|
58
|
+
)
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should be ordered' do
|
62
|
+
expect(json_params).to eq(%w[a b c])
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'when param is only for response' do
|
66
|
+
let(:dsl_data) do
|
67
|
+
super().merge(
|
68
|
+
{
|
69
|
+
params: [
|
70
|
+
[:a, String, nil, { only_in: :request }, nil],
|
71
|
+
[:b, String, nil, { only_in: :response }, nil],
|
72
|
+
[:c, String, nil, {}, nil]
|
73
|
+
]
|
74
|
+
}
|
75
|
+
)
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should ignore response-only parameters' do
|
79
|
+
expect(json_params).to eq(%w[a c])
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe '#method_apis_to_json' do
|
86
|
+
describe 'deprecated' do
|
87
|
+
subject { method_description.method_apis_to_json.first[:deprecated] }
|
88
|
+
|
89
|
+
let(:api_deprecated) { false }
|
90
|
+
let(:dsl_data) { super().merge(api_args: api_args) }
|
91
|
+
|
92
|
+
let(:api_args) do
|
93
|
+
[[:GET, "/foo/bar", "description", { deprecated: api_deprecated }]]
|
94
|
+
end
|
95
|
+
|
96
|
+
it { is_expected.to eq(false) }
|
97
|
+
|
98
|
+
context 'when api is deprecated' do
|
99
|
+
let(:api_deprecated) { true }
|
100
|
+
|
101
|
+
it { is_expected.to eq(true) }
|
102
|
+
end
|
103
|
+
|
104
|
+
context 'when resource description is deprecated' do
|
105
|
+
let(:deprecated_resource_description) { true }
|
106
|
+
|
107
|
+
it { is_expected.to eq(true) }
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe '#returns' do
|
113
|
+
subject(:method_desc) { method_description }
|
114
|
+
|
115
|
+
context 'when both :param_group and :array_of are specified' do
|
116
|
+
let(:returns) do
|
117
|
+
{ 200 => [{ param_group: 'pet', array_of: 'pet' }, nil, nil] }
|
118
|
+
end
|
119
|
+
|
120
|
+
let(:dsl_data) { super().merge({ returns: returns }) }
|
121
|
+
|
122
|
+
it 'raises an error' do
|
123
|
+
expect { method_desc }.to raise_error(Apipie::ReturnsMultipleDefinitionError)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
describe '#method_name' do
|
129
|
+
subject { method_description.method_name }
|
130
|
+
|
131
|
+
it { is_expected.to eq(method_description_method.to_s) }
|
132
|
+
end
|
133
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Apipie::NoDocumentedMethod do
|
4
|
+
let(:error) { described_class.new(controller_name, method_name) }
|
5
|
+
let(:controller_name) { 'UserController' }
|
6
|
+
let(:method_name) { 'index' }
|
7
|
+
|
8
|
+
describe '#to_s' do
|
9
|
+
subject { error.to_s }
|
10
|
+
|
11
|
+
let(:error_message) do
|
12
|
+
"There is no documented method #{controller_name}##{method_name}"
|
13
|
+
end
|
14
|
+
|
15
|
+
it { is_expected.to eq(error_message) }
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Apipie::ParamDescription::Deprecation do
|
4
|
+
let(:info) { nil }
|
5
|
+
let(:deprecated_in) { nil }
|
6
|
+
let(:sunset_at) { nil }
|
7
|
+
|
8
|
+
let(:deprecation) do
|
9
|
+
described_class.new(
|
10
|
+
info: info,
|
11
|
+
deprecated_in: deprecated_in,
|
12
|
+
sunset_at: sunset_at
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#to_json' do
|
17
|
+
subject { deprecation.to_json }
|
18
|
+
|
19
|
+
it { is_expected.to eq({ info: nil, deprecated_in: nil, sunset_at: nil }) }
|
20
|
+
|
21
|
+
context 'when attributes are given' do
|
22
|
+
let(:info) { 'info' }
|
23
|
+
let(:deprecated_in) { '2.3' }
|
24
|
+
let(:sunset_at) { '3.0' }
|
25
|
+
|
26
|
+
it 'returns the correct attributes' do
|
27
|
+
expect(subject).to eq({ info: info, deprecated_in: deprecated_in, sunset_at: sunset_at })
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|