grape-swagger-entity 0.5.1 → 0.5.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45d768ff8d366802a511df94e675aed675d4961c965ac39a130df0e5a5a47f73
4
- data.tar.gz: 29289e700cb29cd5d7078b58e04bb284c5ccad4da1f12e24917d31351cb2210c
3
+ metadata.gz: 66316a1c70ab713f2d7f9899880ed1503f2759d42a3243bf88582f26607f62c3
4
+ data.tar.gz: 8261dc51d4a3b267dd616c3a1e904539962ffe934df614d40ab0a7f378fe79ba
5
5
  SHA512:
6
- metadata.gz: f1f7cb9609b3412b6fb624aaae0346b34549349a40f7912d1c72131fa7c905f47f8307928edb18dbcbc3ba6cefed34ecd861c125b60b45d8cbe1f4633a036199
7
- data.tar.gz: b64399e310447774459e470cb7e9aa1621e2c544641ef16c6ec2e8a3a8cb472fff9cd8e33167a2b61d4939932aaca065172b01526ad099f0011fe989b2e4cdb0
6
+ metadata.gz: '05932d2302fe021785def61b163221e75da82bbb6106026ab5f879b629fd62a2af97034340df6f9273f19a511b56fc913d2471f4c3210e3c09ce679b92d7410a'
7
+ data.tar.gz: 0c86bc0f11753b472db09c658643353dae2e01f369b16f57e19aa816bf9ccf3a249685c2c4b5a4a8fc6a9cde237feec8e81dee7f71ef298e2279653fc0d2a894
@@ -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
@@ -8,4 +8,5 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  .ruby-gemset
11
- .ruby-version
11
+ .ruby-version
12
+ /.idea
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 2020-06-29 22:12:50 UTC using RuboCop version 0.86.0.
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
- Max: 30
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
- Max: 111
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
- Max: 11
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
- Max: 25
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
- Max: 12
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,38 @@
1
- ### Next
1
+ ### 0.5.4 (2024/04/19)
2
2
 
3
3
  #### Features
4
4
 
5
- * Your contribution here.
5
+ * [#69](https://github.com/ruby-grape/grape-swagger-entity/pull/67): Add support for minimum and maximum - [@storey](https://github.com/storey).
6
6
 
7
7
  #### Fixes
8
8
 
9
- * Your contribution here.
9
+ * [#67](https://github.com/ruby-grape/grape-swagger-entity/pull/67): Various build updates - [@mscrivo](https://github.com/mscrivo).
10
+ * [#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
11
 
11
- ### 0.5.1 (June 30, 2020)
12
+ ### 0.5.3 (2024/02/02)
12
13
 
13
14
  #### Features
14
15
 
15
- * [#50](https://github.com/ruby-grape/grape-swagger-entity/pull/50): Features/inheritance and discriminator - [@MaximeRDY](https://github.com/MaximeRDY).
16
+ * [#64](https://github.com/ruby-grape/grape-swagger-entity/pull/64): Pass extension documentation into schema - [@numbata](https://github.com/numbata).
17
+
18
+ #### Fixes
16
19
 
17
- ### 0.5.0 (June 29, 2020)
20
+ * [#66](https://github.com/ruby-grape/grape-swagger-entity/pull/66): Fix danger GHA - [@mscrivo](https://github.com/mscrivo).
21
+
22
+ ### 0.5.2 (2023/07/07)
23
+
24
+ #### Fixes
18
25
 
19
- Yanked due to invalid dependency
26
+ * [#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).
27
+ * [#61](https://github.com/ruby-grape/grape-swagger-entity/pull/61): Migrate from Travis to GHA for CI - [@mscrivo](https://github.com/mscrivo).
28
+
29
+ ### 0.5.1 (2020/06/30)
30
+
31
+ #### Features
32
+
33
+ * [#50](https://github.com/ruby-grape/grape-swagger-entity/pull/50): Features/inheritance and discriminator - [@MaximeRDY](https://github.com/MaximeRDY).
20
34
 
21
- ### 0.4.0 (May 30, 2020)
35
+ ### 0.4.0 (2020/05/30)
22
36
 
23
37
  #### Features
24
38
 
@@ -29,81 +43,81 @@ Yanked due to invalid dependency
29
43
 
30
44
  * [#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
45
 
32
- ### 0.3.4 (January 9, 2020)
46
+ ### 0.3.4 (2020/01/09)
33
47
 
34
48
  #### Features
35
49
 
36
50
  * [#40](https://github.com/ruby-grape/grape-swagger-entity/pull/40): Add support for minLength and maxLength - [@fotos](https://github.com/fotos).
37
51
 
38
- ### 0.3.3 (Fabruary 22, 2019)
52
+ ### 0.3.3 (2019/02/22)
39
53
 
40
54
  #### Features
41
55
 
42
56
  * [#39](https://github.com/ruby-grape/grape-swagger-entity/pull/39): Fix to avoid conflict with polymorphic model - [@kinoppyd](https://github.com/kinoppyd).
43
57
 
44
- ### 0.3.2 (January 15, 2019)
58
+ ### 0.3.2 (2019/01/15)
45
59
 
46
60
  #### Features
47
61
 
48
62
  * [#38](https://github.com/ruby-grape/grape-swagger-entity/pull/38): Added support for hidden option for documentation - [@vitoravelino](https://github.com/vitoravelino).
49
63
 
50
- ### 0.3.1 (November 26, 2018)
64
+ ### 0.3.1 (2018/11/26)
51
65
 
52
66
  #### Features
53
67
 
54
68
  * [#37](https://github.com/ruby-grape/grape-swagger-entity/pull/37): Add support for minItems, maxItems and uniqueItems - [@fotos](https://github.com/fotos).
55
69
 
56
- ### 0.3.0 (August 22, 2018)
70
+ ### 0.3.0 (2018/08/22)
57
71
 
58
72
  #### Features
59
73
 
60
74
  * [#35](https://github.com/ruby-grape/grape-swagger-entity/pull/35): Support for required attributes - [@Bugagazavr](https://github.com/Bugagazavr).
61
75
 
62
- ### 0.2.5 (April 26, 2018)
76
+ ### 0.2.5 (2018/04/26)
63
77
 
64
78
  #### Features
65
79
 
66
80
  * [#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
81
 
68
- ### 0.2.4 (April 3, 2018)
82
+ ### 0.2.4 (2018/04/03)
69
83
 
70
84
  #### Fixes
71
85
 
72
86
  * [#32](https://github.com/ruby-grape/grape-swagger-entity/pull/32): Fix issue with read_only fields - [@mcfilib](https://github.com/mcfilib).
73
87
 
74
- ### 0.2.3 (November 19, 2017)
88
+ ### 0.2.3 (2017/11/19)
75
89
 
76
90
  #### Fixes
77
91
 
78
92
  * [#30](https://github.com/ruby-grape/grape-swagger-entity/pull/30): Fix nested exposures with an alias - [@Kukunin](https://github.com/Kukunin).
79
93
  * [#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
94
 
81
- ### 0.2.2 (November 3, 2017)
95
+ ### 0.2.2 (2017/11/3)
82
96
 
83
97
  #### Features
84
98
 
85
99
  * [#27](https://github.com/ruby-grape/grape-swagger-entity/pull/27): Add support for attribute examples - [@Kukunin](https://github.com/Kukunin).
86
100
 
87
- ### 0.2.1 (Jule 5, 2017)
101
+ ### 0.2.1 (2017/07/05)
88
102
 
89
103
  #### Features
90
104
 
91
105
  * [#26](https://github.com/ruby-grape/grape-swagger-entity/pull/26): Add support for read only field - [@FChaack](https://github.com/FChaack).
92
106
 
93
- ### 0.2.0 (March 2, 2017)
107
+ ### 0.2.0 (2017/03/02)
94
108
 
95
109
  #### Features
96
110
 
97
111
  * [#22](https://github.com/ruby-grape/grape-swagger-entity/pull/22): Nested exposures - [@Bugagazavr](https://github.com/Bugagazavr).
98
112
 
99
- ### 0.1.6 (February 3, 2017)
113
+ ### 0.1.6 (2017/02/03)
100
114
 
101
115
  #### Features
102
116
 
103
117
  * [#21](https://github.com/ruby-grape/grape-swagger-entity/pull/21): Adds support for own format - [@LeFnord](https://github.com/LeFnord).
104
118
  * [#19](https://github.com/ruby-grape/grape-swagger-entity/pull/19): Adds support for default value - [@LeFnord](https://github.com/LeFnord).
105
119
 
106
- ### 0.1.5 (November 21, 2016)
120
+ ### 0.1.5 (2016/11/21)
107
121
 
108
122
  #### Features
109
123
 
@@ -115,7 +129,7 @@ Yanked due to invalid dependency
115
129
  * [#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
130
  * [#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
131
 
118
- ### 0.1.4 (June 7, 2016)
132
+ ### 0.1.4 (2016/06/07)
119
133
 
120
134
  #### Fixes
121
135
 
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', '~> 3.9'
18
- gem 'rubocop', '~> 0.85'
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.6.1')
25
- gem 'ruby-grape-danger', '~> 0.1.1', require: false
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 [![Build Status](https://travis-ci.org/ruby-grape/grape-swagger-entity.svg)](https://travis-ci.org/ruby-grape/grape-swagger-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 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 = '>= 2.4'
23
- s.add_runtime_dependency 'grape-entity', '>= 0.6.0'
24
- s.add_runtime_dependency 'grape-swagger', '>= 1.2.0'
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,30 @@ module GrapeSwagger
10
10
  end
11
11
 
12
12
  def call(entity_options)
13
- documentation = entity_options[:documentation]
14
- entity_model = model_from(entity_options)
15
-
16
- if entity_model
17
- name = GrapeSwagger::Entity::Helper.model_name(entity_model, endpoint)
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]
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
23
19
 
24
- entity_model_type
25
- else
26
- param = data_type_from(entity_options)
27
- return param unless documentation
20
+ documentation = entity_options[:documentation]
21
+ return param if documentation.nil?
28
22
 
29
- add_attribute_sample(param, documentation, :default)
30
- add_attribute_sample(param, documentation, :example)
23
+ if (values = documentation[:values]) && values.is_a?(Array)
24
+ param[:enum] = values
25
+ end
31
26
 
32
- if (values = documentation[:values])
33
- param[:enum] = values if values.is_a?(Array)
34
- end
27
+ add_array_documentation(param, documentation) if documentation[:is_array]
35
28
 
36
- if documentation[:is_array]
37
- param = { type: :array, items: param }
38
- add_array_documentation(param, documentation)
39
- end
29
+ add_attribute_sample(param, documentation, :default)
30
+ add_attribute_sample(param, documentation, :example)
40
31
 
41
- add_attribute_documentation(param, documentation)
32
+ add_attribute_documentation(param, documentation)
42
33
 
43
- add_extension_documentation(param, documentation)
44
- add_discriminator_extension(param, documentation)
45
- param
46
- end
34
+ add_extension_documentation(param, documentation)
35
+ add_discriminator_extension(param, documentation)
36
+ param
47
37
  end
48
38
 
49
39
  private
@@ -74,11 +64,20 @@ module GrapeSwagger
74
64
 
75
65
  def data_type_from(documentation)
76
66
  documented_type = documentation[:type]
77
- documented_type ||= (documentation[:documentation] && documentation[:documentation][:type])
67
+ documented_type ||= documentation[:documentation] && documentation[:documentation][:type]
78
68
 
79
69
  data_type = GrapeSwagger::DocMethods::DataType.call(documented_type)
80
70
 
81
- document_data_type(documentation[:documentation], data_type)
71
+ documented_data_type = document_data_type(documentation[:documentation], data_type)
72
+
73
+ if documentation[:documentation] && documentation[:documentation][:is_array]
74
+ {
75
+ type: :array,
76
+ items: documented_data_type
77
+ }
78
+ else
79
+ documented_data_type
80
+ end
82
81
  end
83
82
 
84
83
  def document_data_type(documentation, data_type)
@@ -116,6 +115,15 @@ module GrapeSwagger
116
115
  end
117
116
 
118
117
  def add_attribute_documentation(param, documentation)
118
+ param[:minimum] = documentation[:minimum] if documentation.key?(:minimum)
119
+ param[:maximum] = documentation[:maximum] if documentation.key?(:maximum)
120
+
121
+ values = documentation[:values]
122
+ if values&.is_a?(Range)
123
+ param[:minimum] = values.begin if values.begin.is_a?(Numeric)
124
+ param[:maximum] = values.end if values.end.is_a?(Numeric)
125
+ end
126
+
119
127
  param[:minLength] = documentation[:min_length] if documentation.key?(:min_length)
120
128
  param[:maxLength] = documentation[:max_length] if documentation.key?(:max_length)
121
129
  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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GrapeSwagger
4
4
  module Entity
5
- VERSION = '0.5.1'
5
+ VERSION = '0.5.4'
6
6
  end
7
7
  end
@@ -13,4 +13,4 @@ module GrapeSwagger
13
13
  end
14
14
  end
15
15
 
16
- GrapeSwagger.model_parsers.register(::GrapeSwagger::Entity::Parser, ::Grape::Entity)
16
+ GrapeSwagger.model_parsers.register(GrapeSwagger::Entity::Parser, Grape::Entity)
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.1
4
+ version: 0.5.4
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: 2020-06-30 00:00:00.000000000 Z
11
+ date: 2024-04-19 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: 0.6.0
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: 0.6.0
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: 1.2.0
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: 1.2.0
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
- post_install_message:
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: '2.4'
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.0.3
88
- signing_key:
90
+ rubygems_version: 3.5.3
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