grape-swagger-entity 0.5.5 → 0.6.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/.github/workflows/test.yml +14 -7
- data/.rubocop.yml +4 -0
- data/.rubocop_todo.yml +88 -38
- data/CHANGELOG.md +11 -0
- data/Gemfile +22 -3
- data/grape-swagger-entity.gemspec +2 -2
- data/lib/grape-swagger/entity/attribute_parser.rb +15 -6
- data/lib/grape-swagger/entity/version.rb +1 -1
- metadata +3 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e938d67caf864101c795754402fd3ddb4bee1f670f17a8d155e7d29a0cd1607a
|
4
|
+
data.tar.gz: 970fb96ed3b1f9e52917e49d1bc21a6a74f5d3764bf0138e131156ed697bc64f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d95a5256cd149e90feb4cd4bb1c5e0848071a38323c97767c98c2546b6c9869afd710d993538a7c6089598f4c3d05e78fb9c8c2b8d1e58e4a14f48eaf563efe
|
7
|
+
data.tar.gz: 41656f10e6f06e5bdbe214e9443f72c72f7e7d4bd2a7bd25c9ee2d92c019f67626dcf02faf8c7a45085a392820b906e24d98a489f30a1511b440e2f3965c1eb8
|
data/.github/workflows/test.yml
CHANGED
@@ -23,21 +23,28 @@ jobs:
|
|
23
23
|
run: bundle exec rubocop
|
24
24
|
|
25
25
|
test:
|
26
|
-
|
27
|
-
GRAPE_ENTITY: 1.0.0
|
28
|
-
|
29
|
-
runs-on: ubuntu-latest
|
26
|
+
name: test (ruby=${{ matrix.ruby }}, grape=${{ matrix.grape }}, grape-swagger=${{ matrix.grape_swagger}}, grape_entity=${{ matrix.grape_entity }})
|
30
27
|
strategy:
|
31
|
-
fail-fast: false
|
32
28
|
matrix:
|
33
|
-
|
29
|
+
grape: [ '~> 2.0.0', 'head' ]
|
30
|
+
grape_swagger: [ '~> 2.0.3', 'head' ]
|
31
|
+
grape_entity: [ '~> 1.0.1', 'head' ]
|
32
|
+
ruby: [ '3.1', '3.4', 'head' ]
|
33
|
+
# Exclude combinations that are not supported.
|
34
|
+
exclude:
|
35
|
+
- { grape_swagger: '~> 2.0.3', grape: 'head' }
|
36
|
+
runs-on: ubuntu-latest
|
37
|
+
env:
|
38
|
+
GRAPE_VERSION: ${{ matrix.grape }}
|
39
|
+
GRAPE_SWAGGER_VERSION: ${{ matrix.grape_swagger }}
|
40
|
+
GRAPE_ENTITY_VERSION: ${{ matrix.grape_entity }}
|
34
41
|
|
35
42
|
steps:
|
36
43
|
- uses: actions/checkout@v4
|
37
44
|
- name: Set up Ruby
|
38
45
|
uses: ruby/setup-ruby@v1
|
39
46
|
with:
|
40
|
-
ruby-version: ${{ matrix.ruby
|
47
|
+
ruby-version: ${{ matrix.ruby }}
|
41
48
|
bundler-cache: true
|
42
49
|
- name: Run tests
|
43
50
|
run: bundle exec rake spec
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
|
-
# `rubocop --auto-gen-config
|
3
|
-
# on
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2024-09-09 22:35:29 UTC using RuboCop version 1.66.1.
|
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
|
@@ -28,7 +28,7 @@ Lint/EmptyBlock:
|
|
28
28
|
Exclude:
|
29
29
|
- 'spec/grape-swagger/entity/attribute_parser_spec.rb'
|
30
30
|
|
31
|
-
# Offense count:
|
31
|
+
# Offense count: 2
|
32
32
|
# This cop supports unsafe autocorrection (--autocorrect-all).
|
33
33
|
# Configuration parameters: AllowedMethods.
|
34
34
|
# AllowedMethods: instance_of?, kind_of?, is_a?, eql?, respond_to?, equal?
|
@@ -37,59 +37,109 @@ Lint/RedundantSafeNavigation:
|
|
37
37
|
- 'lib/grape-swagger/entity/attribute_parser.rb'
|
38
38
|
|
39
39
|
# Offense count: 4
|
40
|
-
# Configuration parameters: AllowedMethods, AllowedPatterns,
|
40
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
|
41
41
|
Metrics/AbcSize:
|
42
|
-
|
43
|
-
- 'lib/grape-swagger/entity/attribute_parser.rb'
|
44
|
-
- 'lib/grape-swagger/entity/parser.rb'
|
45
|
-
|
46
|
-
# Offense count: 13
|
47
|
-
# Configuration parameters: CountComments, Max, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
|
48
|
-
# AllowedMethods: refine
|
49
|
-
Metrics/BlockLength:
|
50
|
-
Exclude:
|
51
|
-
- '**/*.gemspec'
|
52
|
-
- 'spec/grape-swagger/entities/response_model_spec.rb'
|
53
|
-
- 'spec/grape-swagger/entity/attribute_parser_spec.rb'
|
54
|
-
- 'spec/grape-swagger/entity/parser_spec.rb'
|
55
|
-
- 'spec/support/shared_contexts/this_api.rb'
|
42
|
+
Max: 34
|
56
43
|
|
57
|
-
# Offense count:
|
58
|
-
# Configuration parameters: CountComments,
|
44
|
+
# Offense count: 2
|
45
|
+
# Configuration parameters: CountComments, CountAsOne.
|
59
46
|
Metrics/ClassLength:
|
60
|
-
|
61
|
-
- 'lib/grape-swagger/entity/attribute_parser.rb'
|
62
|
-
- 'lib/grape-swagger/entity/parser.rb'
|
47
|
+
Max: 112
|
63
48
|
|
64
49
|
# Offense count: 2
|
65
|
-
# Configuration parameters: AllowedMethods, AllowedPatterns
|
50
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
66
51
|
Metrics/CyclomaticComplexity:
|
67
|
-
|
68
|
-
- 'lib/grape-swagger/entity/attribute_parser.rb'
|
69
|
-
- 'lib/grape-swagger/entity/parser.rb'
|
52
|
+
Max: 11
|
70
53
|
|
71
|
-
# Offense count:
|
72
|
-
# Configuration parameters: CountComments,
|
54
|
+
# Offense count: 7
|
55
|
+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
73
56
|
Metrics/MethodLength:
|
74
|
-
|
75
|
-
- 'lib/grape-swagger/entity/attribute_parser.rb'
|
76
|
-
- 'lib/grape-swagger/entity/parser.rb'
|
57
|
+
Max: 28
|
77
58
|
|
78
59
|
# Offense count: 2
|
79
|
-
# Configuration parameters: AllowedMethods, AllowedPatterns
|
60
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
80
61
|
Metrics/PerceivedComplexity:
|
81
|
-
|
82
|
-
- 'lib/grape-swagger/entity/attribute_parser.rb'
|
83
|
-
- 'lib/grape-swagger/entity/parser.rb'
|
62
|
+
Max: 13
|
84
63
|
|
85
|
-
# Offense count:
|
64
|
+
# Offense count: 5
|
86
65
|
# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
|
87
66
|
# SupportedStyles: snake_case, normalcase, non_integer
|
88
|
-
# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339
|
67
|
+
# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
|
89
68
|
Naming/VariableNumber:
|
90
69
|
Exclude:
|
91
70
|
- 'spec/grape-swagger/entities/response_model_spec.rb'
|
92
71
|
|
72
|
+
# Offense count: 1
|
73
|
+
RSpec/BeforeAfterAll:
|
74
|
+
Exclude:
|
75
|
+
- '**/spec/spec_helper.rb'
|
76
|
+
- '**/spec/rails_helper.rb'
|
77
|
+
- '**/spec/support/**/*.rb'
|
78
|
+
- 'spec/grape-swagger/entities/response_model_spec.rb'
|
79
|
+
|
80
|
+
# Offense count: 4
|
81
|
+
# Configuration parameters: Prefixes, AllowedPatterns.
|
82
|
+
# Prefixes: when, with, without
|
83
|
+
RSpec/ContextWording:
|
84
|
+
Exclude:
|
85
|
+
- 'spec/grape-swagger/entity/parser_spec.rb'
|
86
|
+
- 'spec/support/shared_contexts/inheritance_api.rb'
|
87
|
+
- 'spec/support/shared_contexts/this_api.rb'
|
88
|
+
|
89
|
+
# Offense count: 2
|
90
|
+
# Configuration parameters: IgnoredMetadata.
|
91
|
+
RSpec/DescribeClass:
|
92
|
+
Exclude:
|
93
|
+
- '**/spec/features/**/*'
|
94
|
+
- '**/spec/requests/**/*'
|
95
|
+
- '**/spec/routing/**/*'
|
96
|
+
- '**/spec/system/**/*'
|
97
|
+
- '**/spec/views/**/*'
|
98
|
+
- 'spec/grape-swagger/entities/response_model_spec.rb'
|
99
|
+
|
100
|
+
# Offense count: 4
|
101
|
+
# Configuration parameters: CountAsOne.
|
102
|
+
RSpec/ExampleLength:
|
103
|
+
Max: 187
|
104
|
+
|
105
|
+
# Offense count: 24
|
106
|
+
RSpec/LeakyConstantDeclaration:
|
107
|
+
Exclude:
|
108
|
+
- 'spec/grape-swagger/entities/response_model_spec.rb'
|
109
|
+
- 'spec/support/shared_contexts/inheritance_api.rb'
|
110
|
+
- 'spec/support/shared_contexts/this_api.rb'
|
111
|
+
|
112
|
+
# Offense count: 1
|
113
|
+
RSpec/MultipleDescribes:
|
114
|
+
Exclude:
|
115
|
+
- 'spec/grape-swagger/entities/response_model_spec.rb'
|
116
|
+
|
117
|
+
# Offense count: 5
|
118
|
+
RSpec/MultipleExpectations:
|
119
|
+
Max: 11
|
120
|
+
|
121
|
+
# Offense count: 20
|
122
|
+
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
|
123
|
+
# SupportedStyles: always, named_only
|
124
|
+
RSpec/NamedSubject:
|
125
|
+
Exclude:
|
126
|
+
- 'spec/grape-swagger/entities/response_model_spec.rb'
|
127
|
+
|
128
|
+
# Offense count: 39
|
129
|
+
# Configuration parameters: AllowedGroups.
|
130
|
+
RSpec/NestedGroups:
|
131
|
+
Max: 5
|
132
|
+
|
133
|
+
# Offense count: 3
|
134
|
+
# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata.
|
135
|
+
# Include: **/*_spec.rb
|
136
|
+
RSpec/SpecFilePathFormat:
|
137
|
+
Exclude:
|
138
|
+
- '**/spec/routing/**/*'
|
139
|
+
- 'spec/grape-swagger/entity/attribute_parser_spec.rb'
|
140
|
+
- 'spec/grape-swagger/entity/parser_spec.rb'
|
141
|
+
- 'spec/grape-swagger/entity_spec.rb'
|
142
|
+
|
93
143
|
# Offense count: 4
|
94
144
|
# Configuration parameters: AllowedConstants.
|
95
145
|
Style/Documentation:
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
### 0.6.0 (2025/04/26)
|
2
|
+
|
3
|
+
#### Features
|
4
|
+
|
5
|
+
* [#76](https://github.com/ruby-grape/grape-swagger-entity/pull/76): Update ci matrix and gemfile for multi-version grape testing - [@numbata](https://github.com/numbata).
|
6
|
+
* [#77](https://github.com/ruby-grape/grape-swagger-entity/pull/77): Allow proc for enum values in documentation - [@krororo](https://github.com/krororo).
|
7
|
+
|
8
|
+
#### Fixes
|
9
|
+
|
10
|
+
* [#75](https://github.com/ruby-grape/grape-swagger-entity/pull/75): Fix handling of entity with class names without "entity" or "entities" - [@numbata](https://github.com/numbata).
|
11
|
+
|
1
12
|
### 0.5.5 (2024/09/09)
|
2
13
|
|
3
14
|
#### Fixes
|
data/Gemfile
CHANGED
@@ -5,6 +5,25 @@ source 'https://rubygems.org'
|
|
5
5
|
# Specify your gem's dependencies in grape-swagger-entity.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
+
grape_version = ENV.fetch('GRAPE_VERSION', '< 3.0')
|
9
|
+
grape_swagger_version = ENV.fetch('GRAPE_SWAGGER_VERSION', '< 3.0')
|
10
|
+
grape_entity_version = ENV.fetch('GRAPE_ENTITY_VERSION', '< 2.0')
|
11
|
+
|
12
|
+
grape_spec = grape_version.casecmp('HEAD').zero? ? { git: 'https://github.com/ruby-grape/grape' } : grape_version
|
13
|
+
grape_swagger_spec = if grape_swagger_version.casecmp('HEAD').zero?
|
14
|
+
{ git: 'https://github.com/ruby-grape/grape-swagger.git' }
|
15
|
+
else
|
16
|
+
grape_swagger_version
|
17
|
+
end
|
18
|
+
grape_entity_spec = if grape_entity_version.casecmp('HEAD').zero?
|
19
|
+
{ git: 'https://github.com/ruby-grape/grape-entity.git' }
|
20
|
+
else
|
21
|
+
grape_entity_version
|
22
|
+
end
|
23
|
+
|
24
|
+
gem 'grape', grape_spec
|
25
|
+
gem 'grape-swagger', grape_swagger_spec
|
26
|
+
|
8
27
|
group :development, :test do
|
9
28
|
gem 'bundler'
|
10
29
|
gem 'pry', platforms: [:mri]
|
@@ -16,12 +35,12 @@ group :development, :test do
|
|
16
35
|
gem 'rdoc'
|
17
36
|
gem 'rspec'
|
18
37
|
gem 'rubocop'
|
38
|
+
gem 'rubocop-rake'
|
39
|
+
gem 'rubocop-rspec'
|
19
40
|
end
|
20
41
|
|
21
|
-
gem 'grape-swagger', git: 'https://github.com/ruby-grape/grape-swagger.git'
|
22
|
-
|
23
42
|
group :test do
|
24
|
-
gem 'grape-entity',
|
43
|
+
gem 'grape-entity', grape_entity_spec
|
25
44
|
gem 'ruby-grape-danger', '~> 0.2.1', require: false
|
26
45
|
gem 'simplecov', require: false
|
27
46
|
end
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.require_paths = ['lib']
|
21
21
|
|
22
22
|
s.required_ruby_version = '>= 3.0'
|
23
|
-
s.
|
24
|
-
s.
|
23
|
+
s.add_dependency 'grape-entity', '~> 1'
|
24
|
+
s.add_dependency 'grape-swagger', '~> 2'
|
25
25
|
s.metadata['rubygems_mfa_required'] = 'true'
|
26
26
|
end
|
@@ -5,6 +5,9 @@ module GrapeSwagger
|
|
5
5
|
class AttributeParser
|
6
6
|
attr_reader :endpoint
|
7
7
|
|
8
|
+
# The list of that doesn't handled by `GrapeSwagger::DocMethods::DataType.primitive?` method
|
9
|
+
ADDITIONAL_PRIMITIVE_TYPES = %w[string array].freeze
|
10
|
+
|
8
11
|
def initialize(endpoint)
|
9
12
|
@endpoint = endpoint
|
10
13
|
end
|
@@ -53,9 +56,15 @@ module GrapeSwagger
|
|
53
56
|
end
|
54
57
|
|
55
58
|
def ambiguous_model_type?(type)
|
56
|
-
type&.is_a?(Class) &&
|
57
|
-
|
58
|
-
|
59
|
+
type&.is_a?(Class) && !primitive_type?(type)
|
60
|
+
end
|
61
|
+
|
62
|
+
def primitive_type?(type)
|
63
|
+
type_name = type.name&.downcase
|
64
|
+
return false if type_name.nil?
|
65
|
+
|
66
|
+
GrapeSwagger::DocMethods::DataType.primitive?(type_name) ||
|
67
|
+
ADDITIONAL_PRIMITIVE_TYPES.include?(type_name)
|
59
68
|
end
|
60
69
|
|
61
70
|
def data_type_from(entity_options)
|
@@ -86,9 +95,9 @@ module GrapeSwagger
|
|
86
95
|
|
87
96
|
type[:format] = documentation[:format] if documentation.key?(:format)
|
88
97
|
|
89
|
-
|
90
|
-
|
91
|
-
|
98
|
+
values = documentation[:values]
|
99
|
+
values = values.call if values.is_a?(Proc)
|
100
|
+
type[:enum] = values if values.is_a?(Array)
|
92
101
|
|
93
102
|
type
|
94
103
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grape-swagger-entity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kirill Zaitsev
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-04-26 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: grape-entity
|
@@ -38,7 +37,6 @@ dependencies:
|
|
38
37
|
- - "~>"
|
39
38
|
- !ruby/object:Gem::Version
|
40
39
|
version: '2'
|
41
|
-
description:
|
42
40
|
email:
|
43
41
|
- kirik910@gmail.com
|
44
42
|
executables: []
|
@@ -72,7 +70,6 @@ licenses:
|
|
72
70
|
- MIT
|
73
71
|
metadata:
|
74
72
|
rubygems_mfa_required: 'true'
|
75
|
-
post_install_message:
|
76
73
|
rdoc_options: []
|
77
74
|
require_paths:
|
78
75
|
- lib
|
@@ -87,8 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
84
|
- !ruby/object:Gem::Version
|
88
85
|
version: '0'
|
89
86
|
requirements: []
|
90
|
-
rubygems_version: 3.
|
91
|
-
signing_key:
|
87
|
+
rubygems_version: 3.6.2
|
92
88
|
specification_version: 4
|
93
89
|
summary: Grape swagger adapter to support grape-entity object parsing
|
94
90
|
test_files: []
|