grape-swagger 0.33.0 → 0.34.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -7
- data/.rubocop_todo.yml +0 -6
- data/.travis.yml +10 -11
- data/CHANGELOG.md +72 -6
- data/Gemfile +4 -5
- data/README.md +68 -4
- data/grape-swagger.gemspec +2 -1
- data/lib/grape-swagger/doc_methods/build_model_definition.rb +0 -17
- data/lib/grape-swagger/doc_methods/extensions.rb +6 -1
- data/lib/grape-swagger/doc_methods/format_data.rb +51 -0
- data/lib/grape-swagger/doc_methods/move_params.rb +22 -49
- data/lib/grape-swagger/doc_methods/parse_params.rb +6 -0
- data/lib/grape-swagger/doc_methods.rb +2 -0
- data/lib/grape-swagger/endpoint/params_parser.rb +10 -17
- data/lib/grape-swagger/endpoint.rb +32 -13
- data/lib/grape-swagger/version.rb +1 -1
- data/lib/grape-swagger.rb +1 -1
- data/spec/issues/751_deeply_nested_objects_spec.rb +190 -0
- data/spec/lib/endpoint/params_parser_spec.rb +44 -20
- data/spec/lib/endpoint_spec.rb +3 -3
- data/spec/lib/extensions_spec.rb +10 -0
- data/spec/lib/format_data_spec.rb +91 -0
- data/spec/lib/move_params_spec.rb +4 -266
- data/spec/lib/optional_object_spec.rb +0 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/swagger_v2/api_swagger_v2_hash_and_array_spec.rb +3 -1
- data/spec/swagger_v2/api_swagger_v2_response_with_root_spec.rb +153 -0
- data/spec/swagger_v2/description_not_initialized_spec.rb +39 -0
- data/spec/swagger_v2/endpoint_versioned_path_spec.rb +33 -0
- data/spec/swagger_v2/mounted_target_class_spec.rb +1 -1
- data/spec/swagger_v2/namespace_tags_prefix_spec.rb +15 -1
- data/spec/swagger_v2/params_array_spec.rb +2 -2
- data/spec/swagger_v2/parent_less_namespace_spec.rb +32 -0
- data/spec/swagger_v2/{reference_entity.rb → reference_entity_spec.rb} +17 -10
- metadata +36 -9
- data/spec/swagger_v2/description_not_initialized.rb +0 -39
- data/spec/swagger_v2/parent_less_namespace.rb +0 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1adc600f72fbf0b270ca597d538fc692ab1b06d96aec051dd5aac93b0d9541e4
|
4
|
+
data.tar.gz: 90b38eef4b8736e686c57b9ae3a0a047c3be752076a3c51fe81a2b2ace4534d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: becc52b89b55eaf20b8e17c39b2a2d53592fbe6a92feb1c50d6f1b80d4ee0b14edb16dbcb5e6168a5d7830b80f8d412af19c78fc0a645aabd1ca3570ed3e34fb
|
7
|
+
data.tar.gz: c6da9f8e4818368d67f525898d69b9d15fe46d429cb4223fb44ff1f4d2c52aefff99f8487cf8ecdf702153d1a3d7dbaed93756a0967bbdadd871fdc26f8af229
|
data/.rubocop.yml
CHANGED
@@ -4,14 +4,19 @@ AllCops:
|
|
4
4
|
Exclude:
|
5
5
|
- vendor/**/*
|
6
6
|
- example/**/*
|
7
|
-
TargetRubyVersion: 2.
|
7
|
+
TargetRubyVersion: 2.7
|
8
8
|
|
9
9
|
Layout/EmptyLinesAroundArguments:
|
10
10
|
Enabled: false
|
11
11
|
|
12
|
-
Layout/
|
12
|
+
Layout/FirstHashElementIndentation:
|
13
13
|
EnforcedStyle: consistent
|
14
14
|
|
15
|
+
Layout/LineLength:
|
16
|
+
Max: 120
|
17
|
+
Exclude:
|
18
|
+
- spec/**/*
|
19
|
+
|
15
20
|
Metrics/BlockLength:
|
16
21
|
Exclude:
|
17
22
|
- spec/**/*
|
@@ -19,11 +24,6 @@ Metrics/BlockLength:
|
|
19
24
|
Metrics/ClassLength:
|
20
25
|
Max: 300
|
21
26
|
|
22
|
-
Metrics/LineLength:
|
23
|
-
Max: 120
|
24
|
-
Exclude:
|
25
|
-
- spec/**/*
|
26
|
-
|
27
27
|
Metrics/MethodLength:
|
28
28
|
Exclude:
|
29
29
|
- spec/**/*
|
data/.rubocop_todo.yml
CHANGED
@@ -13,12 +13,6 @@ Gemspec/RequiredRubyVersion:
|
|
13
13
|
Exclude:
|
14
14
|
- 'grape-swagger.gemspec'
|
15
15
|
|
16
|
-
# Offense count: 1
|
17
|
-
# Cop supports --auto-correct.
|
18
|
-
Lint/UnneededCopEnableDirective:
|
19
|
-
Exclude:
|
20
|
-
- 'spec/lib/optional_object_spec.rb'
|
21
|
-
|
22
16
|
# Offense count: 30
|
23
17
|
Metrics/AbcSize:
|
24
18
|
Max: 59
|
data/.travis.yml
CHANGED
@@ -7,28 +7,27 @@ after_success:
|
|
7
7
|
- bundle exec danger
|
8
8
|
|
9
9
|
rvm:
|
10
|
-
- 2.
|
11
|
-
- 2.
|
12
|
-
- 2.
|
10
|
+
- 2.5.7
|
11
|
+
- 2.6.5
|
12
|
+
- 2.7.0
|
13
13
|
env:
|
14
|
-
- MODEL_PARSER=grape-swagger-entity
|
15
|
-
- MODEL_PARSER=grape-swagger-representable
|
14
|
+
- GRAPE_VERSION=1.2.5 MODEL_PARSER=grape-swagger-entity
|
15
|
+
- GRAPE_VERSION=1.2.5 MODEL_PARSER=grape-swagger-representable
|
16
16
|
- GRAPE_VERSION=1.0.3
|
17
|
-
- GRAPE_VERSION=1.2.
|
18
|
-
- GRAPE_VERSION=HEAD
|
17
|
+
- GRAPE_VERSION=1.2.5
|
19
18
|
|
20
19
|
matrix:
|
21
20
|
fast_finish: true
|
22
21
|
|
23
22
|
include:
|
24
|
-
- rvm: 2.
|
25
|
-
env:
|
23
|
+
- rvm: 2.4.9
|
24
|
+
env: GRAPE_VERSION=1.2.5
|
26
25
|
- rvm: ruby-head
|
27
|
-
env:
|
26
|
+
env: GRAPE_VERSION=HEAD
|
28
27
|
- rvm: jruby-head
|
29
28
|
env:
|
30
29
|
|
31
30
|
allow_failures:
|
32
|
-
- rvm: 2.
|
31
|
+
- rvm: 2.4.9
|
33
32
|
- rvm: ruby-head
|
34
33
|
- rvm: jruby-head
|
data/CHANGELOG.md
CHANGED
@@ -6,7 +6,28 @@
|
|
6
6
|
|
7
7
|
#### Fixes
|
8
8
|
|
9
|
-
|
9
|
+
### 0.34.2 (January 20, 2020)
|
10
|
+
|
11
|
+
#### Fixes
|
12
|
+
|
13
|
+
* [#773](https://github.com/ruby-grape/grape-swagger/pull/773): Freeze rack version to 2.0.8 - [@LeFnord](https://github.com/LeFnord).
|
14
|
+
|
15
|
+
|
16
|
+
### 0.34.0 (January 11, 2020)
|
17
|
+
|
18
|
+
#### Features
|
19
|
+
|
20
|
+
* [#768](https://github.com/ruby-grape/grape-swagger/pull/768): Uses ruby 2.7, fixes grape to 1.2.5 (cause of dry-types) - [@LeFnord](https://github.com/LeFnord).
|
21
|
+
* [#761](https://github.com/ruby-grape/grape-swagger/pull/761): Add an option to configure root element for responses - [@bikolya](https://github.com/bikolya).
|
22
|
+
* [#749](https://github.com/ruby-grape/grape-swagger/pull/749): Drop support for Ruby 2.3 and below - [@LeFnord](https://github.com/LeFnord).
|
23
|
+
|
24
|
+
#### Fixes
|
25
|
+
|
26
|
+
* [#758](https://github.com/ruby-grape/grape-swagger/pull/758): Handle cases where a route's prefix is a nested URL - [@SimonKaluza](https://github.com/simonkaluza).
|
27
|
+
* [#757](https://github.com/ruby-grape/grape-swagger/pull/757): Fix `array_use_braces` for nested body params - [@bikolya](https://github.com/bikolya).
|
28
|
+
* [#756](https://github.com/ruby-grape/grape-swagger/pull/756): Fix reference creation when custom type for documentation is provided - [@bikolya](https://github.com/bikolya).
|
29
|
+
* [#764](https://github.com/ruby-grape/grape-swagger/pull/764): Fix root element for multi-word entities - [@bikolya](https://github.com/bikolya).
|
30
|
+
|
10
31
|
|
11
32
|
### 0.33.0 (June 21, 2019)
|
12
33
|
|
@@ -17,6 +38,11 @@
|
|
17
38
|
* [#743](https://github.com/ruby-grape/grape-swagger/pull/743): CI: use 2.4.6, 2.5.5 - [@olleolleolle](https://github.com/olleolleolle).
|
18
39
|
* [#737](https://github.com/ruby-grape/grape-swagger/pull/737): Add swagger endpoint guard to both doc endpoints - [@urkle](https://github.com/urkle).
|
19
40
|
|
41
|
+
#### Changes
|
42
|
+
|
43
|
+
* [#749](https://github.com/ruby-grape/grape-swagger/pull/749) Drop support for Ruby 2.3 and below - [@LeFnord](https://github.com/LeFnord).
|
44
|
+
|
45
|
+
|
20
46
|
### 0.32.1 (December 7, 2018)
|
21
47
|
|
22
48
|
#### Fixes
|
@@ -24,6 +50,7 @@
|
|
24
50
|
* [#731](https://github.com/ruby-grape/grape-swagger/pull/731): Skip empty parameters and tags arrays - [@fotos](https://github.com/fotos).
|
25
51
|
* [#729](https://github.com/ruby-grape/grape-swagger/pull/729): Allow empty security array for endpoints - [@fotos](https://github.com/fotos).
|
26
52
|
|
53
|
+
|
27
54
|
### 0.32.0 (November 26, 2018)
|
28
55
|
|
29
56
|
#### Features
|
@@ -34,13 +61,15 @@
|
|
34
61
|
|
35
62
|
* [#720](https://github.com/ruby-grape/grape-swagger/pull/720): Fix: corrected `termsOfService` field name in additional info - [@dblock](https://github.com/dblock).
|
36
63
|
|
64
|
+
|
37
65
|
### 0.31.1 (October 23, 2018)
|
38
66
|
|
39
67
|
#### Features
|
40
68
|
|
41
69
|
* [#710](https://github.com/ruby-grape/grape-swagger/issues/710): Re-implement `api_documentation` and `specific_api_documentation` options - [@dblock](https://github.com/dblock).
|
42
70
|
|
43
|
-
|
71
|
+
|
72
|
+
### 0.31.0 (August 22, 2018)
|
44
73
|
|
45
74
|
#### Features
|
46
75
|
|
@@ -50,13 +79,15 @@
|
|
50
79
|
* [#691](https://github.com/ruby-grape/grape-swagger/pull/691): Disregard order when parsing request params for arrays - [@jdmurphy](https://github.com/jdmurphy).
|
51
80
|
* [#696](https://github.com/ruby-grape/grape-swagger/pull/696): Delegate required properties parsing to model parsers - [@Bugagazavr](https://github.com/Bugagazavr).
|
52
81
|
|
53
|
-
|
82
|
+
|
83
|
+
### 0.30.1 (July 19, 2018)
|
54
84
|
|
55
85
|
#### Features
|
56
86
|
|
57
87
|
* [#686](https://github.com/ruby-grape/grape-swagger/pull/686): Allow response headers for responses with no content and for files - [@jdmurphy](https://github.com/jdmurphy).
|
58
88
|
|
59
|
-
|
89
|
+
|
90
|
+
### 0.30.0 (July 19, 2018)
|
60
91
|
|
61
92
|
#### Features
|
62
93
|
|
@@ -67,7 +98,8 @@
|
|
67
98
|
* [#681](https://github.com/ruby-grape/grape-swagger/pull/681): Provide error schemas when an endpoint can return a 204 - [@adstratm](https://github.com/adstratm).
|
68
99
|
* [#683](https://github.com/ruby-grape/grape-swagger/pull/683): Fix handling of arrays of complex entities in params so that valid OpenAPI spec is generated - [@jdmurphy](https://github.com/jdmurphy).
|
69
100
|
|
70
|
-
|
101
|
+
|
102
|
+
### 0.29.0 (May 22, 2018)
|
71
103
|
|
72
104
|
#### Features
|
73
105
|
|
@@ -81,6 +113,7 @@
|
|
81
113
|
* [#669](https://github.com/ruby-grape/grape-swagger/pull/669): Fix handling of http status codes from routes - [@milgner](https://github.com/milgner).
|
82
114
|
* [#672](https://github.com/ruby-grape/grape-swagger/pull/672): Rename 'notes' to 'detail' in README - [@kjleitz](https://github.com/kjleitz).
|
83
115
|
|
116
|
+
|
84
117
|
### 0.28.0 (February 3, 2018)
|
85
118
|
|
86
119
|
#### Features
|
@@ -97,6 +130,7 @@
|
|
97
130
|
* [#654](https://github.com/ruby-grape/grape-swagger/pull/654): Allow setting the consumes for PATCH methods - [@anakinj](https://github.com/anakinj).
|
98
131
|
* [#656](https://github.com/ruby-grape/grape-swagger/pull/656): Fix `description` field may be null - [@soranoba](https://github.com/soranoba).
|
99
132
|
|
133
|
+
|
100
134
|
### 0.27.3 (July 11, 2017)
|
101
135
|
|
102
136
|
#### Features
|
@@ -107,6 +141,7 @@
|
|
107
141
|
|
108
142
|
* [#616](https://github.com/ruby-grape/grape-swagger/pull/616): Fix swagger to show root path ([#605](https://github.com/ruby-grape/grape-swagger/issue/605)) - [@NightWolf007](https://github.com/NightWolf007).
|
109
143
|
|
144
|
+
|
110
145
|
### 0.27.2 (May 11, 2017)
|
111
146
|
|
112
147
|
#### Features
|
@@ -115,13 +150,15 @@
|
|
115
150
|
* [#596](https://github.com/ruby-grape/grape-swagger/pull/596): Use route_settings for hidden and operations extensions - [@thogg4](https://github.com/thogg4).
|
116
151
|
* [#607](https://github.com/ruby-grape/grape-swagger/pull/607): Allow body parameter name to be specified - [@tjwp](https://github.com/tjwp).
|
117
152
|
|
153
|
+
|
118
154
|
### 0.27.1 (April 28, 2017)
|
119
155
|
|
120
156
|
#### Features
|
121
157
|
|
122
158
|
* [#602](https://github.com/ruby-grape/grape-swagger/pull/602): Allow security object to be defined - [@markevich](https://github.com/markevich).
|
123
159
|
|
124
|
-
|
160
|
+
|
161
|
+
### 0.27.0 (March 27, 2017)
|
125
162
|
|
126
163
|
#### Features
|
127
164
|
|
@@ -136,6 +173,7 @@
|
|
136
173
|
* [#586](https://github.com/ruby-grape/grape-swagger/pull/586): Issue #587: Parameters delimited by dash cause exception - [@risa](https://github.com/risa).
|
137
174
|
* [#593](https://github.com/ruby-grape/grape-swagger/pull/593): Clarify hidden option in readme - [@thogg4](https://github.com/thogg4).
|
138
175
|
|
176
|
+
|
139
177
|
### 0.26.1 (February 3, 2017)
|
140
178
|
|
141
179
|
#### Features
|
@@ -150,6 +188,7 @@
|
|
150
188
|
* [#562](https://github.com/ruby-grape/grape-swagger/pull/562): The guard method should allow regular object methods as arguments - [@tim-vandecasteele](https://github.com/tim-vandecasteele).
|
151
189
|
* [#574](https://github.com/ruby-grape/grape-swagger/pull/574): Fixes #572: `is_array` should only be applied to success - [@LeFnord](https://github.com/LeFnord).
|
152
190
|
|
191
|
+
|
153
192
|
### 0.26.0 (January 9, 2017)
|
154
193
|
|
155
194
|
#### Features
|
@@ -162,6 +201,7 @@
|
|
162
201
|
|
163
202
|
* [#561](https://github.com/ruby-grape/grape-swagger/pull/561): Rename failures to failure in readme - [@justincampbell](https://github.com/justincampbell).
|
164
203
|
|
204
|
+
|
165
205
|
### 0.25.3 (December 18, 2016)
|
166
206
|
|
167
207
|
#### Features
|
@@ -175,12 +215,14 @@
|
|
175
215
|
* [#548](https://github.com/ruby-grape/grape-swagger/pull/548): Remove dots from operation id - [@frodrigo](https://github.com/frodrigo).
|
176
216
|
* [#553](https://github.com/ruby-grape/grape-swagger/pull/553): Align array params for post, put request - addition to [#540](https://github.com/ruby-grape/grape-swagger/pull/540) - [@LeFnord](https://github.com/LeFnord).
|
177
217
|
|
218
|
+
|
178
219
|
### 0.25.2 (November 30, 2016)
|
179
220
|
|
180
221
|
#### Fixes
|
181
222
|
|
182
223
|
* [#544](https://github.com/ruby-grape/grape-swagger/pull/544): Fixes #539 and #542; not all of 530 was commited - [@LeFnord](https://github.com/LeFnord).
|
183
224
|
|
225
|
+
|
184
226
|
### 0.25.1 (November 29, 2016)
|
185
227
|
|
186
228
|
#### Features
|
@@ -193,6 +235,7 @@
|
|
193
235
|
* [#540](https://github.com/ruby-grape/grape-swagger/pull/540): Corrects exposing of array in post body - [@LeFnord](https://github.com/LeFnord).
|
194
236
|
* [#509](https://github.com/ruby-grape/grape-swagger/pull/509), [#529](https://github.com/ruby-grape/grape-swagger/pull/529): Making parent-less routes working - [@mur-wtag](https://github.com/mur-wtag).
|
195
237
|
|
238
|
+
|
196
239
|
### 0.25.0 (October 31, 2016)
|
197
240
|
|
198
241
|
#### Features
|
@@ -208,6 +251,7 @@
|
|
208
251
|
* [#515](https://github.com/ruby-grape/grape-swagger/pull/515): Removes limit on model names - [@LeFnord](https://github.com/LeFnord).
|
209
252
|
* [#511](https://github.com/ruby-grape/grape-swagger/pull/511): Fix incorrect data type linking for request params of entity types - [@serggl](https://github.com/serggl).
|
210
253
|
|
254
|
+
|
211
255
|
### 0.24.0 (September 23, 2016)
|
212
256
|
|
213
257
|
#### Features
|
@@ -226,6 +270,7 @@
|
|
226
270
|
* [#494](https://github.com/ruby-grape/grape-swagger/pull/494): Header parametes are now included in documentation when body parameters have been defined - [@anakinj](https://github.com/anakinj).
|
227
271
|
* [#505](https://github.com/ruby-grape/grape-swagger/pull/505): Combines namespaces with their mounted paths to allow APIs with specified mount_paths - [@KevinLiddle](https://github.com/KevinLiddle).
|
228
272
|
|
273
|
+
|
229
274
|
### 0.23.0 (August 5, 2016)
|
230
275
|
|
231
276
|
#### Features
|
@@ -241,6 +286,7 @@
|
|
241
286
|
* [#479](https://github.com/ruby-grape/grape-swagger/pull/479): Fix regex for Array and Multi Type in doc_methods. Parsing of "[APoint]" should return "APoint" - [@frodrigo](https://github.com/frodrigo).
|
242
287
|
* [#483](https://github.com/ruby-grape/grape-swagger/pull/483): Added support for nicknamed routes - [@pbendersky](https://github.com/pbendersky).
|
243
288
|
|
289
|
+
|
244
290
|
### 0.22.0 (July 12, 2016)
|
245
291
|
|
246
292
|
#### Features
|
@@ -265,6 +311,7 @@
|
|
265
311
|
* [#454](https://github.com/ruby-grape/grape-swagger/pull/454): Include documented Hashes in documentation output - [@aschuster3](https://github.com/aschuster3).
|
266
312
|
* [#457](https://github.com/ruby-grape/grape-swagger/issues/457): Using camel case on namespace throws exception on add_swagger_documentation method - [@rayko](https://github.com/rayko).
|
267
313
|
|
314
|
+
|
268
315
|
### 0.21.0 (June 1, 2016)
|
269
316
|
|
270
317
|
#### Features
|
@@ -280,6 +327,7 @@
|
|
280
327
|
* [#420](https://github.com/ruby-grape/grape-swagger/pull/420): Raise SwaggerSpec exception if swagger spec isn't satisfied, when no parser for model is registered or response model is empty - [@Bugagazavr](https://github.com/Bugagazavr).
|
281
328
|
* [#438](https://github.com/ruby-grape/grape-swagger/pull/438): Route version was missing in :options passed to PathString, so Endpoint.path_and_definitions_objects wasn't returning a versioned path when required - [@texpert](https://github.com/texpert).
|
282
329
|
|
330
|
+
|
283
331
|
### 0.20.3 (May 9, 2016)
|
284
332
|
|
285
333
|
#### Features
|
@@ -294,6 +342,7 @@
|
|
294
342
|
|
295
343
|
* [#399](https://github.com/ruby-grape/grape-swagger/pull/399), [#395](https://github.com/ruby-grape/grape-swagger/issues/395): Make param description optional - [@LeFnord](https://github.com/LeFnord).
|
296
344
|
|
345
|
+
|
297
346
|
### 0.20.2 (April 22, 2016)
|
298
347
|
|
299
348
|
#### Fixes
|
@@ -302,6 +351,7 @@
|
|
302
351
|
* [#393](https://github.com/ruby-grape/grape-swagger/pull/393): Properly handle header parameters - [@wleeper](https://github.com/wleeper).
|
303
352
|
* [#389](https://github.com/ruby-grape/grape-swagger/pull/389): Respect X-Forwarded-Host - [@edvakf](https://github.com/edvakf).
|
304
353
|
|
354
|
+
|
305
355
|
### 0.20.1 (April 17, 2016)
|
306
356
|
|
307
357
|
#### Features
|
@@ -313,6 +363,7 @@
|
|
313
363
|
|
314
364
|
* [#383](https://github.com/ruby-grape/grape-swagger/pull/383): Fixed support for Grape 0.12.0 through 0.14.0 - [@LeFnord](https://github.com/LeFnord).
|
315
365
|
|
366
|
+
|
316
367
|
### 0.20.0 (April 9, 2016)
|
317
368
|
|
318
369
|
#### Features
|
@@ -326,10 +377,12 @@
|
|
326
377
|
* [#354](https://github.com/ruby-grape/grape-swagger/pull/354): Fixed setting of `base_path` and `host`, added possibility to configure the setting of `version` and `base_path` in documented path and `operationId` - [@LeFnord](https://github.com/LeFnord).
|
327
378
|
* [#353](https://github.com/ruby-grape/grape-swagger/pull/353), [#352](https://github.com/ruby-grape/grape-swagger/pull/353): Fixed exception with routes having a dynamic `:section` - [@LeFnord](https://github.com/LeFnord).
|
328
379
|
|
380
|
+
|
329
381
|
### 0.10.5 (April 12, 2016)
|
330
382
|
|
331
383
|
* [#344](https://github.com/ruby-grape/grape-swagger/pull/344): Namespace based tag included in Swagger JSON - [@LeFnord](https://github.com/LeFnord).
|
332
384
|
|
385
|
+
|
333
386
|
### 0.10.2 (August 19, 2015)
|
334
387
|
|
335
388
|
#### Features
|
@@ -354,11 +407,13 @@
|
|
354
407
|
* [#284](https://github.com/ruby-grape/grape-swagger/pull/284): Use new params syntax for swagger doc endpoint, fix an issue that `:name` params not recognized by `declared` method - [@calfzhou](https://github.com/calfzhou).
|
355
408
|
* [#286](https://github.com/ruby-grape/grape-swagger/pull/286): Use `detail` value for `notes` - fix an issue where `detail` value specified in a block passed to `desc` was ignored - [@rngtng](https://github.com/rngtng).
|
356
409
|
|
410
|
+
|
357
411
|
### 0.10.1 (March 11, 2015)
|
358
412
|
|
359
413
|
* [#227](https://github.com/ruby-grape/grape-swagger/issues/227): Fix: nested routes under prefix not documented - [@dblock](https://github.com/dblock).
|
360
414
|
* [#226](https://github.com/ruby-grape/grape-swagger/issues/226): Fix: be defensive with nil exposure types - [@dblock](https://github.com/dblock).
|
361
415
|
|
416
|
+
|
362
417
|
### 0.10.0 (March 10, 2015)
|
363
418
|
|
364
419
|
#### Features
|
@@ -378,6 +433,7 @@
|
|
378
433
|
* [#208](https://github.com/ruby-grape/grape-swagger/pull/208): Fixed `Float` parameters, exposed as Swagger `float` types - [@u2](https://github.com/u2).
|
379
434
|
* [#216](https://github.com/ruby-grape/grape-swagger/pull/216), [#192](https://github.com/ruby-grape/grape-swagger/issues/192), [#189](https://github.com/ruby-grape/grape-swagger/issues/189): Fixed API route paths matching for root endpoints with `grape ~> 0.10.0`, specific `format` and `:path` versioning - [@dm1try](https://github.com/dm1try), [@minch](https://github.com/minch).
|
380
435
|
|
436
|
+
|
381
437
|
### 0.9.0 (December 19, 2014)
|
382
438
|
|
383
439
|
* [#91](https://github.com/ruby-grape/grape-swagger/issues/91): Fixed empty field for group parameters' name with type hash or Array - [@dukedave](https://github.com/dukedave).
|
@@ -392,6 +448,7 @@
|
|
392
448
|
* [#167](https://github.com/ruby-grape/grape-swagger/pull/167): Support mutli-tenanted APIs, don't cache `base_path` - [@bradrobertson](https://github.com/bradrobertson), (https://github.com/dblock).
|
393
449
|
* [#185](https://github.com/ruby-grape/grape-swagger/pull/185): Support strings in `Grape::Entity.expose`'s `:using` option - [@jhollinger](https://github.com/jhollinger).
|
394
450
|
|
451
|
+
|
395
452
|
### 0.8.0 (August 30, 2014)
|
396
453
|
|
397
454
|
#### Features
|
@@ -421,6 +478,7 @@
|
|
421
478
|
* Added `GrapeSwagger::VERSION` - [@dblock](https://github.com/dblock).
|
422
479
|
* Added Rubocop, Ruby-style linter - [@dblock](https://github.com/dblock).
|
423
480
|
|
481
|
+
|
424
482
|
### 0.7.2 (February 6, 2014)
|
425
483
|
|
426
484
|
* [#84](https://github.com/ruby-grape/grape-swagger/pull/84): Markdown is now Github Flavored Markdown - [@jeromegn](https://github.com/jeromegn).
|
@@ -438,6 +496,7 @@
|
|
438
496
|
* [#54](https://github.com/ruby-grape/grape-swagger/pull/54): Adding support for generating swagger `responseClass` and models from Grape Entities - [@calebwoods](https://github.com/calebwoods).
|
439
497
|
* [#46](https://github.com/ruby-grape/grape-swagger/pull/46): Fixed translating parameter `type` to String, enables using Mongoid fields as parameter definitions - [@dblock](https://github.com/dblock).
|
440
498
|
|
499
|
+
|
441
500
|
### 0.6.0 (June 19, 2013)
|
442
501
|
|
443
502
|
* Added Rails 4 support - [@jrhe](https://github.com/jrhe).
|
@@ -446,14 +505,17 @@
|
|
446
505
|
* Support both `:desc` and `:description` when describing parameters - [@dblock](https://github.com/dblock).
|
447
506
|
* Fix: allow parameters such as `name[]` - [@dblock](https://github.com/dblock).
|
448
507
|
|
508
|
+
|
449
509
|
### 0.5.0 (March 28, 2013)
|
450
510
|
|
451
511
|
* Added Grape 0.5.0 support - [@ruby-grape](https://github.com/ruby-grape).
|
452
512
|
|
513
|
+
|
453
514
|
### 0.4.0 (March 28, 2013)
|
454
515
|
|
455
516
|
* Support https - [@cutalion](https://github.com/cutalion).
|
456
517
|
|
518
|
+
|
457
519
|
### 0.3.0 (October 19, 2012)
|
458
520
|
|
459
521
|
* Added version support - [@agileanimal](https://github.com/agileanimal), [@fknappe](https://github.com/fknappe).
|
@@ -461,24 +523,28 @@
|
|
461
523
|
* Added basic support for specifying parameters that need to be passed in the header - [@agileanimal](https://github.com/agileanimal).
|
462
524
|
* Add possibility to hide the documentation paths in the generated swagger documentation - [@ruby-grape](https://github.com/ruby-grape).
|
463
525
|
|
526
|
+
|
464
527
|
### 0.2.1 (August 17, 2012)
|
465
528
|
|
466
529
|
* Added support for markdown in notes field - [@ruby-grape](https://github.com/ruby-grape).
|
467
530
|
* Fix: compatibility with Rails - [@qwert666](https://github.com/qwert666).
|
468
531
|
* Fix: swagger UI history - [@ruby-grape](https://github.com/ruby-grape).
|
469
532
|
|
533
|
+
|
470
534
|
### 0.2.0 (July 27, 2012)
|
471
535
|
|
472
536
|
* Use resource as root for swagger - [@ruby-grape](https://github.com/ruby-grape).
|
473
537
|
* Added support for file uploads, and proper `paramType` - [@ruby-grape](https://github.com/ruby-grape).
|
474
538
|
* Added tests - [@nathanvda](https://github.com/nathanvda).
|
475
539
|
|
540
|
+
|
476
541
|
### 0.1.0 (July 19, 2012)
|
477
542
|
|
478
543
|
* Added some configurability to the generated documentation - [@ruby-grape](https://github.com/ruby-grape).
|
479
544
|
* Adapted to rails plugin structure - [@ruby-grape](https://github.com/ruby-grape).
|
480
545
|
* Allowed cross origin, so swagger can be used from official site - [@ruby-grape](https://github.com/ruby-grape).
|
481
546
|
|
547
|
+
|
482
548
|
### 0.0.0 (July 19, 2012)
|
483
549
|
|
484
550
|
* Initial public release - [@ruby-grape](https://github.com/ruby-grape).
|
data/Gemfile
CHANGED
@@ -6,7 +6,7 @@ ruby RUBY_VERSION
|
|
6
6
|
|
7
7
|
gemspec
|
8
8
|
|
9
|
-
gem 'grape', case version = ENV['GRAPE_VERSION'] || '
|
9
|
+
gem 'grape', case version = ENV['GRAPE_VERSION'] || '< 1.3.0'
|
10
10
|
when 'HEAD'
|
11
11
|
{ git: 'https://github.com/ruby-grape/grape' }
|
12
12
|
else
|
@@ -14,19 +14,18 @@ gem 'grape', case version = ENV['GRAPE_VERSION'] || '~> 1.2'
|
|
14
14
|
end
|
15
15
|
|
16
16
|
gem ENV['MODEL_PARSER'] if ENV.key?('MODEL_PARSER')
|
17
|
-
|
18
17
|
group :development, :test do
|
19
18
|
gem 'bundler'
|
20
19
|
gem 'grape-entity'
|
21
20
|
gem 'pry', platforms: [:mri]
|
22
21
|
gem 'pry-byebug', platforms: [:mri]
|
23
|
-
|
22
|
+
|
24
23
|
gem 'rack-cors'
|
25
24
|
gem 'rack-test'
|
26
25
|
gem 'rake'
|
27
26
|
gem 'rdoc'
|
28
|
-
gem 'rspec', '~> 3.
|
29
|
-
gem 'rubocop', '~> 0.
|
27
|
+
gem 'rspec', '~> 3.9'
|
28
|
+
gem 'rubocop', '~> 0.75', require: false
|
30
29
|
end
|
31
30
|
|
32
31
|
group :test do
|
data/README.md
CHANGED
@@ -48,9 +48,10 @@ grape-swagger | swagger spec | grape | grape-entity | represen
|
|
48
48
|
0.10.5 | 1.2 | >= 0.10.0 ... <= 0.14.0 | < 0.5.0 | n/a |
|
49
49
|
0.11.0 | 1.2 | >= 0.16.2 | < 0.5.0 | n/a |
|
50
50
|
0.25.2 | 2.0 | >= 0.14.0 ... <= 0.18.0 | <= 0.6.0 | >= 2.4.1 |
|
51
|
-
0.26.0 | 2.0 | >= 0.16.2
|
51
|
+
0.26.0 | 2.0 | >= 0.16.2 ... <= 1.1.0 | <= 0.6.1 | >= 2.4.1 |
|
52
52
|
0.27.0 | 2.0 | >= 0.16.2 ... <= 1.1.0 | >= 0.5.0 | >= 2.4.1 |
|
53
53
|
0.32.0 | 2.0 | >= 0.16.2 | >= 0.5.0 | >= 2.4.1 |
|
54
|
+
0.34.0 | 2.0 | >= 0.16.2 ... < 1.3.0 | >= 0.5.0 | >= 2.4.1 |
|
54
55
|
|
55
56
|
|
56
57
|
## Swagger-Spec <a name="swagger-spec"></a>
|
@@ -104,9 +105,9 @@ Also added support for [representable](https://github.com/apotonick/representabl
|
|
104
105
|
|
105
106
|
```ruby
|
106
107
|
# For Grape::Entity ( https://github.com/ruby-grape/grape-entity )
|
107
|
-
gem 'grape-swagger-entity'
|
108
|
+
gem 'grape-swagger-entity', '~> 0.3'
|
108
109
|
# For representable ( https://github.com/apotonick/representable )
|
109
|
-
gem 'grape-swagger-representable'
|
110
|
+
gem 'grape-swagger-representable', '~> 0.2'
|
110
111
|
```
|
111
112
|
|
112
113
|
If you are not using Rails, make sure to load the parser inside your application initialization logic, e.g., via `require 'grape-swagger/entity'` or `require 'grape-swagger/representable'`.
|
@@ -189,6 +190,7 @@ end
|
|
189
190
|
* [base_path](#base_path)
|
190
191
|
* [mount_path](#mount_path)
|
191
192
|
* [add_base_path](#add_base_path)
|
193
|
+
* [add_root](#add_root)
|
192
194
|
* [add_version](#add_version)
|
193
195
|
* [doc_version](#doc_version)
|
194
196
|
* [endpoint_auth_wrapper](#endpoint_auth_wrapper)
|
@@ -248,6 +250,13 @@ add_swagger_documentation \
|
|
248
250
|
add_base_path: true # only if base_path given
|
249
251
|
```
|
250
252
|
|
253
|
+
#### add_root: <a name="add_root"></a>
|
254
|
+
Add root element to all the responses, default is: `false`.
|
255
|
+
```ruby
|
256
|
+
add_swagger_documentation \
|
257
|
+
add_root: true
|
258
|
+
```
|
259
|
+
|
251
260
|
#### add_version: <a name="add_version"></a>
|
252
261
|
|
253
262
|
Add `version` key to the documented path keys, default is: `true`,
|
@@ -447,6 +456,7 @@ add_swagger_documentation \
|
|
447
456
|
* [Extensions](#extensions)
|
448
457
|
* [Response examples documentation](#response-examples)
|
449
458
|
* [Response headers documentation](#response-headers)
|
459
|
+
* [Adding root element to responses](#response-root)
|
450
460
|
|
451
461
|
#### Swagger Header Parameters <a name="headers"></a>
|
452
462
|
|
@@ -913,7 +923,7 @@ desc 'Attach a field to an entity through a PUT',
|
|
913
923
|
failure: [
|
914
924
|
{ code: 400, message: 'Bad request' },
|
915
925
|
{ code: 404, message: 'Not found' }
|
916
|
-
]
|
926
|
+
]
|
917
927
|
put do
|
918
928
|
# your code comes here
|
919
929
|
end
|
@@ -1180,6 +1190,60 @@ The result will look like following:
|
|
1180
1190
|
|
1181
1191
|
Failure information can be passed as an array of arrays or an array of hashes.
|
1182
1192
|
|
1193
|
+
#### Adding root element to responses <a name="response-root"></a>
|
1194
|
+
|
1195
|
+
You can specify a custom root element for a successful response:
|
1196
|
+
|
1197
|
+
```ruby
|
1198
|
+
route_setting :swagger, root: 'cute_kitten'
|
1199
|
+
desc 'Get a kitten' do
|
1200
|
+
http_codes [{ code: 200, model: Entities::Kitten }]
|
1201
|
+
end
|
1202
|
+
get '/kittens/:id' do
|
1203
|
+
end
|
1204
|
+
```
|
1205
|
+
|
1206
|
+
The result will look like following:
|
1207
|
+
|
1208
|
+
```
|
1209
|
+
"responses": {
|
1210
|
+
"200": {
|
1211
|
+
"description": "Get a kitten",
|
1212
|
+
"schema": {
|
1213
|
+
"type": "object",
|
1214
|
+
"properties": { "cute_kitten": { "$ref": "#/definitions/Kitten" } }
|
1215
|
+
}
|
1216
|
+
}
|
1217
|
+
}
|
1218
|
+
```
|
1219
|
+
|
1220
|
+
If you specify `true`, the value of the root element will be deduced based on the model name.
|
1221
|
+
E.g. in the following example the root element will be "kittens":
|
1222
|
+
|
1223
|
+
```ruby
|
1224
|
+
route_setting :swagger, root: true
|
1225
|
+
desc 'Get kittens' do
|
1226
|
+
is_array true
|
1227
|
+
http_codes [{ code: 200, model: Entities::Kitten }]
|
1228
|
+
end
|
1229
|
+
get '/kittens' do
|
1230
|
+
end
|
1231
|
+
```
|
1232
|
+
|
1233
|
+
The result will look like following:
|
1234
|
+
|
1235
|
+
```
|
1236
|
+
"responses": {
|
1237
|
+
"200": {
|
1238
|
+
"description": "Get kittens",
|
1239
|
+
"schema": {
|
1240
|
+
"type": "object",
|
1241
|
+
"properties": { "type": "array", "items": { "kittens": { "$ref": "#/definitions/Kitten" } } }
|
1242
|
+
}
|
1243
|
+
}
|
1244
|
+
}
|
1245
|
+
```
|
1246
|
+
|
1183
1247
|
## Using Grape Entities <a name="grape-entity"></a>
|
1184
1248
|
|
1185
1249
|
Add the [grape-entity](https://github.com/ruby-grape/grape-entity) and [grape-swagger-entity](https://github.com/ruby-grape/grape-swagger-entity) gem to your Gemfile.
|
data/grape-swagger.gemspec
CHANGED
@@ -14,7 +14,8 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.license = 'MIT'
|
15
15
|
|
16
16
|
s.required_ruby_version = '>= 2.4'
|
17
|
-
s.add_runtime_dependency 'grape', '>= 0.16.2'
|
17
|
+
s.add_runtime_dependency 'grape', '>= 0.16.2', '< 1.3.0'
|
18
|
+
s.add_runtime_dependency 'rack', '2.0.8'
|
18
19
|
|
19
20
|
s.files = `git ls-files`.split("\n")
|
20
21
|
s.test_files = `git ls-files -- {test,spec}/*`.split("\n")
|
@@ -25,27 +25,10 @@ module GrapeSwagger
|
|
25
25
|
|
26
26
|
def parse_entity(model)
|
27
27
|
return unless model.respond_to?(:documentation)
|
28
|
-
|
29
|
-
deprecated_workflow_for('grape-swagger-entity')
|
30
|
-
|
31
|
-
model.documentation
|
32
|
-
.select { |_name, options| options[:required] }
|
33
|
-
.map { |name, options| options[:as] || name }
|
34
28
|
end
|
35
29
|
|
36
30
|
def parse_representable(model)
|
37
31
|
return unless model.respond_to?(:map)
|
38
|
-
|
39
|
-
deprecated_workflow_for('grape-swagger-representable')
|
40
|
-
|
41
|
-
model.map
|
42
|
-
.select { |p| p[:documentation] && p[:documentation][:required] }
|
43
|
-
.map(&:name)
|
44
|
-
end
|
45
|
-
|
46
|
-
def deprecated_workflow_for(gem_name)
|
47
|
-
warn "DEPRECATED: You are using old #{gem_name} version, which doesn't provide " \
|
48
|
-
"required attributes. To solve this problem, please update #{gem_name}"
|
49
32
|
end
|
50
33
|
end
|
51
34
|
end
|
@@ -87,7 +87,12 @@ module GrapeSwagger
|
|
87
87
|
part.select { |x| x == identifier }
|
88
88
|
end
|
89
89
|
|
90
|
-
def method
|
90
|
+
def method(*args)
|
91
|
+
# We're shadowing Object.method(:symbol) here so we provide
|
92
|
+
# a compatibility layer for code that introspects the methods
|
93
|
+
# of this class
|
94
|
+
return super if args.size.positive?
|
95
|
+
|
91
96
|
@route.request_method.downcase.to_sym
|
92
97
|
end
|
93
98
|
end
|