rspec-openapi 0.3.2 → 0.3.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: a6a204535e3afe650434a20936c2d1ec34bc5136071cb76e48f1481b13629de8
4
- data.tar.gz: d102d224884511c60d2b15030083d382d5c8da0bbbfa12dc3c293248456fd7ed
3
+ metadata.gz: b483a73ef32d771b4da3e66f3c63d1cd0a1cfbb839752546d5465cda43ff8444
4
+ data.tar.gz: cf8ec362c29193e2434db5433170ec655008cd5f636a8f2341f9abf7e7f3d454
5
5
  SHA512:
6
- metadata.gz: 241b1dd789ae12fa853dc90b12cb497945dfc1bf4da0974a93d097c9f685ce6d585ddf08874a8dccfdec22467a8e47428e3a85a68ce847e8d306821b402b36fa
7
- data.tar.gz: 60f6569f6d91262742732d45eacf8ef3192e201ddf91254b49fe00bdeada72ef05db02f3fcc61a817ed9ff54dc44a12fc45ffc4a1ee95e229f93c9e14b0e5b08
6
+ metadata.gz: de935612cc1afdd9c8ccca7d69711beca33dea36ec97555293978544c9c1a978c04cdc196c42a39888408d7575e40d0d6dff76adf1d629b27512c569feb9b29a
7
+ data.tar.gz: 423d62a92e8a9b143fae9304af57d893e079dbc9cb956e17320ea45a3bf30d8084f88395fdeaa835cd8689c3b72ecba2b40812bd9c81a0f044ddf91754169f9c
@@ -1,3 +1,8 @@
1
+ ## v0.3.3
2
+
3
+ * Avoid `JSON::ParserError` when a response body is no content
4
+ [#9](https://github.com/k0kubun/rspec-openapi/issues/9)
5
+
1
6
  ## v0.3.2
2
7
 
3
8
  * Stop generating format as path parameters in Rails
@@ -24,6 +24,13 @@ class << RSpec::OpenAPI::RecordBuilder = Object.new
24
24
  summary = "#{request.method} #{request.path}"
25
25
  end
26
26
 
27
+ response_body =
28
+ begin
29
+ response.parsed_body
30
+ rescue JSON::ParserError
31
+ nil
32
+ end
33
+
27
34
  RSpec::OpenAPI::Record.new(
28
35
  method: request.request_method,
29
36
  path: path,
@@ -34,7 +41,7 @@ class << RSpec::OpenAPI::RecordBuilder = Object.new
34
41
  summary: summary,
35
42
  description: RSpec::OpenAPI.description_builder.call(example),
36
43
  status: response.status,
37
- response_body: response.parsed_body,
44
+ response_body: response_body,
38
45
  response_content_type: response.content_type,
39
46
  ).freeze
40
47
  end
@@ -2,6 +2,19 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
2
2
  # @param [RSpec::OpenAPI::Record] record
3
3
  # @return [Hash]
4
4
  def build(record)
5
+ response = {
6
+ description: record.description,
7
+ }
8
+
9
+ if record.response_body
10
+ response[:content] = {
11
+ normalize_content_type(record.response_content_type) => {
12
+ schema: build_property(record.response_body),
13
+ example: (record.response_body if example_enabled?),
14
+ }.compact,
15
+ }
16
+ end
17
+
5
18
  {
6
19
  paths: {
7
20
  normalize_path(record.path) => {
@@ -10,15 +23,7 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
10
23
  parameters: build_parameters(record),
11
24
  requestBody: build_request_body(record),
12
25
  responses: {
13
- record.status.to_s => {
14
- description: record.description,
15
- content: {
16
- normalize_content_type(record.response_content_type) => {
17
- schema: build_property(record.response_body),
18
- example: (record.response_body if example_enabled?),
19
- }.compact,
20
- },
21
- },
26
+ record.status.to_s => response,
22
27
  },
23
28
  }.compact,
24
29
  },
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module OpenAPI
3
- VERSION = '0.3.2'
3
+ VERSION = '0.3.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.3.2
4
+ version: 0.3.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: 2020-08-01 00:00:00.000000000 Z
11
+ date: 2020-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  requirements: []
91
- rubygems_version: 3.2.0.pre1
91
+ rubygems_version: 3.1.2
92
92
  signing_key:
93
93
  specification_version: 4
94
94
  summary: Generate OpenAPI schema from RSpec request specs