grape-swagger 1.6.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -1
  3. data/README.md +1 -0
  4. data/grape-swagger.gemspec +5 -5
  5. data/lib/grape-swagger/doc_methods/extensions.rb +2 -1
  6. data/lib/grape-swagger/doc_methods/move_params.rb +1 -0
  7. data/lib/grape-swagger/endpoint.rb +1 -1
  8. data/lib/grape-swagger/version.rb +1 -1
  9. metadata +26 -129
  10. data/.coveralls.yml +0 -1
  11. data/.github/dependabot.yml +0 -20
  12. data/.github/workflows/ci.yml +0 -120
  13. data/.gitignore +0 -45
  14. data/.rspec +0 -3
  15. data/.rubocop.yml +0 -136
  16. data/.rubocop_todo.yml +0 -45
  17. data/Dangerfile +0 -3
  18. data/Gemfile +0 -43
  19. data/Rakefile +0 -20
  20. data/example/api/endpoints.rb +0 -131
  21. data/example/api/entities.rb +0 -18
  22. data/example/config.ru +0 -42
  23. data/example/example_requests.postman_collection +0 -146
  24. data/example/splines.png +0 -0
  25. data/example/swagger-example.png +0 -0
  26. data/spec/issues/267_nested_namespaces.rb +0 -55
  27. data/spec/issues/403_versions_spec.rb +0 -124
  28. data/spec/issues/427_entity_as_string_spec.rb +0 -39
  29. data/spec/issues/430_entity_definitions_spec.rb +0 -94
  30. data/spec/issues/532_allow_custom_format_spec.rb +0 -38
  31. data/spec/issues/533_specify_status_code_spec.rb +0 -78
  32. data/spec/issues/537_enum_values_spec.rb +0 -50
  33. data/spec/issues/539_array_post_body_spec.rb +0 -65
  34. data/spec/issues/542_array_of_type_in_post_body_spec.rb +0 -46
  35. data/spec/issues/553_align_array_put_post_params_spec.rb +0 -144
  36. data/spec/issues/572_array_post_body_spec.rb +0 -51
  37. data/spec/issues/579_align_put_post_parameters_spec.rb +0 -179
  38. data/spec/issues/582_file_response_spec.rb +0 -55
  39. data/spec/issues/587_range_parameter_delimited_by_dash_spec.rb +0 -26
  40. data/spec/issues/605_root_route_documentation_spec.rb +0 -23
  41. data/spec/issues/650_params_array_spec.rb +0 -59
  42. data/spec/issues/677_consumes_produces_add_swagger_documentation_options_spec.rb +0 -100
  43. data/spec/issues/680_keep_204_error_schemas_spec.rb +0 -55
  44. data/spec/issues/751_deeply_nested_objects_spec.rb +0 -190
  45. data/spec/issues/776_multiple_presents_spec.rb +0 -59
  46. data/spec/issues/784_extensions_on_params_spec.rb +0 -38
  47. data/spec/issues/809_utf8_routes_spec.rb +0 -55
  48. data/spec/issues/832_array_hash_float_decimal_spec.rb +0 -111
  49. data/spec/issues/847_route_param_options_spec.rb +0 -37
  50. data/spec/lib/data_type_spec.rb +0 -111
  51. data/spec/lib/endpoint/params_parser_spec.rb +0 -124
  52. data/spec/lib/endpoint_spec.rb +0 -153
  53. data/spec/lib/extensions_spec.rb +0 -185
  54. data/spec/lib/format_data_spec.rb +0 -115
  55. data/spec/lib/model_parsers_spec.rb +0 -104
  56. data/spec/lib/move_params_spec.rb +0 -444
  57. data/spec/lib/oapi_tasks_spec.rb +0 -163
  58. data/spec/lib/operation_id_spec.rb +0 -55
  59. data/spec/lib/optional_object_spec.rb +0 -47
  60. data/spec/lib/parse_params_spec.rb +0 -82
  61. data/spec/lib/path_string_spec.rb +0 -101
  62. data/spec/lib/produces_consumes_spec.rb +0 -116
  63. data/spec/lib/tag_name_description_spec.rb +0 -80
  64. data/spec/lib/version_spec.rb +0 -28
  65. data/spec/spec_helper.rb +0 -39
  66. data/spec/support/empty_model_parser.rb +0 -23
  67. data/spec/support/grape_version.rb +0 -13
  68. data/spec/support/mock_parser.rb +0 -23
  69. data/spec/support/model_parsers/entity_parser.rb +0 -334
  70. data/spec/support/model_parsers/mock_parser.rb +0 -346
  71. data/spec/support/model_parsers/representable_parser.rb +0 -406
  72. data/spec/support/namespace_tags.rb +0 -93
  73. data/spec/support/the_paths_definitions.rb +0 -109
  74. data/spec/swagger_v2/api_documentation_spec.rb +0 -26
  75. data/spec/swagger_v2/api_swagger_v2_additional_properties_spec.rb +0 -83
  76. data/spec/swagger_v2/api_swagger_v2_body_definitions_spec.rb +0 -48
  77. data/spec/swagger_v2/api_swagger_v2_definitions-models_spec.rb +0 -36
  78. data/spec/swagger_v2/api_swagger_v2_detail_spec.rb +0 -79
  79. data/spec/swagger_v2/api_swagger_v2_extensions_spec.rb +0 -145
  80. data/spec/swagger_v2/api_swagger_v2_format-content_type_spec.rb +0 -137
  81. data/spec/swagger_v2/api_swagger_v2_global_configuration_spec.rb +0 -56
  82. data/spec/swagger_v2/api_swagger_v2_hash_and_array_spec.rb +0 -64
  83. data/spec/swagger_v2/api_swagger_v2_headers_spec.rb +0 -58
  84. data/spec/swagger_v2/api_swagger_v2_hide_documentation_path_spec.rb +0 -57
  85. data/spec/swagger_v2/api_swagger_v2_hide_param_spec.rb +0 -103
  86. data/spec/swagger_v2/api_swagger_v2_ignore_defaults_spec.rb +0 -48
  87. data/spec/swagger_v2/api_swagger_v2_mounted_spec.rb +0 -145
  88. data/spec/swagger_v2/api_swagger_v2_param_type_body_nested_spec.rb +0 -355
  89. data/spec/swagger_v2/api_swagger_v2_param_type_body_spec.rb +0 -217
  90. data/spec/swagger_v2/api_swagger_v2_param_type_spec.rb +0 -239
  91. data/spec/swagger_v2/api_swagger_v2_request_params_fix_spec.rb +0 -72
  92. data/spec/swagger_v2/api_swagger_v2_response_spec.rb +0 -143
  93. data/spec/swagger_v2/api_swagger_v2_response_with_examples_spec.rb +0 -135
  94. data/spec/swagger_v2/api_swagger_v2_response_with_headers_spec.rb +0 -216
  95. data/spec/swagger_v2/api_swagger_v2_response_with_models_spec.rb +0 -55
  96. data/spec/swagger_v2/api_swagger_v2_response_with_root_spec.rb +0 -153
  97. data/spec/swagger_v2/api_swagger_v2_spec.rb +0 -237
  98. data/spec/swagger_v2/api_swagger_v2_status_codes_spec.rb +0 -93
  99. data/spec/swagger_v2/api_swagger_v2_type-format_spec.rb +0 -89
  100. data/spec/swagger_v2/boolean_params_spec.rb +0 -35
  101. data/spec/swagger_v2/default_api_spec.rb +0 -175
  102. data/spec/swagger_v2/deprecated_field_spec.rb +0 -25
  103. data/spec/swagger_v2/description_not_initialized_spec.rb +0 -39
  104. data/spec/swagger_v2/endpoint_versioned_path_spec.rb +0 -130
  105. data/spec/swagger_v2/errors_spec.rb +0 -77
  106. data/spec/swagger_v2/float_api_spec.rb +0 -33
  107. data/spec/swagger_v2/form_params_spec.rb +0 -67
  108. data/spec/swagger_v2/grape-swagger_spec.rb +0 -17
  109. data/spec/swagger_v2/guarded_endpoint_spec.rb +0 -162
  110. data/spec/swagger_v2/hide_api_spec.rb +0 -147
  111. data/spec/swagger_v2/host_spec.rb +0 -43
  112. data/spec/swagger_v2/inheritance_and_discriminator_spec.rb +0 -57
  113. data/spec/swagger_v2/mount_override_api_spec.rb +0 -58
  114. data/spec/swagger_v2/mounted_target_class_spec.rb +0 -76
  115. data/spec/swagger_v2/namespace_tags_prefix_spec.rb +0 -122
  116. data/spec/swagger_v2/namespace_tags_spec.rb +0 -78
  117. data/spec/swagger_v2/namespaced_api_spec.rb +0 -121
  118. data/spec/swagger_v2/nicknamed_api_spec.rb +0 -25
  119. data/spec/swagger_v2/operation_id_api_spec.rb +0 -27
  120. data/spec/swagger_v2/param_multi_type_spec.rb +0 -77
  121. data/spec/swagger_v2/param_type_spec.rb +0 -87
  122. data/spec/swagger_v2/param_values_spec.rb +0 -162
  123. data/spec/swagger_v2/params_array_collection_format_spec.rb +0 -105
  124. data/spec/swagger_v2/params_array_spec.rb +0 -203
  125. data/spec/swagger_v2/params_example_spec.rb +0 -40
  126. data/spec/swagger_v2/params_hash_spec.rb +0 -71
  127. data/spec/swagger_v2/params_nested_spec.rb +0 -86
  128. data/spec/swagger_v2/parent_less_namespace_spec.rb +0 -32
  129. data/spec/swagger_v2/reference_entity_spec.rb +0 -129
  130. data/spec/swagger_v2/security_requirement_spec.rb +0 -46
  131. data/spec/swagger_v2/simple_mounted_api_spec.rb +0 -326
  132. data/spec/version_spec.rb +0 -10
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe 'security requirement on endpoint method' do
6
- def app
7
- Class.new(Grape::API) do
8
- desc 'Endpoint with security requirement', security: [{ oauth_pets: ['read:pets', 'write:pets'] }]
9
- get '/with_security' do
10
- { foo: 'bar' }
11
- end
12
-
13
- desc 'Endpoint without security requirement', security: []
14
- get '/without_security' do
15
- { foo: 'bar' }
16
- end
17
-
18
- add_swagger_documentation(
19
- security_definitions: {
20
- petstore_auth: {
21
- type: 'oauth2',
22
- flow: 'implicit',
23
- authorizationUrl: 'https://petstore.swagger.io/oauth/dialog',
24
- scopes: {
25
- 'read:pets': 'read your pets',
26
- 'write:pets': 'modify pets in your account'
27
- }
28
- }
29
- }
30
- )
31
- end
32
- end
33
-
34
- subject do
35
- get '/swagger_doc.json'
36
- JSON.parse(last_response.body)
37
- end
38
-
39
- it 'defines the security requirement on the endpoint method' do
40
- expect(subject['paths']['/with_security']['get']['security']).to eql [{ 'oauth_pets' => ['read:pets', 'write:pets'] }]
41
- end
42
-
43
- it 'defines an empty security requirement on the endpoint method' do
44
- expect(subject['paths']['/without_security']['get']['security']).to eql []
45
- end
46
- end
@@ -1,326 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe 'a simple mounted api' do
6
- before :all do
7
- # rubocop:disable Lint/EmptyClass
8
- class CustomType; end
9
- # rubocop:enable Lint/EmptyClass
10
-
11
- class SimpleMountedApi < Grape::API
12
- desc 'Document root'
13
- get do
14
- { message: 'hi' }
15
- end
16
-
17
- desc 'This gets something.',
18
- notes: '_test_'
19
-
20
- get '/simple' do
21
- { bla: 'something' }
22
- end
23
-
24
- desc 'This gets something for URL using - separator.',
25
- notes: '_test_'
26
-
27
- get '/simple-test' do
28
- { bla: 'something' }
29
- end
30
-
31
- head '/simple-head-test' do
32
- status 200
33
- end
34
-
35
- options '/simple-options-test' do
36
- status 200
37
- end
38
-
39
- desc 'this gets something else',
40
- headers: {
41
- 'XAuthToken' => { description: 'A required header.', required: true },
42
- 'XOtherHeader' => { description: 'An optional header.', required: false }
43
- },
44
- http_codes: [
45
- { code: 403, message: 'invalid pony' },
46
- { code: 405, message: 'no ponies left!' }
47
- ]
48
-
49
- get '/simple_with_headers' do
50
- { bla: 'something_else' }
51
- end
52
-
53
- desc 'this takes an array of parameters',
54
- params: {
55
- 'items[]' => { description: 'array of items', is_array: true }
56
- }
57
-
58
- post '/items' do
59
- {}
60
- end
61
-
62
- desc 'this uses a custom parameter',
63
- params: {
64
- 'custom' => { type: CustomType, description: 'array of items', is_array: true }
65
- }
66
-
67
- get '/custom' do
68
- {}
69
- end
70
- end
71
-
72
- class SimpleApi < Grape::API
73
- mount SimpleMountedApi
74
- add_swagger_documentation
75
- end
76
- end
77
-
78
- def app
79
- SimpleApi
80
- end
81
-
82
- describe 'retrieves swagger-documentation on /swagger_doc' do
83
- subject do
84
- get '/swagger_doc.json'
85
- JSON.parse(last_response.body)
86
- end
87
-
88
- specify do
89
- expect(subject).to eq(
90
- 'info' => {
91
- 'title' => 'API title', 'version' => '0.0.1'
92
- },
93
- 'swagger' => '2.0',
94
- 'produces' => ['application/xml', 'application/json', 'application/octet-stream', 'text/plain'],
95
- 'host' => 'example.org',
96
- 'tags' => [
97
- { 'name' => 'simple', 'description' => 'Operations about simples' },
98
- { 'name' => 'simple-test', 'description' => 'Operations about simple-tests' },
99
- { 'name' => 'simple-head-test', 'description' => 'Operations about simple-head-tests' },
100
- { 'name' => 'simple-options-test', 'description' => 'Operations about simple-options-tests' },
101
- { 'name' => 'simple_with_headers', 'description' => 'Operations about simple_with_headers' },
102
- { 'name' => 'items', 'description' => 'Operations about items' },
103
- { 'name' => 'custom', 'description' => 'Operations about customs' }
104
- ],
105
- 'paths' => {
106
- '/' => {
107
- 'get' => {
108
- 'description' => 'Document root',
109
- 'produces' => ['application/json'],
110
- 'responses' => { '200' => { 'description' => 'Document root' } },
111
- 'operationId' => 'get'
112
- }
113
- },
114
- '/simple' => {
115
- 'get' => {
116
- 'description' => 'This gets something.',
117
- 'produces' => ['application/json'],
118
- 'tags' => ['simple'],
119
- 'operationId' => 'getSimple',
120
- 'responses' => { '200' => { 'description' => 'This gets something.' } }
121
- }
122
- },
123
- '/simple-test' => {
124
- 'get' => {
125
- 'description' => 'This gets something for URL using - separator.',
126
- 'produces' => ['application/json'],
127
- 'tags' => ['simple-test'],
128
- 'operationId' => 'getSimpleTest',
129
- 'responses' => { '200' => { 'description' => 'This gets something for URL using - separator.' } }
130
- }
131
- },
132
- '/simple-head-test' => {
133
- 'head' => {
134
- 'produces' => ['application/json'],
135
- 'responses' => { '200' => { 'description' => 'head SimpleHeadTest' } },
136
- 'tags' => ['simple-head-test'],
137
- 'operationId' => 'headSimpleHeadTest'
138
- }
139
- },
140
- '/simple-options-test' => {
141
- 'options' => {
142
- 'produces' => ['application/json'],
143
- 'responses' => { '200' => { 'description' => 'option SimpleOptionsTest' } },
144
- 'tags' => ['simple-options-test'],
145
- 'operationId' => 'optionsSimpleOptionsTest'
146
- }
147
- },
148
- '/simple_with_headers' => {
149
- 'get' => {
150
- 'description' => 'this gets something else',
151
- 'produces' => ['application/json'],
152
- 'parameters' => [
153
- { 'in' => 'header', 'name' => 'XAuthToken', 'description' => 'A required header.', 'type' => 'string', 'required' => true },
154
- { 'in' => 'header', 'name' => 'XOtherHeader', 'description' => 'An optional header.', 'type' => 'string', 'required' => false }
155
- ],
156
- 'tags' => ['simple_with_headers'],
157
- 'operationId' => 'getSimpleWithHeaders',
158
- 'responses' => {
159
- '200' => { 'description' => 'this gets something else' },
160
- '403' => { 'description' => 'invalid pony' },
161
- '405' => { 'description' => 'no ponies left!' }
162
- }
163
- }
164
- },
165
- '/items' => {
166
- 'post' => {
167
- 'description' => 'this takes an array of parameters',
168
- 'produces' => ['application/json'],
169
- 'consumes' => ['application/json'],
170
- 'parameters' => [{ 'in' => 'formData', 'name' => 'items[]', 'description' => 'array of items', 'required' => false, 'type' => 'array', 'items' => { 'type' => 'string' } }],
171
- 'tags' => ['items'],
172
- 'operationId' => 'postItems',
173
- 'responses' => { '201' => { 'description' => 'this takes an array of parameters' } }
174
- }
175
- },
176
- '/custom' => {
177
- 'get' => {
178
- 'description' => 'this uses a custom parameter',
179
- 'produces' => ['application/json'],
180
- 'parameters' => [{ 'in' => 'formData', 'name' => 'custom', 'description' => 'array of items', 'required' => false, 'type' => 'array', 'items' => { 'type' => 'CustomType' } }],
181
- 'tags' => ['custom'],
182
- 'operationId' => 'getCustom',
183
- 'responses' => { '200' => { 'description' => 'this uses a custom parameter' } }
184
- }
185
- }
186
- }
187
- )
188
- end
189
- end
190
-
191
- describe 'retrieves the documentation for mounted-api' do
192
- subject do
193
- get '/swagger_doc/simple.json'
194
- JSON.parse(last_response.body)
195
- end
196
-
197
- specify do
198
- expect(subject).to eq(
199
- 'info' => { 'title' => 'API title', 'version' => '0.0.1' },
200
- 'swagger' => '2.0',
201
- 'produces' => ['application/xml', 'application/json', 'application/octet-stream', 'text/plain'],
202
- 'host' => 'example.org',
203
- 'tags' => [
204
- { 'name' => 'simple', 'description' => 'Operations about simples' }
205
- ],
206
- 'paths' => {
207
- '/simple' => {
208
- 'get' => {
209
- 'description' => 'This gets something.',
210
- 'produces' => ['application/json'],
211
- 'tags' => ['simple'],
212
- 'operationId' => 'getSimple',
213
- 'responses' => { '200' => { 'description' => 'This gets something.' } }
214
- }
215
- }
216
- }
217
- )
218
- end
219
- end
220
-
221
- describe 'retrieves the documentation for mounted-api that' do
222
- describe "contains '-' in URL" do
223
- subject do
224
- get '/swagger_doc/simple-test.json'
225
- JSON.parse(last_response.body)
226
- end
227
-
228
- specify do
229
- expect(subject).to eq(
230
- 'info' => { 'title' => 'API title', 'version' => '0.0.1' },
231
- 'swagger' => '2.0',
232
- 'produces' => ['application/xml', 'application/json', 'application/octet-stream', 'text/plain'],
233
- 'host' => 'example.org',
234
- 'tags' => [
235
- { 'name' => 'simple-test', 'description' => 'Operations about simple-tests' }
236
- ],
237
- 'paths' => {
238
- '/simple-test' => {
239
- 'get' => {
240
- 'description' => 'This gets something for URL using - separator.',
241
- 'produces' => ['application/json'],
242
- 'tags' => ['simple-test'],
243
- 'operationId' => 'getSimpleTest',
244
- 'responses' => { '200' => { 'description' => 'This gets something for URL using - separator.' } }
245
- }
246
- }
247
- }
248
- )
249
- end
250
- end
251
-
252
- describe 'includes headers' do
253
- subject do
254
- get '/swagger_doc/simple_with_headers.json'
255
- JSON.parse(last_response.body)
256
- end
257
-
258
- specify do
259
- expect(subject['paths']).to eq(
260
- '/simple_with_headers' => {
261
- 'get' => {
262
- 'description' => 'this gets something else',
263
- 'produces' => ['application/json'],
264
- 'parameters' => [
265
- { 'in' => 'header', 'name' => 'XAuthToken', 'description' => 'A required header.', 'type' => 'string', 'required' => true },
266
- { 'in' => 'header', 'name' => 'XOtherHeader', 'description' => 'An optional header.', 'type' => 'string', 'required' => false }
267
- ],
268
- 'tags' => ['simple_with_headers'],
269
- 'operationId' => 'getSimpleWithHeaders',
270
- 'responses' => {
271
- '200' => { 'description' => 'this gets something else' },
272
- '403' => { 'description' => 'invalid pony' },
273
- '405' => { 'description' => 'no ponies left!' }
274
- }
275
- }
276
- }
277
- )
278
- end
279
- end
280
-
281
- describe 'supports array params' do
282
- subject do
283
- get '/swagger_doc/items.json'
284
- JSON.parse(last_response.body)
285
- end
286
-
287
- specify do
288
- expect(subject['paths']).to eq(
289
- '/items' => {
290
- 'post' => {
291
- 'description' => 'this takes an array of parameters',
292
- 'produces' => ['application/json'],
293
- 'consumes' => ['application/json'],
294
- 'parameters' => [{ 'in' => 'formData', 'name' => 'items[]', 'description' => 'array of items', 'required' => false, 'type' => 'array', 'items' => { 'type' => 'string' } }],
295
- 'tags' => ['items'],
296
- 'operationId' => 'postItems',
297
- 'responses' => { '201' => { 'description' => 'this takes an array of parameters' } }
298
- }
299
- }
300
- )
301
- end
302
- end
303
-
304
- describe 'supports custom params types' do
305
- subject do
306
- get '/swagger_doc/custom.json'
307
- JSON.parse(last_response.body)
308
- end
309
-
310
- specify do
311
- expect(subject['paths']).to eq(
312
- '/custom' => {
313
- 'get' => {
314
- 'description' => 'this uses a custom parameter',
315
- 'produces' => ['application/json'],
316
- 'parameters' => [{ 'in' => 'formData', 'name' => 'custom', 'description' => 'array of items', 'required' => false, 'type' => 'array', 'items' => { 'type' => 'CustomType' } }],
317
- 'tags' => ['custom'],
318
- 'operationId' => 'getCustom',
319
- 'responses' => { '200' => { 'description' => 'this uses a custom parameter' } }
320
- }
321
- }
322
- )
323
- end
324
- end
325
- end
326
- end
data/spec/version_spec.rb DELETED
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe GrapeSwagger do
6
- it '#version' do
7
- expect(GrapeSwagger::VERSION).to_not be_nil
8
- expect(GrapeSwagger::VERSION.split('.').count).to eq 3
9
- end
10
- end