grape-swagger 0.26.1 → 0.27.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -0
  3. data/.rubocop_todo.yml +5 -11
  4. data/.travis.yml +1 -2
  5. data/CHANGELOG.md +20 -1
  6. data/Dangerfile +2 -0
  7. data/Gemfile +5 -2
  8. data/README.md +70 -17
  9. data/RELEASING.md +2 -2
  10. data/Rakefile +2 -1
  11. data/grape-swagger.gemspec +2 -0
  12. data/lib/grape-swagger.rb +3 -1
  13. data/lib/grape-swagger/doc_methods.rb +17 -2
  14. data/lib/grape-swagger/doc_methods/build_model_definition.rb +2 -0
  15. data/lib/grape-swagger/doc_methods/data_type.rb +2 -0
  16. data/lib/grape-swagger/doc_methods/extensions.rb +6 -0
  17. data/lib/grape-swagger/doc_methods/headers.rb +2 -0
  18. data/lib/grape-swagger/doc_methods/move_params.rb +7 -5
  19. data/lib/grape-swagger/doc_methods/operation_id.rb +5 -7
  20. data/lib/grape-swagger/doc_methods/optional_object.rb +2 -0
  21. data/lib/grape-swagger/doc_methods/parse_params.rb +3 -3
  22. data/lib/grape-swagger/doc_methods/path_string.rb +3 -1
  23. data/lib/grape-swagger/doc_methods/produces_consumes.rb +2 -0
  24. data/lib/grape-swagger/doc_methods/status_codes.rb +2 -2
  25. data/lib/grape-swagger/doc_methods/tag_name_description.rb +2 -0
  26. data/lib/grape-swagger/doc_methods/version.rb +1 -0
  27. data/lib/grape-swagger/endpoint.rb +36 -18
  28. data/lib/grape-swagger/errors.rb +2 -0
  29. data/lib/grape-swagger/model_parsers.rb +2 -0
  30. data/lib/grape-swagger/rake/oapi_tasks.rb +2 -0
  31. data/lib/grape-swagger/version.rb +3 -1
  32. data/spec/issues/403_versions_spec.rb +2 -0
  33. data/spec/issues/427_entity_as_string_spec.rb +2 -0
  34. data/spec/issues/430_entity_definitions_spec.rb +2 -0
  35. data/spec/issues/532_allow_custom_format_spec.rb +3 -1
  36. data/spec/issues/533_specify_status_code_spec.rb +2 -0
  37. data/spec/issues/537_enum_values_spec.rb +4 -2
  38. data/spec/issues/539_array_post_body_spec.rb +2 -0
  39. data/spec/issues/542_array_of_type_in_post_body_spec.rb +2 -0
  40. data/spec/issues/553_align_array_put_post_params_spec.rb +2 -0
  41. data/spec/issues/572_array_post_body_spec.rb +2 -0
  42. data/spec/issues/579_align_put_post_parameters_spec.rb +179 -0
  43. data/spec/issues/582_file_response_spec.rb +55 -0
  44. data/spec/issues/587_range_parameter_delimited_by_dash_spec.rb +26 -0
  45. data/spec/lib/data_type_spec.rb +2 -0
  46. data/spec/lib/endpoint_spec.rb +2 -0
  47. data/spec/lib/extensions_spec.rb +2 -0
  48. data/spec/lib/model_parsers_spec.rb +2 -0
  49. data/spec/lib/move_params_spec.rb +8 -5
  50. data/spec/lib/oapi_tasks_spec.rb +2 -0
  51. data/spec/lib/operation_id_spec.rb +2 -0
  52. data/spec/lib/optional_object_spec.rb +6 -1
  53. data/spec/lib/parse_params_spec.rb +2 -0
  54. data/spec/lib/path_string_spec.rb +10 -1
  55. data/spec/lib/produces_consumes_spec.rb +2 -0
  56. data/spec/lib/tag_name_description_spec.rb +10 -7
  57. data/spec/lib/version_spec.rb +5 -3
  58. data/spec/spec_helper.rb +3 -1
  59. data/spec/support/empty_model_parser.rb +2 -0
  60. data/spec/support/grape_version.rb +2 -0
  61. data/spec/support/mock_parser.rb +2 -0
  62. data/spec/support/model_parsers/entity_parser.rb +2 -0
  63. data/spec/support/model_parsers/mock_parser.rb +2 -0
  64. data/spec/support/model_parsers/representable_parser.rb +2 -0
  65. data/spec/support/namespace_tags.rb +2 -0
  66. data/spec/support/the_paths_definitions.rb +2 -0
  67. data/spec/swagger_v2/api_swagger_v2_body_definitions_spec.rb +2 -0
  68. data/spec/swagger_v2/api_swagger_v2_definitions-models_spec.rb +2 -0
  69. data/spec/swagger_v2/api_swagger_v2_detail_spec.rb +14 -12
  70. data/spec/swagger_v2/api_swagger_v2_extensions_spec.rb +2 -0
  71. data/spec/swagger_v2/api_swagger_v2_format-content_type_spec.rb +2 -0
  72. data/spec/swagger_v2/api_swagger_v2_global_configuration_spec.rb +2 -0
  73. data/spec/swagger_v2/api_swagger_v2_hash_and_array_spec.rb +2 -0
  74. data/spec/swagger_v2/api_swagger_v2_headers_spec.rb +2 -0
  75. data/spec/swagger_v2/api_swagger_v2_hide_documentation_path_spec.rb +2 -0
  76. data/spec/swagger_v2/api_swagger_v2_hide_param_spec.rb +2 -0
  77. data/spec/swagger_v2/api_swagger_v2_ignore_defaults_spec.rb +2 -0
  78. data/spec/swagger_v2/api_swagger_v2_mounted_spec.rb +2 -0
  79. data/spec/swagger_v2/api_swagger_v2_param_type_body_nested_spec.rb +2 -0
  80. data/spec/swagger_v2/api_swagger_v2_param_type_body_spec.rb +2 -0
  81. data/spec/swagger_v2/api_swagger_v2_param_type_spec.rb +2 -0
  82. data/spec/swagger_v2/api_swagger_v2_request_params_fix_spec.rb +2 -0
  83. data/spec/swagger_v2/api_swagger_v2_response_spec.rb +2 -0
  84. data/spec/swagger_v2/api_swagger_v2_spec.rb +2 -0
  85. data/spec/swagger_v2/api_swagger_v2_type-format_spec.rb +2 -0
  86. data/spec/swagger_v2/boolean_params_spec.rb +2 -0
  87. data/spec/swagger_v2/default_api_spec.rb +43 -1
  88. data/spec/swagger_v2/description_not_initialized.rb +2 -0
  89. data/spec/swagger_v2/endpoint_versioned_path_spec.rb +2 -0
  90. data/spec/swagger_v2/errors_spec.rb +2 -0
  91. data/spec/swagger_v2/float_api_spec.rb +2 -0
  92. data/spec/swagger_v2/form_params_spec.rb +3 -1
  93. data/spec/swagger_v2/grape-swagger_spec.rb +2 -0
  94. data/spec/swagger_v2/hide_api_spec.rb +2 -0
  95. data/spec/swagger_v2/host.rb +2 -0
  96. data/spec/swagger_v2/mounted_target_class_spec.rb +2 -0
  97. data/spec/swagger_v2/namespace_tags_prefix_spec.rb +3 -1
  98. data/spec/swagger_v2/namespace_tags_spec.rb +2 -0
  99. data/spec/swagger_v2/namespaced_api_spec.rb +2 -0
  100. data/spec/swagger_v2/nicknamed_api_spec.rb +2 -0
  101. data/spec/swagger_v2/operation_id_api_spec.rb +2 -0
  102. data/spec/swagger_v2/param_multi_type_spec.rb +2 -0
  103. data/spec/swagger_v2/param_type_spec.rb +2 -0
  104. data/spec/swagger_v2/param_values_spec.rb +2 -0
  105. data/spec/swagger_v2/params_array_collection_fromat_spec.rb +2 -0
  106. data/spec/swagger_v2/params_array_spec.rb +2 -0
  107. data/spec/swagger_v2/params_hash_spec.rb +2 -0
  108. data/spec/swagger_v2/params_nested_spec.rb +2 -0
  109. data/spec/swagger_v2/parent_less_namespace.rb +2 -0
  110. data/spec/swagger_v2/reference_entity.rb +2 -0
  111. data/spec/swagger_v2/security_requirement_spec.rb +2 -0
  112. data/spec/swagger_v2/simple_mounted_api_spec.rb +2 -0
  113. data/spec/version_spec.rb +2 -0
  114. metadata +8 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e5d302ec60b3bef72593d98458853f1b55cfa9be
4
- data.tar.gz: a58b6ce813533e111d2292959821bb932e581358
3
+ metadata.gz: b76f67355052da445cdb76c9405479606c5fd4e8
4
+ data.tar.gz: 64ab481f4a7eb9479c66f03ee1c3a8489d85db48
5
5
  SHA512:
6
- metadata.gz: d3e31c1740c6605ca8f59a07aeb0b1105ef9d1b789c526f3c212b582bcf36527362ea3f0843b2f5c8cb457659e37177cd9e3a04afbb09a39be5c55c07b41069d
7
- data.tar.gz: 6fc0e0f55ad293e48696ce9721fccba8febb38ceebb85ee9990ef91d03b2c94beb5891875f1c84ef22ac7aaff42bc532a649ebf77e5617583f8053b8528e5713
6
+ metadata.gz: 8132feb353b8a6c9ae6359d86507e5f7e785e414880bf3bbcd3452e73acdb2806281405048397a231d881912676ff1ccda13e9c950ee9031a52fb667bcd6a528
7
+ data.tar.gz: 66a8603fd1ca61891c64b8caf5259b12f3c2ca2c357fff8a0017db6aa53d2399e7478b3b236c48b414819a178cf347bd1bb58c7849fc752c82c9bdb3d3bcc0f2
@@ -2,6 +2,7 @@ AllCops:
2
2
  Exclude:
3
3
  - vendor/**/*
4
4
  - example/**/*
5
+ TargetRubyVersion: 2.4
5
6
 
6
7
  inherit_from: .rubocop_todo.yml
7
8
 
@@ -19,3 +20,6 @@ Metrics/MethodLength:
19
20
 
20
21
  Style/IndentHash:
21
22
  EnforcedStyle: consistent
23
+
24
+ Style/FileName:
25
+ Enabled: false
@@ -18,11 +18,11 @@ Metrics/BlockLength:
18
18
  # Offense count: 3
19
19
  # Configuration parameters: CountComments.
20
20
  Metrics/ClassLength:
21
- Max: 265
21
+ Max: 275
22
22
 
23
23
  # Offense count: 12
24
24
  Metrics/CyclomaticComplexity:
25
- Max: 14
25
+ Max: 15
26
26
 
27
27
  # Offense count: 129
28
28
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives.
@@ -37,7 +37,7 @@ Metrics/MethodLength:
37
37
 
38
38
  # Offense count: 7
39
39
  Metrics/PerceivedComplexity:
40
- Max: 15
40
+ Max: 16
41
41
 
42
42
  # Offense count: 3
43
43
  Style/ClassVars:
@@ -48,15 +48,9 @@ Style/ClassVars:
48
48
  Style/Documentation:
49
49
  Enabled: false
50
50
 
51
- # Offense count: 5
52
- # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts.
53
- Style/FileName:
51
+ Style/MixinGrouping:
54
52
  Exclude:
55
- - 'lib/grape-swagger.rb'
56
- - 'spec/swagger_v2/api_swagger_v2_definitions-models_spec.rb'
57
- - 'spec/swagger_v2/api_swagger_v2_format-content_type_spec.rb'
58
- - 'spec/swagger_v2/api_swagger_v2_type-format_spec.rb'
59
- - 'spec/swagger_v2/grape-swagger_spec.rb'
53
+ - spec/**/*
60
54
 
61
55
  # Offense count: 1
62
56
  # Cop supports --auto-correct.
@@ -8,10 +8,9 @@ before_install:
8
8
 
9
9
  after_success:
10
10
  - bundle exec danger
11
- - coveralls
12
11
 
13
12
  rvm:
14
- - 2.4.0
13
+ - 2.4.1
15
14
  - 2.3.3
16
15
 
17
16
  env:
@@ -8,7 +8,26 @@
8
8
 
9
9
  * Your contribution here.
10
10
 
11
- ### 0.26.1 (February 3, 2014)
11
+ ### 0.27.0 (March 27, 2014)
12
+
13
+ #### Features
14
+
15
+ * [#583](https://github.com/ruby-grape/grape-swagger/pull/583): Issue #582: document file response - [@LeFnord](https://github.com/LeFnord).
16
+ * [#588](https://github.com/ruby-grape/grape-swagger/pull/588): Allow extension keys in Info object - [@mattyr](https://github.com/mattyr).
17
+ * [#589](https://github.com/ruby-grape/grape-swagger/pull/589): Allow overriding tag definitions in Info object - [@mattyr](https://github.com/mattyr).
18
+
19
+ * Your contribution here.
20
+
21
+ #### Fixes
22
+
23
+ * [#580](https://github.com/ruby-grape/grape-swagger/pull/580): Issue #578: fixes duplicated path params - [@LeFnord](https://github.com/LeFnord).
24
+ * [#585](https://github.com/ruby-grape/grape-swagger/pull/585): Issue #584: do not mutate route.path - [@LeFnord](https://github.com/LeFnord).
25
+ * [#586](https://github.com/ruby-grape/grape-swagger/pull/586): Issue #587: Parameters delimited by dash cause exception - [@risa](https://github.com/risa).
26
+ * [#593](https://github.com/ruby-grape/grape-swagger/pull/593): Clarify hidden option in readme - [@thogg4](https://github.com/thogg4).
27
+
28
+ * Your contribution here.
29
+
30
+ ### 0.26.1 (February 3, 2017)
12
31
 
13
32
  #### Features
14
33
 
data/Dangerfile CHANGED
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  danger.import_dangerfile(gem: 'ruby-grape-danger')
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'http://rubygems.org'
2
4
 
3
5
  ruby RUBY_VERSION
@@ -23,11 +25,12 @@ group :development, :test do
23
25
  gem 'rake'
24
26
  gem 'rdoc'
25
27
  gem 'rspec', '~> 3.0'
26
- gem 'rubocop', '~> 0.46'
28
+ gem 'rubocop', '~> 0.47'
27
29
  end
30
+
28
31
  group :test do
29
32
  gem 'coveralls', require: false
30
- gem 'grape-entity'
33
+ gem 'grape-entity', '~>0.5'
31
34
  gem 'grape-swagger-entity'
32
35
  gem 'ruby-grape-danger', '~> 0.1.1', require: false
33
36
  gem 'simplecov', require: false
data/README.md CHANGED
@@ -49,14 +49,9 @@ grape-swagger | swagger spec | grape | grape-entity | represen
49
49
  --------------|--------------|-------------------------|--------------|---------------|
50
50
  0.10.5 | 1.2 | >= 0.10.0 ... <= 0.14.0 | < 0.5.0 | n/a |
51
51
  0.11.0 | 1.2 | >= 0.16.2 | < 0.5.0 | n/a |
52
- 0.20.1 | 2.0 | >= 0.12.0 ... <= 0.14.0 | <= 0.5.1 | n/a |
53
- 0.20.3 | 2.0 | >= 0.12.0 ... ~> 0.16.2 | ~> 0.5.1 | n/a |
54
- 0.21.0 | 2.0 | >= 0.12.0 ... <= 0.16.2 | <= 0.5.1 | >= 2.4.1 |
55
- 0.23.0 | 2.0 | >= 0.12.0 ... <= 0.17.0 | <= 0.5.1 | >= 2.4.1 |
56
- 0.24.0 | 2.0 | >= 0.12.0 ... <= 0.18.0 | <= 0.5.1 | >= 2.4.1 |
57
- 0.25.0 | 2.0 | >= 0.14.0 ... <= 0.18.0 | <= 0.5.2 | >= 2.4.1 |
58
52
  0.25.2 | 2.0 | >= 0.14.0 ... <= 0.18.0 | <= 0.6.0 | >= 2.4.1 |
59
53
  0.26.0 | 2.0 | >= 0.16.2 | <= 0.6.1 | >= 2.4.1 |
54
+ 0.27.0 | 2.0 | >= 0.16.2 | => 0.5.0 | >= 2.4.1 |
60
55
 
61
56
  <a name="swagger-spec" />
62
57
  ## Swagger-Spec
@@ -202,6 +197,7 @@ end
202
197
  * [token_owner](#token_owner)
203
198
  * [security_definitions](#security_definitions)
204
199
  * [models](#models)
200
+ * [tags](#tags)
205
201
  * [hide_documentation_path](#hide_documentation_path)
206
202
  * [info](#info)
207
203
 
@@ -329,6 +325,18 @@ add_swagger_documentation \
329
325
  ]
330
326
  ```
331
327
 
328
+ <a name="tags" />
329
+ ### tags:
330
+ A list of tags to document. By default tags are automatically generated
331
+ for endpoints based on route names.
332
+
333
+ ```ruby
334
+ add_swagger_documentation \
335
+ tags: [
336
+ { name: 'widgets', description: 'A description of widgets' }
337
+ ]
338
+ ```
339
+
332
340
  <a name="hide_documentation_path" />
333
341
  #### hide_documentation_path: (default: `true`)
334
342
  ```ruby
@@ -397,6 +405,7 @@ add_swagger_documentation \
397
405
  * [Setting a Swagger default value](#default-value)
398
406
  * [Response documentation](#response)
399
407
  * [Changing default status codes](#change-status)
408
+ * [File response](#file-response)
400
409
  * [Extensions](#extensions)
401
410
 
402
411
 
@@ -430,6 +439,12 @@ You can hide an endpoint by adding ```hidden: true``` in the description of the
430
439
  desc 'Hide this endpoint', hidden: true
431
440
  ```
432
441
 
442
+ Or by adding ```hidden: true``` on the verb method of the endpoint, such as `get`, `post` and `put`:
443
+
444
+ ```ruby
445
+ get '/kittens', hidden: true do
446
+ ```
447
+
433
448
  Endpoints can be conditionally hidden by providing a callable object such as a lambda which evaluates to the desired
434
449
  state:
435
450
 
@@ -826,16 +841,56 @@ end
826
841
  },
827
842
  ```
828
843
 
844
+ <a name="file-response" />
845
+ #### File response
846
+
847
+ Set `success` to `File` and sets also produces. If produces wasn't set, it defaults to `application/octet-stream`.
848
+ ```ruby
849
+ desc 'Get a file',
850
+ success: File
851
+ get do
852
+ # your file reponse
853
+ end
854
+
855
+ ```
856
+
857
+ ```json
858
+ "produces": [
859
+ "application/octet-stream"
860
+ ],
861
+ "responses": {
862
+ "200": {
863
+ "description": "Get a file",
864
+ "schema": {
865
+ "type": "file"
866
+ }
867
+ }
868
+ }
869
+ ```
829
870
 
830
871
  <a name="extensions" />
831
872
  #### Extensions
832
873
 
833
874
  Swagger spec2.0 supports extensions on different levels, for the moment,
834
- the documentation on `verb`, `path` and `definition` level would be supported.
875
+ the documentation on `info`, `verb`, `path` and `definition` level would be supported.
835
876
  The documented key would be generated from the `x` + `-` + key of the submitted hash,
836
877
  for possibilities refer to the [extensions spec](spec/lib/extensions_spec.rb).
837
878
  To get an overview *how* the extensions would be defined on grape level, see the following examples:
838
879
 
880
+ - `info` extension, add a `x` key to the `info` hash when calling ```add_swagger_documentation```:
881
+ ```ruby
882
+ add_swagger_documentation \
883
+ info: {
884
+ x: { some: 'stuff' }
885
+ }
886
+ ```
887
+ this would generate:
888
+ ```json
889
+ "info":{
890
+ "x-some":"stuff"
891
+ }
892
+ ```
893
+
839
894
  - `verb` extension, add a `x` key to the `desc` hash:
840
895
  ```ruby
841
896
  desc 'This returns something with extension on verb level',
@@ -1079,13 +1134,13 @@ role - only admins can see this endpoint.
1079
1134
  <a name="md_usage" />
1080
1135
  ## Markdown in Detail (deprecated)
1081
1136
 
1082
- Usage of option `markdown` won't no longer be supported,
1137
+ Usage of option `markdown` will no longer be supported,
1083
1138
  cause OAPI accepts [GFM](https://help.github.com/articles/github-flavored-markdown) and plain text.
1084
1139
  (see: [description of `Info`](https://github.com/OAI/OpenAPI-Specification/blob/OpenAPI.next/versions/2.0.md#info-object))
1085
1140
 
1086
1141
 
1087
1142
  <a="example" />
1088
- ## Example
1143
+ ## Examples
1089
1144
 
1090
1145
  Go into example directory and run it: `$ bundle exec rackup`
1091
1146
  go to: `http://localhost:9292/swagger_doc` to get it
@@ -1106,9 +1161,7 @@ class NamespaceApi < Grape::API
1106
1161
  desc 'Document root'
1107
1162
  get '/' do
1108
1163
  end
1109
- end
1110
1164
 
1111
- namespace :hudson do
1112
1165
  desc 'This gets something.',
1113
1166
  notes: '_test_'
1114
1167
 
@@ -1117,12 +1170,12 @@ class NamespaceApi < Grape::API
1117
1170
  end
1118
1171
  end
1119
1172
 
1120
- namespace :colorado do
1121
- desc 'This gets something for URL using - separator.',
1122
- notes: '_test_'
1123
-
1124
- get '/simple-test' do
1125
- { bla: 'something' }
1173
+ namespace :download do
1174
+ desc 'download files',
1175
+ success: File,
1176
+ produces: ['text/csv']
1177
+ get ':id' do
1178
+ # file response
1126
1179
  end
1127
1180
  end
1128
1181
  end
@@ -1,6 +1,6 @@
1
1
  # Releasing Grape-Swagger
2
2
 
3
- There're no particular rules about when to release grape-swagger. Release bug fixes frequenty, features not so frequently and breaking API changes rarely.
3
+ There're no particular rules about when to release grape-swagger. Release bug fixes frequently, features not so frequently and breaking API changes rarely.
4
4
 
5
5
  ### Release
6
6
 
@@ -56,7 +56,7 @@ Next Release
56
56
  * Your contribution here.
57
57
  ```
58
58
 
59
- Comit your changes.
59
+ Commit your changes.
60
60
 
61
61
  ```
62
62
  git add CHANGELOG.md
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'rubygems'
4
5
  require 'bundler'
@@ -17,4 +18,4 @@ RSpec::Core::RakeTask.new(:spec)
17
18
  require 'rubocop/rake_task'
18
19
  RuboCop::RakeTask.new(:rubocop)
19
20
 
20
- task default: [:spec, :rubocop]
21
+ task default: %i(spec rubocop)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  $LOAD_PATH.push File.expand_path('../lib', __FILE__)
2
4
  require 'grape-swagger/version'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'grape'
2
4
 
3
5
  require 'grape-swagger/version'
@@ -106,7 +108,7 @@ module Grape
106
108
  ns.options[:swagger][:nested] != false
107
109
  end
108
110
 
109
- parent_standalone_namespaces = standalone_namespaces.reject { |ns_name, _| !name.start_with?(ns_name) }
111
+ parent_standalone_namespaces = standalone_namespaces.select { |ns_name, _| name.start_with?(ns_name) }
110
112
  # add only to the main route
111
113
  # if the namespace is not within any other namespace appearing as standalone resource
112
114
  # rubocop:disable Style/Next
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'grape-swagger/doc_methods/status_codes'
2
4
  require 'grape-swagger/doc_methods/produces_consumes'
3
5
  require 'grape-swagger/doc_methods/data_type'
@@ -37,7 +39,7 @@ module GrapeSwagger
37
39
  class_variables_from(options)
38
40
 
39
41
  if formatter
40
- [:format, :default_format, :default_error_formatter].each do |method|
42
+ %i(format default_format default_error_formatter).each do |method|
41
43
  send(method, formatter)
42
44
  end
43
45
  end
@@ -52,7 +54,8 @@ module GrapeSwagger
52
54
  )
53
55
 
54
56
  paths, definitions = endpoint.path_and_definition_objects(combi_routes, options)
55
- tags = GrapeSwagger::DocMethods::TagNameDescription.build(paths)
57
+ tags = tags_from(paths, options)
58
+
56
59
  output[:tags] = tags unless tags.empty? || paths.blank?
57
60
  output[:paths] = paths unless paths.blank?
58
61
  output[:definitions] = definitions unless definitions.blank?
@@ -109,5 +112,17 @@ module GrapeSwagger
109
112
  @@class_name = options[:class_name] || options[:mount_path].delete('/')
110
113
  @@hide_documentation_path = options[:hide_documentation_path]
111
114
  end
115
+
116
+ def tags_from(paths, options)
117
+ tags = GrapeSwagger::DocMethods::TagNameDescription.build(paths)
118
+
119
+ if options[:tags]
120
+ names = options[:tags].map { |t| t[:name] }
121
+ tags.reject! { |t| names.include?(t[:name]) }
122
+ tags += options[:tags]
123
+ end
124
+
125
+ tags
126
+ end
112
127
  end
113
128
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module GrapeSwagger
2
4
  module DocMethods
3
5
  class BuildModelDefinition
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module GrapeSwagger
2
4
  module DocMethods
3
5
  class DataType
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module GrapeSwagger
2
4
  module DocMethods
3
5
  class Extensions
@@ -13,6 +15,10 @@ module GrapeSwagger
13
15
  add_extensions_to_definition(settings, path, definitions) if settings && extended?(settings, :x_def)
14
16
  end
15
17
 
18
+ def add_extensions_to_info(settings, info)
19
+ add_extension_to(info, extension(settings)) if extended?(settings, :x)
20
+ end
21
+
16
22
  def add_extensions_to_path(settings, path)
17
23
  add_extension_to(path, extension(settings, :x_path))
18
24
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module GrapeSwagger
2
4
  module DocMethods
3
5
  class Headers
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module GrapeSwagger
2
4
  module DocMethods
3
5
  class MoveParams
@@ -8,7 +10,7 @@ module GrapeSwagger
8
10
  move_methods.include?(http_verb) && includes_body_param?(params)
9
11
  end
10
12
 
11
- def to_definition(params, route, definitions)
13
+ def to_definition(path, params, route, definitions)
12
14
  @definitions = definitions
13
15
  unify!(params)
14
16
 
@@ -16,7 +18,7 @@ module GrapeSwagger
16
18
 
17
19
  return (params + correct_array_param(params_to_move)) if should_correct_array?(params_to_move)
18
20
 
19
- params << parent_definition_of_params(params_to_move, route)
21
+ params << parent_definition_of_params(params_to_move, path, route)
20
22
 
21
23
  params
22
24
  end
@@ -33,8 +35,8 @@ module GrapeSwagger
33
35
  param
34
36
  end
35
37
 
36
- def parent_definition_of_params(params, route)
37
- definition_name = OperationId.manipulate(parse_model(route.path))
38
+ def parent_definition_of_params(params, path, route)
39
+ definition_name = OperationId.manipulate(parse_model(path))
38
40
  referenced_definition = build_definition(definition_name, params, route.request_method.downcase)
39
41
  definition = @definitions[referenced_definition]
40
42
 
@@ -196,7 +198,7 @@ module GrapeSwagger
196
198
  end
197
199
 
198
200
  def property_keys
199
- [:type, :format, :description, :minimum, :maximum, :items]
201
+ %i(type format description minimum maximum items)
200
202
  end
201
203
 
202
204
  def deletable?(param)