swagger_docs_generator 0.2.0 → 0.3.0.pre.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/lib/swagger_docs_generator/configuration/configuration.rb +14 -5
  3. data/lib/swagger_docs_generator/configuration/configuration_info.rb +4 -0
  4. data/lib/swagger_docs_generator/generator.rb +30 -47
  5. data/lib/swagger_docs_generator/info.rb +1 -1
  6. data/lib/swagger_docs_generator/metadata/controller.rb +3 -31
  7. data/lib/swagger_docs_generator/metadata/definition.rb +19 -10
  8. data/lib/swagger_docs_generator/metadata/jsons.rb +32 -0
  9. data/lib/swagger_docs_generator/metadata/metadata.rb +11 -1
  10. data/lib/swagger_docs_generator/parser/action.rb +15 -7
  11. data/lib/swagger_docs_generator/parser/actions/parameters/body.rb +31 -0
  12. data/lib/swagger_docs_generator/parser/actions/parameters/form.rb +20 -0
  13. data/lib/swagger_docs_generator/parser/actions/parameters/header.rb +27 -0
  14. data/lib/swagger_docs_generator/parser/actions/parameters/path.rb +27 -0
  15. data/lib/swagger_docs_generator/parser/actions/parameters/query.rb +28 -0
  16. data/lib/swagger_docs_generator/parser/actions/parameters.rb +31 -57
  17. data/lib/swagger_docs_generator/parser/actions/response.rb +3 -59
  18. data/lib/swagger_docs_generator/parser/actions/schema.rb +4 -0
  19. data/lib/swagger_docs_generator/parser/controller.rb +7 -7
  20. data/lib/swagger_docs_generator/parser/definition.rb +9 -7
  21. data/lib/swagger_docs_generator/parser/model.rb +0 -3
  22. data/lib/swagger_docs_generator/parser/parser.rb +12 -11
  23. data/lib/swagger_docs_generator.rb +6 -0
  24. data/lib/tasks/swagger.rake +6 -5
  25. data/spec/spec_helper.rb +1 -0
  26. data/spec/support/examples/parameters.rb +154 -0
  27. data/spec/swagger_docs_generator/configuration/configuration_customize_spec.rb +6 -6
  28. data/spec/swagger_docs_generator/configuration/configuration_default_spec.rb +8 -3
  29. data/spec/swagger_docs_generator/parser/parameters/param_body_spec.rb +62 -0
  30. data/spec/swagger_docs_generator/parser/parameters/param_form_spec.rb +52 -0
  31. data/spec/swagger_docs_generator/parser/parameters/param_header_spec.rb +62 -0
  32. data/spec/swagger_docs_generator/parser/parameters/param_path_spec.rb +62 -0
  33. data/spec/swagger_docs_generator/parser/parameters/param_query_spec.rb +62 -0
  34. metadata +18 -9
  35. data/lib/swagger_docs_generator/metadata/path.rb +0 -24
  36. data/lib/swagger_docs_generator/metadata/tag.rb +0 -24
  37. data/spec/swagger_docs_generator/metadata/controller_spec.rb +0 -18
  38. /data/lib/swagger_docs_generator/{parser/models → models}/active_record.rb +0 -0
  39. /data/lib/swagger_docs_generator/{parser/models → models}/mongo.rb +0 -0
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe SwaggerDocsGenerator::Actions::Path, type: :parser,
6
+ name: :params_path do
7
+ let(:param_name) { nil }
8
+ let(:param_description) { nil }
9
+ let(:param_required) { nil }
10
+ let(:param_type) { nil }
11
+ let(:param) do
12
+ pname = param_name
13
+ pdescription = param_description
14
+ prequired = param_required
15
+ ptype = param_type
16
+ SwaggerDocsGenerator::Actions::Parameter.new do
17
+ path do
18
+ name pname
19
+ description pdescription
20
+ required prequired
21
+ type ptype
22
+ end
23
+ end
24
+ end
25
+
26
+ context 'when attribute complete' do
27
+ let(:param_name) { Faker::Color.color_name }
28
+ let(:param_description) { Faker::Beer.name }
29
+ let(:param_required) { Faker::Boolean.boolean }
30
+ let(:param_type) { Faker::Name.first_name }
31
+
32
+ it_behaves_like 'parameters path haves'
33
+ end
34
+
35
+ context 'when attribute is incomplete' do
36
+ it_behaves_like 'parameters path haves'
37
+ end
38
+
39
+ context 'when name attribute alone' do
40
+ let(:param_name) { Faker::Color.color_name }
41
+
42
+ it_behaves_like 'parameters path haves'
43
+ end
44
+
45
+ context 'when description attribute alone' do
46
+ let(:param_description) { Faker::Beer.name }
47
+
48
+ it_behaves_like 'parameters path haves'
49
+ end
50
+
51
+ context 'when required attribute alone' do
52
+ let(:param_required) { Faker::Boolean.boolean }
53
+
54
+ it_behaves_like 'parameters path haves'
55
+ end
56
+
57
+ context 'when type attribute alone' do
58
+ let(:param_type) { Faker::Name.first_name }
59
+
60
+ it_behaves_like 'parameters path haves'
61
+ end
62
+ end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe SwaggerDocsGenerator::Actions::Query, type: :parser,
6
+ name: :params_query do
7
+ let(:param_name) { nil }
8
+ let(:param_description) { nil }
9
+ let(:param_required) { nil }
10
+ let(:param_type) { nil }
11
+ let(:param) do
12
+ pname = param_name
13
+ pdescription = param_description
14
+ prequired = param_required
15
+ ptype = param_type
16
+ SwaggerDocsGenerator::Actions::Parameter.new do
17
+ query do
18
+ name pname
19
+ description pdescription
20
+ required prequired
21
+ type ptype
22
+ end
23
+ end
24
+ end
25
+
26
+ context 'when attribute complete' do
27
+ let(:param_name) { Faker::Color.color_name }
28
+ let(:param_description) { Faker::Beer.name }
29
+ let(:param_required) { Faker::Boolean.boolean }
30
+ let(:param_type) { Faker::Name.first_name }
31
+
32
+ it_behaves_like 'parameters query haves'
33
+ end
34
+
35
+ context 'when attribute is incomplete' do
36
+ it_behaves_like 'parameters query haves'
37
+ end
38
+
39
+ context 'when name attribute alone' do
40
+ let(:param_name) { Faker::Color.color_name }
41
+
42
+ it_behaves_like 'parameters query haves'
43
+ end
44
+
45
+ context 'when description attribute alone' do
46
+ let(:param_description) { Faker::Beer.name }
47
+
48
+ it_behaves_like 'parameters query haves'
49
+ end
50
+
51
+ context 'when required attribute alone' do
52
+ let(:param_required) { Faker::Boolean.boolean }
53
+
54
+ it_behaves_like 'parameters query haves'
55
+ end
56
+
57
+ context 'when type attribute alone' do
58
+ let(:param_type) { Faker::Name.first_name }
59
+
60
+ it_behaves_like 'parameters query haves'
61
+ end
62
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swagger_docs_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0.pre.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - VAILLANT Jeremy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-21 00:00:00.000000000 Z
11
+ date: 2017-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -253,16 +253,22 @@ files:
253
253
  - lib/swagger_docs_generator/metadata/controller.rb
254
254
  - lib/swagger_docs_generator/metadata/definition.rb
255
255
  - lib/swagger_docs_generator/metadata/info.rb
256
+ - lib/swagger_docs_generator/metadata/jsons.rb
256
257
  - lib/swagger_docs_generator/metadata/metadata.rb
257
- - lib/swagger_docs_generator/metadata/path.rb
258
- - lib/swagger_docs_generator/metadata/tag.rb
259
258
  - lib/swagger_docs_generator/methods.rb
259
+ - lib/swagger_docs_generator/models/active_record.rb
260
+ - lib/swagger_docs_generator/models/mongo.rb
260
261
  - lib/swagger_docs_generator/parser/action.rb
261
262
  - lib/swagger_docs_generator/parser/actions/actions.rb
262
263
  - lib/swagger_docs_generator/parser/actions/consumes.rb
263
264
  - lib/swagger_docs_generator/parser/actions/deprecated.rb
264
265
  - lib/swagger_docs_generator/parser/actions/description.rb
265
266
  - lib/swagger_docs_generator/parser/actions/parameters.rb
267
+ - lib/swagger_docs_generator/parser/actions/parameters/body.rb
268
+ - lib/swagger_docs_generator/parser/actions/parameters/form.rb
269
+ - lib/swagger_docs_generator/parser/actions/parameters/header.rb
270
+ - lib/swagger_docs_generator/parser/actions/parameters/path.rb
271
+ - lib/swagger_docs_generator/parser/actions/parameters/query.rb
266
272
  - lib/swagger_docs_generator/parser/actions/produces.rb
267
273
  - lib/swagger_docs_generator/parser/actions/response.rb
268
274
  - lib/swagger_docs_generator/parser/actions/schema.rb
@@ -271,8 +277,6 @@ files:
271
277
  - lib/swagger_docs_generator/parser/controller.rb
272
278
  - lib/swagger_docs_generator/parser/definition.rb
273
279
  - lib/swagger_docs_generator/parser/model.rb
274
- - lib/swagger_docs_generator/parser/models/active_record.rb
275
- - lib/swagger_docs_generator/parser/models/mongo.rb
276
280
  - lib/swagger_docs_generator/parser/parser.rb
277
281
  - lib/swagger_docs_generator/railtie.rb
278
282
  - lib/tasks/swagger.rake
@@ -280,6 +284,7 @@ files:
280
284
  - spec/support/examples/configuration.rb
281
285
  - spec/support/examples/generator.rb
282
286
  - spec/support/examples/metadata.rb
287
+ - spec/support/examples/parameters.rb
283
288
  - spec/support/schemas/swagger.json
284
289
  - spec/swagger_docs_generator/configuration/configuration_customize_spec.rb
285
290
  - spec/swagger_docs_generator/configuration/configuration_default_spec.rb
@@ -287,8 +292,12 @@ files:
287
292
  - spec/swagger_docs_generator/gem_spec.rb
288
293
  - spec/swagger_docs_generator/generator_spec.rb
289
294
  - spec/swagger_docs_generator/metadata/configuration_spec.rb
290
- - spec/swagger_docs_generator/metadata/controller_spec.rb
291
295
  - spec/swagger_docs_generator/metadata/info_spec.rb
296
+ - spec/swagger_docs_generator/parser/parameters/param_body_spec.rb
297
+ - spec/swagger_docs_generator/parser/parameters/param_form_spec.rb
298
+ - spec/swagger_docs_generator/parser/parameters/param_header_spec.rb
299
+ - spec/swagger_docs_generator/parser/parameters/param_path_spec.rb
300
+ - spec/swagger_docs_generator/parser/parameters/param_query_spec.rb
292
301
  homepage: https://github.com/Dev-Crea/swagger-docs-generator
293
302
  licenses:
294
303
  - MIT
@@ -304,9 +313,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
304
313
  version: '0'
305
314
  required_rubygems_version: !ruby/object:Gem::Requirement
306
315
  requirements:
307
- - - ">="
316
+ - - ">"
308
317
  - !ruby/object:Gem::Version
309
- version: '0'
318
+ version: 1.3.1
310
319
  requirements: []
311
320
  rubyforge_project:
312
321
  rubygems_version: 2.4.5
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SwaggerDocsGenerator
4
- # # Metadata generated
5
- #
6
- # Generate metadata for block paths in swagger specification
7
- #
8
- # @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#pathsObject
9
- class MetadataPath < MetadataController
10
- def initialize
11
- super
12
- end
13
-
14
- # Each controller parsed
15
- def construct_swagger_file
16
- hash = {}
17
- controllers.each do |controller|
18
- file = File.join(file_path, "#{controller.controller_name}.json")
19
- hash.merge!(JSON.parse(File.read(file))['paths']) if File.exist?(file)
20
- end
21
- { paths: hash }
22
- end
23
- end
24
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SwaggerDocsGenerator
4
- # # Metadata generated
5
- #
6
- # Generate metadata for block tag in swagger specification
7
- #
8
- # @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#tagObject
9
- class MetadataTag < MetadataController
10
- def initialize
11
- super
12
- end
13
-
14
- # Create tag
15
- def construct_swagger_file
16
- array = []
17
- controllers.each do |controller|
18
- file = File.join(file_path, "#{controller.controller_name}.json")
19
- array.push(JSON.parse(File.read(file))['tags']) if File.exist?(file)
20
- end
21
- { tags: array }
22
- end
23
- end
24
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe SwaggerDocsGenerator::MetadataController, type: :metadata,
6
- broken: true,
7
- name: :configuration do
8
- let(:metadata) { SwaggerDocsGenerator::MetadataController.new }
9
-
10
- before(:context) do
11
- class ApplicationController < ::ApplicationController
12
- end
13
- end
14
-
15
- it { expect(metadata.send(:class_controller)).to be_kind_of Array }
16
- it { expect(metadata.send(:array_controller)).to be_kind_of Array }
17
- it { expect(metadata.send(:string_controller)).to be_kind_of String }
18
- end