rspec-openapi 0.3.4 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/README.md +2 -2
- data/lib/rspec/openapi/record_builder.rb +13 -4
- data/lib/rspec/openapi/schema_builder.rb +12 -9
- data/lib/rspec/openapi/version.rb +1 -1
- data/test.png +0 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93751a821ec1800557dddd948ba2096f19c03f86a474dd2d63bf2c181fe44162
|
4
|
+
data.tar.gz: 8dfb18c46f4ba4621c1f46ff9948a2305ffd429ea39b4e36ceb005a3bbd6b8d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fde2eed92e5aec96e7949dc1255d9d55a3fb68cd492356dd1d05744a627f9d7ee04a5d05228f5577d9a8caa70df0d5e01b338b9b7cc65a29ee8c86eaa8c2173
|
7
|
+
data.tar.gz: 8564180885a24f861ca7d3a87e8e6a5f0b6d2750444efac4875b1052b8cfbcfb795157a7feb8fe966d1f8352d1847a78d4237c97b316fb02a1c62651e4974a02
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
## v0.3.9
|
2
|
+
|
3
|
+
* Initial support for multipart/form-data
|
4
|
+
[#12](https://github.com/k0kubun/rspec-openapi/pull/12)
|
5
|
+
|
6
|
+
## v0.3.8
|
7
|
+
|
8
|
+
* Generate `type: 'number', format: 'float'` instead of `type: 'float'` for Float
|
9
|
+
[#11](https://github.com/k0kubun/rspec-openapi/issues/11)
|
10
|
+
|
11
|
+
## v0.3.7
|
12
|
+
|
13
|
+
* Classify tag names and remove controller names from summary in Rails
|
14
|
+
|
15
|
+
## v0.3.6
|
16
|
+
|
17
|
+
* Fix documents generated by Rails engines
|
18
|
+
|
19
|
+
## v0.3.5
|
20
|
+
|
21
|
+
* Support finding routes in Rails engines
|
22
|
+
|
1
23
|
## v0.3.4
|
2
24
|
|
3
25
|
* Generate tags by controller names
|
data/README.md
CHANGED
@@ -18,8 +18,8 @@ class << RSpec::OpenAPI::RecordBuilder = Object.new
|
|
18
18
|
if rails?
|
19
19
|
route = find_rails_route(request)
|
20
20
|
path = route.path.spec.to_s.delete_suffix('(.:format)')
|
21
|
-
summary = "#{route.requirements[:
|
22
|
-
tags = [route.requirements[:controller]]
|
21
|
+
summary = "#{route.requirements[:action]}"
|
22
|
+
tags = [route.requirements[:controller].classify]
|
23
23
|
else
|
24
24
|
path = request.path
|
25
25
|
summary = "#{request.method} #{request.path}"
|
@@ -59,8 +59,17 @@ class << RSpec::OpenAPI::RecordBuilder = Object.new
|
|
59
59
|
end
|
60
60
|
|
61
61
|
# @param [ActionDispatch::Request] request
|
62
|
-
def find_rails_route(request)
|
63
|
-
Rails.
|
62
|
+
def find_rails_route(request, app: Rails.application, fix_path: true)
|
63
|
+
# Reverse the destructive modification by Rails https://github.com/rails/rails/blob/v6.0.3.4/actionpack/lib/action_dispatch/journey/router.rb#L33-L41
|
64
|
+
if fix_path && !request.script_name.empty?
|
65
|
+
request = request.dup
|
66
|
+
request.path_info = File.join(request.script_name, request.path_info)
|
67
|
+
end
|
68
|
+
|
69
|
+
app.routes.router.recognize(request) do |route|
|
70
|
+
unless route.path.anchored
|
71
|
+
route = find_rails_route(request, app: route.app.app, fix_path: false)
|
72
|
+
end
|
64
73
|
return route
|
65
74
|
end
|
66
75
|
raise "No route matched for #{request.request_method} #{request.path_info}"
|
@@ -79,7 +79,8 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def build_property(value)
|
82
|
-
property =
|
82
|
+
property = build_type(value)
|
83
|
+
|
83
84
|
case value
|
84
85
|
when Array
|
85
86
|
property[:items] = build_property(value.first)
|
@@ -96,19 +97,21 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
|
|
96
97
|
def build_type(value)
|
97
98
|
case value
|
98
99
|
when String
|
99
|
-
'string'
|
100
|
-
when Float
|
101
|
-
'float'
|
100
|
+
{ type: 'string' }
|
102
101
|
when Integer
|
103
|
-
'integer'
|
102
|
+
{ type: 'integer' }
|
103
|
+
when Float
|
104
|
+
{ type: 'number', format: 'float' }
|
104
105
|
when TrueClass, FalseClass
|
105
|
-
'boolean'
|
106
|
+
{ type: 'boolean' }
|
106
107
|
when Array
|
107
|
-
'array'
|
108
|
+
{ type: 'array' }
|
108
109
|
when Hash
|
109
|
-
'object'
|
110
|
+
{ type: 'object' }
|
111
|
+
when ActionDispatch::Http::UploadedFile
|
112
|
+
{ type: 'string', format: 'binary' }
|
110
113
|
when NilClass
|
111
|
-
'null'
|
114
|
+
{ type: 'null' }
|
112
115
|
else
|
113
116
|
raise NotImplementedError, "type detection is not implemented for: #{value.inspect}"
|
114
117
|
end
|
data/test.png
ADDED
Binary file
|
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.9
|
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-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- lib/rspec/openapi/schema_merger.rb
|
67
67
|
- lib/rspec/openapi/version.rb
|
68
68
|
- rspec-openapi.gemspec
|
69
|
+
- test.png
|
69
70
|
homepage: https://github.com/k0kubun/rspec-openapi
|
70
71
|
licenses:
|
71
72
|
- MIT
|
@@ -88,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
89
|
- !ruby/object:Gem::Version
|
89
90
|
version: '0'
|
90
91
|
requirements: []
|
91
|
-
rubygems_version: 3.1.
|
92
|
+
rubygems_version: 3.1.4
|
92
93
|
signing_key:
|
93
94
|
specification_version: 4
|
94
95
|
summary: Generate OpenAPI schema from RSpec request specs
|