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