grape-swagger-entity 0.5.3 → 0.5.5
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 +4 -4
- data/.rubocop_todo.yml +1 -0
- data/CHANGELOG.md +11 -3
- data/Gemfile +1 -1
- data/RELEASING.md +1 -1
- data/grape-swagger-entity.gemspec +3 -3
- data/lib/grape-swagger/entity/attribute_parser.rb +43 -35
- data/lib/grape-swagger/entity/parser.rb +13 -10
- data/lib/grape-swagger/entity/version.rb +1 -1
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2acdf9214576f2fd49186e8bf6163382daa19b6842dc08033567d2427aaa5bcc
|
4
|
+
data.tar.gz: 50fa87da0ef94dff6128cea9b5178d3455c831b87457768ea8140bd14f8fc001
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f7f9ef5026e54fd99035d38e84c358cc8446a117aadeb486f900775ff15a83bc3b5aaa7c0f3c27afbde6a870ec77a3e8e6baf9fcc1c13df024826f1164aecf8
|
7
|
+
data.tar.gz: 89b9bcb8ef9693861bf2042f70147f611b9500c0dda4db5cac5b08af03a156281be02ec14afd71722d23fa498fec28308f1d638997bae066f3db4c07c7d98397
|
data/.github/workflows/test.yml
CHANGED
@@ -10,7 +10,7 @@ jobs:
|
|
10
10
|
name: RuboCop
|
11
11
|
runs-on: ubuntu-latest
|
12
12
|
steps:
|
13
|
-
- uses: actions/checkout@
|
13
|
+
- uses: actions/checkout@v4
|
14
14
|
|
15
15
|
- name: Set up Ruby
|
16
16
|
uses: ruby/setup-ruby@v1
|
@@ -24,16 +24,16 @@ jobs:
|
|
24
24
|
|
25
25
|
test:
|
26
26
|
env:
|
27
|
-
GRAPE_ENTITY: 0.
|
27
|
+
GRAPE_ENTITY: 1.0.0
|
28
28
|
|
29
29
|
runs-on: ubuntu-latest
|
30
30
|
strategy:
|
31
31
|
fail-fast: false
|
32
32
|
matrix:
|
33
|
-
ruby-version: ['3.0', '3.1', '3.2']
|
33
|
+
ruby-version: ['3.0', '3.1', '3.2', '3.3']
|
34
34
|
|
35
35
|
steps:
|
36
|
-
- uses: actions/checkout@
|
36
|
+
- uses: actions/checkout@v4
|
37
37
|
- name: Set up Ruby
|
38
38
|
uses: ruby/setup-ruby@v1
|
39
39
|
with:
|
data/.rubocop_todo.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,20 @@
|
|
1
|
-
###
|
1
|
+
### 0.5.5 (2024/09/09)
|
2
|
+
|
3
|
+
#### Fixes
|
4
|
+
|
5
|
+
* [#72](https://github.com/ruby-grape/grape-swagger-entity/pull/72): Ensure inherited nested exposures are merged - [@pirhoo](https://github.com/pirhoo).
|
6
|
+
* [#71](https://github.com/ruby-grape/grape-swagger-entity/pull/71): Fix regression for enum values in array attributes - [@Jell](https://github.com/Jell).
|
7
|
+
|
8
|
+
### 0.5.4 (2024/04/19)
|
2
9
|
|
3
10
|
#### Features
|
4
11
|
|
5
|
-
*
|
12
|
+
* [#69](https://github.com/ruby-grape/grape-swagger-entity/pull/69): Add support for minimum and maximum - [@storey](https://github.com/storey).
|
6
13
|
|
7
14
|
#### Fixes
|
8
15
|
|
9
|
-
*
|
16
|
+
* [#67](https://github.com/ruby-grape/grape-swagger-entity/pull/67): Various build updates - [@mscrivo](https://github.com/mscrivo).
|
17
|
+
* [#68](https://github.com/ruby-grape/grape-swagger-entity/pull/68): Properly render `example` for array exposure done using another entity - [@magni-](https://github.com/magni-).
|
10
18
|
|
11
19
|
### 0.5.3 (2024/02/02)
|
12
20
|
|
data/Gemfile
CHANGED
@@ -21,7 +21,7 @@ end
|
|
21
21
|
gem 'grape-swagger', git: 'https://github.com/ruby-grape/grape-swagger.git'
|
22
22
|
|
23
23
|
group :test do
|
24
|
-
gem 'grape-entity', ENV.fetch('GRAPE_ENTITY', '0.
|
24
|
+
gem 'grape-entity', ENV.fetch('GRAPE_ENTITY', '1.0.0')
|
25
25
|
gem 'ruby-grape-danger', '~> 0.2.1', require: false
|
26
26
|
gem 'simplecov', require: false
|
27
27
|
end
|
data/RELEASING.md
CHANGED
@@ -29,7 +29,7 @@ Remove the line with "Your contribution here.", since there will be no more cont
|
|
29
29
|
Commit your changes.
|
30
30
|
|
31
31
|
```
|
32
|
-
git add CHANGELOG.md lib/grape-swagger
|
32
|
+
git add CHANGELOG.md lib/grape-swagger/entity/version.rb CHANGELOG.md
|
33
33
|
git commit -m "Preparing for release, 0.1.1."
|
34
34
|
git push origin master
|
35
35
|
```
|
@@ -19,8 +19,8 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
s.require_paths = ['lib']
|
21
21
|
|
22
|
-
s.required_ruby_version = '>=
|
23
|
-
s.add_runtime_dependency 'grape-entity', '
|
24
|
-
s.add_runtime_dependency 'grape-swagger', '
|
22
|
+
s.required_ruby_version = '>= 3.0'
|
23
|
+
s.add_runtime_dependency 'grape-entity', '~> 1'
|
24
|
+
s.add_runtime_dependency 'grape-swagger', '~> 2'
|
25
25
|
s.metadata['rubygems_mfa_required'] = 'true'
|
26
26
|
end
|
@@ -10,41 +10,26 @@ module GrapeSwagger
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def call(entity_options)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
entity_model_type = entity_model_type(name, entity_options)
|
20
|
-
return entity_model_type unless documentation
|
21
|
-
|
22
|
-
add_extension_documentation(entity_model_type, documentation)
|
23
|
-
add_array_documentation(entity_model_type, documentation) if documentation[:is_array]
|
24
|
-
|
25
|
-
entity_model_type
|
26
|
-
else
|
27
|
-
param = data_type_from(entity_options)
|
28
|
-
return param unless documentation
|
13
|
+
param = if (entity_model = model_from(entity_options))
|
14
|
+
name = GrapeSwagger::Entity::Helper.model_name(entity_model, endpoint)
|
15
|
+
entity_model_type(name, entity_options)
|
16
|
+
else
|
17
|
+
data_type_from(entity_options)
|
18
|
+
end
|
29
19
|
|
30
|
-
|
31
|
-
|
32
|
-
end
|
20
|
+
documentation = entity_options[:documentation]
|
21
|
+
return param if documentation.nil?
|
33
22
|
|
34
|
-
|
35
|
-
param = { type: :array, items: param }
|
36
|
-
add_array_documentation(param, documentation)
|
37
|
-
end
|
23
|
+
add_array_documentation(param, documentation) if documentation[:is_array]
|
38
24
|
|
39
|
-
|
40
|
-
|
25
|
+
add_attribute_sample(param, documentation, :default)
|
26
|
+
add_attribute_sample(param, documentation, :example)
|
41
27
|
|
42
|
-
|
28
|
+
add_attribute_documentation(param, documentation)
|
43
29
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
30
|
+
add_extension_documentation(param, documentation)
|
31
|
+
add_discriminator_extension(param, documentation)
|
32
|
+
param
|
48
33
|
end
|
49
34
|
|
50
35
|
private
|
@@ -73,13 +58,22 @@ module GrapeSwagger
|
|
73
58
|
!type == Array
|
74
59
|
end
|
75
60
|
|
76
|
-
def data_type_from(
|
77
|
-
|
78
|
-
documented_type
|
61
|
+
def data_type_from(entity_options)
|
62
|
+
documentation = entity_options[:documentation] || {}
|
63
|
+
documented_type = entity_options[:type] || documentation[:type]
|
79
64
|
|
80
65
|
data_type = GrapeSwagger::DocMethods::DataType.call(documented_type)
|
81
66
|
|
82
|
-
document_data_type(documentation
|
67
|
+
documented_data_type = document_data_type(documentation, data_type)
|
68
|
+
|
69
|
+
if documentation[:is_array]
|
70
|
+
{
|
71
|
+
type: :array,
|
72
|
+
items: documented_data_type
|
73
|
+
}
|
74
|
+
else
|
75
|
+
documented_data_type
|
76
|
+
end
|
83
77
|
end
|
84
78
|
|
85
79
|
def document_data_type(documentation, data_type)
|
@@ -89,7 +83,12 @@ module GrapeSwagger
|
|
89
83
|
else
|
90
84
|
{ type: data_type }
|
91
85
|
end
|
92
|
-
|
86
|
+
|
87
|
+
type[:format] = documentation[:format] if documentation.key?(:format)
|
88
|
+
|
89
|
+
if (values = documentation[:values]) && values.is_a?(Array)
|
90
|
+
type[:enum] = values
|
91
|
+
end
|
93
92
|
|
94
93
|
type
|
95
94
|
end
|
@@ -117,6 +116,15 @@ module GrapeSwagger
|
|
117
116
|
end
|
118
117
|
|
119
118
|
def add_attribute_documentation(param, documentation)
|
119
|
+
param[:minimum] = documentation[:minimum] if documentation.key?(:minimum)
|
120
|
+
param[:maximum] = documentation[:maximum] if documentation.key?(:maximum)
|
121
|
+
|
122
|
+
values = documentation[:values]
|
123
|
+
if values&.is_a?(Range)
|
124
|
+
param[:minimum] = values.begin if values.begin.is_a?(Numeric)
|
125
|
+
param[:maximum] = values.end if values.end.is_a?(Numeric)
|
126
|
+
end
|
127
|
+
|
120
128
|
param[:minLength] = documentation[:min_length] if documentation.key?(:min_length)
|
121
129
|
param[:maxLength] = documentation[:max_length] if documentation.key?(:max_length)
|
122
130
|
end
|
@@ -101,19 +101,22 @@ module GrapeSwagger
|
|
101
101
|
end
|
102
102
|
|
103
103
|
def parse_nested(entity_name, entity_options, parent_model = nil)
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
params =
|
104
|
+
nested_entities = if parent_model.nil?
|
105
|
+
model.root_exposures.select_by(entity_name)
|
106
|
+
else
|
107
|
+
parent_model.nested_exposures.select_by(entity_name)
|
108
|
+
end
|
109
|
+
|
110
|
+
params = nested_entities
|
111
|
+
.map(&:nested_exposures)
|
112
|
+
.flatten
|
113
|
+
.each_with_object({}) do |value, memo|
|
111
114
|
memo[value.attribute] = value.send(:options)
|
112
115
|
end
|
113
116
|
|
114
|
-
properties, required = parse_grape_entity_params(params,
|
115
|
-
|
116
|
-
|
117
|
+
properties, required = parse_grape_entity_params(params, nested_entities.last)
|
118
|
+
documentation = entity_options[:documentation]
|
119
|
+
is_a_collection = documentation.is_a?(Hash) && documentation[:type].to_s.casecmp('array').zero?
|
117
120
|
|
118
121
|
if is_a_collection
|
119
122
|
{
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grape-swagger-entity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kirill Zaitsev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: grape-entity
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: grape-swagger
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: '2'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: '2'
|
41
41
|
description:
|
42
42
|
email:
|
43
43
|
- kirik910@gmail.com
|
@@ -80,14 +80,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
80
80
|
requirements:
|
81
81
|
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: '
|
83
|
+
version: '3.0'
|
84
84
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - ">="
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '0'
|
89
89
|
requirements: []
|
90
|
-
rubygems_version: 3.
|
90
|
+
rubygems_version: 3.3.7
|
91
91
|
signing_key:
|
92
92
|
specification_version: 4
|
93
93
|
summary: Grape swagger adapter to support grape-entity object parsing
|