rspec-openapi 0.3.9 → 0.3.14

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: 93751a821ec1800557dddd948ba2096f19c03f86a474dd2d63bf2c181fe44162
4
- data.tar.gz: 8dfb18c46f4ba4621c1f46ff9948a2305ffd429ea39b4e36ceb005a3bbd6b8d9
3
+ metadata.gz: bbc3cc18aaa05b8683cb432500f56304dcea0184e6c82065656ffcd7981ebb5e
4
+ data.tar.gz: 5775f3b73a25c9e9288a4a0f08f61e14f1cb302e7df912d467821d8da84feda2
5
5
  SHA512:
6
- metadata.gz: 0fde2eed92e5aec96e7949dc1255d9d55a3fb68cd492356dd1d05744a627f9d7ee04a5d05228f5577d9a8caa70df0d5e01b338b9b7cc65a29ee8c86eaa8c2173
7
- data.tar.gz: 8564180885a24f861ca7d3a87e8e6a5f0b6d2750444efac4875b1052b8cfbcfb795157a7feb8fe966d1f8352d1847a78d4237c97b316fb02a1c62651e4974a02
6
+ metadata.gz: b4d9d94770f14ce395366e6a0f6e84ea3105660a2417c936e0b98cf9684d3b24ff52bf5e743989679e4a126cfe279ea5e64464dab6bdf560e2bad6d88b0f4089
7
+ data.tar.gz: 61693320247f631552d5692fdf8e1894cf7bbc798a402488c7fe833613fb47548a01acc81123a0682f50b957664150fade4a429a7e7d4f511e7930a71f9209ca
@@ -19,6 +19,7 @@ jobs:
19
19
  - ruby:2.5
20
20
  - ruby:2.6
21
21
  - ruby:2.7
22
+ - ruby:3.0
22
23
  steps:
23
24
  - uses: actions/checkout@v2
24
25
  - name: bundle install
data/CHANGELOG.md CHANGED
@@ -1,3 +1,28 @@
1
+ ## v0.3.14
2
+
3
+ * Avoid an error when an application calls `request.body.read`
4
+ [#20](https://github.com/k0kubun/rspec-openapi/pull/20)
5
+
6
+ ## v0.3.13
7
+
8
+ * Avoid crashing when there's no request made in a spec
9
+ [#19](https://github.com/k0kubun/rspec-openapi/pull/19)
10
+
11
+ ## v0.3.12
12
+
13
+ * Generate `nullable: true` for null fields in schema
14
+ [#18](https://github.com/k0kubun/rspec-openapi/pull/18)
15
+
16
+ ## v0.3.11
17
+
18
+ * Show a filename as an `example` for `ActionDispatch::Http::UploadedFile`
19
+ [#17](https://github.com/k0kubun/rspec-openapi/pull/17)
20
+
21
+ ## v0.3.10
22
+
23
+ * Add `info.version`
24
+ [#16](https://github.com/k0kubun/rspec-openapi/pull/16)
25
+
1
26
  ## v0.3.9
2
27
 
3
28
  * Initial support for multipart/form-data
data/README.md CHANGED
@@ -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
@@ -4,6 +4,7 @@ class << RSpec::OpenAPI::DefaultSchema = Object.new
4
4
  openapi: '3.0.3',
5
5
  info: {
6
6
  title: title,
7
+ version: RSpec::OpenAPI.application_version,
7
8
  },
8
9
  paths: {},
9
10
  }.freeze
@@ -8,11 +8,13 @@ class << RSpec::OpenAPI::RecordBuilder = Object.new
8
8
  def build(context, example:)
9
9
  if rack_test?(context)
10
10
  request = ActionDispatch::Request.new(context.last_request.env)
11
+ request.body.rewind if request.body.respond_to?(:rewind)
11
12
  response = ActionDispatch::TestResponse.new(*context.last_response.to_a)
12
13
  else
13
14
  request = context.request
14
15
  response = context.response
15
16
  end
17
+ return if request.nil?
16
18
 
17
19
  # Generate `path` and `summary` in a framework-friendly manner when possible
18
20
  if rails?
@@ -72,7 +72,7 @@ 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
  }
@@ -111,7 +111,7 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
111
111
  when ActionDispatch::Http::UploadedFile
112
112
  { type: 'string', format: 'binary' }
113
113
  when NilClass
114
- { type: 'null' }
114
+ { nullable: true }
115
115
  else
116
116
  raise NotImplementedError, "type detection is not implemented for: #{value.inspect}"
117
117
  end
@@ -126,6 +126,16 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
126
126
  end
127
127
  end
128
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
+
129
139
  def normalize_path(path)
130
140
  path.gsub(%r|/:([^:/]+)|, '/{\1}')
131
141
  end
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module OpenAPI
3
- VERSION = '0.3.9'
3
+ VERSION = '0.3.14'
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.9
4
+ version: 0.3.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-14 00:00:00.000000000 Z
11
+ date: 2021-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -74,7 +74,7 @@ metadata:
74
74
  homepage_uri: https://github.com/k0kubun/rspec-openapi
75
75
  source_code_uri: https://github.com/k0kubun/rspec-openapi
76
76
  changelog_uri: https://github.com/k0kubun/rspec-openapi/blob/master/CHANGELOG.md
77
- post_install_message:
77
+ post_install_message:
78
78
  rdoc_options: []
79
79
  require_paths:
80
80
  - lib
@@ -89,8 +89,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
91
  requirements: []
92
- rubygems_version: 3.1.4
93
- signing_key:
92
+ rubygems_version: 3.2.6
93
+ signing_key:
94
94
  specification_version: 4
95
95
  summary: Generate OpenAPI schema from RSpec request specs
96
96
  test_files: []