rspec-openapi 0.3.14 → 0.3.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +1 -0
- data/CHANGELOG.md +5 -0
- data/lib/rspec/openapi/record.rb +1 -0
- data/lib/rspec/openapi/record_builder.rb +1 -0
- data/lib/rspec/openapi/schema_builder.rb +18 -5
- data/lib/rspec/openapi/version.rb +1 -1
- 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: 76a7b33ccfea2d2fbaf9cb45b49171c46c0b6b9df44280ac6d6bf0f864aedb60
|
4
|
+
data.tar.gz: d52a3651c1dc945711c378d39e53867f518c9b8aed2d6bf7502c00aade767856
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8eac8961aa0b71a48f3af48c118dad88b8e4e90767dfb37c87d0902422a9ed6bea2c43cf87c713c209be0d7284f114cd455d49069b8521d3d34ad6ffcd901eb
|
7
|
+
data.tar.gz: d2a984317e8b93f8f2f29540c2a34af9fa89b46aadbdd300cc2247212d338530aff7d53aae75b27cabbd1d21ea3a30698051e1cd836509bf36c202f5c538eec9
|
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
github: k0kubun
|
data/CHANGELOG.md
CHANGED
data/lib/rspec/openapi/record.rb
CHANGED
@@ -11,5 +11,6 @@ RSpec::OpenAPI::Record = Struct.new(
|
|
11
11
|
:status, # @param [Integer] - 200
|
12
12
|
:response_body, # @param [Object] - {"status" => "ok"}
|
13
13
|
:response_content_type, # @param [String] - "application/json"
|
14
|
+
:response_content_disposition, # @param [String] - "inline"
|
14
15
|
keyword_init: true,
|
15
16
|
)
|
@@ -7,10 +7,11 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
|
|
7
7
|
}
|
8
8
|
|
9
9
|
if record.response_body
|
10
|
+
disposition = normalize_content_disposition(record.response_content_disposition)
|
10
11
|
response[:content] = {
|
11
12
|
normalize_content_type(record.response_content_type) => {
|
12
|
-
schema: build_property(record.response_body),
|
13
|
-
example: (record
|
13
|
+
schema: build_property(record.response_body, disposition: disposition),
|
14
|
+
example: response_example(record, disposition: disposition),
|
14
15
|
}.compact,
|
15
16
|
}
|
16
17
|
end
|
@@ -34,6 +35,12 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
|
|
34
35
|
|
35
36
|
private
|
36
37
|
|
38
|
+
def response_example(record, disposition:)
|
39
|
+
return nil if !example_enabled? || disposition
|
40
|
+
|
41
|
+
record.response_body
|
42
|
+
end
|
43
|
+
|
37
44
|
def example_enabled?
|
38
45
|
RSpec::OpenAPI.enable_example
|
39
46
|
end
|
@@ -78,8 +85,8 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
|
|
78
85
|
}
|
79
86
|
end
|
80
87
|
|
81
|
-
def build_property(value)
|
82
|
-
property = build_type(value)
|
88
|
+
def build_property(value, disposition: nil)
|
89
|
+
property = build_type(value, disposition)
|
83
90
|
|
84
91
|
case value
|
85
92
|
when Array
|
@@ -94,7 +101,9 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
|
|
94
101
|
property
|
95
102
|
end
|
96
103
|
|
97
|
-
def build_type(value)
|
104
|
+
def build_type(value, disposition)
|
105
|
+
return { type: 'string', format: 'binary' } if disposition
|
106
|
+
|
98
107
|
case value
|
99
108
|
when String
|
100
109
|
{ type: 'string' }
|
@@ -143,4 +152,8 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
|
|
143
152
|
def normalize_content_type(content_type)
|
144
153
|
content_type&.sub(/;.+\z/, '')
|
145
154
|
end
|
155
|
+
|
156
|
+
def normalize_content_disposition(content_disposition)
|
157
|
+
content_disposition&.sub(/;.+\z/, '')
|
158
|
+
end
|
146
159
|
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.
|
4
|
+
version: 0.3.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Kokubun
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -45,6 +45,7 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
+
- ".github/FUNDING.yml"
|
48
49
|
- ".github/workflows/test.yml"
|
49
50
|
- ".gitignore"
|
50
51
|
- ".rspec"
|
@@ -89,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
90
|
- !ruby/object:Gem::Version
|
90
91
|
version: '0'
|
91
92
|
requirements: []
|
92
|
-
rubygems_version: 3.2.
|
93
|
+
rubygems_version: 3.2.3
|
93
94
|
signing_key:
|
94
95
|
specification_version: 4
|
95
96
|
summary: Generate OpenAPI schema from RSpec request specs
|