rspec-openapi 0.4.2 → 0.4.3

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: a02d800d2c00b3cfec6a1a860f17eafaed45e51329aaa7407ed1e96892a10ac9
4
- data.tar.gz: db0ec61540014497148d218846c01287d2b4f0e1ec4782148d932c5308ccbc75
3
+ metadata.gz: 3bf318171323fbd3fa8d664a4f34ec1fe5af39a4d39ab5ee7b020b3871a31cb4
4
+ data.tar.gz: 610173247f3b9c99c7f5d2461bad49ae1d9000d7c8f63dfc4ac884472830c005
5
5
  SHA512:
6
- metadata.gz: b357caa7a5b3f497a743ddf7be434ceb141e5de9b93d5995ac66e7d42abce47fddaa65f5f62f0ceffca4e4d42a40405c7b6d8190b4d2557148d633af1c9e289d
7
- data.tar.gz: c8166a897c99f4b60747bc4c51f223c20627303fd6276c2e8e9a4908fee6287d43f1fb43135354ff7615f7c0cece8665c1b5a96da234e3598dbe311c1468d712
6
+ metadata.gz: 4b8c0402fe94dbcc43353c210acb1c9c4b182331020670bb8955dc4abf17a18732852fc4b191a3d1ded1d3613ef5e0059aa79e09084eb23bd9ce7ca5beec9e25
7
+ data.tar.gz: 6c4cd49edbaea41dfc1c2b17c89ec85dac8e1063612ff29f3c63dccde9dacd7a19eb276253363f1091a19976e0e6a20d40dc32f5deae36fa291e17f054b22eaf
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## v0.4.3
2
+
3
+ * Allow customizing `schema`, `description`, and `tags` through `:openapi` metadata
4
+ [#36](https://github.com/k0kubun/rspec-openapi/pull/36)
5
+
1
6
  ## v0.4.2
2
7
 
3
8
  * Allow using Proc as `RSpec::OpenAPI.path`
data/README.md CHANGED
@@ -172,6 +172,22 @@ RSpec.describe '/resources', type: :request do
172
172
  end
173
173
  ```
174
174
 
175
+ ## Customizations
176
+
177
+ Some examples' attributes can be overwritten via RSpec metadata options. Example:
178
+
179
+ ```rb
180
+ describe 'GET /api/v1/posts', openapi: {
181
+ summary: 'list all posts',
182
+ description: 'list all posts ordered by pub_date',
183
+ tags: %w[v1 posts],
184
+ } do
185
+ # ...
186
+ end
187
+ ```
188
+
189
+ **NOTE**: `description` key will override also the one provided by `RSpec::OpenAPI.description_builder` method.
190
+
175
191
  ## Links
176
192
 
177
193
  Existing RSpec plugins which have OpenAPI integration:
@@ -40,6 +40,8 @@ class << RSpec::OpenAPI::RecordBuilder = Object.new
40
40
  headers_arr << [header, header_value] if header_value
41
41
  end
42
42
 
43
+ metadata_options = example.metadata[:openapi] || {}
44
+
43
45
  RSpec::OpenAPI::Record.new(
44
46
  method: request.request_method,
45
47
  path: path,
@@ -48,9 +50,9 @@ class << RSpec::OpenAPI::RecordBuilder = Object.new
48
50
  request_params: raw_request_params(request),
49
51
  request_content_type: request.media_type,
50
52
  request_headers: request_headers,
51
- summary: summary,
52
- tags: tags,
53
- description: RSpec::OpenAPI.description_builder.call(example),
53
+ summary: metadata_options[:summary] || summary,
54
+ tags: metadata_options[:tags] || tags,
55
+ description: metadata_options[:description] || RSpec::OpenAPI.description_builder.call(example),
54
56
  status: response.status,
55
57
  response_body: response_body,
56
58
  response_content_type: response.media_type,
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module OpenAPI
3
- VERSION = '0.4.2'
3
+ VERSION = '0.4.3'
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.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-10 00:00:00.000000000 Z
11
+ date: 2022-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  - !ruby/object:Gem::Version
91
91
  version: '0'
92
92
  requirements: []
93
- rubygems_version: 3.2.22
93
+ rubygems_version: 3.3.7
94
94
  signing_key:
95
95
  specification_version: 4
96
96
  summary: Generate OpenAPI schema from RSpec request specs