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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbc3cc18aaa05b8683cb432500f56304dcea0184e6c82065656ffcd7981ebb5e
4
- data.tar.gz: 5775f3b73a25c9e9288a4a0f08f61e14f1cb302e7df912d467821d8da84feda2
3
+ metadata.gz: 76a7b33ccfea2d2fbaf9cb45b49171c46c0b6b9df44280ac6d6bf0f864aedb60
4
+ data.tar.gz: d52a3651c1dc945711c378d39e53867f518c9b8aed2d6bf7502c00aade767856
5
5
  SHA512:
6
- metadata.gz: b4d9d94770f14ce395366e6a0f6e84ea3105660a2417c936e0b98cf9684d3b24ff52bf5e743989679e4a126cfe279ea5e64464dab6bdf560e2bad6d88b0f4089
7
- data.tar.gz: 61693320247f631552d5692fdf8e1894cf7bbc798a402488c7fe833613fb47548a01acc81123a0682f50b957664150fade4a429a7e7d4f511e7930a71f9209ca
6
+ metadata.gz: f8eac8961aa0b71a48f3af48c118dad88b8e4e90767dfb37c87d0902422a9ed6bea2c43cf87c713c209be0d7284f114cd455d49069b8521d3d34ad6ffcd901eb
7
+ data.tar.gz: d2a984317e8b93f8f2f29540c2a34af9fa89b46aadbdd300cc2247212d338530aff7d53aae75b27cabbd1d21ea3a30698051e1cd836509bf36c202f5c538eec9
@@ -0,0 +1 @@
1
+ github: k0kubun
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## v0.3.15
2
+
3
+ * Fix an error when Content-Disposition header is inline
4
+ [#24](https://github.com/k0kubun/rspec-openapi/pull/24)
5
+
1
6
  ## v0.3.14
2
7
 
3
8
  * Avoid an error when an application calls `request.body.read`
@@ -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
  )
@@ -47,6 +47,7 @@ class << RSpec::OpenAPI::RecordBuilder = Object.new
47
47
  status: response.status,
48
48
  response_body: response_body,
49
49
  response_content_type: response.content_type,
50
+ response_content_disposition: response.header["Content-Disposition"],
50
51
  ).freeze
51
52
  end
52
53
 
@@ -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.response_body if example_enabled?),
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
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module OpenAPI
3
- VERSION = '0.3.14'
3
+ VERSION = '0.3.15'
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.14
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-02-20 00:00:00.000000000 Z
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.6
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