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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'global configuration stuff' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'document hash and array' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'headers' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'hide documentation path' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'hidden flag enables a single endpoint parameter to be excluded from the documentation' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'swagger spec v2.0' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'swagger spec v2.0' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'moving body/formData Params to definitions' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'setting of param type, such as `query`, `path`, `formData`, `body`, `header`' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'setting of param type, such as `query`, `path`, `formData`, `body`, `header`' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'additional parameter settings' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'response' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'swagger spec v2.0' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  # mapping of parameter types
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'Boolean Params' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  # require 'grape_version'
3
5
 
@@ -98,7 +100,10 @@ describe 'Default API' do
98
100
  license: 'Apache 2',
99
101
  license_url: 'http://test.com',
100
102
  terms_of_service_url: 'http://terms.com',
101
- contact_email: 'support@test.com'
103
+ contact_email: 'support@test.com',
104
+ x: {
105
+ logo: 'http://logo.com/img.png'
106
+ }
102
107
  }
103
108
  end
104
109
  end
@@ -131,5 +136,42 @@ describe 'Default API' do
131
136
  it 'documents the contact email' do
132
137
  expect(subject['contact']['email']).to eql('support@test.com')
133
138
  end
139
+
140
+ it 'documents the extension field' do
141
+ expect(subject['x-logo']).to eql('http://logo.com/img.png')
142
+ end
143
+ end
144
+
145
+ context 'with tags' do
146
+ def app
147
+ Class.new(Grape::API) do
148
+ format :json
149
+ desc 'This gets something.'
150
+ get '/something' do
151
+ { bla: 'something' }
152
+ end
153
+ get '/somethingelse' do
154
+ { bla: 'somethingelse' }
155
+ end
156
+
157
+ add_swagger_documentation tags: [
158
+ { name: 'something', description: 'customized description' }
159
+ ]
160
+ end
161
+ end
162
+
163
+ subject do
164
+ get '/swagger_doc'
165
+ JSON.parse(last_response.body)
166
+ end
167
+
168
+ it 'documents the customized tag' do
169
+ expect(subject['tags']).to eql(
170
+ [
171
+ { 'name' => 'somethingelse', 'description' => 'Operations about somethingelses' },
172
+ { 'name' => 'something', 'description' => 'customized description' }
173
+ ]
174
+ )
175
+ end
134
176
  end
135
177
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'details' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'Grape::Endpoint#path_and_definitions' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'Errors' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'Float Params' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'Form Params' do
@@ -33,7 +35,7 @@ describe 'Form Params' do
33
35
  params do
34
36
  requires :id, type: Integer, desc: 'id of item'
35
37
  requires :name, type: String, desc: 'name of item'
36
- optional :conditions, type: Symbol, desc: 'conditions of item', values: [:one, :two]
38
+ optional :conditions, type: Symbol, desc: 'conditions of item', values: %i(one two)
37
39
  end
38
40
  post '/items/:id' do
39
41
  {}
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Grape::API do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'a hide mounted api' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'host in the swagger_doc' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'docs mounted separately from api' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'namespace tags check while using prefix and version' do
@@ -6,7 +8,7 @@ describe 'namespace tags check while using prefix and version' do
6
8
  before :all do
7
9
  module TheApi
8
10
  class NamespaceApi < Grape::API
9
- version [:v1, :v2]
11
+ version %i(v1 v2)
10
12
  end
11
13
 
12
14
  class CascadingVersionApi < Grape::API
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'namespace tags check' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'namespace' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'a nicknamed mounted api' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'an operation id api' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'Params Multi Types' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'Params Types' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  # require 'grape_version'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'Group Array Params, using collection format' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'Group Params as Array' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'Group Params as Hash' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'nested group params' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'a parent less namespace' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'referenceEntity' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'security requirement on endpoint method' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'a simple mounted api' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe GrapeSwagger do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-swagger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.26.1
4
+ version: 0.27.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Vandecasteele
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-03 00:00:00.000000000 Z
11
+ date: 2017-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grape
@@ -85,6 +85,9 @@ files:
85
85
  - spec/issues/542_array_of_type_in_post_body_spec.rb
86
86
  - spec/issues/553_align_array_put_post_params_spec.rb
87
87
  - spec/issues/572_array_post_body_spec.rb
88
+ - spec/issues/579_align_put_post_parameters_spec.rb
89
+ - spec/issues/582_file_response_spec.rb
90
+ - spec/issues/587_range_parameter_delimited_by_dash_spec.rb
88
91
  - spec/lib/data_type_spec.rb
89
92
  - spec/lib/endpoint_spec.rb
90
93
  - spec/lib/extensions_spec.rb
@@ -191,6 +194,9 @@ test_files:
191
194
  - spec/issues/542_array_of_type_in_post_body_spec.rb
192
195
  - spec/issues/553_align_array_put_post_params_spec.rb
193
196
  - spec/issues/572_array_post_body_spec.rb
197
+ - spec/issues/579_align_put_post_parameters_spec.rb
198
+ - spec/issues/582_file_response_spec.rb
199
+ - spec/issues/587_range_parameter_delimited_by_dash_spec.rb
194
200
  - spec/lib/data_type_spec.rb
195
201
  - spec/lib/endpoint_spec.rb
196
202
  - spec/lib/extensions_spec.rb