apipie-rails 0.9.1 → 0.9.3
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 +81 -0
- data/.rubocop_todo.yml +815 -351
- data/CHANGELOG.md +17 -0
- data/README.rst +20 -0
- data/apipie-rails.gemspec +4 -0
- data/app/controllers/apipie/apipies_controller.rb +5 -6
- 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 +10 -12
- data/lib/apipie/configuration.rb +24 -13
- data/lib/apipie/dsl_definition.rb +13 -12
- data/lib/apipie/error_description.rb +2 -2
- data/lib/apipie/extractor/recorder.rb +1 -1
- data/lib/apipie/extractor/writer.rb +11 -11
- data/lib/apipie/extractor.rb +1 -1
- data/lib/apipie/generator/swagger/context.rb +27 -0
- data/lib/apipie/generator/swagger/operation_id.rb +51 -0
- data/lib/apipie/generator/swagger/param_description/builder.rb +105 -0
- data/lib/apipie/generator/swagger/param_description/composite.rb +111 -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/type.rb +108 -0
- data/lib/apipie/generator/swagger/param_description.rb +18 -0
- data/lib/apipie/generator/swagger/type_extractor.rb +2 -2
- data/lib/apipie/markup.rb +9 -8
- data/lib/apipie/method_description.rb +4 -5
- data/lib/apipie/param_description/deprecation.rb +24 -0
- data/lib/apipie/param_description.rb +45 -18
- data/lib/apipie/resource_description.rb +4 -4
- data/lib/apipie/response_description.rb +2 -2
- data/lib/apipie/response_description_adapter.rb +7 -5
- data/lib/apipie/swagger_generator.rb +54 -202
- data/lib/apipie/validator.rb +8 -9
- data/lib/apipie/version.rb +1 -1
- data/lib/apipie-rails.rb +10 -0
- data/lib/tasks/apipie.rake +6 -6
- data/spec/controllers/users_controller_spec.rb +11 -3
- data/spec/{controllers → lib/apipie}/apipies_controller_spec.rb +2 -2
- data/spec/lib/{application_spec.rb → apipie/application_spec.rb} +6 -3
- data/spec/lib/apipie/configuration_spec.rb +23 -0
- data/spec/lib/apipie/extractor/recorder_spec.rb +40 -0
- data/spec/lib/apipie/generator/swagger/context_spec.rb +35 -0
- data/spec/lib/apipie/generator/swagger/operation_id_spec.rb +63 -0
- data/spec/lib/apipie/generator/swagger/param_description/builder_spec.rb +163 -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 +178 -0
- data/spec/lib/apipie/generator/swagger/param_description_spec.rb +28 -0
- data/spec/lib/{generator → apipie/generator}/swagger/type_extractor_spec.rb +38 -18
- data/spec/lib/{method_description_spec.rb → apipie/method_description_spec.rb} +4 -4
- 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/{param_group_spec.rb → apipie/param_group_spec.rb} +5 -5
- data/spec/lib/{resource_description_spec.rb → apipie/resource_description_spec.rb} +2 -2
- data/spec/lib/swagger/swagger_dsl_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +85 -19
- /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/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/{validator_spec.rb → apipie/validator_spec.rb} +0 -0
- /data/spec/{controllers → test_engine}/memes_controller_spec.rb +0 -0
@@ -0,0 +1,178 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Apipie::Generator::Swagger::ParamDescription::Type do
|
4
|
+
let(:validator_options) { {} }
|
5
|
+
let(:param_description_options) { {}.merge(validator_options) }
|
6
|
+
let(:with_null) { false }
|
7
|
+
let(:http_method) { :GET }
|
8
|
+
let(:path) { '/api' }
|
9
|
+
let(:validator) { String }
|
10
|
+
|
11
|
+
let(:base_dsl_data) do
|
12
|
+
{
|
13
|
+
:api => false,
|
14
|
+
:api_args => [],
|
15
|
+
:api_from_routes => nil,
|
16
|
+
:errors => [],
|
17
|
+
:tag_list => [],
|
18
|
+
:returns => {},
|
19
|
+
:params => [],
|
20
|
+
:headers => [],
|
21
|
+
:resource_id => nil,
|
22
|
+
:short_description => nil,
|
23
|
+
:description => nil,
|
24
|
+
:examples => [],
|
25
|
+
:see => [],
|
26
|
+
:formats => nil,
|
27
|
+
:api_versions => [],
|
28
|
+
:meta => nil,
|
29
|
+
:show => true,
|
30
|
+
:deprecated => false
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
let(:dsl_data) do
|
35
|
+
base_dsl_data.merge({
|
36
|
+
api_args: [
|
37
|
+
[
|
38
|
+
http_method,
|
39
|
+
path,
|
40
|
+
'description',
|
41
|
+
{ deprecated: true }
|
42
|
+
]
|
43
|
+
]
|
44
|
+
})
|
45
|
+
end
|
46
|
+
|
47
|
+
let(:resource_desc) do
|
48
|
+
Apipie::ResourceDescription.new(UsersController, 'dummy')
|
49
|
+
end
|
50
|
+
|
51
|
+
let(:method_desc) do
|
52
|
+
Apipie::MethodDescription.new(:show, resource_desc, dsl_data)
|
53
|
+
end
|
54
|
+
|
55
|
+
let(:param_description_name) { 'some_param' }
|
56
|
+
|
57
|
+
let(:param_description) do
|
58
|
+
Apipie::ParamDescription.new(
|
59
|
+
method_desc,
|
60
|
+
param_description_name,
|
61
|
+
validator,
|
62
|
+
param_description_options
|
63
|
+
)
|
64
|
+
end
|
65
|
+
|
66
|
+
let(:type_definition) do
|
67
|
+
described_class.
|
68
|
+
new(param_description, with_null: with_null, controller_method: 'index').
|
69
|
+
to_hash
|
70
|
+
end
|
71
|
+
|
72
|
+
describe 'type' do
|
73
|
+
subject { type_definition[:type] }
|
74
|
+
|
75
|
+
it { is_expected.to eq(validator.to_s.downcase) }
|
76
|
+
|
77
|
+
context 'when validator is enum' do
|
78
|
+
let(:validator) { ['name', 'enum'] }
|
79
|
+
|
80
|
+
it { is_expected.to eq('string') }
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'when validator is a Hash' do
|
84
|
+
let(:validator) { Hash }
|
85
|
+
|
86
|
+
it { is_expected.to eq('object') }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe 'items' do
|
91
|
+
let(:items) { type_definition[:items] }
|
92
|
+
|
93
|
+
subject { items }
|
94
|
+
|
95
|
+
context 'when has validator is Array' do
|
96
|
+
let(:validator) { Array }
|
97
|
+
|
98
|
+
it { is_expected.to eq({ type: 'string' }) }
|
99
|
+
|
100
|
+
context 'of Hash' do
|
101
|
+
let(:validator_options) { { of: Hash } }
|
102
|
+
|
103
|
+
let(:reference) do
|
104
|
+
Apipie::Generator::Swagger::OperationId.
|
105
|
+
new(http_method: http_method, path: path, param: param_description_name).
|
106
|
+
to_s
|
107
|
+
end
|
108
|
+
|
109
|
+
it { is_expected.to eq({ type: 'string' }) }
|
110
|
+
|
111
|
+
context 'and swagger_json_input_uses_refs is set to true' do
|
112
|
+
before { Apipie.configuration.swagger_json_input_uses_refs = true }
|
113
|
+
after { Apipie.configuration.swagger_json_input_uses_refs = false }
|
114
|
+
|
115
|
+
it 'returns the reference' do
|
116
|
+
expect(subject).to eq({ '$ref' => reference })
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
describe 'enum' do
|
123
|
+
subject { items[:enum] }
|
124
|
+
|
125
|
+
it { is_expected.to be_blank }
|
126
|
+
|
127
|
+
context 'when validator is Array' do
|
128
|
+
let(:validator) { Array }
|
129
|
+
|
130
|
+
it { is_expected.to be_blank }
|
131
|
+
|
132
|
+
context 'and an array of in values is given' do
|
133
|
+
let(:enum_values) { ['enum-value-1', 'enum-value-2'] }
|
134
|
+
let(:validator_options) { { in: ['enum-value-1', 'enum-value-2'] } }
|
135
|
+
|
136
|
+
it { is_expected.to eq(enum_values) }
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
describe 'enum' do
|
144
|
+
subject { type_definition[:enum] }
|
145
|
+
|
146
|
+
context 'and an array of in values is given' do
|
147
|
+
let(:validator) { ['enum-value-1', 'enum-value-2'] }
|
148
|
+
|
149
|
+
it { is_expected.to eq(validator) }
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
describe 'additionalProperties' do
|
154
|
+
subject { type_definition[:additionalProperties] }
|
155
|
+
|
156
|
+
it { is_expected.to be_blank }
|
157
|
+
|
158
|
+
context 'when validator is a Hash' do
|
159
|
+
let(:validator) { Hash }
|
160
|
+
|
161
|
+
it { is_expected.to be_truthy }
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
describe 'warnings' do
|
166
|
+
before { Singleton.__init__(Apipie::Generator::Swagger::WarningWriter) }
|
167
|
+
|
168
|
+
subject { type_definition }
|
169
|
+
|
170
|
+
context 'when validator is a Hash' do
|
171
|
+
let(:validator) { Hash }
|
172
|
+
|
173
|
+
it 'outputs a hash without internal typespec warning' do
|
174
|
+
expect { subject }.to output(/is a generic Hash without an internal type specification/).to_stderr
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Apipie::Generator::Swagger::ParamDescription do
|
4
|
+
describe '.create_for_missing_param' do
|
5
|
+
let(:name) { 'ok' }
|
6
|
+
|
7
|
+
let(:method_description) do
|
8
|
+
Apipie.get_method_description(UsersController, :update)
|
9
|
+
end
|
10
|
+
|
11
|
+
subject do
|
12
|
+
described_class.create_for_missing_param(method_description, name)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'creates a required param description' do
|
16
|
+
expect(subject.required).to eq(true)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'has the correct name' do
|
20
|
+
expect(subject.name).to eq(name)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'has been created from path' do
|
24
|
+
expect(subject.options[:added_from_path]).to eq(true)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
@@ -1,15 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Apipie::Generator::Swagger::TypeExtractor do
|
4
|
-
let(:validator) {}
|
5
4
|
let(:extractor) { described_class.new(validator) }
|
6
5
|
|
7
|
-
|
6
|
+
shared_examples 'extractable method' do
|
8
7
|
let(:warnings) { {} }
|
9
|
-
|
10
|
-
before { Apipie.configuration.swagger_suppress_warnings = false }
|
11
|
-
|
12
|
-
subject { extractor.extract_with_warnings(warnings) }
|
8
|
+
let(:validator) {}
|
13
9
|
|
14
10
|
it { is_expected.to eq(Apipie::Generator::Swagger::TypeExtractor::TYPES[:string]) }
|
15
11
|
|
@@ -38,21 +34,45 @@ describe Apipie::Generator::Swagger::TypeExtractor do
|
|
38
34
|
it 'returns a boolean type' do
|
39
35
|
expect(subject).to eq(Apipie::Generator::Swagger::TypeExtractor::TYPES[:boolean])
|
40
36
|
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#extract' do
|
43
|
+
subject { extractor.extract }
|
41
44
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
45
|
+
it_behaves_like 'extractable method'
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#extarct_with_warnings' do
|
49
|
+
before { Apipie.configuration.swagger_suppress_warnings = false }
|
50
|
+
|
51
|
+
subject { extractor.extract_with_warnings(warnings) }
|
52
|
+
|
53
|
+
it_behaves_like 'extractable method'
|
54
|
+
|
55
|
+
context "when enum validator is used" do
|
56
|
+
context "and has `true`, `false` as values" do
|
57
|
+
let(:enum_values) { [true, false] }
|
58
|
+
|
59
|
+
let(:validator) do
|
60
|
+
Apipie::ResponseDescriptionAdapter::PropDesc::Validator.new('some-type', enum_values)
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'and a boolean warning is passed' do
|
64
|
+
let(:boolean_warning) do
|
65
|
+
Apipie::Generator::Swagger::Warning.for_code(
|
66
|
+
Apipie::Generator::Swagger::Warning::INFERRING_BOOLEAN_CODE,
|
67
|
+
'SampleController#action',
|
68
|
+
{ parameter: 'some-param' }
|
69
|
+
)
|
70
|
+
end
|
50
71
|
|
51
|
-
|
72
|
+
let(:warnings) { { boolean: boolean_warning } }
|
52
73
|
|
53
|
-
|
54
|
-
|
55
|
-
end
|
74
|
+
it 'outputs the warning' do
|
75
|
+
expect { subject }.to output(boolean_warning.warning_message).to_stderr
|
56
76
|
end
|
57
77
|
end
|
58
78
|
end
|
@@ -58,12 +58,12 @@ describe Apipie::MethodDescription do
|
|
58
58
|
|
59
59
|
it "should be ordered" do
|
60
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'])
|
61
|
+
expect(@method.to_json[:params].map { |h| h[:name] }).to eq(['a', 'b', 'c'])
|
62
62
|
end
|
63
63
|
|
64
64
|
it "should be still ordered" do
|
65
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'])
|
66
|
+
expect(@method.to_json[:params].map { |h| h[:name] }).to eq(['a', 'b', 'c'])
|
67
67
|
end
|
68
68
|
|
69
69
|
end
|
@@ -80,7 +80,7 @@ describe Apipie::MethodDescription do
|
|
80
80
|
|
81
81
|
it "should ignore response-only parameters" do
|
82
82
|
expect(@method.params.keys).to eq([:a, :c])
|
83
|
-
expect(@method.to_json[:params].map{|h| h[:name]}).to eq(['a', 'c'])
|
83
|
+
expect(@method.to_json[:params].map { |h| h[:name] }).to eq(['a', 'c'])
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
@@ -90,7 +90,7 @@ describe Apipie::MethodDescription do
|
|
90
90
|
@resource = Apipie::ResourceDescription.new(ApplicationController, "dummy")
|
91
91
|
dsl_data[:returns] = { 200 => [{:param_group => 'pet', :array_of => 'pet'}, nil, nil] }
|
92
92
|
|
93
|
-
expect {Apipie::MethodDescription.new(:a, @resource, dsl_data)}.to raise_error(Apipie::ReturnsMultipleDefinitionError)
|
93
|
+
expect { Apipie::MethodDescription.new(:a, @resource, dsl_data) }.to raise_error(Apipie::ReturnsMultipleDefinitionError)
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
@@ -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
|
@@ -188,7 +188,9 @@ describe Apipie::ParamDescription do
|
|
188
188
|
end
|
189
189
|
context 'when allow_blank is specified as false' do
|
190
190
|
it "should throw an exception when passed an empty value" do
|
191
|
-
expect
|
191
|
+
expect do
|
192
|
+
Apipie::ParamDescription.new(method_desc, :param, String, allow_blank: false).validate('')
|
193
|
+
end.to raise_error(Apipie::ParamInvalid)
|
192
194
|
end
|
193
195
|
end
|
194
196
|
context 'when allow_blank is not specified' do
|
@@ -428,4 +430,82 @@ describe Apipie::ParamDescription do
|
|
428
430
|
end
|
429
431
|
end
|
430
432
|
|
433
|
+
describe '#deprecated?' do
|
434
|
+
subject do
|
435
|
+
Apipie::ParamDescription.new(method_desc, :param, Integer, options)
|
436
|
+
end
|
437
|
+
|
438
|
+
let(:options) { {} }
|
439
|
+
|
440
|
+
it { is_expected.not_to be_deprecated }
|
441
|
+
|
442
|
+
context 'when deprecated option is passed' do
|
443
|
+
context 'and is true' do
|
444
|
+
let(:options) { { deprecated: true } }
|
445
|
+
|
446
|
+
it { is_expected.to be_deprecated }
|
447
|
+
end
|
448
|
+
|
449
|
+
context 'and is false' do
|
450
|
+
let(:options) { { deprecated: false } }
|
451
|
+
|
452
|
+
it { is_expected.not_to be_deprecated }
|
453
|
+
end
|
454
|
+
|
455
|
+
context 'and is a string' do
|
456
|
+
let(:options) { { deprecated: 'Some description' } }
|
457
|
+
|
458
|
+
it { is_expected.to be_deprecated }
|
459
|
+
end
|
460
|
+
|
461
|
+
context 'and deprecation options are given' do
|
462
|
+
let(:options) do
|
463
|
+
{ deprecated: { in: '2.3', info: 'Something', sunset: '3.0' } }
|
464
|
+
end
|
465
|
+
|
466
|
+
it { is_expected.to be_deprecated }
|
467
|
+
end
|
468
|
+
end
|
469
|
+
end
|
470
|
+
|
471
|
+
describe '#deprecation' do
|
472
|
+
subject { param_description.deprecation }
|
473
|
+
|
474
|
+
let(:options) { {} }
|
475
|
+
|
476
|
+
let(:param_description) do
|
477
|
+
Apipie::ParamDescription.new(method_desc, :param, Integer, options)
|
478
|
+
end
|
479
|
+
|
480
|
+
it { is_expected.to be_blank }
|
481
|
+
|
482
|
+
context 'when deprecated option is passed' do
|
483
|
+
context 'and is true' do
|
484
|
+
let(:options) { { deprecated: true } }
|
485
|
+
|
486
|
+
it { is_expected.to be_blank }
|
487
|
+
end
|
488
|
+
|
489
|
+
context 'and is false' do
|
490
|
+
let(:options) { { deprecated: false } }
|
491
|
+
|
492
|
+
it { is_expected.to be_blank }
|
493
|
+
end
|
494
|
+
|
495
|
+
context 'and is a string' do
|
496
|
+
let(:options) { { deprecated: 'Some description' } }
|
497
|
+
|
498
|
+
it { is_expected.to be_an_instance_of(Apipie::ParamDescription::Deprecation) }
|
499
|
+
end
|
500
|
+
|
501
|
+
context 'and deprecation options are given' do
|
502
|
+
let(:options) do
|
503
|
+
{ deprecated: { in: '2.3', info: 'Something', sunset: '3.0' } }
|
504
|
+
end
|
505
|
+
|
506
|
+
it { is_expected.to be_an_instance_of(Apipie::ParamDescription::Deprecation) }
|
507
|
+
end
|
508
|
+
end
|
509
|
+
end
|
510
|
+
|
431
511
|
end
|
@@ -43,17 +43,17 @@ describe "param groups" do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should replace parameter name in a group when it comes from concern" do
|
46
|
-
expect(Apipie["overridden_concern_resources#update"].params.
|
46
|
+
expect(Apipie["overridden_concern_resources#update"].params.key?(:user)).to eq(true)
|
47
47
|
end
|
48
48
|
|
49
49
|
it "shouldn't replace parameter name in a group redefined in the controller" do
|
50
|
-
expect(Apipie["overridden_concern_resources#create"].params.
|
51
|
-
expect(Apipie["overridden_concern_resources#create"].params.
|
50
|
+
expect(Apipie["overridden_concern_resources#create"].params.key?(:concern)).to eq(true)
|
51
|
+
expect(Apipie["overridden_concern_resources#create"].params.key?(:user)).to eq(false)
|
52
52
|
end
|
53
53
|
|
54
54
|
it "shouldn't replace name of a parameter defined in the controller" do
|
55
|
-
expect(Apipie["overridden_concern_resources#custom"].params.
|
56
|
-
expect(Apipie["overridden_concern_resources#custom"].params.
|
55
|
+
expect(Apipie["overridden_concern_resources#custom"].params.key?(:concern)).to eq(true)
|
56
|
+
expect(Apipie["overridden_concern_resources#custom"].params.key?(:user)).to eq(false)
|
57
57
|
end
|
58
58
|
|
59
59
|
end
|
@@ -36,12 +36,12 @@ describe Apipie::ResourceDescription do
|
|
36
36
|
|
37
37
|
it "should be ordered" do
|
38
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'])
|
39
|
+
expect(@resource.to_json[:methods].map { |h| h[:name] }).to eq(['a', 'b', 'c'])
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should be still ordered" do
|
43
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'])
|
44
|
+
expect(@resource.to_json[:methods].map { |h| h[:name] }).to eq(['a', 'b', 'c'])
|
45
45
|
end
|
46
46
|
|
47
47
|
end
|
@@ -37,7 +37,7 @@ describe "Swagger Responses" do
|
|
37
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
|
|
data/spec/spec_helper.rb
CHANGED
@@ -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', __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
|
|
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.3
|
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-03-08 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
|
@@ -235,6 +279,15 @@ files:
|
|
235
279
|
- lib/apipie/extractor/recorder.rb
|
236
280
|
- lib/apipie/extractor/writer.rb
|
237
281
|
- lib/apipie/generator/generator.rb
|
282
|
+
- lib/apipie/generator/swagger/context.rb
|
283
|
+
- lib/apipie/generator/swagger/operation_id.rb
|
284
|
+
- lib/apipie/generator/swagger/param_description.rb
|
285
|
+
- lib/apipie/generator/swagger/param_description/builder.rb
|
286
|
+
- lib/apipie/generator/swagger/param_description/composite.rb
|
287
|
+
- lib/apipie/generator/swagger/param_description/description.rb
|
288
|
+
- lib/apipie/generator/swagger/param_description/in.rb
|
289
|
+
- lib/apipie/generator/swagger/param_description/name.rb
|
290
|
+
- lib/apipie/generator/swagger/param_description/type.rb
|
238
291
|
- lib/apipie/generator/swagger/swagger.rb
|
239
292
|
- lib/apipie/generator/swagger/type.rb
|
240
293
|
- lib/apipie/generator/swagger/type_extractor.rb
|
@@ -247,6 +300,7 @@ files:
|
|
247
300
|
- lib/apipie/method_description/apis_service.rb
|
248
301
|
- lib/apipie/middleware/checksum_in_headers.rb
|
249
302
|
- lib/apipie/param_description.rb
|
303
|
+
- lib/apipie/param_description/deprecation.rb
|
250
304
|
- lib/apipie/railtie.rb
|
251
305
|
- lib/apipie/resource_description.rb
|
252
306
|
- lib/apipie/response_description.rb
|
@@ -272,11 +326,10 @@ files:
|
|
272
326
|
- spec/controllers/api/v1/architectures_controller_spec.rb
|
273
327
|
- spec/controllers/api/v2/architectures_controller_spec.rb
|
274
328
|
- spec/controllers/api/v2/nested/resources_controller_spec.rb
|
275
|
-
- spec/controllers/apipies_controller_spec.rb
|
276
329
|
- spec/controllers/concerns_controller_spec.rb
|
277
330
|
- spec/controllers/extended_controller_spec.rb
|
278
331
|
- spec/controllers/included_param_group_controller_spec.rb
|
279
|
-
- spec/controllers/
|
332
|
+
- spec/controllers/pets_controller_spec.rb
|
280
333
|
- spec/controllers/users_controller_spec.rb
|
281
334
|
- spec/dummy/Rakefile
|
282
335
|
- spec/dummy/app/controllers/api/base_controller.rb
|
@@ -335,29 +388,42 @@ files:
|
|
335
388
|
- spec/dummy/public/favicon.ico
|
336
389
|
- spec/dummy/public/stylesheets/.gitkeep
|
337
390
|
- spec/dummy/script/rails
|
338
|
-
- spec/lib/
|
339
|
-
- spec/lib/
|
340
|
-
- spec/lib/
|
341
|
-
- spec/lib/extractor/
|
342
|
-
- spec/lib/
|
343
|
-
- spec/lib/
|
344
|
-
- spec/lib/
|
345
|
-
- spec/lib/
|
346
|
-
- spec/lib/
|
347
|
-
- spec/lib/
|
348
|
-
- spec/lib/
|
349
|
-
- 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/param_description/deprecation_spec.rb
|
414
|
+
- spec/lib/apipie/param_description_spec.rb
|
415
|
+
- spec/lib/apipie/param_group_spec.rb
|
416
|
+
- spec/lib/apipie/resource_description_spec.rb
|
417
|
+
- spec/lib/apipie/validator_spec.rb
|
350
418
|
- spec/lib/rake_spec.rb
|
351
|
-
- spec/lib/resource_description_spec.rb
|
352
419
|
- spec/lib/swagger/openapi_2_0_schema.json
|
353
420
|
- spec/lib/swagger/rake_swagger_spec.rb
|
354
|
-
- spec/lib/swagger/response_validation_spec.rb
|
355
421
|
- spec/lib/swagger/swagger_dsl_spec.rb
|
356
|
-
- spec/lib/validator_spec.rb
|
357
422
|
- spec/lib/validators/array_validator_spec.rb
|
358
423
|
- spec/spec_helper.rb
|
359
424
|
- spec/support/custom_bool_validator.rb
|
360
425
|
- spec/support/rake.rb
|
426
|
+
- spec/test_engine/memes_controller_spec.rb
|
361
427
|
homepage: http://github.com/Apipie/apipie-rails
|
362
428
|
licenses: []
|
363
429
|
metadata: {}
|
File without changes
|
File without changes
|
File without changes
|