brainstem 1.4.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +77 -0
- data/README.md +119 -0
- data/docs/api_doc_generator.markdown +45 -4
- data/docs/brainstem_executable.markdown +1 -1
- data/docs/oas_2_docgen.png +0 -0
- data/docs/oas_2_docgen_ascii.txt +78 -0
- data/lib/brainstem/api_docs.rb +23 -9
- data/lib/brainstem/api_docs/abstract_collection.rb +0 -13
- data/lib/brainstem/api_docs/atlas.rb +0 -14
- data/lib/brainstem/api_docs/builder.rb +0 -14
- data/lib/brainstem/api_docs/controller.rb +7 -16
- data/lib/brainstem/api_docs/controller_collection.rb +0 -3
- data/lib/brainstem/api_docs/endpoint.rb +73 -19
- data/lib/brainstem/api_docs/endpoint_collection.rb +0 -7
- data/lib/brainstem/api_docs/formatters/abstract_formatter.rb +0 -2
- data/lib/brainstem/api_docs/formatters/markdown/controller_formatter.rb +1 -9
- data/lib/brainstem/api_docs/formatters/markdown/endpoint_collection_formatter.rb +1 -9
- data/lib/brainstem/api_docs/formatters/markdown/endpoint_formatter.rb +39 -24
- data/lib/brainstem/api_docs/formatters/markdown/helper.rb +0 -13
- data/lib/brainstem/api_docs/formatters/markdown/presenter_formatter.rb +22 -35
- data/lib/brainstem/api_docs/formatters/open_api_specification/helper.rb +66 -0
- data/lib/brainstem/api_docs/formatters/open_api_specification/version_2/controller_formatter.rb +57 -0
- data/lib/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint/param_definitions_formatter.rb +311 -0
- data/lib/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint/response_definitions_formatter.rb +197 -0
- data/lib/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint_collection_formatter.rb +60 -0
- data/lib/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint_formatter.rb +162 -0
- data/lib/brainstem/api_docs/formatters/open_api_specification/version_2/info_formatter.rb +126 -0
- data/lib/brainstem/api_docs/formatters/open_api_specification/version_2/presenter_formatter.rb +132 -0
- data/lib/brainstem/api_docs/formatters/open_api_specification/version_2/security_definitions_formatter.rb +99 -0
- data/lib/brainstem/api_docs/formatters/open_api_specification/version_2/tags_formatter.rb +123 -0
- data/lib/brainstem/api_docs/introspectors/abstract_introspector.rb +0 -7
- data/lib/brainstem/api_docs/introspectors/rails_introspector.rb +1 -20
- data/lib/brainstem/api_docs/presenter.rb +21 -27
- data/lib/brainstem/api_docs/presenter_collection.rb +1 -11
- data/lib/brainstem/api_docs/resolver.rb +1 -8
- data/lib/brainstem/api_docs/sinks/abstract_sink.rb +0 -4
- data/lib/brainstem/api_docs/sinks/controller_presenter_multifile_sink.rb +0 -9
- data/lib/brainstem/api_docs/sinks/open_api_specification_sink.rb +234 -0
- data/lib/brainstem/api_docs/sinks/stdout_sink.rb +0 -5
- data/lib/brainstem/cli.rb +0 -13
- data/lib/brainstem/cli/abstract_command.rb +0 -7
- data/lib/brainstem/cli/generate_api_docs_command.rb +48 -24
- data/lib/brainstem/concerns/controller_dsl.rb +288 -145
- data/lib/brainstem/concerns/formattable.rb +0 -5
- data/lib/brainstem/concerns/optional.rb +0 -1
- data/lib/brainstem/concerns/presenter_dsl.rb +2 -21
- data/lib/brainstem/dsl/configuration.rb +0 -11
- data/lib/brainstem/presenter.rb +0 -4
- data/lib/brainstem/version.rb +1 -1
- data/spec/brainstem/api_docs/abstract_collection_spec.rb +0 -11
- data/spec/brainstem/api_docs/atlas_spec.rb +0 -6
- data/spec/brainstem/api_docs/builder_spec.rb +0 -4
- data/spec/brainstem/api_docs/controller_collection_spec.rb +0 -2
- data/spec/brainstem/api_docs/controller_spec.rb +29 -18
- data/spec/brainstem/api_docs/endpoint_collection_spec.rb +0 -6
- data/spec/brainstem/api_docs/endpoint_spec.rb +343 -13
- data/spec/brainstem/api_docs/formatters/abstract_formatter_spec.rb +0 -2
- data/spec/brainstem/api_docs/formatters/markdown/controller_formatter_spec.rb +0 -1
- data/spec/brainstem/api_docs/formatters/markdown/endpoint_collection_formatter_spec.rb +0 -5
- data/spec/brainstem/api_docs/formatters/markdown/endpoint_formatter_spec.rb +94 -8
- data/spec/brainstem/api_docs/formatters/markdown/helper_spec.rb +0 -8
- data/spec/brainstem/api_docs/formatters/markdown/presenter_formatter_spec.rb +0 -7
- data/spec/brainstem/api_docs/formatters/open_api_specification/helper_spec.rb +210 -0
- data/spec/brainstem/api_docs/formatters/open_api_specification/version_2/controller_formatter_spec.rb +81 -0
- data/spec/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint/param_definitions_formatter_spec.rb +672 -0
- data/spec/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint/response_definitions_formatter_spec.rb +335 -0
- data/spec/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint_collection_formatter_spec.rb +59 -0
- data/spec/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint_formatter_spec.rb +308 -0
- data/spec/brainstem/api_docs/formatters/open_api_specification/version_2/info_formatter_spec.rb +89 -0
- data/spec/brainstem/api_docs/formatters/open_api_specification/version_2/presenter_formatter_spec.rb +430 -0
- data/spec/brainstem/api_docs/formatters/open_api_specification/version_2/security_definitions_formatter_spec.rb +190 -0
- data/spec/brainstem/api_docs/formatters/open_api_specification/version_2/tags_formatter_spec.rb +217 -0
- data/spec/brainstem/api_docs/introspectors/abstract_introspector_spec.rb +0 -2
- data/spec/brainstem/api_docs/introspectors/rails_introspector_spec.rb +0 -2
- data/spec/brainstem/api_docs/presenter_collection_spec.rb +0 -2
- data/spec/brainstem/api_docs/presenter_spec.rb +58 -18
- data/spec/brainstem/api_docs/resolver_spec.rb +0 -1
- data/spec/brainstem/api_docs/sinks/controller_presenter_multifile_sink_spec.rb +0 -2
- data/spec/brainstem/api_docs/sinks/open_api_specification_sink_spec.rb +371 -0
- data/spec/brainstem/api_docs_spec.rb +2 -0
- data/spec/brainstem/cli/abstract_command_spec.rb +0 -4
- data/spec/brainstem/cli/generate_api_docs_command_spec.rb +53 -2
- data/spec/brainstem/concerns/controller_dsl_spec.rb +430 -64
- data/spec/brainstem/concerns/presenter_dsl_spec.rb +0 -20
- data/spec/brainstem/preloader_spec.rb +0 -7
- data/spec/brainstem/presenter_spec.rb +0 -1
- data/spec/dummy/rails.rb +0 -1
- data/spec/spec_helpers/db.rb +0 -1
- metadata +37 -2
@@ -608,26 +608,6 @@ describe Brainstem::Concerns::PresenterDSL do
|
|
608
608
|
expect(foo[:item_type]).to eq("string")
|
609
609
|
end
|
610
610
|
end
|
611
|
-
|
612
|
-
|
613
|
-
context "when type is not specified" do
|
614
|
-
before do
|
615
|
-
mock(presenter_class).deprecated_type_warning
|
616
|
-
end
|
617
|
-
|
618
|
-
it "adds a deprecation warning and creates an entry in the filters configuration" do
|
619
|
-
my_proc = Proc.new { 1 }
|
620
|
-
presenter_class.filter(:foo, :default => true, &my_proc)
|
621
|
-
|
622
|
-
expect(foo).to eq({ "default" => true, "value" => my_proc, "type" => "string" })
|
623
|
-
end
|
624
|
-
|
625
|
-
it "adds a deprecation warning and records the info option" do
|
626
|
-
presenter_class.filter(:foo, :info => "This is documented.")
|
627
|
-
expect(foo[:info]).to eq "This is documented."
|
628
|
-
expect(foo[:type]).to eq "string"
|
629
|
-
end
|
630
|
-
end
|
631
611
|
end
|
632
612
|
|
633
613
|
describe ".search" do
|
@@ -8,7 +8,6 @@ describe Brainstem::Preloader do
|
|
8
8
|
let(:args) { [ models, preloads, reflections ] }
|
9
9
|
let!(:preloader) { Brainstem::Preloader.new(*args) }
|
10
10
|
|
11
|
-
|
12
11
|
describe ".preload" do
|
13
12
|
it "creates a new instance, passing args and calls it" do
|
14
13
|
preloader = mock(Object.new).call
|
@@ -17,7 +16,6 @@ describe Brainstem::Preloader do
|
|
17
16
|
end
|
18
17
|
end
|
19
18
|
|
20
|
-
|
21
19
|
describe "#call" do
|
22
20
|
it "cleans" do
|
23
21
|
mock(preloader).clean!
|
@@ -30,7 +28,6 @@ describe Brainstem::Preloader do
|
|
30
28
|
end
|
31
29
|
end
|
32
30
|
|
33
|
-
|
34
31
|
describe "#clean!" do
|
35
32
|
it "dedupes the associations" do
|
36
33
|
mock(preloader).dedupe!
|
@@ -43,7 +40,6 @@ describe Brainstem::Preloader do
|
|
43
40
|
end
|
44
41
|
end
|
45
42
|
|
46
|
-
|
47
43
|
describe "#dedupe!" do
|
48
44
|
before do
|
49
45
|
preloader.send(:dedupe!)
|
@@ -67,7 +63,6 @@ describe Brainstem::Preloader do
|
|
67
63
|
end
|
68
64
|
end
|
69
65
|
|
70
|
-
|
71
66
|
describe "combination" do
|
72
67
|
let(:preloads) { [
|
73
68
|
{ :workspaces => :other_things },
|
@@ -87,7 +82,6 @@ describe Brainstem::Preloader do
|
|
87
82
|
end
|
88
83
|
end
|
89
84
|
|
90
|
-
|
91
85
|
describe "#remove_unreflected_preloads!" do
|
92
86
|
before do
|
93
87
|
stub(preloader).dedupe!
|
@@ -116,7 +110,6 @@ describe Brainstem::Preloader do
|
|
116
110
|
end
|
117
111
|
end
|
118
112
|
|
119
|
-
|
120
113
|
describe "#preload!" do
|
121
114
|
let(:preload_method) { Object.new }
|
122
115
|
let(:valid_preloads) { { users: [], posts: [] } }
|
@@ -840,7 +840,6 @@ describe Brainstem::Presenter do
|
|
840
840
|
end
|
841
841
|
end
|
842
842
|
|
843
|
-
|
844
843
|
it "preloads associations when they are full model-level associations" do
|
845
844
|
preloader_should_receive("tasks" => [], "user" => [])
|
846
845
|
presenter.group_present(Workspace.order('id desc'), %w[tasks user lead_user tasks_with_lambda])
|
data/spec/dummy/rails.rb
CHANGED
data/spec/spec_helpers/db.rb
CHANGED
@@ -8,7 +8,6 @@ Workspace.create!(:id => 4, :user_id => 1, :title => "bob workspace 4", :descrip
|
|
8
8
|
Workspace.create!(:id => 5, :user_id => 2, :title => "jane workspace 1", :description => "c")
|
9
9
|
Workspace.create!(:id => 6, :user_id => 2, :title => "jane workspace 2", :description => "3")
|
10
10
|
|
11
|
-
|
12
11
|
Cheese.create!(id: 1, user_id: 1, flavor: 'colby jack' )
|
13
12
|
Cheese.create!(id: 2, user_id: 1, flavor: 'swiss' )
|
14
13
|
Cheese.create!(id: 3, user_id: 1, flavor: 'cheese curds' )
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brainstem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mavenlink
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -216,6 +216,8 @@ files:
|
|
216
216
|
- docs/docgen_ascii.txt
|
217
217
|
- docs/executable.png
|
218
218
|
- docs/executable_ascii.txt
|
219
|
+
- docs/oas_2_docgen.png
|
220
|
+
- docs/oas_2_docgen_ascii.txt
|
219
221
|
- lib/brainstem.rb
|
220
222
|
- lib/brainstem/api_docs.rb
|
221
223
|
- lib/brainstem/api_docs/abstract_collection.rb
|
@@ -232,6 +234,16 @@ files:
|
|
232
234
|
- lib/brainstem/api_docs/formatters/markdown/endpoint_formatter.rb
|
233
235
|
- lib/brainstem/api_docs/formatters/markdown/helper.rb
|
234
236
|
- lib/brainstem/api_docs/formatters/markdown/presenter_formatter.rb
|
237
|
+
- lib/brainstem/api_docs/formatters/open_api_specification/helper.rb
|
238
|
+
- lib/brainstem/api_docs/formatters/open_api_specification/version_2/controller_formatter.rb
|
239
|
+
- lib/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint/param_definitions_formatter.rb
|
240
|
+
- lib/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint/response_definitions_formatter.rb
|
241
|
+
- lib/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint_collection_formatter.rb
|
242
|
+
- lib/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint_formatter.rb
|
243
|
+
- lib/brainstem/api_docs/formatters/open_api_specification/version_2/info_formatter.rb
|
244
|
+
- lib/brainstem/api_docs/formatters/open_api_specification/version_2/presenter_formatter.rb
|
245
|
+
- lib/brainstem/api_docs/formatters/open_api_specification/version_2/security_definitions_formatter.rb
|
246
|
+
- lib/brainstem/api_docs/formatters/open_api_specification/version_2/tags_formatter.rb
|
235
247
|
- lib/brainstem/api_docs/introspectors/abstract_introspector.rb
|
236
248
|
- lib/brainstem/api_docs/introspectors/rails_introspector.rb
|
237
249
|
- lib/brainstem/api_docs/presenter.rb
|
@@ -239,6 +251,7 @@ files:
|
|
239
251
|
- lib/brainstem/api_docs/resolver.rb
|
240
252
|
- lib/brainstem/api_docs/sinks/abstract_sink.rb
|
241
253
|
- lib/brainstem/api_docs/sinks/controller_presenter_multifile_sink.rb
|
254
|
+
- lib/brainstem/api_docs/sinks/open_api_specification_sink.rb
|
242
255
|
- lib/brainstem/api_docs/sinks/stdout_sink.rb
|
243
256
|
- lib/brainstem/cli.rb
|
244
257
|
- lib/brainstem/cli/abstract_command.rb
|
@@ -289,6 +302,16 @@ files:
|
|
289
302
|
- spec/brainstem/api_docs/formatters/markdown/endpoint_formatter_spec.rb
|
290
303
|
- spec/brainstem/api_docs/formatters/markdown/helper_spec.rb
|
291
304
|
- spec/brainstem/api_docs/formatters/markdown/presenter_formatter_spec.rb
|
305
|
+
- spec/brainstem/api_docs/formatters/open_api_specification/helper_spec.rb
|
306
|
+
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/controller_formatter_spec.rb
|
307
|
+
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint/param_definitions_formatter_spec.rb
|
308
|
+
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint/response_definitions_formatter_spec.rb
|
309
|
+
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint_collection_formatter_spec.rb
|
310
|
+
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint_formatter_spec.rb
|
311
|
+
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/info_formatter_spec.rb
|
312
|
+
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/presenter_formatter_spec.rb
|
313
|
+
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/security_definitions_formatter_spec.rb
|
314
|
+
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/tags_formatter_spec.rb
|
292
315
|
- spec/brainstem/api_docs/introspectors/abstract_introspector_spec.rb
|
293
316
|
- spec/brainstem/api_docs/introspectors/rails_introspector_spec.rb
|
294
317
|
- spec/brainstem/api_docs/presenter_collection_spec.rb
|
@@ -296,6 +319,7 @@ files:
|
|
296
319
|
- spec/brainstem/api_docs/resolver_spec.rb
|
297
320
|
- spec/brainstem/api_docs/sinks/abstract_sink_spec.rb
|
298
321
|
- spec/brainstem/api_docs/sinks/controller_presenter_multifile_sink_spec.rb
|
322
|
+
- spec/brainstem/api_docs/sinks/open_api_specification_sink_spec.rb
|
299
323
|
- spec/brainstem/api_docs/sinks/stdout_sink_spec.rb
|
300
324
|
- spec/brainstem/api_docs_spec.rb
|
301
325
|
- spec/brainstem/cli/abstract_command_spec.rb
|
@@ -370,6 +394,16 @@ test_files:
|
|
370
394
|
- spec/brainstem/api_docs/formatters/markdown/endpoint_formatter_spec.rb
|
371
395
|
- spec/brainstem/api_docs/formatters/markdown/helper_spec.rb
|
372
396
|
- spec/brainstem/api_docs/formatters/markdown/presenter_formatter_spec.rb
|
397
|
+
- spec/brainstem/api_docs/formatters/open_api_specification/helper_spec.rb
|
398
|
+
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/controller_formatter_spec.rb
|
399
|
+
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint/param_definitions_formatter_spec.rb
|
400
|
+
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint/response_definitions_formatter_spec.rb
|
401
|
+
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint_collection_formatter_spec.rb
|
402
|
+
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/endpoint_formatter_spec.rb
|
403
|
+
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/info_formatter_spec.rb
|
404
|
+
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/presenter_formatter_spec.rb
|
405
|
+
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/security_definitions_formatter_spec.rb
|
406
|
+
- spec/brainstem/api_docs/formatters/open_api_specification/version_2/tags_formatter_spec.rb
|
373
407
|
- spec/brainstem/api_docs/introspectors/abstract_introspector_spec.rb
|
374
408
|
- spec/brainstem/api_docs/introspectors/rails_introspector_spec.rb
|
375
409
|
- spec/brainstem/api_docs/presenter_collection_spec.rb
|
@@ -377,6 +411,7 @@ test_files:
|
|
377
411
|
- spec/brainstem/api_docs/resolver_spec.rb
|
378
412
|
- spec/brainstem/api_docs/sinks/abstract_sink_spec.rb
|
379
413
|
- spec/brainstem/api_docs/sinks/controller_presenter_multifile_sink_spec.rb
|
414
|
+
- spec/brainstem/api_docs/sinks/open_api_specification_sink_spec.rb
|
380
415
|
- spec/brainstem/api_docs/sinks/stdout_sink_spec.rb
|
381
416
|
- spec/brainstem/api_docs_spec.rb
|
382
417
|
- spec/brainstem/cli/abstract_command_spec.rb
|