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
@@ -1,98 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Apipie::MethodDescription do
|
4
|
-
|
5
|
-
let(:dsl_data) { ActionController::Base.send(:_apipie_dsl_data_init) }
|
6
|
-
|
7
|
-
describe "metadata" do
|
8
|
-
|
9
|
-
before(:each) do
|
10
|
-
@resource = Apipie::ResourceDescription.new(ApplicationController, "dummy")
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should return nil when no metadata is provided" do
|
14
|
-
method = Apipie::MethodDescription.new(:a, @resource, dsl_data)
|
15
|
-
expect(method.to_json[:metadata]).to eq(nil)
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should return the metadata" do
|
19
|
-
meta = {
|
20
|
-
:lenght => 32,
|
21
|
-
:weight => '830g'
|
22
|
-
}
|
23
|
-
method = Apipie::MethodDescription.new(:a, @resource, dsl_data.update(:meta => meta))
|
24
|
-
expect(method.to_json[:metadata]).to eq(meta)
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
describe "deprecated flag" do
|
30
|
-
before(:each) do
|
31
|
-
@resource = Apipie::ResourceDescription.new(ApplicationController, "dummy")
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should return the deprecated flag when provided" do
|
35
|
-
dsl_data[:api_args] = [[:GET, "/foo/bar", "description", {:deprecated => true}]]
|
36
|
-
method = Apipie::MethodDescription.new(:a, @resource, dsl_data)
|
37
|
-
expect(method.method_apis_to_json.first[:deprecated]).to eq(true)
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should return the deprecated flag if resource is deprecated" do
|
41
|
-
@resource.instance_variable_set("@_deprecated", true)
|
42
|
-
dsl_data[:api_args] = [[:GET, "/foo/bar", "description", {}]]
|
43
|
-
method = Apipie::MethodDescription.new(:a, @resource, dsl_data)
|
44
|
-
expect(method.method_apis_to_json.first[:deprecated]).to eq(true)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe "params descriptions" do
|
49
|
-
|
50
|
-
before(:each) do
|
51
|
-
@resource = Apipie::ResourceDescription.new(ApplicationController, "dummy")
|
52
|
-
dsl_data[:params] = [[:a, String, nil, {}, nil],
|
53
|
-
[:b, String, nil, {}, nil],
|
54
|
-
[:c, String, nil, {}, nil]]
|
55
|
-
@method = Apipie::MethodDescription.new(:a, @resource, dsl_data)
|
56
|
-
@resource.add_method_description @method
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should be ordered" do
|
60
|
-
expect(@method.params.keys).to eq([:a, :b, :c])
|
61
|
-
expect(@method.to_json[:params].map{|h| h[:name]}).to eq(['a', 'b', 'c'])
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should be still ordered" do
|
65
|
-
expect(@method.params.keys).to eq([:a, :b, :c])
|
66
|
-
expect(@method.to_json[:params].map{|h| h[:name]}).to eq(['a', 'b', 'c'])
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|
70
|
-
|
71
|
-
describe "response-only properties" do
|
72
|
-
before(:each) do
|
73
|
-
@resource = Apipie::ResourceDescription.new(ApplicationController, "dummy")
|
74
|
-
dsl_data[:params] = [[:a, String, nil, {:only_in => :request}, nil],
|
75
|
-
[:b, String, nil, {:only_in => :response}, nil],
|
76
|
-
[:c, String, nil, {}, nil]]
|
77
|
-
@method = Apipie::MethodDescription.new(:a, @resource, dsl_data)
|
78
|
-
@resource.add_method_description @method
|
79
|
-
end
|
80
|
-
|
81
|
-
it "should ignore response-only parameters" do
|
82
|
-
expect(@method.params.keys).to eq([:a, :c])
|
83
|
-
expect(@method.to_json[:params].map{|h| h[:name]}).to eq(['a', 'c'])
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
|
88
|
-
describe "'returns' properties" do
|
89
|
-
it "should raise an error if both :param_group and :array_of are specified in 'returns'" do
|
90
|
-
@resource = Apipie::ResourceDescription.new(ApplicationController, "dummy")
|
91
|
-
dsl_data[:returns] = { 200 => [{:param_group => 'pet', :array_of => 'pet'}, nil, nil] }
|
92
|
-
|
93
|
-
expect {Apipie::MethodDescription.new(:a, @resource, dsl_data)}.to raise_error(Apipie::ReturnsMultipleDefinitionError)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
|
98
|
-
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
|