rspec-openapi 0.4.4 → 0.4.7

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: 78fd09cf0ef8419c47bd5b9f8f225260b83f700fcfcb23a2515c50e341832961
4
- data.tar.gz: f1895433af3d0a5ee6b065f1e4bbc92bdd4707749480a95b307b685132206bc3
3
+ metadata.gz: 91fc5996b0273d0dd4a7e0261b86902db52e7a64c1433bbcb8cf107abf5d3784
4
+ data.tar.gz: 342051d1e3b6bb7a81af2f46fbb75b4c99658bf9cb075359104b6e2feef09985
5
5
  SHA512:
6
- metadata.gz: ae459f44e0471afec512959b999b47fa23b3144efd9272d140a47af6a65ec4f40c234b1f317d197610952263225e247505f8febca1901fe094ebd74b5c8e27b4
7
- data.tar.gz: a74f8c5a3121ecbff640c40eccd0f420ae2869b676fdb592411c13e7fddfbfb13fd31c96b9d1ea1e73578c9007c3e78f34dda9bcb820ae4f67b9db5d209fbad7
6
+ metadata.gz: 0445f41450ef4cfa70548431356aea9dc94abe0a18a6b5132398f63db7c5c46eaf1a572ee41cdf234ed864d0aba490a51abfb36859edc637f4098c32c8ef39c1
7
+ data.tar.gz: 5b318c2f1bec7f0608b89ab6cda871f4dddf6e8e2a2c7bd6dfed8430bb28597b97733bb34f1e03ee5fa0100170fedb0e47545b082b787e24e22e0e98a471591b
data/CHANGELOG.md CHANGED
@@ -1,6 +1,21 @@
1
+ ## v0.4.7
2
+
3
+ * Add `info` config hash
4
+ [#43](https://github.com/k0kubun/rspec-openapi/pull/43)
5
+
6
+ ## v0.4.6
7
+
8
+ * Fix "No route matched for" error in engine routes
9
+ [#38](https://github.com/k0kubun/rspec-openapi/pull/38)
10
+
11
+ ## v0.4.5
12
+
13
+ * Fix linter issues for `tags` and `summary`
14
+ [#40](https://github.com/k0kubun/rspec-openapi/pull/40)
15
+
1
16
  ## v0.4.4
2
17
 
3
- - De-duplicate parameters by a combination of `name` and `in`
18
+ * De-duplicate parameters by a combination of `name` and `in`
4
19
  [#39](https://github.com/k0kubun/rspec-openapi/pull/39)
5
20
 
6
21
  ## 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))
@@ -20,8 +20,8 @@ class << RSpec::OpenAPI::RecordBuilder = Object.new
20
20
  if rails?
21
21
  route = find_rails_route(request)
22
22
  path = route.path.spec.to_s.delete_suffix('(.:format)')
23
- summary = "#{route.requirements[:action]}"
24
- tags = [route.requirements[:controller].classify]
23
+ summary = route.requirements[:action] || "#{request.method} #{path}"
24
+ tags = [route.requirements[:controller]&.classify].compact
25
25
  else
26
26
  path = request.path
27
27
  summary = "#{request.method} #{request.path}"
@@ -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
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module OpenAPI
3
- VERSION = '0.4.4'
3
+ VERSION = '0.4.7'
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.4
4
+ version: 0.4.7
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-18 00:00:00.000000000 Z
11
+ date: 2022-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack