grape-swagger 0.20.2 → 0.20.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +0 -3
- data/.rubocop_todo.yml +43 -33
- data/.travis.yml +22 -13
- data/CHANGELOG.md +29 -53
- data/Gemfile +1 -1
- data/README.md +24 -24
- data/example/api/endpoints.rb +28 -29
- data/example/api/entities.rb +1 -1
- data/example/config.ru +5 -7
- data/grape-swagger.gemspec +1 -1
- data/lib/grape-swagger.rb +9 -6
- data/lib/grape-swagger/doc_methods.rb +1 -1
- data/lib/grape-swagger/doc_methods/extensions.rb +3 -3
- data/lib/grape-swagger/doc_methods/headers.rb +1 -1
- data/lib/grape-swagger/doc_methods/move_params.rb +25 -16
- data/lib/grape-swagger/doc_methods/operation_id.rb +2 -2
- data/lib/grape-swagger/doc_methods/parse_params.rb +12 -5
- data/lib/grape-swagger/doc_methods/path_string.rb +1 -1
- data/lib/grape-swagger/doc_methods/status_codes.rb +3 -1
- data/lib/grape-swagger/doc_methods/tag_name_description.rb +1 -1
- data/lib/grape-swagger/endpoint.rb +33 -46
- data/lib/grape-swagger/grape/route.rb +16 -0
- data/lib/grape-swagger/version.rb +1 -1
- data/spec/issues/403_versions_spec.rb +158 -0
- data/spec/lib/data_type_spec.rb +9 -10
- data/spec/lib/endpoint_spec.rb +1 -2
- data/spec/lib/extensions_spec.rb +44 -40
- data/spec/lib/move_params_spec.rb +113 -93
- data/spec/lib/operation_id_spec.rb +42 -12
- data/spec/lib/optional_object_spec.rb +3 -4
- data/spec/lib/path_string_spec.rb +2 -2
- data/spec/lib/produces_consumes_spec.rb +64 -53
- data/spec/markdown/redcarpet_adapter_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/support/api_swagger_v2_result.rb +122 -128
- data/spec/support/namespace_tags.rb +17 -19
- data/spec/support/the_api_entities.rb +1 -3
- data/spec/support/the_paths_definitions.rb +95 -85
- data/spec/swagger_v2/api_swagger_v2_definitions-models_spec.rb +1 -1
- data/spec/swagger_v2/api_swagger_v2_detail_spec.rb +19 -19
- data/spec/swagger_v2/api_swagger_v2_extensions_spec.rb +21 -21
- data/spec/swagger_v2/api_swagger_v2_format-content_type_spec.rb +34 -32
- data/spec/swagger_v2/api_swagger_v2_global_configuration_spec.rb +5 -7
- data/spec/swagger_v2/api_swagger_v2_headers_spec.rb +19 -18
- data/spec/swagger_v2/api_swagger_v2_hide_documentation_path_spec.rb +9 -10
- data/spec/swagger_v2/api_swagger_v2_mounted_spec.rb +21 -24
- data/spec/swagger_v2/api_swagger_v2_param_type_body_nested_spec.rb +90 -92
- data/spec/swagger_v2/api_swagger_v2_param_type_body_spec.rb +54 -54
- data/spec/swagger_v2/api_swagger_v2_param_type_spec.rb +65 -57
- data/spec/swagger_v2/api_swagger_v2_request_params_fix_spec.rb +17 -14
- data/spec/swagger_v2/api_swagger_v2_response_spec.rb +79 -123
- data/spec/swagger_v2/api_swagger_v2_spec.rb +33 -34
- data/spec/swagger_v2/api_swagger_v2_type-format_spec.rb +32 -36
- data/spec/swagger_v2/boolean_params_spec.rb +1 -1
- data/spec/swagger_v2/default_api_spec.rb +26 -29
- data/spec/swagger_v2/description_not_initialized.rb +3 -3
- data/spec/swagger_v2/float_api_spec.rb +1 -1
- data/spec/swagger_v2/form_params_spec.rb +4 -4
- data/spec/swagger_v2/hide_api_spec.rb +48 -51
- data/spec/swagger_v2/host.rb +1 -1
- data/spec/swagger_v2/mounted_target_class_spec.rb +31 -33
- data/spec/swagger_v2/namespace_tags_prefix_spec.rb +23 -21
- data/spec/swagger_v2/namespace_tags_spec.rb +23 -20
- data/spec/swagger_v2/param_type_spec.rb +5 -6
- data/spec/swagger_v2/param_values_spec.rb +31 -37
- data/spec/swagger_v2/params_array_spec.rb +17 -15
- data/spec/swagger_v2/params_hash_spec.rb +17 -15
- data/spec/swagger_v2/params_nested_spec.rb +12 -10
- data/spec/swagger_v2/reference_entity.rb +9 -9
- data/spec/swagger_v2/response_model_spec.rb +58 -62
- data/spec/swagger_v2/simple_mounted_api_spec.rb +179 -147
- metadata +5 -10
- data/spec/params_entity_spec.rb +0 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d7b5486e6ee350258521fef6c57ee68169423f0
|
4
|
+
data.tar.gz: 105ff9de1347190740ec19228cc5839246758288
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c22549eeab271d9c11100edb328f91707695632ed36ee4ae201e2e716d1526b9285d068035e356dbaea61098d7d5b6f4c11297af27be3b072c20e7a28ade9ebb
|
7
|
+
data.tar.gz: d2256e0601621560fb665543731632c2177a16a8b0e0b03c1d5bc356cd5f198b779fd81ae2ffc9fac2ad3445ddc114c76b000d88c14c4c850560cb5ef0c505e3
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,73 +1,83 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2016-05-06 15:08:19 -0400 using RuboCop version 0.39.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
# Offense count:
|
10
|
-
|
11
|
-
|
9
|
+
# Offense count: 1
|
10
|
+
Lint/AmbiguousOperator:
|
11
|
+
Exclude:
|
12
|
+
- 'spec/lib/move_params_spec.rb'
|
13
|
+
|
14
|
+
# Offense count: 1
|
15
|
+
Lint/UnreachableCode:
|
16
|
+
Exclude:
|
17
|
+
- 'example/config.ru'
|
12
18
|
|
13
19
|
# Offense count: 1
|
20
|
+
Lint/UselessAssignment:
|
21
|
+
Exclude:
|
22
|
+
- 'spec/lib/move_params_spec.rb'
|
23
|
+
|
24
|
+
# Offense count: 27
|
25
|
+
Metrics/AbcSize:
|
26
|
+
Max: 68
|
27
|
+
|
28
|
+
# Offense count: 3
|
14
29
|
# Configuration parameters: CountComments.
|
15
30
|
Metrics/ClassLength:
|
16
|
-
Max:
|
31
|
+
Max: 234
|
17
32
|
|
18
|
-
# Offense count:
|
33
|
+
# Offense count: 11
|
19
34
|
Metrics/CyclomaticComplexity:
|
20
|
-
Max:
|
35
|
+
Max: 16
|
21
36
|
|
22
|
-
# Offense count:
|
23
|
-
# Configuration parameters: AllowURI, URISchemes.
|
37
|
+
# Offense count: 624
|
38
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
|
39
|
+
# URISchemes: http, https
|
24
40
|
Metrics/LineLength:
|
25
|
-
Max:
|
41
|
+
Max: 487
|
26
42
|
|
27
|
-
# Offense count:
|
43
|
+
# Offense count: 33
|
28
44
|
# Configuration parameters: CountComments.
|
29
45
|
Metrics/MethodLength:
|
30
|
-
Max:
|
46
|
+
Max: 101
|
31
47
|
|
32
|
-
# Offense count:
|
33
|
-
# Configuration parameters: CountComments.
|
34
|
-
Metrics/ModuleLength:
|
35
|
-
Max: 200
|
36
|
-
|
37
|
-
# Offense count: 4
|
48
|
+
# Offense count: 7
|
38
49
|
Metrics/PerceivedComplexity:
|
39
|
-
Max:
|
50
|
+
Max: 19
|
40
51
|
|
41
|
-
# Offense count:
|
52
|
+
# Offense count: 4
|
42
53
|
Style/ClassVars:
|
43
54
|
Exclude:
|
44
|
-
- 'example/api.rb'
|
55
|
+
- 'example/api/endpoints.rb'
|
45
56
|
- 'lib/grape-swagger/doc_methods.rb'
|
46
57
|
|
47
|
-
# Offense count:
|
58
|
+
# Offense count: 24
|
48
59
|
Style/Documentation:
|
49
60
|
Enabled: false
|
50
61
|
|
51
|
-
# Offense count:
|
62
|
+
# Offense count: 1
|
52
63
|
Style/DoubleNegation:
|
53
64
|
Exclude:
|
65
|
+
- 'example/api/endpoints.rb'
|
54
66
|
|
55
|
-
# Offense count:
|
56
|
-
# Configuration parameters:
|
67
|
+
# Offense count: 5
|
68
|
+
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts.
|
57
69
|
Style/FileName:
|
58
70
|
Exclude:
|
59
71
|
- 'lib/grape-swagger.rb'
|
60
|
-
- 'spec/
|
61
|
-
- 'spec/
|
72
|
+
- 'spec/swagger_v2/api_swagger_v2_definitions-models_spec.rb'
|
73
|
+
- 'spec/swagger_v2/api_swagger_v2_format-content_type_spec.rb'
|
74
|
+
- 'spec/swagger_v2/api_swagger_v2_type-format_spec.rb'
|
75
|
+
- 'spec/swagger_v2/grape-swagger_spec.rb'
|
62
76
|
|
63
|
-
# Offense count:
|
64
|
-
# Configuration parameters: NamePrefix, NamePrefixBlacklist.
|
65
|
-
Style/PredicateName:
|
66
|
-
Exclude:
|
67
|
-
|
68
|
-
# Offense count: 4
|
77
|
+
# Offense count: 3
|
69
78
|
# Cop supports --auto-correct.
|
70
79
|
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
|
80
|
+
# SupportedStyles: slashes, percent_r, mixed
|
71
81
|
Style/RegexpLiteral:
|
72
82
|
Exclude:
|
73
83
|
- 'lib/grape-swagger.rb'
|
data/.travis.yml
CHANGED
@@ -2,20 +2,29 @@ language: ruby
|
|
2
2
|
|
3
3
|
sudo: false
|
4
4
|
|
5
|
-
rvm:
|
6
|
-
- 2.3.0
|
7
|
-
- 2.2.3
|
8
|
-
- 2.1.7
|
9
|
-
- jruby-19mode
|
10
|
-
- jruby-9.0.5.0
|
11
|
-
- rbx-2
|
12
|
-
|
13
5
|
matrix:
|
6
|
+
include:
|
7
|
+
- rvm: 2.3.1
|
8
|
+
env: GRAPE_VERSION=0.12.0
|
9
|
+
- rvm: 2.3.1
|
10
|
+
env: GRAPE_VERSION=0.13.0
|
11
|
+
- rvm: 2.3.1
|
12
|
+
env: GRAPE_VERSION=0.14.0
|
13
|
+
- rvm: 2.3.1
|
14
|
+
env: GRAPE_VERSION=0.15.0
|
15
|
+
- rvm: 2.3.1
|
16
|
+
env: GRAPE_VERSION=0.16.2
|
17
|
+
- rvm: 2.3.1
|
18
|
+
env: GRAPE_VERSION=HEAD
|
19
|
+
- rvm: 2.3.0
|
20
|
+
- rvm: 2.2.5
|
21
|
+
- rvm: 2.1
|
22
|
+
- rvm: rbx-2
|
23
|
+
- rvm: jruby-19mode
|
24
|
+
- rvm: ruby-head
|
25
|
+
- rvm: jruby-head
|
14
26
|
allow_failures:
|
15
27
|
- rvm: rbx-2
|
16
28
|
- rvm: jruby-19mode
|
17
|
-
|
18
|
-
|
19
|
-
- GRAPE_VERSION=0.13.0
|
20
|
-
- GRAPE_VERSION=0.14.0
|
21
|
-
# - GRAPE_VERSION=HEAD
|
29
|
+
- rvm: ruby-head
|
30
|
+
- rvm: jruby-head
|
data/CHANGELOG.md
CHANGED
@@ -1,76 +1,52 @@
|
|
1
|
-
###
|
1
|
+
### 0.20.3 (May 9, 2016)
|
2
2
|
|
3
3
|
#### Features
|
4
4
|
|
5
|
-
|
5
|
+
* [#407](https://github.com/ruby-grape/grape-swagger/issues/407): Added support for Grape 0.15.x and 0.16.x - [@dblock](https://github.com/dblock).
|
6
|
+
* [#406](https://github.com/ruby-grape/grape-swagger/pull/406): Force usage of entities for response definition [issue #385](https://github.com/ruby-grape/grape-swagger/issues/385) - [@LeFnord](https://github.com/LeFnord).
|
7
|
+
* [#405](https://github.com/ruby-grape/grape-swagger/pull/405), [#403](https://github.com/ruby-grape/grape-swagger/issues/403): Added version support matrix - [@LeFnord](https://github.com/LeFnord).
|
8
|
+
* [#408](https://github.com/ruby-grape/grape-swagger/pull/408): Added support for `HEAD` endpoints - [@Bugagazavr](https://github.com/Bugagazavr).
|
9
|
+
* [#408](https://github.com/ruby-grape/grape-swagger/pull/411): Added support for `OPTIONS` endpoints - [@Bugagazavr](https://github.com/Bugagazavr).
|
6
10
|
|
7
|
-
|
8
|
-
* [#393](https://github.com/ruby-grape/grape-swagger/pull/393): properly handle header parameters - [@wleeper](https://github.com/wleeper).
|
9
|
-
* [#389](https://github.com/ruby-grape/grape-swagger/pull/389): respect X-Forwarded-Host - [@edvakf](https://github.com/edvakf).
|
11
|
+
#### Fixes
|
10
12
|
|
11
|
-
|
13
|
+
* [#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).
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
* [#382](https://github.com/ruby-grape/grape-swagger/pull/382): make schemes optional - [@wleeper](https://github.com/wleeper).
|
16
|
-
* [#381](https://github.com/ruby-grape/grape-swagger/pull/381): adding entity property description when property documentation desc option is present - [@elciok](https://github.com/elciok).
|
15
|
+
### 0.20.2 (April 22, 2016)
|
17
16
|
|
18
17
|
#### Fixes
|
19
18
|
|
20
|
-
* [#
|
19
|
+
* [#394](https://github.com/ruby-grape/grape-swagger/pull/394): Removed overiding default through example - [@LeFnord](https://github.com/LeFnord).
|
20
|
+
* [#393](https://github.com/ruby-grape/grape-swagger/pull/393): Properly handle header parameters - [@wleeper](https://github.com/wleeper).
|
21
|
+
* [#389](https://github.com/ruby-grape/grape-swagger/pull/389): Respect X-Forwarded-Host - [@edvakf](https://github.com/edvakf).
|
21
22
|
|
22
|
-
### 0.20.
|
23
|
+
### 0.20.1 (April 17, 2016)
|
23
24
|
|
24
25
|
#### Features
|
25
26
|
|
26
|
-
[#
|
27
|
-
|
28
|
-
- adds param type `body` handling
|
29
|
-
|
30
|
-
[#367](https://github.com/ruby-grape/grape-swagger/pull/367)
|
31
|
-
|
32
|
-
- set default `type: Integer` and `required: true` for path params,
|
33
|
-
if they wasn't specified inside the `params` bloack as required
|
34
|
-
|
35
|
-
[#365](https://github.com/ruby-grape/grape-swagger/pull/365)
|
36
|
-
|
37
|
-
- fixes passing markdown with redcarpet even with nil description and detail
|
27
|
+
* [#382](https://github.com/ruby-grape/grape-swagger/pull/382): Made schemes optional - [@wleeper](https://github.com/wleeper).
|
28
|
+
* [#381](https://github.com/ruby-grape/grape-swagger/pull/381): Added entity property description when property documentation desc option is present - [@elciok](https://github.com/elciok).
|
38
29
|
|
39
|
-
|
40
|
-
|
41
|
-
- removes `allowMultiple` property from params
|
42
|
-
- adds `format` to definition property
|
43
|
-
- renames `defaultValue` to `default`
|
44
|
-
|
45
|
-
|
46
|
-
[#356](https://github.com/ruby-grape/grape-swagger/pull/356)
|
47
|
-
|
48
|
-
- adds `consumes` setting
|
49
|
-
- refactoring
|
50
|
-
|
51
|
-
[#354](https://github.com/ruby-grape/grape-swagger/pull/354) some improvements
|
52
|
-
|
53
|
-
- fixes setting of `base_path` and `host`;
|
54
|
-
- adds possibility to configure the setting of `version` and `base_path` in documented path;
|
55
|
-
- adds `operationId`
|
56
|
-
|
57
|
-
[#353](https://github.com/ruby-grape/grape-swagger/pull/353) resolves issue #352
|
30
|
+
#### Fixes
|
58
31
|
|
59
|
-
|
32
|
+
* [#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).
|
60
33
|
|
61
|
-
|
34
|
+
### 0.20.0 (April 9, 2016)
|
62
35
|
|
63
|
-
|
36
|
+
#### Features
|
64
37
|
|
65
|
-
|
38
|
+
* [#336](https://github.com/ruby-grape/grape-swagger/pull/336): Added Swagger 2.0 support - [@LeFnord](https://github.com/LeFnord).
|
39
|
+
* [#371](https://github.com/ruby-grape/grape-swagger/pull/371): Added param type `body` handling - [@LeFnord](https://github.com/LeFnord).
|
40
|
+
* [#367](https://github.com/ruby-grape/grape-swagger/pull/367): Set default `type: Integer` and `required: true` for path params, if they weren't specified inside the `params` block as required - [@LeFnord](https://github.com/LeFnord).
|
41
|
+
* [#365](https://github.com/ruby-grape/grape-swagger/pull/365): Fixed passing markdown with redcarpet even with nil description and detail - [@LeFnord](https://github.com/LeFnord).
|
42
|
+
* [#358](https://github.com/ruby-grape/grape-swagger/pull/358): Removed `allowMultiple` property from params, added `format` to definition property and renamed `defaultValue` to `default` - [@LeFnord](https://github.com/LeFnord).
|
43
|
+
* [#356](https://github.com/ruby-grape/grape-swagger/pull/356): Added `consumes` - [@LeFnord](https://github.com/LeFnord).
|
44
|
+
* [#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).
|
45
|
+
* [#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).
|
66
46
|
|
67
|
-
|
47
|
+
### 0.10.5 (April 12, 2016)
|
68
48
|
|
69
|
-
*
|
70
|
-
* runs under 2.3
|
71
|
-
* documents produces of an end-point
|
72
|
-
* Update api_swagger_v2_format-content_type_spec.rb
|
73
|
-
* upgrades to grape 0.14.x; grape-entity 0.5.x
|
49
|
+
* [#344](https://github.com/ruby-grape/grape-swagger/pull/344): Namespace based tag included in Swagger JSON - [@LeFnord](https://github.com/LeFnord).
|
74
50
|
|
75
51
|
### 0.10.2 (August 19, 2015)
|
76
52
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
[![Gem Version](https://badge.fury.io/rb/grape-swagger.svg)](http://badge.fury.io/rb/grape-swagger)
|
2
|
-
[![Build Status](https://travis-ci.org/ruby-grape/grape-swagger.svg?branch=
|
2
|
+
[![Build Status](https://travis-ci.org/ruby-grape/grape-swagger.svg?branch=master)](https://travis-ci.org/ruby-grape/grape-swagger)
|
3
3
|
[![Dependency Status](https://gemnasium.com/ruby-grape/grape-swagger.svg)](https://gemnasium.com/ruby-grape/grape-swagger)
|
4
4
|
[![Code Climate](https://codeclimate.com/github/ruby-grape/grape-swagger.svg)](https://codeclimate.com/github/ruby-grape/grape-swagger)
|
5
5
|
|
@@ -41,12 +41,12 @@ These screenshot is based on the [Hussars](https://github.com/LeFnord/hussars) s
|
|
41
41
|
|
42
42
|
The following versions of grape, grape-entity and grape-swagger can currently be used together.
|
43
43
|
|
44
|
-
grape-swagger | grape | grape-entity
|
45
|
-
|
46
|
-
0.10.5 | >= 0.10.0 ... <= 0.14.0 | < 0.5.0
|
47
|
-
0.11.0 | >= 0.16.2 | < 0.5.0
|
48
|
-
0.20.1 | >= 0.12.0 ... <= 0.14.0 | <= 0.5.1
|
49
|
-
|
44
|
+
grape-swagger | swagger spec | grape | grape-entity
|
45
|
+
--------------|--------------|-------------------------|-------------
|
46
|
+
0.10.5 | 1.2 | >= 0.10.0 ... <= 0.14.0 | < 0.5.0
|
47
|
+
0.11.0 | 1.2 | >= 0.16.2 | < 0.5.0
|
48
|
+
0.20.1 | 2.0 | >= 0.12.0 ... <= 0.14.0 | <= 0.5.1
|
49
|
+
0.20.3 | 2.0 | >= 0.12.0 ... ~> 0.16.2 | ~> 0.5.1
|
50
50
|
|
51
51
|
<a name="swagger-spec" />
|
52
52
|
## Swagger-Spec
|
@@ -123,8 +123,8 @@ end
|
|
123
123
|
* [mount_path](#mount_path)
|
124
124
|
* [add_base_path](#add_base_path)
|
125
125
|
* [add_version](#add_version)
|
126
|
+
* [doc_version](#doc_version)
|
126
127
|
* [markdown](#markdown)
|
127
|
-
* [api_version](#api_version)
|
128
128
|
* [models](#models)
|
129
129
|
* [hide_documentation_path](#hide_documentation_path)
|
130
130
|
* [info](#info)
|
@@ -139,15 +139,15 @@ You can pass a hash with optional configuration settings to ```add_swagger_docum
|
|
139
139
|
|
140
140
|
<a name="host" />
|
141
141
|
#### host:
|
142
|
-
Sets explicit the `host`
|
142
|
+
Sets explicit the `host`, default would be taken from `request`.
|
143
143
|
```ruby
|
144
144
|
add_swagger_documentation \
|
145
|
-
host: 'www.
|
145
|
+
host: 'www.example.com'
|
146
146
|
```
|
147
147
|
|
148
148
|
<a name="base_path" />
|
149
149
|
#### base_path:
|
150
|
-
Base path of the API that's being exposed
|
150
|
+
Base path of the API that's being exposed, default would be taken from `request`.
|
151
151
|
```ruby
|
152
152
|
add_swagger_documentation \
|
153
153
|
base_path: '/super/api'
|
@@ -155,26 +155,35 @@ add_swagger_documentation \
|
|
155
155
|
|
156
156
|
<a name="mount_path" />
|
157
157
|
#### mount_path:
|
158
|
-
The path where the API documentation is loaded, default is `/swagger_doc`.
|
158
|
+
The path where the API documentation is loaded, default is: `/swagger_doc`.
|
159
159
|
```ruby
|
160
160
|
add_swagger_documentation \
|
161
161
|
mount_path: '/docu'
|
162
162
|
```
|
163
163
|
|
164
164
|
#### add_base_path:
|
165
|
-
Add `basePath` key to the
|
165
|
+
Add `basePath` key to the documented path keys, default is: `false`.
|
166
166
|
```ruby
|
167
167
|
add_swagger_documentation \
|
168
168
|
add_base_path: true
|
169
169
|
```
|
170
170
|
|
171
171
|
#### add_version:
|
172
|
-
Add `version` key to the
|
172
|
+
Add `version` key to the documented path keys, default is: `true`,
|
173
|
+
here the version is the API version, specified by `grape` in [`path`](https://github.com/ruby-grape/grape/#path)
|
174
|
+
|
173
175
|
```ruby
|
174
176
|
add_swagger_documentation \
|
175
177
|
add_version: false
|
176
178
|
```
|
177
179
|
|
180
|
+
<a name="doc_version" />
|
181
|
+
#### doc_version:
|
182
|
+
Specify the version of the documentation at [info section](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#info-object), default is: `'0.0.1'`
|
183
|
+
```ruby
|
184
|
+
add_swagger_documentation \
|
185
|
+
doc_version: '0.0.1'
|
186
|
+
```
|
178
187
|
|
179
188
|
<a name="markdown" />
|
180
189
|
#### markdown:
|
@@ -190,15 +199,6 @@ add_swagger_documentation \
|
|
190
199
|
markdown: GrapeSwagger::Markdown::RedcarpetAdapter.new
|
191
200
|
```
|
192
201
|
|
193
|
-
<a name="api_version" />
|
194
|
-
#### api_version:
|
195
|
-
```ruby
|
196
|
-
add_swagger_documentation \
|
197
|
-
api_version: 'v1'
|
198
|
-
```
|
199
|
-
|
200
|
-
Version of the API that's being exposed.
|
201
|
-
|
202
202
|
|
203
203
|
#### *authorizations*:
|
204
204
|
This value is added to the `authorizations` key in the JSON documentation.
|
@@ -459,7 +459,7 @@ end
|
|
459
459
|
|
460
460
|
### Grape Entities
|
461
461
|
|
462
|
-
Add the [grape-entity](https://github.com/agileanimal/grape-entity) gem to
|
462
|
+
Add the [grape-entity](https://github.com/agileanimal/grape-entity) gem to your Gemfile.
|
463
463
|
|
464
464
|
The following example exposes statuses. And exposes statuses documentation adding :type and :desc.
|
465
465
|
|
data/example/api/endpoints.rb
CHANGED
@@ -18,41 +18,40 @@ module Api
|
|
18
18
|
end
|
19
19
|
|
20
20
|
class Splines < Grape::API
|
21
|
-
|
22
21
|
@@splines = []
|
23
22
|
|
24
23
|
namespace :splines do
|
25
24
|
#
|
26
25
|
desc 'Get all splines',
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
is_array: true,
|
27
|
+
http_codes: [
|
28
|
+
{ code: 200, message: 'get Splines', model: Api::Entities::Splines },
|
29
|
+
{ code: 422, message: 'SplinesOutError' }
|
30
|
+
]
|
32
31
|
get do
|
33
32
|
present :items, @@splines, with: Entities::Splines
|
34
33
|
end
|
35
34
|
|
36
35
|
#
|
37
36
|
desc 'Return a spline.',
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
http_codes: [
|
38
|
+
{ code: 200, message: 'get Splines' },
|
39
|
+
{ code: 422, message: 'SplinesOutError' }
|
40
|
+
]
|
42
41
|
params do
|
43
42
|
requires :id, type: Integer, desc: 'Spline id.'
|
44
43
|
end
|
45
44
|
get ':id' do
|
46
|
-
error!(
|
45
|
+
error!(code: 422, message: 'SplinesOutError') unless @@splines[params[:id] - 1]
|
47
46
|
|
48
47
|
present @@splines[params[:id] - 1], with: Entities::Splines
|
49
48
|
end
|
50
49
|
|
51
50
|
#
|
52
51
|
desc 'Create a spline.',
|
53
|
-
|
54
|
-
|
55
|
-
|
52
|
+
http_codes: [
|
53
|
+
{ code: 201, message: 'Spline created', model: Api::Entities::Splines }
|
54
|
+
]
|
56
55
|
params do
|
57
56
|
requires :spline, type: Hash do
|
58
57
|
requires :x, type: Numeric
|
@@ -62,9 +61,9 @@ module Api
|
|
62
61
|
end
|
63
62
|
post do
|
64
63
|
spline = Spline.new
|
65
|
-
spline.id =
|
66
|
-
spline.x = (params[:spline][:x]/params[:spline][:y] || 0.0)
|
67
|
-
spline.y = (params[:spline][:y]/params[:spline][:x] || 0.0)
|
64
|
+
spline.id = @@splines.size + 1
|
65
|
+
spline.x = (params[:spline][:x] / params[:spline][:y] || 0.0)
|
66
|
+
spline.y = (params[:spline][:y] / params[:spline][:x] || 0.0)
|
68
67
|
spline.reticulated = params[:reticulated]
|
69
68
|
|
70
69
|
@@splines << spline
|
@@ -74,10 +73,10 @@ module Api
|
|
74
73
|
|
75
74
|
#
|
76
75
|
desc 'Update a spline.',
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
76
|
+
http_codes: [
|
77
|
+
{ code: 200, message: 'update Splines', model: Api::Entities::Splines },
|
78
|
+
{ code: 422, message: 'SplinesOutError' }
|
79
|
+
]
|
81
80
|
params do
|
82
81
|
requires :id, type: Integer, desc: 'Spline id.'
|
83
82
|
optional :spline, type: Hash do
|
@@ -87,14 +86,14 @@ module Api
|
|
87
86
|
optional :reticulated, type: Boolean, default: true, desc: 'True if the spline is reticulated.'
|
88
87
|
end
|
89
88
|
put ':id' do
|
90
|
-
error!(
|
89
|
+
error!(code: 422, message: 'SplinesOutError') unless @@splines[params[:id] - 1]
|
91
90
|
|
92
91
|
update_data = params[:spline]
|
93
92
|
spline = @@splines[params[:id] - 1]
|
94
93
|
|
95
94
|
spline.reticulated = !!update_data[:reticulated]
|
96
|
-
spline.x = update_data[:x]/update_data[:y] || 0.0
|
97
|
-
spline.y = update_data[:y]/update_data[:x] || 0.0
|
95
|
+
spline.x = update_data[:x] / update_data[:y] || 0.0
|
96
|
+
spline.y = update_data[:y] / update_data[:x] || 0.0
|
98
97
|
|
99
98
|
present spline, with: Entities::Splines
|
100
99
|
end
|
@@ -105,10 +104,10 @@ module Api
|
|
105
104
|
requires :id, type: Integer, desc: 'Spline id.'
|
106
105
|
end
|
107
106
|
delete ':id' do
|
108
|
-
error!(
|
107
|
+
error!(code: 422, message: 'SplinesOutError') unless @@splines[params[:id] - 1]
|
109
108
|
|
110
109
|
@@splines.delete_at(params[:id] - 1)
|
111
|
-
{
|
110
|
+
{ 'deleted' => params[:id] }
|
112
111
|
end
|
113
112
|
end
|
114
113
|
end
|
@@ -116,9 +115,9 @@ module Api
|
|
116
115
|
class FileAccessor < Grape::API
|
117
116
|
namespace :file do
|
118
117
|
desc 'Update image',
|
119
|
-
|
120
|
-
|
121
|
-
|
118
|
+
details: "# TEST api for testing uploading\n
|
119
|
+
# curl --form file=@splines.png http://localhost:9292/file/upload",
|
120
|
+
content_type: 'application/octet-stream'
|
122
121
|
post 'upload' do
|
123
122
|
filename = params[:file][:filename]
|
124
123
|
content_type 'binary', 'application/octet-stream'
|