rspec-openapi 0.4.5 → 0.4.8

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: f962e8e048c5a935842a4d45896ead010b7e8bf0568161f8b9dddadd17b6c751
4
- data.tar.gz: c4d0098e4f6a8c4d3a747b9045897627621085cf5c995d4129b099293dc99bdb
3
+ metadata.gz: 4d6f2c98f9e3462e319dc05435274d53b933deb41553c2f4d7b70b3d4d135c7e
4
+ data.tar.gz: 48e8862133eebc1cf0a700eb720603159f6274012342b4f9d259157d527af525
5
5
  SHA512:
6
- metadata.gz: 37626fc7ba17753cc589d76e68c1cafb2cb84039873985ca702b6439448303f62bb7527257aea1128db3b4bbd53cdd12f909c8a5aa40c9feccc2ab00ba27e16e
7
- data.tar.gz: 2dacbbf2be2111fe1a80a8482e885b07b56a8e09f78b002d5b5e1ba15d7d109e02ee81f29ecc50ebbb7c6bd1a24c080e62d05e98d34f67cbb7120e1e3578c55f
6
+ metadata.gz: 8420b3ad4d97a8a5e1d1dd89280f2dd95335e362997740fbbd342d7a352a2a90f3b1d912366ac3d32693c44e3b65ef0058522323fbdd5f1d6900cc122d1d1ae1
7
+ data.tar.gz: 891a7b33e112310e66ec6bcff616aac5c93a8036028ba95cf25b5ac40a3d89e2599a906782a15a107c37779a7c657bfda4b92d5fb4e364725300d071c2a870e3
data/CHANGELOG.md CHANGED
@@ -1,11 +1,26 @@
1
+ ## v0.4.8
2
+
3
+ * Fix a bug in nested parameters handling
4
+ [#46](https://github.com/k0kubun/rspec-openapi/pull/46)
5
+
6
+ ## v0.4.7
7
+
8
+ * Add `info` config hash
9
+ [#43](https://github.com/k0kubun/rspec-openapi/pull/43)
10
+
11
+ ## v0.4.6
12
+
13
+ * Fix "No route matched for" error in engine routes
14
+ [#38](https://github.com/k0kubun/rspec-openapi/pull/38)
15
+
1
16
  ## v0.4.5
2
17
 
3
- - Fix linter issues for `tags` and `summary`
18
+ * Fix linter issues for `tags` and `summary`
4
19
  [#40](https://github.com/k0kubun/rspec-openapi/pull/40)
5
20
 
6
21
  ## v0.4.4
7
22
 
8
- - De-duplicate parameters by a combination of `name` and `in`
23
+ * De-duplicate parameters by a combination of `name` and `in`
9
24
  [#39](https://github.com/k0kubun/rspec-openapi/pull/39)
10
25
 
11
26
  ## v0.4.3
data/README.md CHANGED
@@ -126,6 +126,15 @@ RSpec::OpenAPI.enable_example = false
126
126
  # Change `info.version`
127
127
  RSpec::OpenAPI.application_version = '1.0.0'
128
128
 
129
+ # Set the info header details
130
+ RSpec::OpenAPI.info = {
131
+ description: 'My beautiful API',
132
+ license: {
133
+ 'name': 'Apache 2.0',
134
+ 'url': 'https://www.apache.org/licenses/LICENSE-2.0.html'
135
+ }
136
+ }
137
+
129
138
  # Set `headers` - generate parameters with headers for a request
130
139
  RSpec::OpenAPI.request_headers = %w[X-Authorization-Token]
131
140
 
@@ -20,7 +20,9 @@ RSpec.configuration.after(:suite) do
20
20
  title = File.basename(Dir.pwd)
21
21
  path_records.each do |path, records|
22
22
  RSpec::OpenAPI::SchemaFile.new(path).edit do |spec|
23
- RSpec::OpenAPI::SchemaMerger.reverse_merge!(spec, RSpec::OpenAPI::DefaultSchema.build(title))
23
+ schema = RSpec::OpenAPI::DefaultSchema.build(title)
24
+ schema[:info].merge!(RSpec::OpenAPI.info)
25
+ RSpec::OpenAPI::SchemaMerger.reverse_merge!(spec, schema)
24
26
  records.each do |record|
25
27
  begin
26
28
  RSpec::OpenAPI::SchemaMerger.reverse_merge!(spec, RSpec::OpenAPI::SchemaBuilder.build(record))
@@ -79,10 +79,13 @@ class << RSpec::OpenAPI::RecordBuilder = Object.new
79
79
  end
80
80
 
81
81
  app.routes.router.recognize(request) do |route|
82
- unless route.path.anchored
83
- route = find_rails_route(request, app: route.app.app, fix_path: false)
82
+ if route.app.matches?(request)
83
+ if route.app.engine?
84
+ return find_rails_route(request, app: route.app.app, fix_path: false)
85
+ else
86
+ return route
87
+ end
84
88
  end
85
- return route
86
89
  end
87
90
  raise "No route matched for #{request.request_method} #{request.path_info}"
88
91
  end
@@ -158,9 +158,15 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
158
158
  def build_example(value)
159
159
  return nil if value.nil?
160
160
  value = value.dup
161
+ adjust_params(value)
162
+ end
163
+
164
+ def adjust_params(value)
161
165
  value.each do |key, v|
162
166
  if v.is_a?(ActionDispatch::Http::UploadedFile)
163
167
  value[key] = v.original_filename
168
+ elsif v.is_a?(Hash)
169
+ adjust_params(v)
164
170
  end
165
171
  end
166
172
  end
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module OpenAPI
3
- VERSION = '0.4.5'
3
+ VERSION = '0.4.8'
4
4
  end
5
5
  end
data/lib/rspec/openapi.rb CHANGED
@@ -6,12 +6,13 @@ module RSpec::OpenAPI
6
6
  @comment = nil
7
7
  @enable_example = true
8
8
  @description_builder = -> (example) { example.description }
9
+ @info = {}
9
10
  @application_version = '1.0.0'
10
11
  @request_headers = []
11
12
  @server_urls = []
12
13
  @example_types = %i[request]
13
14
 
14
15
  class << self
15
- attr_accessor :path, :comment, :enable_example, :description_builder, :application_version, :request_headers, :server_urls, :example_types
16
+ attr_accessor :path, :comment, :enable_example, :description_builder, :info, :application_version, :request_headers, :server_urls, :example_types
16
17
  end
17
18
  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.5
4
+ version: 0.4.8
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-19 00:00:00.000000000 Z
11
+ date: 2022-03-30 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.3.7
93
+ rubygems_version: 3.1.2
94
94
  signing_key:
95
95
  specification_version: 4
96
96
  summary: Generate OpenAPI schema from RSpec request specs