grape-swagger-entity 0.5.1 → 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/danger.yml +21 -0
- data/.github/workflows/test.yml +43 -0
- data/.gitignore +2 -1
- data/.rubocop.yml +1 -12
- data/.rubocop_todo.yml +72 -13
- data/CHANGELOG.md +43 -22
- data/Gemfile +4 -4
- data/README.md +15 -1
- data/RELEASING.md +64 -0
- data/grape-swagger-entity.gemspec +4 -3
- data/lib/grape-swagger/entity/attribute_parser.rb +43 -34
- data/lib/grape-swagger/entity/parser.rb +14 -13
- data/lib/grape-swagger/entity/version.rb +1 -1
- data/lib/grape-swagger/entity.rb +1 -1
- metadata +21 -18
- data/.travis.yml +0 -36
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
|
@@ -0,0 +1,21 @@
|
|
1
|
+
name: danger
|
2
|
+
on: pull_request
|
3
|
+
|
4
|
+
jobs:
|
5
|
+
danger:
|
6
|
+
runs-on: ubuntu-latest
|
7
|
+
steps:
|
8
|
+
- uses: actions/checkout@v4
|
9
|
+
with:
|
10
|
+
fetch-depth: 100
|
11
|
+
- name: Set up Ruby
|
12
|
+
uses: ruby/setup-ruby@v1
|
13
|
+
with:
|
14
|
+
ruby-version: 3.2
|
15
|
+
bundler-cache: true
|
16
|
+
rubygems: latest
|
17
|
+
- name: Run Danger
|
18
|
+
run: |
|
19
|
+
# the token is public, has public_repo scope and belongs to the grape-bot user owned by @dblock, this is ok
|
20
|
+
TOKEN=$(echo -n Z2hwX2lYb0dPNXNyejYzOFJyaTV3QUxUdkNiS1dtblFwZTFuRXpmMwo= | base64 --decode)
|
21
|
+
DANGER_GITHUB_API_TOKEN=$TOKEN bundle exec danger --verbose
|
@@ -0,0 +1,43 @@
|
|
1
|
+
name: test
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
permissions:
|
6
|
+
contents: read
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
lint:
|
10
|
+
name: RuboCop
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v4
|
14
|
+
|
15
|
+
- name: Set up Ruby
|
16
|
+
uses: ruby/setup-ruby@v1
|
17
|
+
with:
|
18
|
+
ruby-version: 3.2
|
19
|
+
bundler-cache: true
|
20
|
+
rubygems: latest
|
21
|
+
|
22
|
+
- name: Run RuboCop
|
23
|
+
run: bundle exec rubocop
|
24
|
+
|
25
|
+
test:
|
26
|
+
env:
|
27
|
+
GRAPE_ENTITY: 1.0.0
|
28
|
+
|
29
|
+
runs-on: ubuntu-latest
|
30
|
+
strategy:
|
31
|
+
fail-fast: false
|
32
|
+
matrix:
|
33
|
+
ruby-version: ['3.0', '3.1', '3.2', '3.3']
|
34
|
+
|
35
|
+
steps:
|
36
|
+
- uses: actions/checkout@v4
|
37
|
+
- name: Set up Ruby
|
38
|
+
uses: ruby/setup-ruby@v1
|
39
|
+
with:
|
40
|
+
ruby-version: ${{ matrix.ruby-version }}
|
41
|
+
bundler-cache: true
|
42
|
+
- name: Run tests
|
43
|
+
run: bundle exec rake spec
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
AllCops:
|
2
|
+
NewCops: enable
|
2
3
|
Exclude:
|
3
4
|
- vendor/**/*
|
4
5
|
TargetRubyVersion:
|
@@ -6,18 +7,6 @@ AllCops:
|
|
6
7
|
|
7
8
|
inherit_from: .rubocop_todo.yml
|
8
9
|
|
9
|
-
Metrics/BlockLength:
|
10
|
-
Exclude:
|
11
|
-
- spec/**/*
|
12
|
-
|
13
|
-
Metrics/LineLength:
|
14
|
-
Exclude:
|
15
|
-
- spec/**/*
|
16
|
-
|
17
|
-
Metrics/MethodLength:
|
18
|
-
Exclude:
|
19
|
-
- spec/**/*
|
20
|
-
|
21
10
|
Naming/FileName:
|
22
11
|
Enabled: false
|
23
12
|
|
data/.rubocop_todo.yml
CHANGED
@@ -1,44 +1,97 @@
|
|
1
1
|
# This configuration was generated by
|
2
|
-
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
2
|
+
# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 5000`
|
3
|
+
# on 2023-07-06 20:16:40 UTC using RuboCop version 1.42.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
|
-
# Configuration parameters: Include.
|
10
|
+
# Configuration parameters: Severity, Include.
|
11
11
|
# Include: **/*.gemspec
|
12
12
|
Gemspec/RequiredRubyVersion:
|
13
13
|
Exclude:
|
14
14
|
- 'grape-swagger-entity.gemspec'
|
15
15
|
|
16
|
+
# Offense count: 3
|
17
|
+
# Configuration parameters: AllowedMethods.
|
18
|
+
# AllowedMethods: enums
|
19
|
+
Lint/ConstantDefinitionInBlock:
|
20
|
+
Exclude:
|
21
|
+
- 'spec/grape-swagger/entities/response_model_spec.rb'
|
22
|
+
- 'spec/support/shared_contexts/inheritance_api.rb'
|
23
|
+
- 'spec/support/shared_contexts/this_api.rb'
|
24
|
+
|
25
|
+
# Offense count: 1
|
26
|
+
# Configuration parameters: AllowComments, AllowEmptyLambdas.
|
27
|
+
Lint/EmptyBlock:
|
28
|
+
Exclude:
|
29
|
+
- 'spec/grape-swagger/entity/attribute_parser_spec.rb'
|
30
|
+
|
31
|
+
# Offense count: 1
|
32
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
33
|
+
# Configuration parameters: AllowedMethods.
|
34
|
+
# AllowedMethods: instance_of?, kind_of?, is_a?, eql?, respond_to?, equal?
|
35
|
+
Lint/RedundantSafeNavigation:
|
36
|
+
Exclude:
|
37
|
+
- 'lib/grape-swagger/entity/attribute_parser.rb'
|
38
|
+
|
16
39
|
# Offense count: 4
|
17
|
-
# Configuration parameters: IgnoredMethods.
|
40
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes, Max.
|
18
41
|
Metrics/AbcSize:
|
19
|
-
|
42
|
+
Exclude:
|
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'
|
20
56
|
|
21
57
|
# Offense count: 1
|
22
|
-
# Configuration parameters: CountComments.
|
58
|
+
# Configuration parameters: CountComments, Max, CountAsOne.
|
23
59
|
Metrics/ClassLength:
|
24
|
-
|
60
|
+
Exclude:
|
61
|
+
- 'lib/grape-swagger/entity/attribute_parser.rb'
|
62
|
+
- 'lib/grape-swagger/entity/parser.rb'
|
25
63
|
|
26
64
|
# Offense count: 2
|
27
|
-
# Configuration parameters: IgnoredMethods.
|
65
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, Max.
|
28
66
|
Metrics/CyclomaticComplexity:
|
29
|
-
|
67
|
+
Exclude:
|
68
|
+
- 'lib/grape-swagger/entity/attribute_parser.rb'
|
69
|
+
- 'lib/grape-swagger/entity/parser.rb'
|
30
70
|
|
31
71
|
# Offense count: 5
|
32
|
-
# Configuration parameters: CountComments, ExcludedMethods.
|
72
|
+
# Configuration parameters: CountComments, Max, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
|
33
73
|
Metrics/MethodLength:
|
34
|
-
|
74
|
+
Exclude:
|
75
|
+
- 'lib/grape-swagger/entity/attribute_parser.rb'
|
76
|
+
- 'lib/grape-swagger/entity/parser.rb'
|
35
77
|
|
36
78
|
# Offense count: 2
|
37
|
-
# Configuration parameters: IgnoredMethods.
|
79
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, Max.
|
38
80
|
Metrics/PerceivedComplexity:
|
39
|
-
|
81
|
+
Exclude:
|
82
|
+
- 'lib/grape-swagger/entity/attribute_parser.rb'
|
83
|
+
- 'lib/grape-swagger/entity/parser.rb'
|
84
|
+
|
85
|
+
# Offense count: 2
|
86
|
+
# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
|
87
|
+
# SupportedStyles: snake_case, normalcase, non_integer
|
88
|
+
# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339
|
89
|
+
Naming/VariableNumber:
|
90
|
+
Exclude:
|
91
|
+
- 'spec/grape-swagger/entities/response_model_spec.rb'
|
40
92
|
|
41
93
|
# Offense count: 4
|
94
|
+
# Configuration parameters: AllowedConstants.
|
42
95
|
Style/Documentation:
|
43
96
|
Exclude:
|
44
97
|
- 'spec/**/*'
|
@@ -46,3 +99,9 @@ Style/Documentation:
|
|
46
99
|
- 'lib/grape-swagger/entity.rb'
|
47
100
|
- 'lib/grape-swagger/entity/attribute_parser.rb'
|
48
101
|
- 'lib/grape-swagger/entity/parser.rb'
|
102
|
+
|
103
|
+
# Offense count: 4
|
104
|
+
Style/OpenStructUse:
|
105
|
+
Exclude:
|
106
|
+
- 'spec/grape-swagger/entities/response_model_spec.rb'
|
107
|
+
- 'spec/support/shared_contexts/this_api.rb'
|
data/CHANGELOG.md
CHANGED
@@ -1,24 +1,45 @@
|
|
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
|
-
### 0.5.
|
19
|
+
### 0.5.3 (2024/02/02)
|
12
20
|
|
13
21
|
#### Features
|
14
22
|
|
15
|
-
* [#
|
23
|
+
* [#64](https://github.com/ruby-grape/grape-swagger-entity/pull/64): Pass extension documentation into schema - [@numbata](https://github.com/numbata).
|
24
|
+
|
25
|
+
#### Fixes
|
26
|
+
|
27
|
+
* [#66](https://github.com/ruby-grape/grape-swagger-entity/pull/66): Fix danger GHA - [@mscrivo](https://github.com/mscrivo).
|
16
28
|
|
17
|
-
### 0.5.
|
29
|
+
### 0.5.2 (2023/07/07)
|
18
30
|
|
19
|
-
|
31
|
+
#### Fixes
|
32
|
+
|
33
|
+
* [#60](https://github.com/ruby-grape/grape-swagger-entity/pull/60): Examples on arrays should be directly on the property, not on the item - [@collinsauve](https://github.com/collinsauve).
|
34
|
+
* [#61](https://github.com/ruby-grape/grape-swagger-entity/pull/61): Migrate from Travis to GHA for CI - [@mscrivo](https://github.com/mscrivo).
|
35
|
+
|
36
|
+
### 0.5.1 (2020/06/30)
|
37
|
+
|
38
|
+
#### Features
|
39
|
+
|
40
|
+
* [#50](https://github.com/ruby-grape/grape-swagger-entity/pull/50): Features/inheritance and discriminator - [@MaximeRDY](https://github.com/MaximeRDY).
|
20
41
|
|
21
|
-
### 0.4.0 (
|
42
|
+
### 0.4.0 (2020/05/30)
|
22
43
|
|
23
44
|
#### Features
|
24
45
|
|
@@ -29,81 +50,81 @@ Yanked due to invalid dependency
|
|
29
50
|
|
30
51
|
* [#46](https://github.com/ruby-grape/grape-swagger-entity/pull/46): Fixed issue where a boolean example value of false would not display in swagger file - [@drewnichols](https://github.com/drewnichols).
|
31
52
|
|
32
|
-
### 0.3.4 (
|
53
|
+
### 0.3.4 (2020/01/09)
|
33
54
|
|
34
55
|
#### Features
|
35
56
|
|
36
57
|
* [#40](https://github.com/ruby-grape/grape-swagger-entity/pull/40): Add support for minLength and maxLength - [@fotos](https://github.com/fotos).
|
37
58
|
|
38
|
-
### 0.3.3 (
|
59
|
+
### 0.3.3 (2019/02/22)
|
39
60
|
|
40
61
|
#### Features
|
41
62
|
|
42
63
|
* [#39](https://github.com/ruby-grape/grape-swagger-entity/pull/39): Fix to avoid conflict with polymorphic model - [@kinoppyd](https://github.com/kinoppyd).
|
43
64
|
|
44
|
-
### 0.3.2 (
|
65
|
+
### 0.3.2 (2019/01/15)
|
45
66
|
|
46
67
|
#### Features
|
47
68
|
|
48
69
|
* [#38](https://github.com/ruby-grape/grape-swagger-entity/pull/38): Added support for hidden option for documentation - [@vitoravelino](https://github.com/vitoravelino).
|
49
70
|
|
50
|
-
### 0.3.1 (
|
71
|
+
### 0.3.1 (2018/11/26)
|
51
72
|
|
52
73
|
#### Features
|
53
74
|
|
54
75
|
* [#37](https://github.com/ruby-grape/grape-swagger-entity/pull/37): Add support for minItems, maxItems and uniqueItems - [@fotos](https://github.com/fotos).
|
55
76
|
|
56
|
-
### 0.3.0 (
|
77
|
+
### 0.3.0 (2018/08/22)
|
57
78
|
|
58
79
|
#### Features
|
59
80
|
|
60
81
|
* [#35](https://github.com/ruby-grape/grape-swagger-entity/pull/35): Support for required attributes - [@Bugagazavr](https://github.com/Bugagazavr).
|
61
82
|
|
62
|
-
### 0.2.5 (
|
83
|
+
### 0.2.5 (2018/04/26)
|
63
84
|
|
64
85
|
#### Features
|
65
86
|
|
66
87
|
* [#33](https://github.com/ruby-grape/grape-swagger-entity/pull/33): Update parser to respect merge option for entities - [@b-boogaard](https://github.com/b-boogaard).
|
67
88
|
|
68
|
-
### 0.2.4 (
|
89
|
+
### 0.2.4 (2018/04/03)
|
69
90
|
|
70
91
|
#### Fixes
|
71
92
|
|
72
93
|
* [#32](https://github.com/ruby-grape/grape-swagger-entity/pull/32): Fix issue with read_only fields - [@mcfilib](https://github.com/mcfilib).
|
73
94
|
|
74
|
-
### 0.2.3 (
|
95
|
+
### 0.2.3 (2017/11/19)
|
75
96
|
|
76
97
|
#### Fixes
|
77
98
|
|
78
99
|
* [#30](https://github.com/ruby-grape/grape-swagger-entity/pull/30): Fix nested exposures with an alias - [@Kukunin](https://github.com/Kukunin).
|
79
100
|
* [#31](https://github.com/ruby-grape/grape-swagger-entity/pull/31): Respect `required: true` for nested attributes as well - [@Kukunin](https://github.com/Kukunin).
|
80
101
|
|
81
|
-
### 0.2.2 (
|
102
|
+
### 0.2.2 (2017/11/3)
|
82
103
|
|
83
104
|
#### Features
|
84
105
|
|
85
106
|
* [#27](https://github.com/ruby-grape/grape-swagger-entity/pull/27): Add support for attribute examples - [@Kukunin](https://github.com/Kukunin).
|
86
107
|
|
87
|
-
### 0.2.1 (
|
108
|
+
### 0.2.1 (2017/07/05)
|
88
109
|
|
89
110
|
#### Features
|
90
111
|
|
91
112
|
* [#26](https://github.com/ruby-grape/grape-swagger-entity/pull/26): Add support for read only field - [@FChaack](https://github.com/FChaack).
|
92
113
|
|
93
|
-
### 0.2.0 (
|
114
|
+
### 0.2.0 (2017/03/02)
|
94
115
|
|
95
116
|
#### Features
|
96
117
|
|
97
118
|
* [#22](https://github.com/ruby-grape/grape-swagger-entity/pull/22): Nested exposures - [@Bugagazavr](https://github.com/Bugagazavr).
|
98
119
|
|
99
|
-
### 0.1.6 (
|
120
|
+
### 0.1.6 (2017/02/03)
|
100
121
|
|
101
122
|
#### Features
|
102
123
|
|
103
124
|
* [#21](https://github.com/ruby-grape/grape-swagger-entity/pull/21): Adds support for own format - [@LeFnord](https://github.com/LeFnord).
|
104
125
|
* [#19](https://github.com/ruby-grape/grape-swagger-entity/pull/19): Adds support for default value - [@LeFnord](https://github.com/LeFnord).
|
105
126
|
|
106
|
-
### 0.1.5 (
|
127
|
+
### 0.1.5 (2016/11/21)
|
107
128
|
|
108
129
|
#### Features
|
109
130
|
|
@@ -115,7 +136,7 @@ Yanked due to invalid dependency
|
|
115
136
|
* [#8](https://github.com/ruby-grape/grape-swagger-entity/pull/8): Generate enum property if values key is passed in documentation - [@lordnibbler](https://github.com/lordnibbler).
|
116
137
|
* [#15](https://github.com/ruby-grape/grape-swagger-entity/pull/15): Support grape entity 0.6.x and later - [@Bugagazavr](https://github.com/Bugagazavr).
|
117
138
|
|
118
|
-
### 0.1.4 (
|
139
|
+
### 0.1.4 (2016/06/07)
|
119
140
|
|
120
141
|
#### Fixes
|
121
142
|
|
data/Gemfile
CHANGED
@@ -14,14 +14,14 @@ group :development, :test do
|
|
14
14
|
gem 'rack-test'
|
15
15
|
gem 'rake'
|
16
16
|
gem 'rdoc'
|
17
|
-
gem 'rspec'
|
18
|
-
gem 'rubocop'
|
17
|
+
gem 'rspec'
|
18
|
+
gem 'rubocop'
|
19
19
|
end
|
20
20
|
|
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.
|
25
|
-
gem 'ruby-grape-danger', '~> 0.
|
24
|
+
gem 'grape-entity', ENV.fetch('GRAPE_ENTITY', '1.0.0')
|
25
|
+
gem 'ruby-grape-danger', '~> 0.2.1', require: false
|
26
26
|
gem 'simplecov', require: false
|
27
27
|
end
|
data/README.md
CHANGED
@@ -1,4 +1,18 @@
|
|
1
|
-
# GrapeSwagger::Entity
|
1
|
+
# GrapeSwagger::Entity
|
2
|
+
|
3
|
+
[](https://badge.fury.io/rb/grape-swagger-entity)
|
4
|
+
[](https://github.com/ruby-grape/grape-swagger-entity/actions)
|
5
|
+
|
6
|
+
## Table of Contents
|
7
|
+
|
8
|
+
- [What is grape-swagger-entity?](#what-is-grape-swagger-entity)
|
9
|
+
- [Installation](#installation)
|
10
|
+
- [Development](#development)
|
11
|
+
- [Contributing](#contributing)
|
12
|
+
- [License](#license)
|
13
|
+
|
14
|
+
|
15
|
+
## What is grape-swagger-entity?
|
2
16
|
|
3
17
|
A simple grape-swagger adapter to allow parse representers as response model
|
4
18
|
|
data/RELEASING.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# Releasing Grape-Swagger-Entity
|
2
|
+
|
3
|
+
There are no particular rules about when to release Grape-Swagger-Entity. Release bug fixes frequent, features not so frequently and breaking API changes rarely.
|
4
|
+
|
5
|
+
### Release
|
6
|
+
|
7
|
+
Run tests, check that all tests succeed locally.
|
8
|
+
|
9
|
+
```
|
10
|
+
bundle install
|
11
|
+
rake
|
12
|
+
```
|
13
|
+
|
14
|
+
Check that the last build succeeded in [GitHub Actions](https://github.com/ruby-grape/grape-swagger-entity/actions) for all supported platforms.
|
15
|
+
|
16
|
+
Increment the version, modify [lib/grape-swagger/entity/version.rb](lib/grape-swagger/entity/version.rb).
|
17
|
+
|
18
|
+
* Increment the third number if the release has bug fixes and/or very minor features, only (eg. change `0.1.0` to `0.1.1`).
|
19
|
+
* Increment the second number if the release contains major features or breaking API changes (eg. change `0.1.0` to `0.2.0`).
|
20
|
+
|
21
|
+
Change "Next Release" in [CHANGELOG.md](CHANGELOG.md) to the new version.
|
22
|
+
|
23
|
+
```
|
24
|
+
### 0.1.1 (February 5, 2015)
|
25
|
+
```
|
26
|
+
|
27
|
+
Remove the line with "Your contribution here.", since there will be no more contributions to this release.
|
28
|
+
|
29
|
+
Commit your changes.
|
30
|
+
|
31
|
+
```
|
32
|
+
git add CHANGELOG.md lib/grape-swagger/entity/version.rb CHANGELOG.md
|
33
|
+
git commit -m "Preparing for release, 0.1.1."
|
34
|
+
git push origin master
|
35
|
+
```
|
36
|
+
|
37
|
+
Release.
|
38
|
+
|
39
|
+
```
|
40
|
+
$ rake release
|
41
|
+
|
42
|
+
Grape-Swagger-Entity 0.1.1 built to pkg/grape-swagger-entity-0.1.1.gem.
|
43
|
+
Tagged v0.1.1.
|
44
|
+
Pushed git commits and tags.
|
45
|
+
Pushed grape-swagger-entity 0.1.1 to rubygems.org.
|
46
|
+
```
|
47
|
+
|
48
|
+
### Prepare for the Next Version
|
49
|
+
|
50
|
+
Add the next release to [CHANGELOG.md](CHANGELOG.md).
|
51
|
+
|
52
|
+
```
|
53
|
+
### Next Release
|
54
|
+
|
55
|
+
* Your contribution here.
|
56
|
+
```
|
57
|
+
|
58
|
+
Commit your changes.
|
59
|
+
|
60
|
+
```
|
61
|
+
git add CHANGELOG.md
|
62
|
+
git commit -m "Preparing for next release."
|
63
|
+
git push origin master
|
64
|
+
```
|
@@ -19,7 +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
|
+
s.metadata['rubygems_mfa_required'] = 'true'
|
25
26
|
end
|
@@ -10,40 +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_array_documentation(entity_model_type, documentation) if documentation[:is_array]
|
23
|
-
|
24
|
-
entity_model_type
|
25
|
-
else
|
26
|
-
param = data_type_from(entity_options)
|
27
|
-
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
|
28
19
|
|
29
|
-
|
30
|
-
|
20
|
+
documentation = entity_options[:documentation]
|
21
|
+
return param if documentation.nil?
|
31
22
|
|
32
|
-
|
33
|
-
param[:enum] = values if values.is_a?(Array)
|
34
|
-
end
|
23
|
+
add_array_documentation(param, documentation) if documentation[:is_array]
|
35
24
|
|
36
|
-
|
37
|
-
|
38
|
-
add_array_documentation(param, documentation)
|
39
|
-
end
|
25
|
+
add_attribute_sample(param, documentation, :default)
|
26
|
+
add_attribute_sample(param, documentation, :example)
|
40
27
|
|
41
|
-
|
28
|
+
add_attribute_documentation(param, documentation)
|
42
29
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
30
|
+
add_extension_documentation(param, documentation)
|
31
|
+
add_discriminator_extension(param, documentation)
|
32
|
+
param
|
47
33
|
end
|
48
34
|
|
49
35
|
private
|
@@ -72,13 +58,22 @@ module GrapeSwagger
|
|
72
58
|
!type == Array
|
73
59
|
end
|
74
60
|
|
75
|
-
def data_type_from(
|
76
|
-
|
77
|
-
documented_type
|
61
|
+
def data_type_from(entity_options)
|
62
|
+
documentation = entity_options[:documentation] || {}
|
63
|
+
documented_type = entity_options[:type] || documentation[:type]
|
78
64
|
|
79
65
|
data_type = GrapeSwagger::DocMethods::DataType.call(documented_type)
|
80
66
|
|
81
|
-
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
|
82
77
|
end
|
83
78
|
|
84
79
|
def document_data_type(documentation, data_type)
|
@@ -88,7 +83,12 @@ module GrapeSwagger
|
|
88
83
|
else
|
89
84
|
{ type: data_type }
|
90
85
|
end
|
91
|
-
|
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
|
92
92
|
|
93
93
|
type
|
94
94
|
end
|
@@ -116,6 +116,15 @@ module GrapeSwagger
|
|
116
116
|
end
|
117
117
|
|
118
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
|
+
|
119
128
|
param[:minLength] = documentation[:min_length] if documentation.key?(:min_length)
|
120
129
|
param[:maxLength] = documentation[:max_length] if documentation.key?(:max_length)
|
121
130
|
end
|
@@ -3,9 +3,7 @@
|
|
3
3
|
module GrapeSwagger
|
4
4
|
module Entity
|
5
5
|
class Parser
|
6
|
-
attr_reader :model
|
7
|
-
attr_reader :endpoint
|
8
|
-
attr_reader :attribute_parser
|
6
|
+
attr_reader :model, :endpoint, :attribute_parser
|
9
7
|
|
10
8
|
def initialize(model, endpoint)
|
11
9
|
@model = model
|
@@ -103,19 +101,22 @@ module GrapeSwagger
|
|
103
101
|
end
|
104
102
|
|
105
103
|
def parse_nested(entity_name, entity_options, parent_model = nil)
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
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|
|
113
114
|
memo[value.attribute] = value.send(:options)
|
114
115
|
end
|
115
116
|
|
116
|
-
properties, required = parse_grape_entity_params(params,
|
117
|
-
|
118
|
-
|
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?
|
119
120
|
|
120
121
|
if is_a_collection
|
121
122
|
{
|
data/lib/grape-swagger/entity.rb
CHANGED
metadata
CHANGED
@@ -1,60 +1,62 @@
|
|
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
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
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:
|
41
|
-
description:
|
40
|
+
version: '2'
|
41
|
+
description:
|
42
42
|
email:
|
43
43
|
- kirik910@gmail.com
|
44
44
|
executables: []
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
+
- ".github/workflows/danger.yml"
|
49
|
+
- ".github/workflows/test.yml"
|
48
50
|
- ".gitignore"
|
49
51
|
- ".rspec"
|
50
52
|
- ".rubocop.yml"
|
51
53
|
- ".rubocop_todo.yml"
|
52
|
-
- ".travis.yml"
|
53
54
|
- CHANGELOG.md
|
54
55
|
- Dangerfile
|
55
56
|
- Gemfile
|
56
57
|
- LICENSE.txt
|
57
58
|
- README.md
|
59
|
+
- RELEASING.md
|
58
60
|
- Rakefile
|
59
61
|
- bin/pry
|
60
62
|
- bin/setup
|
@@ -68,8 +70,9 @@ files:
|
|
68
70
|
homepage: https://github.com/ruby-grape/grape-swagger-entity
|
69
71
|
licenses:
|
70
72
|
- MIT
|
71
|
-
metadata:
|
72
|
-
|
73
|
+
metadata:
|
74
|
+
rubygems_mfa_required: 'true'
|
75
|
+
post_install_message:
|
73
76
|
rdoc_options: []
|
74
77
|
require_paths:
|
75
78
|
- lib
|
@@ -77,15 +80,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
77
80
|
requirements:
|
78
81
|
- - ">="
|
79
82
|
- !ruby/object:Gem::Version
|
80
|
-
version: '
|
83
|
+
version: '3.0'
|
81
84
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
85
|
requirements:
|
83
86
|
- - ">="
|
84
87
|
- !ruby/object:Gem::Version
|
85
88
|
version: '0'
|
86
89
|
requirements: []
|
87
|
-
rubygems_version: 3.
|
88
|
-
signing_key:
|
90
|
+
rubygems_version: 3.3.7
|
91
|
+
signing_key:
|
89
92
|
specification_version: 4
|
90
93
|
summary: Grape swagger adapter to support grape-entity object parsing
|
91
94
|
test_files: []
|
data/.travis.yml
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
|
3
|
-
sudo: false
|
4
|
-
|
5
|
-
before_install:
|
6
|
-
- gem update --system
|
7
|
-
- gem install bundler
|
8
|
-
|
9
|
-
after_success:
|
10
|
-
- bundle exec danger
|
11
|
-
|
12
|
-
rvm:
|
13
|
-
- 2.5.8
|
14
|
-
- 2.6.6
|
15
|
-
- 2.7.1
|
16
|
-
|
17
|
-
env:
|
18
|
-
- GRAPE_ENTITY=0.6.1
|
19
|
-
- GRAPE_ENTITY=0.7.1
|
20
|
-
- GRAPE_ENTITY=0.8.0
|
21
|
-
|
22
|
-
matrix:
|
23
|
-
fast_finish: true
|
24
|
-
|
25
|
-
include:
|
26
|
-
- rvm: 2.4.10
|
27
|
-
env:
|
28
|
-
- rvm: ruby-head
|
29
|
-
env:
|
30
|
-
- rvm: jruby-head
|
31
|
-
env:
|
32
|
-
|
33
|
-
allow_failures:
|
34
|
-
- rvm: 2.4.10
|
35
|
-
- rvm: ruby-head
|
36
|
-
- rvm: jruby-head
|