grape-swagger-entity 0.5.2 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c52f57bfdcfb52cd362e65afc3a53ac2a442eada913a5323866d1b9b485e4f56
4
- data.tar.gz: 6e0e4d87db0738dcaf8e5e5d51a6db8863449dc468dfcc482e8b833e1ef4e27d
3
+ metadata.gz: 66316a1c70ab713f2d7f9899880ed1503f2759d42a3243bf88582f26607f62c3
4
+ data.tar.gz: 8261dc51d4a3b267dd616c3a1e904539962ffe934df614d40ab0a7f378fe79ba
5
5
  SHA512:
6
- metadata.gz: 58121f8454551c748d77754e93ebc54522aeb71f8811dd5186265cc4b7697f5cb9be6a20dd6dd1b3f14e8a3aaf59a5f73aefaf1fea55d7cd702c9996143ea8b7
7
- data.tar.gz: 632da40699409c7d9e4d1954b9159fa80b8f1ef2196672706d15d88f5f8fcf6c55c911d83f2d0ba6a06e7fb9158bc77788b120675ab8ea478a6632379659958e
6
+ metadata.gz: '05932d2302fe021785def61b163221e75da82bbb6106026ab5f879b629fd62a2af97034340df6f9273f19a511b56fc913d2471f4c3210e3c09ce679b92d7410a'
7
+ data.tar.gz: 0c86bc0f11753b472db09c658643353dae2e01f369b16f57e19aa816bf9ccf3a249685c2c4b5a4a8fc6a9cde237feec8e81dee7f71ef298e2279653fc0d2a894
@@ -5,13 +5,13 @@ jobs:
5
5
  danger:
6
6
  runs-on: ubuntu-latest
7
7
  steps:
8
- - uses: actions/checkout@v3
8
+ - uses: actions/checkout@v4
9
9
  with:
10
10
  fetch-depth: 100
11
11
  - name: Set up Ruby
12
12
  uses: ruby/setup-ruby@v1
13
13
  with:
14
- ruby-version: 2.7
14
+ ruby-version: 3.2
15
15
  bundler-cache: true
16
16
  rubygems: latest
17
17
  - name: Run Danger
@@ -10,7 +10,7 @@ jobs:
10
10
  name: RuboCop
11
11
  runs-on: ubuntu-latest
12
12
  steps:
13
- - uses: actions/checkout@v3
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.8.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@v3
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
@@ -58,6 +58,7 @@ Metrics/BlockLength:
58
58
  # Configuration parameters: CountComments, Max, CountAsOne.
59
59
  Metrics/ClassLength:
60
60
  Exclude:
61
+ - 'lib/grape-swagger/entity/attribute_parser.rb'
61
62
  - 'lib/grape-swagger/entity/parser.rb'
62
63
 
63
64
  # Offense count: 2
data/CHANGELOG.md CHANGED
@@ -1,12 +1,23 @@
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-).
11
+
12
+ ### 0.5.3 (2024/02/02)
13
+
14
+ #### Features
15
+
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
19
+
20
+ * [#66](https://github.com/ruby-grape/grape-swagger-entity/pull/66): Fix danger GHA - [@mscrivo](https://github.com/mscrivo).
10
21
 
11
22
  ### 0.5.2 (2023/07/07)
12
23
 
@@ -14,7 +25,6 @@
14
25
 
15
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).
16
27
  * [#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
28
 
19
29
  ### 0.5.1 (2020/06/30)
20
30
 
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.6.1')
25
- gem 'ruby-grape-danger', '~> 0.2.0', 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/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-entity/version.rb
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 = '>= 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
25
  s.metadata['rubygems_mfa_required'] = 'true'
26
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
- if (values = documentation[:values]) && values.is_a?(Array)
30
- param[:enum] = values
31
- end
23
+ if (values = documentation[:values]) && values.is_a?(Array)
24
+ param[:enum] = values
25
+ end
32
26
 
33
- if documentation[:is_array]
34
- param = { type: :array, items: param }
35
- add_array_documentation(param, documentation)
36
- end
27
+ add_array_documentation(param, documentation) if documentation[:is_array]
37
28
 
38
- add_attribute_sample(param, documentation, :default)
39
- add_attribute_sample(param, documentation, :example)
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GrapeSwagger
4
4
  module Entity
5
- VERSION = '0.5.2'
5
+ VERSION = '0.5.4'
6
6
  end
7
7
  end
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.2
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Zaitsev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-10 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
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: '2.4'
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.4.10
90
+ rubygems_version: 3.5.3
91
91
  signing_key:
92
92
  specification_version: 4
93
93
  summary: Grape swagger adapter to support grape-entity object parsing