rspec-openapi 0.4.3 → 0.4.6

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: 3bf318171323fbd3fa8d664a4f34ec1fe5af39a4d39ab5ee7b020b3871a31cb4
4
- data.tar.gz: 610173247f3b9c99c7f5d2461bad49ae1d9000d7c8f63dfc4ac884472830c005
3
+ metadata.gz: f83672f313f4451abb668adf66697c74be2d0ad7866c6fbc433b2ef815e06419
4
+ data.tar.gz: 696c074c32d5ec4f6dfc0f5ea2ab02f9123a4b88a8ce7d09a4c8aada60fe1b6f
5
5
  SHA512:
6
- metadata.gz: 4b8c0402fe94dbcc43353c210acb1c9c4b182331020670bb8955dc4abf17a18732852fc4b191a3d1ded1d3613ef5e0059aa79e09084eb23bd9ce7ca5beec9e25
7
- data.tar.gz: 6c4cd49edbaea41dfc1c2b17c89ec85dac8e1063612ff29f3c63dccde9dacd7a19eb276253363f1091a19976e0e6a20d40dc32f5deae36fa291e17f054b22eaf
6
+ metadata.gz: 232765a27c157fdbb1bd479b14987d095c0fce190e3b76cc10a4f8f3b990c253456af15a79924be632daaf0d08254e934b9da00f24c9779f4f9c4531b3f36bae
7
+ data.tar.gz: fbf0fb968a2d1afde12566cc472bb72a97b800101e60c640c1b7fa218a5563f993f48070532af6903c0cf1432a4142fd08235c1e9b6443847e5c2e4b6b22dfdb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## v0.4.6
2
+
3
+ * Fix "No route matched for" error in engine routes
4
+ [#38](https://github.com/k0kubun/rspec-openapi/pull/38)
5
+
6
+ ## v0.4.5
7
+
8
+ * Fix linter issues for `tags` and `summary`
9
+ [#40](https://github.com/k0kubun/rspec-openapi/pull/40)
10
+
11
+ ## v0.4.4
12
+
13
+ * De-duplicate parameters by a combination of `name` and `in`
14
+ [#39](https://github.com/k0kubun/rspec-openapi/pull/39)
15
+
1
16
  ## v0.4.3
2
17
 
3
18
  * Allow customizing `schema`, `description`, and `tags` through `:openapi` metadata
@@ -20,8 +20,8 @@ class << RSpec::OpenAPI::RecordBuilder = Object.new
20
20
  if rails?
21
21
  route = find_rails_route(request)
22
22
  path = route.path.spec.to_s.delete_suffix('(.:format)')
23
- summary = "#{route.requirements[:action]}"
24
- tags = [route.requirements[:controller].classify]
23
+ summary = route.requirements[:action] || "#{request.method} #{path}"
24
+ tags = [route.requirements[:controller]&.classify].compact
25
25
  else
26
26
  path = request.path
27
27
  summary = "#{request.method} #{request.path}"
@@ -79,10 +79,13 @@ class << RSpec::OpenAPI::RecordBuilder = Object.new
79
79
  end
80
80
 
81
81
  app.routes.router.recognize(request) do |route|
82
- unless route.path.anchored
83
- route = find_rails_route(request, app: route.app.app, fix_path: false)
82
+ if route.app.matches?(request)
83
+ if route.app.engine?
84
+ return find_rails_route(request, app: route.app.app, fix_path: false)
85
+ else
86
+ return route
87
+ end
84
88
  end
85
- return route
86
89
  end
87
90
  raise "No route matched for #{request.request_method} #{request.path_info}"
88
91
  end
@@ -21,9 +21,12 @@ class << RSpec::OpenAPI::SchemaMerger = Object.new
21
21
  end
22
22
  end
23
23
 
24
- # Not doing `base.replace(deep_merge(base, spec))` to preserve key orders
24
+ # Not doing `base.replace(deep_merge(base, spec))` to preserve key orders.
25
+ # Also this needs to be aware of OpenAPI details unlike an ordinary deep_reverse_merge
26
+ # because a Hash-like structure may be an array whose Hash elements have a key name.
27
+ #
25
28
  # TODO: Perform more intelligent merges like rerouting edits / merging types
26
- # Should we probably force-merge `summary` regardless of manual modifications?
29
+ # TODO: Should we probably force-merge `summary` regardless of manual modifications?
27
30
  def deep_reverse_merge!(base, spec)
28
31
  spec.each do |key, value|
29
32
  if base[key].is_a?(Hash) && value.is_a?(Hash)
@@ -31,9 +34,10 @@ class << RSpec::OpenAPI::SchemaMerger = Object.new
31
34
  elsif !base.key?(key)
32
35
  base[key] = value
33
36
  elsif base[key].is_a?(Array) && value.is_a?(Array)
34
- if key == "parameters"
35
- # merge arrays
37
+ # parameters need to be merged as if `name` and `in` were the Hash keys.
38
+ if key == 'parameters'
36
39
  base[key] |= value
40
+ base[key].uniq! { |param| param.slice('name', 'in') }
37
41
  end
38
42
  else
39
43
  # no-op
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module OpenAPI
3
- VERSION = '0.4.3'
3
+ VERSION = '0.4.6'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-openapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-17 00:00:00.000000000 Z
11
+ date: 2022-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  - !ruby/object:Gem::Version
91
91
  version: '0'
92
92
  requirements: []
93
- rubygems_version: 3.3.7
93
+ rubygems_version: 3.1.2
94
94
  signing_key:
95
95
  specification_version: 4
96
96
  summary: Generate OpenAPI schema from RSpec request specs