jbuilder-schema 2.5.0 → 2.6.0

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: 7b91da7438556fc92910dbf0f50ac15c54f62593985f1baacb9d1cda87c09e2e
4
- data.tar.gz: bd9e173ce9473d32ca6c3a62d0af33411e76782a927c6ec6b0542a23a8f340dc
3
+ metadata.gz: ee4548cc207982dd75132d63f96e9396757af0b812b8649fb648cf978de0c4a7
4
+ data.tar.gz: fa0b95d49b9b0cb1cde94381bc0f217b08f89900d1b7f2bac72e9e3e2cd6ab41
5
5
  SHA512:
6
- metadata.gz: d5be408235c5190215d78d4d5946f4bb3a28becd80ccbb3a727225efc5f9c48f48903b8ed719296b344bcbf648f9a0d9a2e93ccedf4e475e4e874ca7142b6fa0
7
- data.tar.gz: 89775b8f6a5819561eb33c8e0af6847167db2de6c0f719981de6bf393e072234fd36baf763dace85e773c5cd761dc93781c81c2a7548f19811111cefa24114e6
6
+ metadata.gz: e7d4fd3b56407c18a94877387f92f7c53f8632f0c610a7595bb567ec380454b72de0be3c68be5f17d9ece12dc78785aabb965a9a44d078b78b2d25e043c8b93c
7
+ data.tar.gz: 33ed871b094e1bb4103c7e07f4ab949ca9e595fa959433f449aed6e1f81a6b6f85d29da22b4185baee392a9385fdbd20035d0d8b045801844c9d1751675b371e
@@ -112,7 +112,13 @@ class Jbuilder::Schema
112
112
  @within_block = _within_block?(&block)
113
113
 
114
114
  _with_schema_overrides(schema) do
115
- _attributes.merge! type: :array, items: _scope { super(collection, *args, &block) }
115
+ # TODO: Find a better solution
116
+ # Here we basically remove allOf key from items, because it's redundant, although valid.
117
+ # Better would be not to set it if it's not needed, but I couldn't figure how,
118
+ # as we have array of separate object partials hare, so each one of them would legally have allOf key.
119
+ items = _scope { super(collection, *args, &block) }
120
+ items = items[:allOf].first if items.key?(:allOf)
121
+ _attributes.merge! type: :array, items: items
116
122
  end
117
123
  end
118
124
  ensure
@@ -174,7 +180,7 @@ class Jbuilder::Schema
174
180
 
175
181
  def _nullify_non_required_types(attributes, required)
176
182
  attributes.transform_values! {
177
- _1[:type] = [_1[:type], "null"] unless required.include?(attributes.key(_1))
183
+ _1[:nullable] = true unless required.include?(attributes.key(_1))
178
184
  _1
179
185
  }
180
186
  end
@@ -191,7 +197,7 @@ class Jbuilder::Schema
191
197
  if array
192
198
  _attributes.merge! type: :array, items: ref
193
199
  else
194
- _attributes.merge! type: :object, **ref
200
+ _attributes.merge! allOf: [ref]
195
201
  end
196
202
  end
197
203
 
@@ -236,7 +242,7 @@ class Jbuilder::Schema
236
242
  end
237
243
 
238
244
  def _set_value(key, value)
239
- value = _schema(key, value) unless value.is_a?(::Hash) && value.key?(:type)
245
+ value = _schema(key, value) unless value.is_a?(::Hash) && (value.key?(:type) || value.key?(:allOf)) # rubocop:disable Style/UnlessLogicalOperators
240
246
  _set_description(key, value)
241
247
  super
242
248
  end
@@ -259,7 +265,8 @@ class Jbuilder::Schema
259
265
  raise NullError.build(key) if current_value.nil?
260
266
 
261
267
  value = _scope { yield self }
262
- value = _object(value, _required!(value.keys)) unless value[:type] == :array || value.key?(:$ref)
268
+ value = _object(value, _required!(value.keys)) unless value[:type] == :array || value.key?(:allOf)
269
+
263
270
  _merge_values(current_value, value)
264
271
  end
265
272
 
@@ -1,4 +1,4 @@
1
1
  # We can't use the standard `Jbuilder::Schema::VERSION =` because
2
2
  # `Jbuilder` isn't a regular module namespace, but a class …which also loads Active Support.
3
3
  # So we use trickery, and assign the proper version once `jbuilder/schema.rb` is loaded.
4
- JBUILDER_SCHEMA_VERSION = "2.5.0"
4
+ JBUILDER_SCHEMA_VERSION = "2.6.0"
@@ -37,7 +37,7 @@ class Jbuilder::Schema
37
37
  if paths.nil? && locals.nil?
38
38
  @renderer ||= Renderer.new("app/views")
39
39
  else
40
- Renderer.new(paths, locals)
40
+ @renderer = Renderer.new(paths, locals)
41
41
  end
42
42
  end
43
43
  singleton_class.delegate :yaml, :json, :render, to: :renderer
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jbuilder-schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuri Sidorov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-17 00:00:00.000000000 Z
11
+ date: 2023-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jbuilder