rspec-openapi 0.3.1 → 0.3.2

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: 98be98f98f98819f1d1b018ad1a155184ebbe1c226b96414895acc0f60106b18
4
- data.tar.gz: 6985138afe53b9223647f67d8802acdab580d737c18caec6b312d625d649d7c7
3
+ metadata.gz: a6a204535e3afe650434a20936c2d1ec34bc5136071cb76e48f1481b13629de8
4
+ data.tar.gz: d102d224884511c60d2b15030083d382d5c8da0bbbfa12dc3c293248456fd7ed
5
5
  SHA512:
6
- metadata.gz: 13906efcf4d94054aea6c6132c09990bc99f264fc3fc37842f6d4d98515a5974f91a39cc3c7d749f0b2f24107e7fc9fb6bb94cfa6f3655fa0f13429101d17a20
7
- data.tar.gz: 10ca07bb2370cf61dee4bdbc0d19d1194d64daf558813d8fff113868226a5d1ff6036f71071f58106492592e012ab999dc430976e1e5b7a4361dc36ec1bc5fb8
6
+ metadata.gz: 241b1dd789ae12fa853dc90b12cb497945dfc1bf4da0974a93d097c9f685ce6d585ddf08874a8dccfdec22467a8e47428e3a85a68ce847e8d306821b402b36fa
7
+ data.tar.gz: 60f6569f6d91262742732d45eacf8ef3192e201ddf91254b49fe00bdeada72ef05db02f3fcc61a817ed9ff54dc44a12fc45ffc4a1ee95e229f93c9e14b0e5b08
@@ -1,4 +1,9 @@
1
- ## Unreleased
1
+ ## v0.3.2
2
+
3
+ * Stop generating format as path parameters in Rails
4
+ [#8](https://github.com/k0kubun/rspec-openapi/issues/8)
5
+
6
+ ## v0.3.1
2
7
 
3
8
  * Add `RSpec::OpenAPI.description_builder` config to dynamically generate a description [experimental]
4
9
  [#6](https://github.com/k0kubun/rspec-openapi/issues/6)
data/README.md CHANGED
@@ -115,7 +115,7 @@ RSpec::OpenAPI.comment = <<~EOS
115
115
  update this file automatically. You can also manually edit this file.
116
116
  EOS
117
117
 
118
- # Generate a custom description, given a RSpec example
118
+ # Generate a custom description, given an RSpec example
119
119
  RSpec::OpenAPI.description_builder = -> (example) { example.description }
120
120
  ```
121
121
 
@@ -15,7 +15,7 @@ class << RSpec::OpenAPI::RecordBuilder = Object.new
15
15
  end
16
16
 
17
17
  # Generate `path` and `summary` in a framework-friendly manner when possible
18
- if defined?(Rails) && Rails.application
18
+ if rails?
19
19
  route = find_rails_route(request)
20
20
  path = route.path.spec.to_s.delete_suffix('(.:format)')
21
21
  summary = "#{route.requirements[:controller]} ##{route.requirements[:action]}"
@@ -27,7 +27,7 @@ class << RSpec::OpenAPI::RecordBuilder = Object.new
27
27
  RSpec::OpenAPI::Record.new(
28
28
  method: request.request_method,
29
29
  path: path,
30
- path_params: request.path_parameters,
30
+ path_params: raw_path_params(request),
31
31
  query_params: request.query_parameters,
32
32
  request_params: raw_request_params(request),
33
33
  request_content_type: request.content_type,
@@ -41,6 +41,10 @@ class << RSpec::OpenAPI::RecordBuilder = Object.new
41
41
 
42
42
  private
43
43
 
44
+ def rails?
45
+ defined?(Rails) && Rails.application
46
+ end
47
+
44
48
  def rack_test?(context)
45
49
  defined?(Rack::Test::Methods) && context.class < Rack::Test::Methods
46
50
  end
@@ -53,6 +57,17 @@ class << RSpec::OpenAPI::RecordBuilder = Object.new
53
57
  raise "No route matched for #{request.request_method} #{request.path_info}"
54
58
  end
55
59
 
60
+ # :controller and :action always exist. :format is added when routes is configured as such.
61
+ def raw_path_params(request)
62
+ if rails?
63
+ request.path_parameters.reject do |key, _value|
64
+ %i[controller action format].include?(key)
65
+ end
66
+ else
67
+ request.path_parameters
68
+ end
69
+ end
70
+
56
71
  # workaround to get real request parameters
57
72
  # because ActionController::ParamsWrapper overwrites request_parameters
58
73
  def raw_request_params(request)
@@ -36,7 +36,6 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
36
36
  parameters = []
37
37
 
38
38
  record.path_params.each do |key, value|
39
- next if %i[controller action].include?(key)
40
39
  parameters << {
41
40
  name: key.to_s,
42
41
  in: 'path',
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module OpenAPI
3
- VERSION = '0.3.1'
3
+ VERSION = '0.3.2'
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.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-13 00:00:00.000000000 Z
11
+ date: 2020-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack