grape-swagger 1.6.0 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9cff361f819d42d8c3f847c605a31190f82764da573728d043debfe312d30069
4
- data.tar.gz: faada4385a0db1fec73606585085deec766991007a9f050df1f2c0bbd9e9e018
3
+ metadata.gz: 994c2be4c9a0a44106876c31785adc73458d67c669ac80db7352e831511b8b2d
4
+ data.tar.gz: ae834e4ab3533e107eec6f74763a3679da626fd1fffe0334fe9546b54b6f12e5
5
5
  SHA512:
6
- metadata.gz: 7a86553f29d5b5a338a0ac21d049845ab609ee4adc2864940813f61384a8bcc19c8b0a644bb484f2b79533a111ab16a51c192236b23f540ed672e5e7a161fb23
7
- data.tar.gz: 9b5bc29e3ead5f683781cbc0418e3d18f4b056368885e470224bb57ebe03f4232725a971e8589e109240c949aad565e80d5b4ecd31e31f6e5721f0c86c8aaf2f
6
+ metadata.gz: a8a3cafba1066fef61afcc744f9fc39f7aa607765a772cc071e4ac6d931c61a7810b6876bf2c35ba1722ce20b939e19a512983f4e185bae473c09486b06d4c8a
7
+ data.tar.gz: cc5f17f8c99c2abccc49bf1da169134dcfdbf249d5f039c10eb00ab8d373cd03a29afc1c46534a296d8b4fc4d2b82eae969561bf64ca47abd7405e67c26ee6fa
@@ -1,4 +1,4 @@
1
- name: Ruby
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
- rspec:
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
- GRAPE_VERSION: ${{ matrix.grape-version }}
42
- MODEL_PARSER: ${{ matrix.model-parser }}
43
- bundler-cache: true
44
- - name: Run rspec rest of the suite
45
- run: bundle exec rspec
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 2022-01-14 10:22:29 UTC using RuboCop version 1.24.1.
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
- # Cop supports --auto-correct.
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: 31
25
- # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
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, ExcludedMethods, IgnoredMethods.
22
+ # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
31
23
  Metrics/MethodLength:
32
24
  Max: 28
33
25
 
34
- # Offense count: 7
35
- # Configuration parameters: IgnoredMethods.
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', '~> 3.0'
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.0', require: false
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/wordnik/swagger-ui). You should be able to point [the petstore demo](http://petstore.swagger.io/) to your API.
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
  ![Demo Screenshot](example/swagger-example.png)
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/wordnik/swagger-ui)
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/wordnik/swagger-ui) and set it up yourself or go to the [online swagger demo](http://petstore.swagger.wordnik.com/) and enter your localhost url documentation root in the url field (probably something in the line of http://localhost:3000/swagger_doc).
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/apotonick/representable) via `grape-swagger-representable`.
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/apotonick/roar).
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].delete_if { |_k, v| v.nil? }
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.delete_if { |_k, v| v.nil? }
47
+ p.compact!
48
48
  end
49
49
  end
50
50
  end
@@ -171,7 +171,7 @@ module GrapeSwagger
171
171
  end
172
172
 
173
173
  def parse_range_values(values)
174
- { minimum: values.first, maximum: values.last }
174
+ { minimum: values.begin, maximum: values.end }.compact
175
175
  end
176
176
  end
177
177
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GrapeSwagger
4
- VERSION = '1.6.0'
4
+ VERSION = '1.6.1'
5
5
  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 eq(
22
- [
23
- { description: 'Swagger compatible API description' },
24
- { description: 'Swagger compatible API description for specific API', params: {} }
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.0
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-03-19 00:00:00.000000000 Z
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.7
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