grape-swagger-entity 0.5.4 → 0.5.5

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: 66316a1c70ab713f2d7f9899880ed1503f2759d42a3243bf88582f26607f62c3
4
- data.tar.gz: 8261dc51d4a3b267dd616c3a1e904539962ffe934df614d40ab0a7f378fe79ba
3
+ metadata.gz: 2acdf9214576f2fd49186e8bf6163382daa19b6842dc08033567d2427aaa5bcc
4
+ data.tar.gz: 50fa87da0ef94dff6128cea9b5178d3455c831b87457768ea8140bd14f8fc001
5
5
  SHA512:
6
- metadata.gz: '05932d2302fe021785def61b163221e75da82bbb6106026ab5f879b629fd62a2af97034340df6f9273f19a511b56fc913d2471f4c3210e3c09ce679b92d7410a'
7
- data.tar.gz: 0c86bc0f11753b472db09c658643353dae2e01f369b16f57e19aa816bf9ccf3a249685c2c4b5a4a8fc6a9cde237feec8e81dee7f71ef298e2279653fc0d2a894
6
+ metadata.gz: 6f7f9ef5026e54fd99035d38e84c358cc8446a117aadeb486f900775ff15a83bc3b5aaa7c0f3c27afbde6a870ec77a3e8e6baf9fcc1c13df024826f1164aecf8
7
+ data.tar.gz: 89b9bcb8ef9693861bf2042f70147f611b9500c0dda4db5cac5b08af03a156281be02ec14afd71722d23fa498fec28308f1d638997bae066f3db4c07c7d98397
data/CHANGELOG.md CHANGED
@@ -1,8 +1,15 @@
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
+
1
8
  ### 0.5.4 (2024/04/19)
2
9
 
3
10
  #### Features
4
11
 
5
- * [#69](https://github.com/ruby-grape/grape-swagger-entity/pull/67): Add support for minimum and maximum - [@storey](https://github.com/storey).
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
 
@@ -20,10 +20,6 @@ module GrapeSwagger
20
20
  documentation = entity_options[:documentation]
21
21
  return param if documentation.nil?
22
22
 
23
- if (values = documentation[:values]) && values.is_a?(Array)
24
- param[:enum] = values
25
- end
26
-
27
23
  add_array_documentation(param, documentation) if documentation[:is_array]
28
24
 
29
25
  add_attribute_sample(param, documentation, :default)
@@ -62,15 +58,15 @@ module GrapeSwagger
62
58
  !type == Array
63
59
  end
64
60
 
65
- def data_type_from(documentation)
66
- documented_type = documentation[:type]
67
- documented_type ||= documentation[:documentation] && documentation[:documentation][:type]
61
+ def data_type_from(entity_options)
62
+ documentation = entity_options[:documentation] || {}
63
+ documented_type = entity_options[:type] || documentation[:type]
68
64
 
69
65
  data_type = GrapeSwagger::DocMethods::DataType.call(documented_type)
70
66
 
71
- documented_data_type = document_data_type(documentation[:documentation], data_type)
67
+ documented_data_type = document_data_type(documentation, data_type)
72
68
 
73
- if documentation[:documentation] && documentation[:documentation][:is_array]
69
+ if documentation[:is_array]
74
70
  {
75
71
  type: :array,
76
72
  items: documented_data_type
@@ -87,7 +83,12 @@ module GrapeSwagger
87
83
  else
88
84
  { type: data_type }
89
85
  end
90
- type[:format] = documentation[:format] if documentation&.key?(:format)
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
91
92
 
92
93
  type
93
94
  end
@@ -101,19 +101,22 @@ module GrapeSwagger
101
101
  end
102
102
 
103
103
  def parse_nested(entity_name, entity_options, parent_model = nil)
104
- nested_entity = if parent_model.nil?
105
- model.root_exposures.find_by(entity_name)
106
- else
107
- parent_model.nested_exposures.find_by(entity_name)
108
- end
109
-
110
- params = nested_entity.nested_exposures.each_with_object({}) do |value, memo|
104
+ nested_entities = if parent_model.nil?
105
+ model.root_exposures.select_by(entity_name)
106
+ else
107
+ parent_model.nested_exposures.select_by(entity_name)
108
+ end
109
+
110
+ params = nested_entities
111
+ .map(&:nested_exposures)
112
+ .flatten
113
+ .each_with_object({}) do |value, memo|
111
114
  memo[value.attribute] = value.send(:options)
112
115
  end
113
116
 
114
- properties, required = parse_grape_entity_params(params, nested_entity)
115
- is_a_collection = entity_options[:documentation].is_a?(Hash) &&
116
- entity_options[:documentation][:type].to_s.casecmp('array').zero?
117
+ properties, required = parse_grape_entity_params(params, nested_entities.last)
118
+ documentation = entity_options[:documentation]
119
+ is_a_collection = documentation.is_a?(Hash) && documentation[:type].to_s.casecmp('array').zero?
117
120
 
118
121
  if is_a_collection
119
122
  {
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GrapeSwagger
4
4
  module Entity
5
- VERSION = '0.5.4'
5
+ VERSION = '0.5.5'
6
6
  end
7
7
  end
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.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Zaitsev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-19 00:00:00.000000000 Z
11
+ date: 2024-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grape-entity
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
89
  requirements: []
90
- rubygems_version: 3.5.3
90
+ rubygems_version: 3.3.7
91
91
  signing_key:
92
92
  specification_version: 4
93
93
  summary: Grape swagger adapter to support grape-entity object parsing