grape-swagger-entity 0.4.0 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- 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 +32 -14
- data/.rubocop_todo.yml +79 -22
- data/CHANGELOG.md +30 -16
- data/Dangerfile +2 -0
- data/Gemfile +5 -3
- data/README.md +15 -1
- data/RELEASING.md +64 -0
- data/Rakefile +2 -0
- data/bin/pry +1 -0
- data/grape-swagger-entity.gemspec +6 -3
- data/lib/grape-swagger/entity/attribute_parser.rb +15 -10
- data/lib/grape-swagger/entity/helper.rb +38 -0
- data/lib/grape-swagger/entity/parser.rb +38 -5
- data/lib/grape-swagger/entity/version.rb +3 -1
- data/lib/grape-swagger/entity.rb +4 -1
- data/lib/grape-swagger-entity.rb +2 -0
- metadata +18 -14
- data/.travis.yml +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c52f57bfdcfb52cd362e65afc3a53ac2a442eada913a5323866d1b9b485e4f56
|
4
|
+
data.tar.gz: 6e0e4d87db0738dcaf8e5e5d51a6db8863449dc468dfcc482e8b833e1ef4e27d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58121f8454551c748d77754e93ebc54522aeb71f8811dd5186265cc4b7697f5cb9be6a20dd6dd1b3f14e8a3aaf59a5f73aefaf1fea55d7cd702c9996143ea8b7
|
7
|
+
data.tar.gz: 632da40699409c7d9e4d1954b9159fa80b8f1ef2196672706d15d88f5f8fcf6c55c911d83f2d0ba6a06e7fb9158bc77788b120675ab8ea478a6632379659958e
|
@@ -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@v3
|
9
|
+
with:
|
10
|
+
fetch-depth: 100
|
11
|
+
- name: Set up Ruby
|
12
|
+
uses: ruby/setup-ruby@v1
|
13
|
+
with:
|
14
|
+
ruby-version: 2.7
|
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@v3
|
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: 0.8.0
|
28
|
+
|
29
|
+
runs-on: ubuntu-latest
|
30
|
+
strategy:
|
31
|
+
fail-fast: false
|
32
|
+
matrix:
|
33
|
+
ruby-version: ['3.0', '3.1', '3.2']
|
34
|
+
|
35
|
+
steps:
|
36
|
+
- uses: actions/checkout@v3
|
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,25 +1,43 @@
|
|
1
1
|
AllCops:
|
2
|
+
NewCops: enable
|
2
3
|
Exclude:
|
3
4
|
- vendor/**/*
|
4
5
|
TargetRubyVersion:
|
5
|
-
2.
|
6
|
+
2.7
|
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
|
|
24
|
-
Layout/
|
13
|
+
Layout/FirstHashElementIndentation:
|
25
14
|
EnforcedStyle: consistent
|
15
|
+
|
16
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
17
|
+
Enabled: true
|
18
|
+
Layout/SpaceAroundMethodCallOperator:
|
19
|
+
Enabled: true
|
20
|
+
Lint/DeprecatedOpenSSLConstant:
|
21
|
+
Enabled: true
|
22
|
+
Lint/MixedRegexpCaptureTypes:
|
23
|
+
Enabled: true
|
24
|
+
Lint/RaiseException:
|
25
|
+
Enabled: true
|
26
|
+
Lint/StructNewOverride:
|
27
|
+
Enabled: true
|
28
|
+
Style/ExponentialNotation:
|
29
|
+
Enabled: true
|
30
|
+
Style/HashEachMethods:
|
31
|
+
Enabled: true
|
32
|
+
Style/HashTransformKeys:
|
33
|
+
Enabled: true
|
34
|
+
Style/HashTransformValues:
|
35
|
+
Enabled: true
|
36
|
+
Style/RedundantFetchBlock:
|
37
|
+
Enabled: true
|
38
|
+
Style/RedundantRegexpCharacterClass:
|
39
|
+
Enabled: true
|
40
|
+
Style/RedundantRegexpEscape:
|
41
|
+
Enabled: true
|
42
|
+
Style/SlicingWithRange:
|
43
|
+
Enabled: true
|
data/.rubocop_todo.yml
CHANGED
@@ -1,49 +1,106 @@
|
|
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
|
-
# Offense count:
|
10
|
-
|
11
|
-
|
9
|
+
# Offense count: 1
|
10
|
+
# Configuration parameters: Severity, Include.
|
11
|
+
# Include: **/*.gemspec
|
12
|
+
Gemspec/RequiredRubyVersion:
|
13
|
+
Exclude:
|
14
|
+
- 'grape-swagger-entity.gemspec'
|
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'
|
12
30
|
|
13
31
|
# Offense count: 1
|
14
|
-
#
|
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
|
+
|
39
|
+
# Offense count: 4
|
40
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes, Max.
|
41
|
+
Metrics/AbcSize:
|
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
|
15
49
|
Metrics/BlockLength:
|
16
|
-
|
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'
|
17
56
|
|
18
57
|
# Offense count: 1
|
19
|
-
# Configuration parameters: CountComments.
|
58
|
+
# Configuration parameters: CountComments, Max, CountAsOne.
|
20
59
|
Metrics/ClassLength:
|
21
|
-
|
60
|
+
Exclude:
|
61
|
+
- 'lib/grape-swagger/entity/parser.rb'
|
22
62
|
|
23
|
-
# Offense count:
|
63
|
+
# Offense count: 2
|
64
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, Max.
|
24
65
|
Metrics/CyclomaticComplexity:
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
29
|
-
# URISchemes: http, https
|
30
|
-
Metrics/LineLength:
|
31
|
-
Max: 120
|
66
|
+
Exclude:
|
67
|
+
- 'lib/grape-swagger/entity/attribute_parser.rb'
|
68
|
+
- 'lib/grape-swagger/entity/parser.rb'
|
32
69
|
|
33
|
-
# Offense count:
|
34
|
-
# Configuration parameters: CountComments.
|
70
|
+
# Offense count: 5
|
71
|
+
# Configuration parameters: CountComments, Max, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
|
35
72
|
Metrics/MethodLength:
|
36
|
-
|
73
|
+
Exclude:
|
74
|
+
- 'lib/grape-swagger/entity/attribute_parser.rb'
|
75
|
+
- 'lib/grape-swagger/entity/parser.rb'
|
37
76
|
|
38
77
|
# Offense count: 2
|
78
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, Max.
|
39
79
|
Metrics/PerceivedComplexity:
|
40
|
-
|
80
|
+
Exclude:
|
81
|
+
- 'lib/grape-swagger/entity/attribute_parser.rb'
|
82
|
+
- 'lib/grape-swagger/entity/parser.rb'
|
41
83
|
|
42
84
|
# Offense count: 2
|
85
|
+
# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
|
86
|
+
# SupportedStyles: snake_case, normalcase, non_integer
|
87
|
+
# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339
|
88
|
+
Naming/VariableNumber:
|
89
|
+
Exclude:
|
90
|
+
- 'spec/grape-swagger/entities/response_model_spec.rb'
|
91
|
+
|
92
|
+
# Offense count: 4
|
93
|
+
# Configuration parameters: AllowedConstants.
|
43
94
|
Style/Documentation:
|
44
95
|
Exclude:
|
45
96
|
- 'spec/**/*'
|
46
97
|
- 'test/**/*'
|
47
98
|
- 'lib/grape-swagger/entity.rb'
|
48
|
-
- 'lib/grape-swagger/entity/parser.rb'
|
49
99
|
- 'lib/grape-swagger/entity/attribute_parser.rb'
|
100
|
+
- 'lib/grape-swagger/entity/parser.rb'
|
101
|
+
|
102
|
+
# Offense count: 4
|
103
|
+
Style/OpenStructUse:
|
104
|
+
Exclude:
|
105
|
+
- 'spec/grape-swagger/entities/response_model_spec.rb'
|
106
|
+
- 'spec/support/shared_contexts/this_api.rb'
|
data/CHANGELOG.md
CHANGED
@@ -4,11 +4,25 @@
|
|
4
4
|
|
5
5
|
* Your contribution here.
|
6
6
|
|
7
|
-
####
|
7
|
+
#### Fixes
|
8
8
|
|
9
9
|
* Your contribution here.
|
10
10
|
|
11
|
-
### 0.
|
11
|
+
### 0.5.2 (2023/07/07)
|
12
|
+
|
13
|
+
#### Fixes
|
14
|
+
|
15
|
+
* [#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).
|
16
|
+
* [#61](https://github.com/ruby-grape/grape-swagger-entity/pull/61): Migrate from Travis to GHA for CI - [@mscrivo](https://github.com/mscrivo).
|
17
|
+
* Your contribution here.
|
18
|
+
|
19
|
+
### 0.5.1 (2020/06/30)
|
20
|
+
|
21
|
+
#### Features
|
22
|
+
|
23
|
+
* [#50](https://github.com/ruby-grape/grape-swagger-entity/pull/50): Features/inheritance and discriminator - [@MaximeRDY](https://github.com/MaximeRDY).
|
24
|
+
|
25
|
+
### 0.4.0 (2020/05/30)
|
12
26
|
|
13
27
|
#### Features
|
14
28
|
|
@@ -19,81 +33,81 @@
|
|
19
33
|
|
20
34
|
* [#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).
|
21
35
|
|
22
|
-
### 0.3.4 (
|
36
|
+
### 0.3.4 (2020/01/09)
|
23
37
|
|
24
38
|
#### Features
|
25
39
|
|
26
40
|
* [#40](https://github.com/ruby-grape/grape-swagger-entity/pull/40): Add support for minLength and maxLength - [@fotos](https://github.com/fotos).
|
27
41
|
|
28
|
-
### 0.3.3 (
|
42
|
+
### 0.3.3 (2019/02/22)
|
29
43
|
|
30
44
|
#### Features
|
31
45
|
|
32
46
|
* [#39](https://github.com/ruby-grape/grape-swagger-entity/pull/39): Fix to avoid conflict with polymorphic model - [@kinoppyd](https://github.com/kinoppyd).
|
33
47
|
|
34
|
-
### 0.3.2 (
|
48
|
+
### 0.3.2 (2019/01/15)
|
35
49
|
|
36
50
|
#### Features
|
37
51
|
|
38
52
|
* [#38](https://github.com/ruby-grape/grape-swagger-entity/pull/38): Added support for hidden option for documentation - [@vitoravelino](https://github.com/vitoravelino).
|
39
53
|
|
40
|
-
### 0.3.1 (
|
54
|
+
### 0.3.1 (2018/11/26)
|
41
55
|
|
42
56
|
#### Features
|
43
57
|
|
44
58
|
* [#37](https://github.com/ruby-grape/grape-swagger-entity/pull/37): Add support for minItems, maxItems and uniqueItems - [@fotos](https://github.com/fotos).
|
45
59
|
|
46
|
-
### 0.3.0 (
|
60
|
+
### 0.3.0 (2018/08/22)
|
47
61
|
|
48
62
|
#### Features
|
49
63
|
|
50
64
|
* [#35](https://github.com/ruby-grape/grape-swagger-entity/pull/35): Support for required attributes - [@Bugagazavr](https://github.com/Bugagazavr).
|
51
65
|
|
52
|
-
### 0.2.5 (
|
66
|
+
### 0.2.5 (2018/04/26)
|
53
67
|
|
54
68
|
#### Features
|
55
69
|
|
56
70
|
* [#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).
|
57
71
|
|
58
|
-
### 0.2.4 (
|
72
|
+
### 0.2.4 (2018/04/03)
|
59
73
|
|
60
74
|
#### Fixes
|
61
75
|
|
62
76
|
* [#32](https://github.com/ruby-grape/grape-swagger-entity/pull/32): Fix issue with read_only fields - [@mcfilib](https://github.com/mcfilib).
|
63
77
|
|
64
|
-
### 0.2.3 (
|
78
|
+
### 0.2.3 (2017/11/19)
|
65
79
|
|
66
80
|
#### Fixes
|
67
81
|
|
68
82
|
* [#30](https://github.com/ruby-grape/grape-swagger-entity/pull/30): Fix nested exposures with an alias - [@Kukunin](https://github.com/Kukunin).
|
69
83
|
* [#31](https://github.com/ruby-grape/grape-swagger-entity/pull/31): Respect `required: true` for nested attributes as well - [@Kukunin](https://github.com/Kukunin).
|
70
84
|
|
71
|
-
### 0.2.2 (
|
85
|
+
### 0.2.2 (2017/11/3)
|
72
86
|
|
73
87
|
#### Features
|
74
88
|
|
75
89
|
* [#27](https://github.com/ruby-grape/grape-swagger-entity/pull/27): Add support for attribute examples - [@Kukunin](https://github.com/Kukunin).
|
76
90
|
|
77
|
-
### 0.2.1 (
|
91
|
+
### 0.2.1 (2017/07/05)
|
78
92
|
|
79
93
|
#### Features
|
80
94
|
|
81
95
|
* [#26](https://github.com/ruby-grape/grape-swagger-entity/pull/26): Add support for read only field - [@FChaack](https://github.com/FChaack).
|
82
96
|
|
83
|
-
### 0.2.0 (
|
97
|
+
### 0.2.0 (2017/03/02)
|
84
98
|
|
85
99
|
#### Features
|
86
100
|
|
87
101
|
* [#22](https://github.com/ruby-grape/grape-swagger-entity/pull/22): Nested exposures - [@Bugagazavr](https://github.com/Bugagazavr).
|
88
102
|
|
89
|
-
### 0.1.6 (
|
103
|
+
### 0.1.6 (2017/02/03)
|
90
104
|
|
91
105
|
#### Features
|
92
106
|
|
93
107
|
* [#21](https://github.com/ruby-grape/grape-swagger-entity/pull/21): Adds support for own format - [@LeFnord](https://github.com/LeFnord).
|
94
108
|
* [#19](https://github.com/ruby-grape/grape-swagger-entity/pull/19): Adds support for default value - [@LeFnord](https://github.com/LeFnord).
|
95
109
|
|
96
|
-
### 0.1.5 (
|
110
|
+
### 0.1.5 (2016/11/21)
|
97
111
|
|
98
112
|
#### Features
|
99
113
|
|
@@ -105,7 +119,7 @@
|
|
105
119
|
* [#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).
|
106
120
|
* [#15](https://github.com/ruby-grape/grape-swagger-entity/pull/15): Support grape entity 0.6.x and later - [@Bugagazavr](https://github.com/Bugagazavr).
|
107
121
|
|
108
|
-
### 0.1.4 (
|
122
|
+
### 0.1.4 (2016/06/07)
|
109
123
|
|
110
124
|
#### Fixes
|
111
125
|
|
data/Dangerfile
CHANGED
data/Gemfile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
# Specify your gem's dependencies in grape-swagger-entity.gemspec
|
@@ -12,14 +14,14 @@ group :development, :test do
|
|
12
14
|
gem 'rack-test'
|
13
15
|
gem 'rake'
|
14
16
|
gem 'rdoc'
|
15
|
-
gem 'rspec'
|
16
|
-
gem 'rubocop'
|
17
|
+
gem 'rspec'
|
18
|
+
gem 'rubocop'
|
17
19
|
end
|
18
20
|
|
19
21
|
gem 'grape-swagger', git: 'https://github.com/ruby-grape/grape-swagger.git'
|
20
22
|
|
21
23
|
group :test do
|
22
24
|
gem 'grape-entity', ENV.fetch('GRAPE_ENTITY', '0.6.1')
|
23
|
-
gem 'ruby-grape-danger', '~> 0.
|
25
|
+
gem 'ruby-grape-danger', '~> 0.2.0', require: false
|
24
26
|
gem 'simplecov', require: false
|
25
27
|
end
|
data/README.md
CHANGED
@@ -1,4 +1,18 @@
|
|
1
|
-
# GrapeSwagger::Entity
|
1
|
+
# GrapeSwagger::Entity
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/grape-swagger-entity.svg)](https://badge.fury.io/rb/grape-swagger-entity)
|
4
|
+
[![Build Status](https://github.com/ruby-grape/grape-swagger-entity/workflows/test/badge.svg?branch=master)](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
|
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
|
+
```
|
data/Rakefile
CHANGED
data/bin/pry
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
lib = File.expand_path('lib', __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
require 'grape-swagger/entity/version'
|
@@ -17,7 +19,8 @@ Gem::Specification.new do |s|
|
|
17
19
|
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
20
|
s.require_paths = ['lib']
|
19
21
|
|
20
|
-
s.required_ruby_version = '>= 2.
|
21
|
-
s.add_runtime_dependency 'grape-entity', '>= 0.
|
22
|
-
s.add_runtime_dependency 'grape-swagger', '>= 1.
|
22
|
+
s.required_ruby_version = '>= 2.4'
|
23
|
+
s.add_runtime_dependency 'grape-entity', '>= 0.6.0'
|
24
|
+
s.add_runtime_dependency 'grape-swagger', '>= 1.2.0'
|
25
|
+
s.metadata['rubygems_mfa_required'] = 'true'
|
23
26
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module GrapeSwagger
|
2
4
|
module Entity
|
3
5
|
class AttributeParser
|
@@ -12,7 +14,7 @@ module GrapeSwagger
|
|
12
14
|
entity_model = model_from(entity_options)
|
13
15
|
|
14
16
|
if entity_model
|
15
|
-
name =
|
17
|
+
name = GrapeSwagger::Entity::Helper.model_name(entity_model, endpoint)
|
16
18
|
|
17
19
|
entity_model_type = entity_model_type(name, entity_options)
|
18
20
|
return entity_model_type unless documentation
|
@@ -24,11 +26,8 @@ module GrapeSwagger
|
|
24
26
|
param = data_type_from(entity_options)
|
25
27
|
return param unless documentation
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
if (values = documentation[:values])
|
31
|
-
param[:enum] = values if values.is_a?(Array)
|
29
|
+
if (values = documentation[:values]) && values.is_a?(Array)
|
30
|
+
param[:enum] = values
|
32
31
|
end
|
33
32
|
|
34
33
|
if documentation[:is_array]
|
@@ -36,10 +35,13 @@ module GrapeSwagger
|
|
36
35
|
add_array_documentation(param, documentation)
|
37
36
|
end
|
38
37
|
|
38
|
+
add_attribute_sample(param, documentation, :default)
|
39
|
+
add_attribute_sample(param, documentation, :example)
|
40
|
+
|
39
41
|
add_attribute_documentation(param, documentation)
|
40
42
|
|
41
43
|
add_extension_documentation(param, documentation)
|
42
|
-
|
44
|
+
add_discriminator_extension(param, documentation)
|
43
45
|
param
|
44
46
|
end
|
45
47
|
end
|
@@ -65,8 +67,7 @@ module GrapeSwagger
|
|
65
67
|
end
|
66
68
|
|
67
69
|
def ambiguous_model_type?(type)
|
68
|
-
type &&
|
69
|
-
type.is_a?(Class) &&
|
70
|
+
type&.is_a?(Class) &&
|
70
71
|
!GrapeSwagger::DocMethods::DataType.primitive?(type.name.downcase) &&
|
71
72
|
!type == Array
|
72
73
|
end
|
@@ -87,7 +88,7 @@ module GrapeSwagger
|
|
87
88
|
else
|
88
89
|
{ type: data_type }
|
89
90
|
end
|
90
|
-
type[:format] = documentation[:format] if documentation
|
91
|
+
type[:format] = documentation[:format] if documentation&.key?(:format)
|
91
92
|
|
92
93
|
type
|
93
94
|
end
|
@@ -128,6 +129,10 @@ module GrapeSwagger
|
|
128
129
|
def add_extension_documentation(param, documentation)
|
129
130
|
GrapeSwagger::DocMethods::Extensions.add_extensions_to_root(documentation, param)
|
130
131
|
end
|
132
|
+
|
133
|
+
def add_discriminator_extension(param, documentation)
|
134
|
+
param[:documentation] = { is_discriminator: true } if documentation.key?(:is_discriminator)
|
135
|
+
end
|
131
136
|
end
|
132
137
|
end
|
133
138
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GrapeSwagger
|
4
|
+
module Entity
|
5
|
+
# Helper methods for DRY
|
6
|
+
class Helper
|
7
|
+
class << self
|
8
|
+
def model_name(entity_model, endpoint)
|
9
|
+
if endpoint.nil?
|
10
|
+
entity_model.to_s.demodulize
|
11
|
+
else
|
12
|
+
endpoint.send(:expose_params_from_model, entity_model)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def discriminator(entity_model)
|
17
|
+
entity_model.superclass.root_exposures.detect do |value|
|
18
|
+
value.documentation&.dig(:is_discriminator)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def root_exposures_without_parent(entity_model)
|
23
|
+
entity_model.root_exposures.select do |value|
|
24
|
+
entity_model.superclass.root_exposures.find_by(value.attribute).nil?
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def root_exposure_with_discriminator(entity_model)
|
29
|
+
if discriminator(entity_model)
|
30
|
+
root_exposures_without_parent(entity_model)
|
31
|
+
else
|
32
|
+
entity_model.root_exposures
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module GrapeSwagger
|
2
4
|
module Entity
|
3
5
|
class Parser
|
4
|
-
attr_reader :model
|
5
|
-
attr_reader :endpoint
|
6
|
-
attr_reader :attribute_parser
|
6
|
+
attr_reader :model, :endpoint, :attribute_parser
|
7
7
|
|
8
8
|
def initialize(model, endpoint)
|
9
9
|
@model = model
|
@@ -19,6 +19,7 @@ module GrapeSwagger
|
|
19
19
|
|
20
20
|
class Alias
|
21
21
|
attr_reader :original, :renamed
|
22
|
+
|
22
23
|
def initialize(original, renamed)
|
23
24
|
@original = original
|
24
25
|
@renamed = renamed
|
@@ -26,7 +27,7 @@ module GrapeSwagger
|
|
26
27
|
end
|
27
28
|
|
28
29
|
def extract_params(exposure)
|
29
|
-
exposure.
|
30
|
+
GrapeSwagger::Entity::Helper.root_exposure_with_discriminator(exposure).each_with_object({}) do |value, memo|
|
30
31
|
if value.for_merge && (value.respond_to?(:entity_class) || value.respond_to?(:using_class_name))
|
31
32
|
entity_class = value.respond_to?(:entity_class) ? value.entity_class : value.using_class_name
|
32
33
|
|
@@ -64,7 +65,39 @@ module GrapeSwagger
|
|
64
65
|
memo[final_entity_name][:description] = documentation[:desc] if documentation[:desc]
|
65
66
|
end
|
66
67
|
|
67
|
-
|
68
|
+
discriminator = GrapeSwagger::Entity::Helper.discriminator(model)
|
69
|
+
if discriminator
|
70
|
+
respond_with_all_of(parsed, params, discriminator)
|
71
|
+
else
|
72
|
+
[parsed, required_params(params)]
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def respond_with_all_of(parsed, params, discriminator)
|
77
|
+
parent_name = GrapeSwagger::Entity::Helper.model_name(model.superclass, endpoint)
|
78
|
+
|
79
|
+
{
|
80
|
+
allOf: [
|
81
|
+
{
|
82
|
+
'$ref' => "#/definitions/#{parent_name}"
|
83
|
+
},
|
84
|
+
[
|
85
|
+
add_discriminator(parsed, discriminator),
|
86
|
+
required_params(params).push(discriminator.attribute)
|
87
|
+
]
|
88
|
+
]
|
89
|
+
}
|
90
|
+
end
|
91
|
+
|
92
|
+
def add_discriminator(parsed, discriminator)
|
93
|
+
model_name = GrapeSwagger::Entity::Helper.model_name(model, endpoint)
|
94
|
+
|
95
|
+
parsed.merge(
|
96
|
+
discriminator.attribute => {
|
97
|
+
type: 'string',
|
98
|
+
enum: [model_name]
|
99
|
+
}
|
100
|
+
)
|
68
101
|
end
|
69
102
|
|
70
103
|
def parse_nested(entity_name, entity_options, parent_model = nil)
|
data/lib/grape-swagger/entity.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'grape-swagger'
|
2
4
|
require 'grape-entity'
|
3
5
|
|
4
6
|
require 'grape-swagger/entity/version'
|
7
|
+
require 'grape-swagger/entity/helper'
|
5
8
|
require 'grape-swagger/entity/attribute_parser'
|
6
9
|
require 'grape-swagger/entity/parser'
|
7
10
|
|
@@ -10,4 +13,4 @@ module GrapeSwagger
|
|
10
13
|
end
|
11
14
|
end
|
12
15
|
|
13
|
-
GrapeSwagger.model_parsers.register(
|
16
|
+
GrapeSwagger.model_parsers.register(GrapeSwagger::Entity::Parser, Grape::Entity)
|
data/lib/grape-swagger-entity.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.5.2
|
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: 2023-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: grape-entity
|
@@ -16,45 +16,47 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.6.0
|
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: 0.
|
26
|
+
version: 0.6.0
|
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: 1.
|
33
|
+
version: 1.2.0
|
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: 1.
|
41
|
-
description:
|
40
|
+
version: 1.2.0
|
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
|
@@ -62,13 +64,15 @@ files:
|
|
62
64
|
- lib/grape-swagger-entity.rb
|
63
65
|
- lib/grape-swagger/entity.rb
|
64
66
|
- lib/grape-swagger/entity/attribute_parser.rb
|
67
|
+
- lib/grape-swagger/entity/helper.rb
|
65
68
|
- lib/grape-swagger/entity/parser.rb
|
66
69
|
- lib/grape-swagger/entity/version.rb
|
67
70
|
homepage: https://github.com/ruby-grape/grape-swagger-entity
|
68
71
|
licenses:
|
69
72
|
- MIT
|
70
|
-
metadata:
|
71
|
-
|
73
|
+
metadata:
|
74
|
+
rubygems_mfa_required: 'true'
|
75
|
+
post_install_message:
|
72
76
|
rdoc_options: []
|
73
77
|
require_paths:
|
74
78
|
- lib
|
@@ -76,15 +80,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
76
80
|
requirements:
|
77
81
|
- - ">="
|
78
82
|
- !ruby/object:Gem::Version
|
79
|
-
version: 2.
|
83
|
+
version: '2.4'
|
80
84
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
85
|
requirements:
|
82
86
|
- - ">="
|
83
87
|
- !ruby/object:Gem::Version
|
84
88
|
version: '0'
|
85
89
|
requirements: []
|
86
|
-
rubygems_version: 3.
|
87
|
-
signing_key:
|
90
|
+
rubygems_version: 3.4.10
|
91
|
+
signing_key:
|
88
92
|
specification_version: 4
|
89
93
|
summary: Grape swagger adapter to support grape-entity object parsing
|
90
94
|
test_files: []
|
data/.travis.yml
DELETED
@@ -1,38 +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.4.5
|
14
|
-
- 2.5.3
|
15
|
-
- 2.6.0
|
16
|
-
|
17
|
-
env:
|
18
|
-
- GRAPE_ENTITY=0.6.1
|
19
|
-
- GRAPE_ENTITY=0.7.1
|
20
|
-
|
21
|
-
matrix:
|
22
|
-
fast_finish: true
|
23
|
-
|
24
|
-
include:
|
25
|
-
- rvm: 2.3.8
|
26
|
-
env:
|
27
|
-
- rvm: ruby-head
|
28
|
-
env:
|
29
|
-
- rvm: jruby-head
|
30
|
-
env:
|
31
|
-
- rvm: rbx-2
|
32
|
-
env:
|
33
|
-
|
34
|
-
allow_failures:
|
35
|
-
- rvm: 2.3.8
|
36
|
-
- rvm: ruby-head
|
37
|
-
- rvm: jruby-head
|
38
|
-
- rvm: rbx-2
|