rspec-openapi 0.3.1 → 0.3.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 +4 -4
- data/CHANGELOG.md +6 -1
- data/README.md +1 -1
- data/lib/rspec/openapi/record_builder.rb +17 -2
- data/lib/rspec/openapi/schema_builder.rb +0 -1
- data/lib/rspec/openapi/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6a204535e3afe650434a20936c2d1ec34bc5136071cb76e48f1481b13629de8
|
4
|
+
data.tar.gz: d102d224884511c60d2b15030083d382d5c8da0bbbfa12dc3c293248456fd7ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 241b1dd789ae12fa853dc90b12cb497945dfc1bf4da0974a93d097c9f685ce6d585ddf08874a8dccfdec22467a8e47428e3a85a68ce847e8d306821b402b36fa
|
7
|
+
data.tar.gz: 60f6569f6d91262742732d45eacf8ef3192e201ddf91254b49fe00bdeada72ef05db02f3fcc61a817ed9ff54dc44a12fc45ffc4a1ee95e229f93c9e14b0e5b08
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
##
|
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
|
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
|
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
|
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)
|
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.
|
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-
|
11
|
+
date: 2020-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|