rspec-openapi 0.3.6 → 0.3.11
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/.github/workflows/test.yml +1 -0
- data/CHANGELOG.md +24 -0
- data/README.md +5 -2
- data/lib/rspec/openapi.rb +2 -1
- data/lib/rspec/openapi/default_schema.rb +1 -0
- data/lib/rspec/openapi/record_builder.rb +2 -2
- data/lib/rspec/openapi/schema_builder.rb +23 -10
- 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: 07e405e19fc7324fbfb0c67f18643ef3a924441f75971920e29dcb074c5fee41
|
4
|
+
data.tar.gz: 55ed7e046ef1dccb8e51d5d9d04012f32007a22da8d20217a582e14112eadc64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8784246f9827274f9a16ad7e70201f0470a63c9568109ae8e5f02a6a154a02829d6ae8e34d6e4b767ec92afa470a3b72be2bf32dcb2c51b6a628b0fdfa3c8fe
|
7
|
+
data.tar.gz: b690fb8885f58626825f072cd75e740649faa05e1b398bf26480a2b8b6013f51f0596c177c92ed57c23fa7c5e49d92d3110c6af406c17bf0f570a8fdcc50f272
|
data/.github/workflows/test.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,27 @@
|
|
1
|
+
## v0.3.11
|
2
|
+
|
3
|
+
* Show a filename as an `example` for `ActionDispatch::Http::UploadedFile`
|
4
|
+
[#17](https://github.com/k0kubun/rspec-openapi/pull/17)
|
5
|
+
|
6
|
+
## v0.3.10
|
7
|
+
|
8
|
+
* Add `info.version`
|
9
|
+
[#16](https://github.com/k0kubun/rspec-openapi/pull/16)
|
10
|
+
|
11
|
+
## v0.3.9
|
12
|
+
|
13
|
+
* Initial support for multipart/form-data
|
14
|
+
[#12](https://github.com/k0kubun/rspec-openapi/pull/12)
|
15
|
+
|
16
|
+
## v0.3.8
|
17
|
+
|
18
|
+
* Generate `type: 'number', format: 'float'` instead of `type: 'float'` for Float
|
19
|
+
[#11](https://github.com/k0kubun/rspec-openapi/issues/11)
|
20
|
+
|
21
|
+
## v0.3.7
|
22
|
+
|
23
|
+
* Classify tag names and remove controller names from summary in Rails
|
24
|
+
|
1
25
|
## v0.3.6
|
2
26
|
|
3
27
|
* Fix documents generated by Rails engines
|
data/README.md
CHANGED
@@ -64,9 +64,9 @@ info:
|
|
64
64
|
paths:
|
65
65
|
"/tables":
|
66
66
|
get:
|
67
|
-
summary:
|
67
|
+
summary: index
|
68
68
|
tags:
|
69
|
-
-
|
69
|
+
- Table
|
70
70
|
parameters:
|
71
71
|
- name: page
|
72
72
|
in: query
|
@@ -111,6 +111,9 @@ RSpec::OpenAPI.path = 'doc/schema.yaml'
|
|
111
111
|
# Disable generating `example`
|
112
112
|
RSpec::OpenAPI.enable_example = false
|
113
113
|
|
114
|
+
# Change `info.version`
|
115
|
+
RSpec::OpenAPI.application_version = '1.0.0'
|
116
|
+
|
114
117
|
# Generate a comment on top of a schema file
|
115
118
|
RSpec::OpenAPI.comment = <<~EOS
|
116
119
|
This file is auto-generated by rspec-openapi https://github.com/k0kubun/rspec-openapi
|
data/lib/rspec/openapi.rb
CHANGED
@@ -6,8 +6,9 @@ module RSpec::OpenAPI
|
|
6
6
|
@comment = nil
|
7
7
|
@enable_example = true
|
8
8
|
@description_builder = -> (example) { example.description }
|
9
|
+
@application_version = '1.0.0'
|
9
10
|
|
10
11
|
class << self
|
11
|
-
attr_accessor :path, :comment, :enable_example, :description_builder
|
12
|
+
attr_accessor :path, :comment, :enable_example, :description_builder, :application_version
|
12
13
|
end
|
13
14
|
end
|
@@ -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}"
|
@@ -72,14 +72,15 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
|
|
72
72
|
content: {
|
73
73
|
normalize_content_type(record.request_content_type) => {
|
74
74
|
schema: build_property(record.request_params),
|
75
|
-
example: (record.request_params if example_enabled?),
|
75
|
+
example: (build_example(record.request_params) if example_enabled?),
|
76
76
|
}.compact
|
77
77
|
}
|
78
78
|
}
|
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
|
@@ -123,6 +126,16 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
|
|
123
126
|
end
|
124
127
|
end
|
125
128
|
|
129
|
+
def build_example(value)
|
130
|
+
return nil if value.nil?
|
131
|
+
value = value.dup
|
132
|
+
value.each do |key, v|
|
133
|
+
if v.is_a?(ActionDispatch::Http::UploadedFile)
|
134
|
+
value[key] = v.original_filename
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
126
139
|
def normalize_path(path)
|
127
140
|
path.gsub(%r|/:([^:/]+)|, '/{\1}')
|
128
141
|
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.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Kokubun
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-27 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.
|
92
|
+
rubygems_version: 3.2.6
|
92
93
|
signing_key:
|
93
94
|
specification_version: 4
|
94
95
|
summary: Generate OpenAPI schema from RSpec request specs
|