grape-swagger 1.6.0 → 1.6.1
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/.github/workflows/ci.yml +84 -9
- data/.rubocop_todo.yml +13 -28
- data/CHANGELOG.md +7 -0
- data/Gemfile +2 -2
- data/README.md +5 -5
- data/lib/grape-swagger/doc_methods/format_data.rb +2 -2
- data/lib/grape-swagger/doc_methods/parse_params.rb +1 -1
- data/lib/grape-swagger/version.rb +1 -1
- data/spec/lib/parse_params_spec.rb +14 -0
- data/spec/swagger_v2/api_documentation_spec.rb +4 -6
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 994c2be4c9a0a44106876c31785adc73458d67c669ac80db7352e831511b8b2d
|
|
4
|
+
data.tar.gz: ae834e4ab3533e107eec6f74763a3679da626fd1fffe0334fe9546b54b6f12e5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a8a3cafba1066fef61afcc744f9fc39f7aa607765a772cc071e4ac6d931c61a7810b6876bf2c35ba1722ce20b939e19a512983f4e185bae473c09486b06d4c8a
|
|
7
|
+
data.tar.gz: cc5f17f8c99c2abccc49bf1da169134dcfdbf249d5f039c10eb00ab8d373cd03a29afc1c46534a296d8b4fc4d2b82eae969561bf64ca47abd7405e67c26ee6fa
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
name:
|
|
1
|
+
name: RSpec
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
4
|
push:
|
|
@@ -23,14 +23,14 @@ jobs:
|
|
|
23
23
|
- name: Run rubocop
|
|
24
24
|
run: bundle exec rubocop --parallel --format progress
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
grape-16:
|
|
27
27
|
runs-on: ubuntu-latest
|
|
28
28
|
needs: ['rubocop']
|
|
29
|
+
env:
|
|
30
|
+
GRAPE_VERSION: '1.6.2'
|
|
29
31
|
strategy:
|
|
30
32
|
matrix:
|
|
31
33
|
ruby-version: ['3.0', '3.1', '3.2', 'head']
|
|
32
|
-
grape-version: [1.6.2, 1.7.0]
|
|
33
|
-
model-parser: [grape-swagger-entity, grape-swagger-representable, '']
|
|
34
34
|
steps:
|
|
35
35
|
- name: Check out branch
|
|
36
36
|
uses: actions/checkout@v3
|
|
@@ -38,8 +38,83 @@ jobs:
|
|
|
38
38
|
uses: ruby/setup-ruby@v1
|
|
39
39
|
with:
|
|
40
40
|
ruby-version: ${{ matrix.ruby-version }}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
- name: Run rspec wo model parser
|
|
42
|
+
run: |
|
|
43
|
+
bundle update
|
|
44
|
+
bundle exec rspec
|
|
45
|
+
- name: Run rspec w entity parser
|
|
46
|
+
env:
|
|
47
|
+
MODEL_PARSER: grape-swagger-entity
|
|
48
|
+
run: |
|
|
49
|
+
bundle update
|
|
50
|
+
bundle exec rspec
|
|
51
|
+
- name: Run rspec w representable parser
|
|
52
|
+
env:
|
|
53
|
+
MODEL_PARSER: grape-swagger-representable
|
|
54
|
+
run: |
|
|
55
|
+
bundle update
|
|
56
|
+
bundle exec rspec
|
|
57
|
+
|
|
58
|
+
grape-17:
|
|
59
|
+
runs-on: ubuntu-latest
|
|
60
|
+
needs: ['rubocop']
|
|
61
|
+
env:
|
|
62
|
+
GRAPE_VERSION: '1.7.1'
|
|
63
|
+
strategy:
|
|
64
|
+
matrix:
|
|
65
|
+
ruby-version: ['3.0', '3.1', '3.2', 'head']
|
|
66
|
+
steps:
|
|
67
|
+
- name: Check out branch
|
|
68
|
+
uses: actions/checkout@v3
|
|
69
|
+
- name: Set up Ruby
|
|
70
|
+
uses: ruby/setup-ruby@v1
|
|
71
|
+
with:
|
|
72
|
+
ruby-version: ${{ matrix.ruby-version }}
|
|
73
|
+
- name: Run rspec wo model parser
|
|
74
|
+
run: |
|
|
75
|
+
bundle update
|
|
76
|
+
bundle exec rspec
|
|
77
|
+
- name: Run rspec w entity parser
|
|
78
|
+
env:
|
|
79
|
+
MODEL_PARSER: grape-swagger-entity
|
|
80
|
+
run: |
|
|
81
|
+
bundle update
|
|
82
|
+
bundle exec rspec
|
|
83
|
+
- name: Run rspec w representable parser
|
|
84
|
+
env:
|
|
85
|
+
MODEL_PARSER: grape-swagger-representable
|
|
86
|
+
run: |
|
|
87
|
+
bundle update
|
|
88
|
+
bundle exec rspec
|
|
89
|
+
|
|
90
|
+
grape-HEAD:
|
|
91
|
+
runs-on: ubuntu-latest
|
|
92
|
+
needs: ['rubocop']
|
|
93
|
+
env:
|
|
94
|
+
GRAPE_VERSION: 'HEAD'
|
|
95
|
+
strategy:
|
|
96
|
+
matrix:
|
|
97
|
+
ruby-version: ['3.0', '3.1', '3.2', 'head']
|
|
98
|
+
steps:
|
|
99
|
+
- name: Check out branch
|
|
100
|
+
uses: actions/checkout@v3
|
|
101
|
+
- name: Set up Ruby
|
|
102
|
+
uses: ruby/setup-ruby@v1
|
|
103
|
+
with:
|
|
104
|
+
ruby-version: ${{ matrix.ruby-version }}
|
|
105
|
+
- name: Run rspec wo model parser
|
|
106
|
+
run: |
|
|
107
|
+
bundle update
|
|
108
|
+
bundle exec rspec
|
|
109
|
+
- name: Run rspec w entity parser
|
|
110
|
+
env:
|
|
111
|
+
MODEL_PARSER: grape-swagger-entity
|
|
112
|
+
run: |
|
|
113
|
+
bundle update
|
|
114
|
+
bundle exec rspec
|
|
115
|
+
- name: Run rspec w representable parser
|
|
116
|
+
env:
|
|
117
|
+
MODEL_PARSER: grape-swagger-representable
|
|
118
|
+
run: |
|
|
119
|
+
bundle update
|
|
120
|
+
bundle exec rspec
|
data/.rubocop_todo.yml
CHANGED
|
@@ -1,38 +1,30 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on
|
|
3
|
+
# on 2023-05-20 18:23:47 UTC using RuboCop version 1.51.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
9
|
# Offense count: 1
|
|
10
|
-
#
|
|
11
|
-
# Configuration parameters: Include.
|
|
12
|
-
# Include: **/*.gemspec
|
|
13
|
-
Gemspec/RequireMFA:
|
|
14
|
-
Exclude:
|
|
15
|
-
- 'grape-swagger.gemspec'
|
|
16
|
-
|
|
17
|
-
# Offense count: 1
|
|
18
|
-
# Configuration parameters: Include.
|
|
10
|
+
# Configuration parameters: Severity, Include.
|
|
19
11
|
# Include: **/*.gemspec
|
|
20
12
|
Gemspec/RequiredRubyVersion:
|
|
21
13
|
Exclude:
|
|
22
14
|
- 'grape-swagger.gemspec'
|
|
23
15
|
|
|
24
|
-
# Offense count:
|
|
25
|
-
# Configuration parameters:
|
|
16
|
+
# Offense count: 32
|
|
17
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
|
|
26
18
|
Metrics/AbcSize:
|
|
27
19
|
Max: 56
|
|
28
20
|
|
|
29
21
|
# Offense count: 30
|
|
30
|
-
# Configuration parameters: CountComments, CountAsOne,
|
|
22
|
+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
31
23
|
Metrics/MethodLength:
|
|
32
24
|
Max: 28
|
|
33
25
|
|
|
34
|
-
# Offense count:
|
|
35
|
-
# Configuration parameters:
|
|
26
|
+
# Offense count: 8
|
|
27
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
|
36
28
|
Metrics/PerceivedComplexity:
|
|
37
29
|
Max: 16
|
|
38
30
|
|
|
@@ -41,20 +33,13 @@ Style/ClassVars:
|
|
|
41
33
|
Exclude:
|
|
42
34
|
- 'lib/grape-swagger/doc_methods.rb'
|
|
43
35
|
|
|
36
|
+
# Offense count: 1
|
|
37
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
38
|
+
Style/CollectionCompact:
|
|
39
|
+
Exclude:
|
|
40
|
+
- 'lib/grape-swagger/endpoint.rb'
|
|
41
|
+
|
|
44
42
|
# Offense count: 23
|
|
45
43
|
# Configuration parameters: AllowedConstants.
|
|
46
44
|
Style/Documentation:
|
|
47
45
|
Enabled: false
|
|
48
|
-
|
|
49
|
-
# Offense count: 43
|
|
50
|
-
Style/OpenStructUse:
|
|
51
|
-
Exclude:
|
|
52
|
-
- 'spec/lib/endpoint_spec.rb'
|
|
53
|
-
- 'spec/lib/version_spec.rb'
|
|
54
|
-
- 'spec/support/mock_parser.rb'
|
|
55
|
-
- 'spec/support/model_parsers/mock_parser.rb'
|
|
56
|
-
- 'spec/swagger_v2/api_swagger_v2_hide_documentation_path_spec.rb'
|
|
57
|
-
- 'spec/swagger_v2/api_swagger_v2_mounted_spec.rb'
|
|
58
|
-
- 'spec/swagger_v2/api_swagger_v2_spec.rb'
|
|
59
|
-
- 'spec/swagger_v2/errors_spec.rb'
|
|
60
|
-
- 'spec/swagger_v2/reference_entity_spec.rb'
|
data/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,13 @@
|
|
|
9
9
|
* Your contribution here.
|
|
10
10
|
|
|
11
11
|
|
|
12
|
+
### 1.6.1 (May 21, 2023)
|
|
13
|
+
|
|
14
|
+
#### Fixes
|
|
15
|
+
|
|
16
|
+
* [#868](https://github.com/ruby-grape/grape-swagger/pull/896): Fix parsing endless range values - [@dhruvCW](https://github.com/dhruvCW)
|
|
17
|
+
|
|
18
|
+
|
|
12
19
|
### 1.6.0 (March 19, 2023)
|
|
13
20
|
|
|
14
21
|
#### Features
|
data/Gemfile
CHANGED
|
@@ -19,13 +19,13 @@ group :development, :test do
|
|
|
19
19
|
gem 'pry', platforms: [:mri]
|
|
20
20
|
gem 'pry-byebug', platforms: [:mri]
|
|
21
21
|
|
|
22
|
-
gem 'rack'
|
|
22
|
+
gem 'rack'
|
|
23
23
|
gem 'rack-cors'
|
|
24
24
|
gem 'rack-test'
|
|
25
25
|
gem 'rake'
|
|
26
26
|
gem 'rdoc'
|
|
27
27
|
gem 'rspec', '~> 3.9'
|
|
28
|
-
gem 'rubocop', '~> 1.
|
|
28
|
+
gem 'rubocop', '~> 1.50', require: false
|
|
29
29
|
gem 'webrick'
|
|
30
30
|
end
|
|
31
31
|
|
data/README.md
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
|
|
23
23
|
## What is grape-swagger? <a name="what"></a>
|
|
24
24
|
|
|
25
|
-
The grape-swagger gem provides an autogenerated documentation for your [Grape](https://github.com/ruby-grape/grape) API. The generated documentation is Swagger-compliant, meaning it can easily be discovered in [Swagger UI](https://github.com/
|
|
25
|
+
The grape-swagger gem provides an autogenerated documentation for your [Grape](https://github.com/ruby-grape/grape) API. The generated documentation is Swagger-compliant, meaning it can easily be discovered in [Swagger UI](https://github.com/swagger-api/swagger-ui). You should be able to point [the petstore demo](http://petstore.swagger.io/) to your API.
|
|
26
26
|
|
|
27
27
|

|
|
28
28
|
|
|
@@ -35,7 +35,7 @@ This screenshot is based on the [Hussars](https://github.com/LeFnord/hussars) sa
|
|
|
35
35
|
* [Grape Swagger Entity](https://github.com/ruby-grape/grape-swagger-entity)
|
|
36
36
|
* [Grape Entity](https://github.com/ruby-grape/grape-entity)
|
|
37
37
|
* [Grape Swagger Representable](https://github.com/ruby-grape/grape-swagger-representable)
|
|
38
|
-
* [Swagger UI](https://github.com/
|
|
38
|
+
* [Swagger UI](https://github.com/swagger-api/swagger-ui)
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
|
|
@@ -95,14 +95,14 @@ module API
|
|
|
95
95
|
end
|
|
96
96
|
```
|
|
97
97
|
|
|
98
|
-
To explore your API, either download [Swagger UI](https://github.com/
|
|
98
|
+
To explore your API, either download [Swagger UI](https://github.com/swagger-api/swagger-ui) and set it up yourself or go to the [online swagger demo](http://petstore.swagger.io/) and enter your localhost url documentation root in the url field (probably something in the line of http://localhost:3000/swagger_doc).
|
|
99
99
|
|
|
100
100
|
|
|
101
101
|
|
|
102
102
|
## Model Parsers <a name="model_parsers"></a>
|
|
103
103
|
|
|
104
104
|
Since 0.21.0, `Grape::Entity` is not a part of grape-swagger, you need to add `grape-swagger-entity` manually to your Gemfile.
|
|
105
|
-
Also added support for [representable](https://github.com/
|
|
105
|
+
Also added support for [representable](https://github.com/trailblazer/representable) via `grape-swagger-representable`.
|
|
106
106
|
|
|
107
107
|
```ruby
|
|
108
108
|
# For Grape::Entity ( https://github.com/ruby-grape/grape-entity )
|
|
@@ -115,7 +115,7 @@ If you are not using Rails, make sure to load the parser inside your application
|
|
|
115
115
|
|
|
116
116
|
### Custom Model Parsers
|
|
117
117
|
|
|
118
|
-
You can create your own model parser, for example for [roar](https://github.com/
|
|
118
|
+
You can create your own model parser, for example for [roar](https://github.com/trailblazer/roar).
|
|
119
119
|
|
|
120
120
|
```ruby
|
|
121
121
|
module GrapeSwagger
|
|
@@ -39,12 +39,12 @@ module GrapeSwagger
|
|
|
39
39
|
|
|
40
40
|
p_type = p[:type] == 'array' ? 'string' : p[:type]
|
|
41
41
|
p[:items] = { type: p_type, format: p[:format], enum: p[:enum], is_array: p[:is_array] }
|
|
42
|
-
p[:items].
|
|
42
|
+
p[:items].compact!
|
|
43
43
|
p[:type] = 'array'
|
|
44
44
|
p[:is_array] = parameter[:is_array]
|
|
45
45
|
p.delete(:format)
|
|
46
46
|
p.delete(:enum)
|
|
47
|
-
p.
|
|
47
|
+
p.compact!
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
end
|
|
@@ -12,6 +12,20 @@ describe GrapeSwagger::DocMethods::ParseParams do
|
|
|
12
12
|
parsed_range = subject.send(:parse_range_values, start_value..end_value)
|
|
13
13
|
expect(parsed_range).to eql(minimum: start_value, maximum: end_value)
|
|
14
14
|
end
|
|
15
|
+
|
|
16
|
+
describe 'endless range' do
|
|
17
|
+
specify do
|
|
18
|
+
parsed_range = subject.send(:parse_range_values, start_value..)
|
|
19
|
+
expect(parsed_range).to eql(minimum: start_value)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe 'beginless range' do
|
|
24
|
+
specify do
|
|
25
|
+
parsed_range = subject.send(:parse_range_values, ..end_value)
|
|
26
|
+
expect(parsed_range).to eql(maximum: end_value)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
15
29
|
end
|
|
16
30
|
|
|
17
31
|
describe '#parse_enum_or_range_values' do
|
|
@@ -18,11 +18,9 @@ describe 'API with additional options' do
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
it 'documents api' do
|
|
21
|
-
expect(subject).to
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
]
|
|
26
|
-
)
|
|
21
|
+
expect(subject.pluck(:description)).to match_array [
|
|
22
|
+
'Swagger compatible API description',
|
|
23
|
+
'Swagger compatible API description for specific API'
|
|
24
|
+
]
|
|
27
25
|
end
|
|
28
26
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: grape-swagger
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.6.
|
|
4
|
+
version: 1.6.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- LeFnord
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2023-
|
|
12
|
+
date: 2023-05-20 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: grape
|
|
@@ -206,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
206
206
|
- !ruby/object:Gem::Version
|
|
207
207
|
version: '0'
|
|
208
208
|
requirements: []
|
|
209
|
-
rubygems_version: 3.4.
|
|
209
|
+
rubygems_version: 3.4.10
|
|
210
210
|
signing_key:
|
|
211
211
|
specification_version: 4
|
|
212
212
|
summary: Add auto generated documentation to your Grape API that can be displayed
|