grape-swagger 0.33.0 → 1.0.0
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 +11 -10
- data/CHANGELOG.md +75 -5
- data/Gemfile +5 -5
- data/README.md +73 -5
- data/grape-swagger.gemspec +1 -1
- data/lib/grape-swagger/doc_methods/build_model_definition.rb +0 -17
- data/lib/grape-swagger/doc_methods/data_type.rb +1 -1
- 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 +22 -22
- data/lib/grape-swagger/endpoint.rb +33 -14
- 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/data_type_spec.rb +2 -2
- data/spec/lib/endpoint/params_parser_spec.rb +46 -21
- data/spec/lib/endpoint_spec.rb +4 -4
- 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/support/model_parsers/entity_parser.rb +1 -1
- data/spec/support/model_parsers/representable_parser.rb +1 -1
- data/spec/swagger_v2/api_swagger_v2_hash_and_array_spec.rb +3 -1
- data/spec/swagger_v2/api_swagger_v2_hide_param_spec.rb +14 -3
- data/spec/swagger_v2/api_swagger_v2_response_with_root_spec.rb +153 -0
- data/spec/swagger_v2/boolean_params_spec.rb +1 -1
- 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 +20 -13
- 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: a02b298de5d3db8a877e2d19c3a33d926793beea5f6de12f637a142593ebf6cd
|
4
|
+
data.tar.gz: d794323888e880667ba53916e4b8e028c200910309da26fbbc823c5a1a11f4d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f52b468dcfc8bb22a52a2b0d3cb9609d9b512c31836c69644dfbfbb63ece456dfa9e0eb3200b54006bda1ebac848bf10538bed4ab7cc92241af19b63c01451e4
|
7
|
+
data.tar.gz: ccf7750c17e52a0172b5c8d6df101ebad543e9960793267e6d607be4f812e7dd1d6d3fab8cd07919b4bee39dad80c6ac3f79628ece4d4fd45c51314a6cc6049c
|
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
@@ -1,5 +1,7 @@
|
|
1
1
|
language: ruby
|
2
2
|
|
3
|
+
os: linux
|
4
|
+
|
3
5
|
before_install:
|
4
6
|
- gem install bundler
|
5
7
|
|
@@ -7,21 +9,20 @@ after_success:
|
|
7
9
|
- bundle exec danger
|
8
10
|
|
9
11
|
rvm:
|
10
|
-
- 2.
|
11
|
-
- 2.
|
12
|
-
- 2.
|
12
|
+
- 2.5.7
|
13
|
+
- 2.6.5
|
14
|
+
- 2.7.0
|
13
15
|
env:
|
14
|
-
- MODEL_PARSER=grape-swagger-entity
|
15
|
-
- MODEL_PARSER=grape-swagger-representable
|
16
|
-
- GRAPE_VERSION=1.0
|
17
|
-
- GRAPE_VERSION=1.2.4
|
16
|
+
- GRAPE_VERSION=1.3.0 MODEL_PARSER=grape-swagger-entity
|
17
|
+
- GRAPE_VERSION=1.3.0 MODEL_PARSER=grape-swagger-representable
|
18
|
+
- GRAPE_VERSION=1.3.0
|
18
19
|
- GRAPE_VERSION=HEAD
|
19
20
|
|
20
|
-
|
21
|
+
jobs:
|
21
22
|
fast_finish: true
|
22
23
|
|
23
24
|
include:
|
24
|
-
- rvm: 2.
|
25
|
+
- rvm: 2.4.9
|
25
26
|
env:
|
26
27
|
- rvm: ruby-head
|
27
28
|
env:
|
@@ -29,6 +30,6 @@ matrix:
|
|
29
30
|
env:
|
30
31
|
|
31
32
|
allow_failures:
|
32
|
-
- rvm: 2.
|
33
|
+
- rvm: 2.4.9
|
33
34
|
- rvm: ruby-head
|
34
35
|
- rvm: jruby-head
|
data/CHANGELOG.md
CHANGED
@@ -3,11 +3,36 @@
|
|
3
3
|
#### Features
|
4
4
|
|
5
5
|
* Your contribution here.
|
6
|
+
* [#777](https://github.com/ruby-grape/grape-swagger/pull/777): Make usage of grape >= 1.3, rack >= 2.1 - [@LeFnord](https://github.com/LeFnord).
|
7
|
+
* [#775](https://github.com/ruby-grape/grape-swagger/pull/775): Add in token_owner support to param hidden procs - [@urkle](https://github.com/urkle).
|
6
8
|
|
7
9
|
#### Fixes
|
8
10
|
|
9
11
|
* Your contribution here.
|
10
12
|
|
13
|
+
### 0.34.2 (January 20, 2020)
|
14
|
+
|
15
|
+
#### Fixes
|
16
|
+
|
17
|
+
* [#773](https://github.com/ruby-grape/grape-swagger/pull/773): Freeze rack version to 2.0.8 - [@LeFnord](https://github.com/LeFnord).
|
18
|
+
|
19
|
+
|
20
|
+
### 0.34.0 (January 11, 2020)
|
21
|
+
|
22
|
+
#### Features
|
23
|
+
|
24
|
+
* [#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).
|
25
|
+
* [#761](https://github.com/ruby-grape/grape-swagger/pull/761): Add an option to configure root element for responses - [@bikolya](https://github.com/bikolya).
|
26
|
+
* [#749](https://github.com/ruby-grape/grape-swagger/pull/749): Drop support for Ruby 2.3 and below - [@LeFnord](https://github.com/LeFnord).
|
27
|
+
|
28
|
+
#### Fixes
|
29
|
+
|
30
|
+
* [#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).
|
31
|
+
* [#757](https://github.com/ruby-grape/grape-swagger/pull/757): Fix `array_use_braces` for nested body params - [@bikolya](https://github.com/bikolya).
|
32
|
+
* [#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).
|
33
|
+
* [#764](https://github.com/ruby-grape/grape-swagger/pull/764): Fix root element for multi-word entities - [@bikolya](https://github.com/bikolya).
|
34
|
+
|
35
|
+
|
11
36
|
### 0.33.0 (June 21, 2019)
|
12
37
|
|
13
38
|
#### Fixes
|
@@ -17,6 +42,11 @@
|
|
17
42
|
* [#743](https://github.com/ruby-grape/grape-swagger/pull/743): CI: use 2.4.6, 2.5.5 - [@olleolleolle](https://github.com/olleolleolle).
|
18
43
|
* [#737](https://github.com/ruby-grape/grape-swagger/pull/737): Add swagger endpoint guard to both doc endpoints - [@urkle](https://github.com/urkle).
|
19
44
|
|
45
|
+
#### Changes
|
46
|
+
|
47
|
+
* [#749](https://github.com/ruby-grape/grape-swagger/pull/749) Drop support for Ruby 2.3 and below - [@LeFnord](https://github.com/LeFnord).
|
48
|
+
|
49
|
+
|
20
50
|
### 0.32.1 (December 7, 2018)
|
21
51
|
|
22
52
|
#### Fixes
|
@@ -24,6 +54,7 @@
|
|
24
54
|
* [#731](https://github.com/ruby-grape/grape-swagger/pull/731): Skip empty parameters and tags arrays - [@fotos](https://github.com/fotos).
|
25
55
|
* [#729](https://github.com/ruby-grape/grape-swagger/pull/729): Allow empty security array for endpoints - [@fotos](https://github.com/fotos).
|
26
56
|
|
57
|
+
|
27
58
|
### 0.32.0 (November 26, 2018)
|
28
59
|
|
29
60
|
#### Features
|
@@ -34,13 +65,15 @@
|
|
34
65
|
|
35
66
|
* [#720](https://github.com/ruby-grape/grape-swagger/pull/720): Fix: corrected `termsOfService` field name in additional info - [@dblock](https://github.com/dblock).
|
36
67
|
|
68
|
+
|
37
69
|
### 0.31.1 (October 23, 2018)
|
38
70
|
|
39
71
|
#### Features
|
40
72
|
|
41
73
|
* [#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
74
|
|
43
|
-
|
75
|
+
|
76
|
+
### 0.31.0 (August 22, 2018)
|
44
77
|
|
45
78
|
#### Features
|
46
79
|
|
@@ -50,13 +83,15 @@
|
|
50
83
|
* [#691](https://github.com/ruby-grape/grape-swagger/pull/691): Disregard order when parsing request params for arrays - [@jdmurphy](https://github.com/jdmurphy).
|
51
84
|
* [#696](https://github.com/ruby-grape/grape-swagger/pull/696): Delegate required properties parsing to model parsers - [@Bugagazavr](https://github.com/Bugagazavr).
|
52
85
|
|
53
|
-
|
86
|
+
|
87
|
+
### 0.30.1 (July 19, 2018)
|
54
88
|
|
55
89
|
#### Features
|
56
90
|
|
57
91
|
* [#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
92
|
|
59
|
-
|
93
|
+
|
94
|
+
### 0.30.0 (July 19, 2018)
|
60
95
|
|
61
96
|
#### Features
|
62
97
|
|
@@ -67,7 +102,8 @@
|
|
67
102
|
* [#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
103
|
* [#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
104
|
|
70
|
-
|
105
|
+
|
106
|
+
### 0.29.0 (May 22, 2018)
|
71
107
|
|
72
108
|
#### Features
|
73
109
|
|
@@ -81,6 +117,7 @@
|
|
81
117
|
* [#669](https://github.com/ruby-grape/grape-swagger/pull/669): Fix handling of http status codes from routes - [@milgner](https://github.com/milgner).
|
82
118
|
* [#672](https://github.com/ruby-grape/grape-swagger/pull/672): Rename 'notes' to 'detail' in README - [@kjleitz](https://github.com/kjleitz).
|
83
119
|
|
120
|
+
|
84
121
|
### 0.28.0 (February 3, 2018)
|
85
122
|
|
86
123
|
#### Features
|
@@ -97,6 +134,7 @@
|
|
97
134
|
* [#654](https://github.com/ruby-grape/grape-swagger/pull/654): Allow setting the consumes for PATCH methods - [@anakinj](https://github.com/anakinj).
|
98
135
|
* [#656](https://github.com/ruby-grape/grape-swagger/pull/656): Fix `description` field may be null - [@soranoba](https://github.com/soranoba).
|
99
136
|
|
137
|
+
|
100
138
|
### 0.27.3 (July 11, 2017)
|
101
139
|
|
102
140
|
#### Features
|
@@ -107,6 +145,7 @@
|
|
107
145
|
|
108
146
|
* [#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
147
|
|
148
|
+
|
110
149
|
### 0.27.2 (May 11, 2017)
|
111
150
|
|
112
151
|
#### Features
|
@@ -115,13 +154,15 @@
|
|
115
154
|
* [#596](https://github.com/ruby-grape/grape-swagger/pull/596): Use route_settings for hidden and operations extensions - [@thogg4](https://github.com/thogg4).
|
116
155
|
* [#607](https://github.com/ruby-grape/grape-swagger/pull/607): Allow body parameter name to be specified - [@tjwp](https://github.com/tjwp).
|
117
156
|
|
157
|
+
|
118
158
|
### 0.27.1 (April 28, 2017)
|
119
159
|
|
120
160
|
#### Features
|
121
161
|
|
122
162
|
* [#602](https://github.com/ruby-grape/grape-swagger/pull/602): Allow security object to be defined - [@markevich](https://github.com/markevich).
|
123
163
|
|
124
|
-
|
164
|
+
|
165
|
+
### 0.27.0 (March 27, 2017)
|
125
166
|
|
126
167
|
#### Features
|
127
168
|
|
@@ -136,6 +177,7 @@
|
|
136
177
|
* [#586](https://github.com/ruby-grape/grape-swagger/pull/586): Issue #587: Parameters delimited by dash cause exception - [@risa](https://github.com/risa).
|
137
178
|
* [#593](https://github.com/ruby-grape/grape-swagger/pull/593): Clarify hidden option in readme - [@thogg4](https://github.com/thogg4).
|
138
179
|
|
180
|
+
|
139
181
|
### 0.26.1 (February 3, 2017)
|
140
182
|
|
141
183
|
#### Features
|
@@ -150,6 +192,7 @@
|
|
150
192
|
* [#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
193
|
* [#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
194
|
|
195
|
+
|
153
196
|
### 0.26.0 (January 9, 2017)
|
154
197
|
|
155
198
|
#### Features
|
@@ -162,6 +205,7 @@
|
|
162
205
|
|
163
206
|
* [#561](https://github.com/ruby-grape/grape-swagger/pull/561): Rename failures to failure in readme - [@justincampbell](https://github.com/justincampbell).
|
164
207
|
|
208
|
+
|
165
209
|
### 0.25.3 (December 18, 2016)
|
166
210
|
|
167
211
|
#### Features
|
@@ -175,12 +219,14 @@
|
|
175
219
|
* [#548](https://github.com/ruby-grape/grape-swagger/pull/548): Remove dots from operation id - [@frodrigo](https://github.com/frodrigo).
|
176
220
|
* [#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
221
|
|
222
|
+
|
178
223
|
### 0.25.2 (November 30, 2016)
|
179
224
|
|
180
225
|
#### Fixes
|
181
226
|
|
182
227
|
* [#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
228
|
|
229
|
+
|
184
230
|
### 0.25.1 (November 29, 2016)
|
185
231
|
|
186
232
|
#### Features
|
@@ -193,6 +239,7 @@
|
|
193
239
|
* [#540](https://github.com/ruby-grape/grape-swagger/pull/540): Corrects exposing of array in post body - [@LeFnord](https://github.com/LeFnord).
|
194
240
|
* [#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
241
|
|
242
|
+
|
196
243
|
### 0.25.0 (October 31, 2016)
|
197
244
|
|
198
245
|
#### Features
|
@@ -208,6 +255,7 @@
|
|
208
255
|
* [#515](https://github.com/ruby-grape/grape-swagger/pull/515): Removes limit on model names - [@LeFnord](https://github.com/LeFnord).
|
209
256
|
* [#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
257
|
|
258
|
+
|
211
259
|
### 0.24.0 (September 23, 2016)
|
212
260
|
|
213
261
|
#### Features
|
@@ -226,6 +274,7 @@
|
|
226
274
|
* [#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
275
|
* [#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
276
|
|
277
|
+
|
229
278
|
### 0.23.0 (August 5, 2016)
|
230
279
|
|
231
280
|
#### Features
|
@@ -241,6 +290,7 @@
|
|
241
290
|
* [#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
291
|
* [#483](https://github.com/ruby-grape/grape-swagger/pull/483): Added support for nicknamed routes - [@pbendersky](https://github.com/pbendersky).
|
243
292
|
|
293
|
+
|
244
294
|
### 0.22.0 (July 12, 2016)
|
245
295
|
|
246
296
|
#### Features
|
@@ -265,6 +315,7 @@
|
|
265
315
|
* [#454](https://github.com/ruby-grape/grape-swagger/pull/454): Include documented Hashes in documentation output - [@aschuster3](https://github.com/aschuster3).
|
266
316
|
* [#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
317
|
|
318
|
+
|
268
319
|
### 0.21.0 (June 1, 2016)
|
269
320
|
|
270
321
|
#### Features
|
@@ -280,6 +331,7 @@
|
|
280
331
|
* [#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
332
|
* [#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
333
|
|
334
|
+
|
283
335
|
### 0.20.3 (May 9, 2016)
|
284
336
|
|
285
337
|
#### Features
|
@@ -294,6 +346,7 @@
|
|
294
346
|
|
295
347
|
* [#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
348
|
|
349
|
+
|
297
350
|
### 0.20.2 (April 22, 2016)
|
298
351
|
|
299
352
|
#### Fixes
|
@@ -302,6 +355,7 @@
|
|
302
355
|
* [#393](https://github.com/ruby-grape/grape-swagger/pull/393): Properly handle header parameters - [@wleeper](https://github.com/wleeper).
|
303
356
|
* [#389](https://github.com/ruby-grape/grape-swagger/pull/389): Respect X-Forwarded-Host - [@edvakf](https://github.com/edvakf).
|
304
357
|
|
358
|
+
|
305
359
|
### 0.20.1 (April 17, 2016)
|
306
360
|
|
307
361
|
#### Features
|
@@ -313,6 +367,7 @@
|
|
313
367
|
|
314
368
|
* [#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
369
|
|
370
|
+
|
316
371
|
### 0.20.0 (April 9, 2016)
|
317
372
|
|
318
373
|
#### Features
|
@@ -326,10 +381,12 @@
|
|
326
381
|
* [#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
382
|
* [#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
383
|
|
384
|
+
|
329
385
|
### 0.10.5 (April 12, 2016)
|
330
386
|
|
331
387
|
* [#344](https://github.com/ruby-grape/grape-swagger/pull/344): Namespace based tag included in Swagger JSON - [@LeFnord](https://github.com/LeFnord).
|
332
388
|
|
389
|
+
|
333
390
|
### 0.10.2 (August 19, 2015)
|
334
391
|
|
335
392
|
#### Features
|
@@ -354,11 +411,13 @@
|
|
354
411
|
* [#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
412
|
* [#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
413
|
|
414
|
+
|
357
415
|
### 0.10.1 (March 11, 2015)
|
358
416
|
|
359
417
|
* [#227](https://github.com/ruby-grape/grape-swagger/issues/227): Fix: nested routes under prefix not documented - [@dblock](https://github.com/dblock).
|
360
418
|
* [#226](https://github.com/ruby-grape/grape-swagger/issues/226): Fix: be defensive with nil exposure types - [@dblock](https://github.com/dblock).
|
361
419
|
|
420
|
+
|
362
421
|
### 0.10.0 (March 10, 2015)
|
363
422
|
|
364
423
|
#### Features
|
@@ -378,6 +437,7 @@
|
|
378
437
|
* [#208](https://github.com/ruby-grape/grape-swagger/pull/208): Fixed `Float` parameters, exposed as Swagger `float` types - [@u2](https://github.com/u2).
|
379
438
|
* [#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
439
|
|
440
|
+
|
381
441
|
### 0.9.0 (December 19, 2014)
|
382
442
|
|
383
443
|
* [#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 +452,7 @@
|
|
392
452
|
* [#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
453
|
* [#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
454
|
|
455
|
+
|
395
456
|
### 0.8.0 (August 30, 2014)
|
396
457
|
|
397
458
|
#### Features
|
@@ -421,6 +482,7 @@
|
|
421
482
|
* Added `GrapeSwagger::VERSION` - [@dblock](https://github.com/dblock).
|
422
483
|
* Added Rubocop, Ruby-style linter - [@dblock](https://github.com/dblock).
|
423
484
|
|
485
|
+
|
424
486
|
### 0.7.2 (February 6, 2014)
|
425
487
|
|
426
488
|
* [#84](https://github.com/ruby-grape/grape-swagger/pull/84): Markdown is now Github Flavored Markdown - [@jeromegn](https://github.com/jeromegn).
|
@@ -438,6 +500,7 @@
|
|
438
500
|
* [#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
501
|
* [#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
502
|
|
503
|
+
|
441
504
|
### 0.6.0 (June 19, 2013)
|
442
505
|
|
443
506
|
* Added Rails 4 support - [@jrhe](https://github.com/jrhe).
|
@@ -446,14 +509,17 @@
|
|
446
509
|
* Support both `:desc` and `:description` when describing parameters - [@dblock](https://github.com/dblock).
|
447
510
|
* Fix: allow parameters such as `name[]` - [@dblock](https://github.com/dblock).
|
448
511
|
|
512
|
+
|
449
513
|
### 0.5.0 (March 28, 2013)
|
450
514
|
|
451
515
|
* Added Grape 0.5.0 support - [@ruby-grape](https://github.com/ruby-grape).
|
452
516
|
|
517
|
+
|
453
518
|
### 0.4.0 (March 28, 2013)
|
454
519
|
|
455
520
|
* Support https - [@cutalion](https://github.com/cutalion).
|
456
521
|
|
522
|
+
|
457
523
|
### 0.3.0 (October 19, 2012)
|
458
524
|
|
459
525
|
* Added version support - [@agileanimal](https://github.com/agileanimal), [@fknappe](https://github.com/fknappe).
|
@@ -461,24 +527,28 @@
|
|
461
527
|
* Added basic support for specifying parameters that need to be passed in the header - [@agileanimal](https://github.com/agileanimal).
|
462
528
|
* Add possibility to hide the documentation paths in the generated swagger documentation - [@ruby-grape](https://github.com/ruby-grape).
|
463
529
|
|
530
|
+
|
464
531
|
### 0.2.1 (August 17, 2012)
|
465
532
|
|
466
533
|
* Added support for markdown in notes field - [@ruby-grape](https://github.com/ruby-grape).
|
467
534
|
* Fix: compatibility with Rails - [@qwert666](https://github.com/qwert666).
|
468
535
|
* Fix: swagger UI history - [@ruby-grape](https://github.com/ruby-grape).
|
469
536
|
|
537
|
+
|
470
538
|
### 0.2.0 (July 27, 2012)
|
471
539
|
|
472
540
|
* Use resource as root for swagger - [@ruby-grape](https://github.com/ruby-grape).
|
473
541
|
* Added support for file uploads, and proper `paramType` - [@ruby-grape](https://github.com/ruby-grape).
|
474
542
|
* Added tests - [@nathanvda](https://github.com/nathanvda).
|
475
543
|
|
544
|
+
|
476
545
|
### 0.1.0 (July 19, 2012)
|
477
546
|
|
478
547
|
* Added some configurability to the generated documentation - [@ruby-grape](https://github.com/ruby-grape).
|
479
548
|
* Adapted to rails plugin structure - [@ruby-grape](https://github.com/ruby-grape).
|
480
549
|
* Allowed cross origin, so swagger can be used from official site - [@ruby-grape](https://github.com/ruby-grape).
|
481
550
|
|
551
|
+
|
482
552
|
### 0.0.0 (July 19, 2012)
|
483
553
|
|
484
554
|
* 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,19 @@ 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
|
+
|
23
|
+
gem 'rack', '~> 2.1'
|
24
24
|
gem 'rack-cors'
|
25
25
|
gem 'rack-test'
|
26
26
|
gem 'rake'
|
27
27
|
gem 'rdoc'
|
28
|
-
gem 'rspec', '~> 3.
|
29
|
-
gem 'rubocop', '~> 0.
|
28
|
+
gem 'rspec', '~> 3.9'
|
29
|
+
gem 'rubocop', '~> 0.79', require: false
|
30
30
|
end
|
31
31
|
|
32
32
|
group :test do
|
data/README.md
CHANGED
@@ -48,9 +48,11 @@ 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 |
|
55
|
+
1.0.0 | 2.0 | >= 1.3.0 | >= 0.5.0 | >= 2.4.1 |
|
54
56
|
|
55
57
|
|
56
58
|
## Swagger-Spec <a name="swagger-spec"></a>
|
@@ -104,9 +106,9 @@ Also added support for [representable](https://github.com/apotonick/representabl
|
|
104
106
|
|
105
107
|
```ruby
|
106
108
|
# For Grape::Entity ( https://github.com/ruby-grape/grape-entity )
|
107
|
-
gem 'grape-swagger-entity'
|
109
|
+
gem 'grape-swagger-entity', '~> 0.3'
|
108
110
|
# For representable ( https://github.com/apotonick/representable )
|
109
|
-
gem 'grape-swagger-representable'
|
111
|
+
gem 'grape-swagger-representable', '~> 0.2'
|
110
112
|
```
|
111
113
|
|
112
114
|
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 +191,7 @@ end
|
|
189
191
|
* [base_path](#base_path)
|
190
192
|
* [mount_path](#mount_path)
|
191
193
|
* [add_base_path](#add_base_path)
|
194
|
+
* [add_root](#add_root)
|
192
195
|
* [add_version](#add_version)
|
193
196
|
* [doc_version](#doc_version)
|
194
197
|
* [endpoint_auth_wrapper](#endpoint_auth_wrapper)
|
@@ -248,6 +251,13 @@ add_swagger_documentation \
|
|
248
251
|
add_base_path: true # only if base_path given
|
249
252
|
```
|
250
253
|
|
254
|
+
#### add_root: <a name="add_root"></a>
|
255
|
+
Add root element to all the responses, default is: `false`.
|
256
|
+
```ruby
|
257
|
+
add_swagger_documentation \
|
258
|
+
add_root: true
|
259
|
+
```
|
260
|
+
|
251
261
|
#### add_version: <a name="add_version"></a>
|
252
262
|
|
253
263
|
Add `version` key to the documented path keys, default is: `true`,
|
@@ -447,6 +457,7 @@ add_swagger_documentation \
|
|
447
457
|
* [Extensions](#extensions)
|
448
458
|
* [Response examples documentation](#response-examples)
|
449
459
|
* [Response headers documentation](#response-headers)
|
460
|
+
* [Adding root element to responses](#response-root)
|
450
461
|
|
451
462
|
#### Swagger Header Parameters <a name="headers"></a>
|
452
463
|
|
@@ -733,9 +744,12 @@ end
|
|
733
744
|
Exclude single optional parameter from the documentation
|
734
745
|
|
735
746
|
```ruby
|
747
|
+
not_admins = lambda { |token_owner = nil| token_owner.nil? || !token_owner.admin? }
|
748
|
+
|
736
749
|
params do
|
737
750
|
optional :one, documentation: { hidden: true }
|
738
|
-
optional :two, documentation: { hidden: -> { true } }
|
751
|
+
optional :two, documentation: { hidden: -> { |t=nil| true } }
|
752
|
+
optional :three, documentation: { hidden: not_admins }
|
739
753
|
end
|
740
754
|
post :act do
|
741
755
|
...
|
@@ -913,7 +927,7 @@ desc 'Attach a field to an entity through a PUT',
|
|
913
927
|
failure: [
|
914
928
|
{ code: 400, message: 'Bad request' },
|
915
929
|
{ code: 404, message: 'Not found' }
|
916
|
-
]
|
930
|
+
]
|
917
931
|
put do
|
918
932
|
# your code comes here
|
919
933
|
end
|
@@ -1180,6 +1194,60 @@ The result will look like following:
|
|
1180
1194
|
|
1181
1195
|
Failure information can be passed as an array of arrays or an array of hashes.
|
1182
1196
|
|
1197
|
+
#### Adding root element to responses <a name="response-root"></a>
|
1198
|
+
|
1199
|
+
You can specify a custom root element for a successful response:
|
1200
|
+
|
1201
|
+
```ruby
|
1202
|
+
route_setting :swagger, root: 'cute_kitten'
|
1203
|
+
desc 'Get a kitten' do
|
1204
|
+
http_codes [{ code: 200, model: Entities::Kitten }]
|
1205
|
+
end
|
1206
|
+
get '/kittens/:id' do
|
1207
|
+
end
|
1208
|
+
```
|
1209
|
+
|
1210
|
+
The result will look like following:
|
1211
|
+
|
1212
|
+
```
|
1213
|
+
"responses": {
|
1214
|
+
"200": {
|
1215
|
+
"description": "Get a kitten",
|
1216
|
+
"schema": {
|
1217
|
+
"type": "object",
|
1218
|
+
"properties": { "cute_kitten": { "$ref": "#/definitions/Kitten" } }
|
1219
|
+
}
|
1220
|
+
}
|
1221
|
+
}
|
1222
|
+
```
|
1223
|
+
|
1224
|
+
If you specify `true`, the value of the root element will be deduced based on the model name.
|
1225
|
+
E.g. in the following example the root element will be "kittens":
|
1226
|
+
|
1227
|
+
```ruby
|
1228
|
+
route_setting :swagger, root: true
|
1229
|
+
desc 'Get kittens' do
|
1230
|
+
is_array true
|
1231
|
+
http_codes [{ code: 200, model: Entities::Kitten }]
|
1232
|
+
end
|
1233
|
+
get '/kittens' do
|
1234
|
+
end
|
1235
|
+
```
|
1236
|
+
|
1237
|
+
The result will look like following:
|
1238
|
+
|
1239
|
+
```
|
1240
|
+
"responses": {
|
1241
|
+
"200": {
|
1242
|
+
"description": "Get kittens",
|
1243
|
+
"schema": {
|
1244
|
+
"type": "object",
|
1245
|
+
"properties": { "type": "array", "items": { "kittens": { "$ref": "#/definitions/Kitten" } } }
|
1246
|
+
}
|
1247
|
+
}
|
1248
|
+
}
|
1249
|
+
```
|
1250
|
+
|
1183
1251
|
## Using Grape Entities <a name="grape-entity"></a>
|
1184
1252
|
|
1185
1253
|
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,7 @@ 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', '
|
17
|
+
s.add_runtime_dependency 'grape', '~> 1.3.0'
|
18
18
|
|
19
19
|
s.files = `git ls-files`.split("\n")
|
20
20
|
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
|