rspec-openapi 0.8.0 → 0.8.1

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: f835fe8be895164639ec2bfdbb6414b922734cc9598b30b100ac7da15d31b98f
4
- data.tar.gz: 60ba1234561313d8e9fbe5c1f5667e6c759d477ad124867045e3e2e516174ece
3
+ metadata.gz: 86927b142ea56ae6b4c2c4f70c1cf8d21159b85f614369d4af15c91489e56647
4
+ data.tar.gz: 3711fffd6052537911f4bfaafdb2d22fba78a1649f71c97f16325d79ccc3d427
5
5
  SHA512:
6
- metadata.gz: 44c56d011d95c1350eef4ed83011ff00c749cf9e83ec3cb44f605a6e3ee50c05173117d618d3472ea44b20aeef8981c17ae35f8b91220ff8891382447c1a4679
7
- data.tar.gz: c264b04decebbcd4389633eed77cd98a0241980fa283c320e99c5bdaf5a5b5be36e242367da23abcefbf0f31802dd27f1d123324005c8234657d11328e9e1e60
6
+ metadata.gz: 7a54a6a78f142fc39b7a4ad5a5afd92e2486ba320e414e0782f0eb2c386535588e6126c851d868b265807a29844706547a6757fb1d45a2eb1cda820923fa7c15
7
+ data.tar.gz: b53892f024ecb7733fb99e83ab1c299d3ae0b36465a2ca806d1234896a90fd45bf47df335bc14977004aa8c113c272daadf029b4c0c7ad46773be1ad5e2dec0e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## v0.8.1
2
+ - bugfix: Empty `required` array should not be present.
3
+ [#111](https://github.com/exoego/rspec-openapi/pull/111)
4
+
1
5
  ## v0.8.0
2
6
  - Set `required` in request body and response body
3
7
  [#95](https://github.com/exoego/rspec-openapi/pull/95), [#98](https://github.com/exoego/rspec-openapi/pull/98)
@@ -26,6 +26,7 @@ class RSpec::OpenAPI::ResultRecorder
26
26
  end
27
27
  RSpec::OpenAPI::SchemaCleaner.cleanup!(spec, new_from_zero)
28
28
  RSpec::OpenAPI::ComponentsUpdater.update!(spec, new_from_zero)
29
+ RSpec::OpenAPI::SchemaCleaner.cleanup_empty_required_array!(spec)
29
30
  end
30
31
  end
31
32
  end
@@ -39,6 +39,18 @@ class << RSpec::OpenAPI::SchemaCleaner = Object.new
39
39
  base
40
40
  end
41
41
 
42
+ def cleanup_empty_required_array!(base)
43
+ paths_to_objects = [
44
+ *RSpec::OpenAPI::HashHelper.matched_paths_deeply_nested(base, 'components.schemas', 'properties'),
45
+ *RSpec::OpenAPI::HashHelper.matched_paths_deeply_nested(base, 'paths', 'properties'),
46
+ ]
47
+ paths_to_objects.each do |path|
48
+ parent = base.dig(*path.take(path.length - 1))
49
+ # "required" array must not be present if empty
50
+ parent.delete('required') if parent['required'].empty?
51
+ end
52
+ end
53
+
42
54
  private
43
55
 
44
56
  def cleanup_array!(base, spec, selector, fields_for_identity = [])
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module OpenAPI
5
- VERSION = '0.8.0'
5
+ VERSION = '0.8.1'
6
6
  end
7
7
  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.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2023-04-20 00:00:00.000000000 Z
12
+ date: 2023-04-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack