rspec-openapi 0.21.1 → 0.21.2
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3d8b74f9e75f015e91e3ebc37ab353459d0a8d887fb096ad7e9fcf829898290e
|
|
4
|
+
data.tar.gz: 1fdbc903fdb61f685ca02d63a88a82eb9a3184e00a0766f1e31e82001ed068b1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eb64851800a090a4cf4d9f78921f1203456ddf8b9d4e820af73d9449a259c7d6e5dd9997e01058136b0dc7b551bc5406e2e176f2818c27b6d7e5a6a00a136fb3
|
|
7
|
+
data.tar.gz: 82600b4917083f3b4a27f7bf4ee8b8b4314dc76a4c9c03f5143e5e182d652edea3cb6cef97f7b2f3598a2c27f143fdcb714058143d47fb44d2ccb6181fafe4fd
|
data/.github/workflows/test.yml
CHANGED
|
@@ -32,7 +32,7 @@ jobs:
|
|
|
32
32
|
RAILS_VERSION: ${{ matrix.rails == '' && '6.1.6' || matrix.rails }}
|
|
33
33
|
COVERAGE: ${{ matrix.coverage || '' }}
|
|
34
34
|
steps:
|
|
35
|
-
- uses: actions/checkout@
|
|
35
|
+
- uses: actions/checkout@v6
|
|
36
36
|
- name: bundle install
|
|
37
37
|
run: bundle install -j$(nproc) --retry 3
|
|
38
38
|
- run: bundle exec rspec
|
|
@@ -256,12 +256,19 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
|
|
|
256
256
|
all_keys = all_schemas.flat_map { |s| s[:properties]&.keys || [] }.uniq
|
|
257
257
|
|
|
258
258
|
all_keys.each do |key|
|
|
259
|
-
|
|
259
|
+
all_property_schemas = all_schemas.map { |s| s[:properties]&.[](key) }
|
|
260
260
|
|
|
261
|
-
|
|
261
|
+
nullable_only_schemas = all_property_schemas.select { |p| p && p.keys == [:nullable] }
|
|
262
|
+
property_variations = all_property_schemas.select { |p| p && p.keys != [:nullable] }
|
|
262
263
|
|
|
263
|
-
|
|
264
|
-
|
|
264
|
+
has_nullable = all_property_schemas.any?(&:nil?) || nullable_only_schemas.any?
|
|
265
|
+
|
|
266
|
+
next if property_variations.empty? && !has_nullable
|
|
267
|
+
|
|
268
|
+
if property_variations.empty? && has_nullable
|
|
269
|
+
merged_schema[:properties][key] = { nullable: true }
|
|
270
|
+
elsif property_variations.size == 1
|
|
271
|
+
merged_schema[:properties][key] = property_variations.first.dup
|
|
265
272
|
else
|
|
266
273
|
unique_types = property_variations.map { |p| p[:type] }.compact.uniq
|
|
267
274
|
|
|
@@ -275,9 +282,9 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
|
|
|
275
282
|
else
|
|
276
283
|
merged_schema[:properties][key] = property_variations.first.dup
|
|
277
284
|
end
|
|
278
|
-
|
|
279
|
-
merged_schema[:properties][key][:nullable] = true if property_variations.size < all_schemas.size
|
|
280
285
|
end
|
|
286
|
+
|
|
287
|
+
merged_schema[:properties][key][:nullable] = true if has_nullable && merged_schema[:properties][key].is_a?(Hash)
|
|
281
288
|
end
|
|
282
289
|
|
|
283
290
|
all_required_sets = all_schemas.map { |s| s[:required] || [] }
|
|
@@ -297,21 +304,32 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
|
|
|
297
304
|
all_keys = variations.flat_map { |v| v[:properties]&.keys || [] }.uniq
|
|
298
305
|
|
|
299
306
|
all_keys.each do |key|
|
|
300
|
-
|
|
307
|
+
all_prop_variations = variations.map { |v| v[:properties]&.[](key) }
|
|
308
|
+
|
|
309
|
+
nullable_only = all_prop_variations.select { |p| p && p.keys == [:nullable] }
|
|
310
|
+
prop_variations = all_prop_variations.select { |p| p && p.keys != [:nullable] }.compact
|
|
311
|
+
|
|
312
|
+
has_nullable = all_prop_variations.any?(&:nil?) || nullable_only.any?
|
|
301
313
|
|
|
302
314
|
if prop_variations.size == 1
|
|
303
|
-
merged[:properties][key] =
|
|
315
|
+
merged[:properties][key] = prop_variations.first.dup
|
|
316
|
+
merged[:properties][key][:nullable] = true if has_nullable
|
|
304
317
|
elsif prop_variations.size > 1
|
|
305
318
|
prop_types = prop_variations.map { |p| p[:type] }.compact.uniq
|
|
306
319
|
|
|
307
320
|
if prop_types.size == 1
|
|
308
|
-
|
|
321
|
+
# Only recursively merge if it's an object type
|
|
322
|
+
merged[:properties][key] = if prop_types.first == 'object'
|
|
323
|
+
build_merged_schema_from_variations(prop_variations)
|
|
324
|
+
else
|
|
325
|
+
prop_variations.first.dup
|
|
326
|
+
end
|
|
309
327
|
else
|
|
310
328
|
unique_props = prop_variations.map { |p| p.reject { |k, _| k == :nullable } }.uniq
|
|
311
329
|
merged[:properties][key] = { oneOf: unique_props }
|
|
312
330
|
end
|
|
313
331
|
|
|
314
|
-
merged[:properties][key][:nullable] = true if prop_variations.size < variations.size
|
|
332
|
+
merged[:properties][key][:nullable] = true if has_nullable || prop_variations.size < variations.size
|
|
315
333
|
end
|
|
316
334
|
end
|
|
317
335
|
|
|
@@ -323,56 +341,4 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
|
|
|
323
341
|
variations.first
|
|
324
342
|
end
|
|
325
343
|
end
|
|
326
|
-
|
|
327
|
-
def merge_object_schemas(schema1, schema2)
|
|
328
|
-
return schema1 unless schema2.is_a?(Hash) && schema1.is_a?(Hash)
|
|
329
|
-
return schema1 unless schema1[:type] == 'object' && schema2[:type] == 'object'
|
|
330
|
-
|
|
331
|
-
merged = schema1.dup
|
|
332
|
-
|
|
333
|
-
if schema1[:properties] && schema2[:properties]
|
|
334
|
-
merged[:properties] = schema1[:properties].dup
|
|
335
|
-
|
|
336
|
-
schema2[:properties].each do |key, prop2|
|
|
337
|
-
if merged[:properties][key]
|
|
338
|
-
prop1 = merged[:properties][key]
|
|
339
|
-
merged[:properties][key] = merge_property_schemas(prop1, prop2)
|
|
340
|
-
else
|
|
341
|
-
merged[:properties][key] = make_property_nullable(prop2)
|
|
342
|
-
end
|
|
343
|
-
end
|
|
344
|
-
|
|
345
|
-
schema1[:properties].each do |key, prop1|
|
|
346
|
-
merged[:properties][key] = make_property_nullable(prop1) unless schema2[:properties][key]
|
|
347
|
-
end
|
|
348
|
-
|
|
349
|
-
required1 = Set.new(schema1[:required] || [])
|
|
350
|
-
required2 = Set.new(schema2[:required] || [])
|
|
351
|
-
merged[:required] = (required1 & required2).to_a
|
|
352
|
-
end
|
|
353
|
-
|
|
354
|
-
merged
|
|
355
|
-
end
|
|
356
|
-
|
|
357
|
-
def merge_property_schemas(prop1, prop2)
|
|
358
|
-
return prop1 unless prop2.is_a?(Hash) && prop1.is_a?(Hash)
|
|
359
|
-
|
|
360
|
-
merged = prop1.dup
|
|
361
|
-
|
|
362
|
-
# If either property is nullable, the merged property should be nullable
|
|
363
|
-
merged[:nullable] = true if prop2[:nullable] && !prop1[:nullable]
|
|
364
|
-
|
|
365
|
-
# If both are objects, recursively merge their properties
|
|
366
|
-
merged = merge_object_schemas(prop1, prop2) if prop1[:type] == 'object' && prop2[:type] == 'object'
|
|
367
|
-
|
|
368
|
-
merged
|
|
369
|
-
end
|
|
370
|
-
|
|
371
|
-
def make_property_nullable(property)
|
|
372
|
-
return property unless property.is_a?(Hash)
|
|
373
|
-
|
|
374
|
-
nullable_prop = property.dup
|
|
375
|
-
nullable_prop[:nullable] = true unless nullable_prop[:nullable]
|
|
376
|
-
nullable_prop
|
|
377
|
-
end
|
|
378
344
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rspec-openapi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.21.
|
|
4
|
+
version: 0.21.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Takashi Kokubun
|
|
@@ -108,7 +108,7 @@ licenses:
|
|
|
108
108
|
metadata:
|
|
109
109
|
homepage_uri: https://github.com/exoego/rspec-openapi
|
|
110
110
|
source_code_uri: https://github.com/exoego/rspec-openapi
|
|
111
|
-
changelog_uri: https://github.com/exoego/rspec-openapi/releases/tag/v0.21.
|
|
111
|
+
changelog_uri: https://github.com/exoego/rspec-openapi/releases/tag/v0.21.2
|
|
112
112
|
rubygems_mfa_required: 'true'
|
|
113
113
|
rdoc_options: []
|
|
114
114
|
require_paths:
|