rspec-openapi 0.12.0 → 0.14.0

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: b221d36e6ff92306e1bd720b4bb07e114839c8e047ad530f6ac4cb2a11eb4ae5
4
- data.tar.gz: 5f5daf56dddc8a7b9477f961611d3bd4550eb498aa38d166035e5b18fe7027bd
3
+ metadata.gz: 032e7acfd3a1818b7bffc9130fb58116cc8f8e2045d40e426cabb9c47d37d323
4
+ data.tar.gz: 4dad6278000051a228fbe41f0210931411ddb119730055bd9262bd8dfd18ea23
5
5
  SHA512:
6
- metadata.gz: 18410768ff613a19b39f910e20e58ecda87337095b354e718bdb5f6b6e2713429acd26a289fd4ffa89a493348aa226561d89340d9685d37caa30b44c54d17be8
7
- data.tar.gz: 5542bf85a5f1d46eacbdc0936b57ae197279bf618fa1628082e7d33c5600a2583f450426999dbc6eea4d4a401ffb307ea5d207b551aa27d586eb4682e572c9fb
6
+ metadata.gz: 75d7e8fb034bffdb1ed6d5dafbd1acdffd45d28db52bcb39c5606dad7bac41656415b2b0473a9aaed24bc2a9577ab9dd0bc8c413f547fabaaa5e4df7fe62f806
7
+ data.tar.gz: 2489d638c378f1f061ba992804761af38795a414535df628a5a3b419fcc73f11b116a23bb9d1a3f5a90f687fb30a70e220417463f75c33519194068440e155a2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # THIS CHANGELOG IS DEPRECATED!!
2
+
3
+ Refer https://github.com/exoego/rspec-openapi/releases instead.
4
+
1
5
  ## v0.12.0
2
6
 
3
7
  - feat: Initial support of complex schema with manually-added `oneOf`
data/README.md CHANGED
@@ -184,6 +184,12 @@ RSpec::OpenAPI.example_types = %i[request]
184
184
  # :controller and :action always exist. :format is added when routes is configured as such.
185
185
  RSpec::OpenAPI.ignored_path_params = %i[controller action format]
186
186
 
187
+ # Configure which paths to ignore.
188
+ # You can exclude some specs via `openapi: false`.
189
+ # But, in a complex API usage scenario, you may need to include spec itself, but exclude some private paths.
190
+ # In that case, you can specify the paths to ignore.
191
+ # String or Regexp is acceptable.
192
+ RSpec::OpenAPI.ignored_paths = ["/admin/full/path/", Regexp.new("^/_internal/")]
187
193
  ```
188
194
 
189
195
  ### Can I use rspec-openapi with `$ref` to minimize duplication of schema?
@@ -10,7 +10,7 @@ module RSpec::OpenAPI::Minitest
10
10
  result = super
11
11
  if ENV['OPENAPI'] && self.class.openapi?
12
12
  file_path = method(name).source_location.first
13
- human_name = name.sub(/^test_/, '').gsub(/_/, ' ')
13
+ human_name = name.sub(/^test_/, '').gsub('_', ' ')
14
14
  example = Example.new(self, human_name, {}, file_path)
15
15
  path = RSpec::OpenAPI.path.yield_self { |p| p.is_a?(Proc) ? p.call(example) : p }
16
16
  record = RSpec::OpenAPI::RecordBuilder.build(self, example: example)
@@ -14,6 +14,8 @@ class << RSpec::OpenAPI::RecordBuilder = Object.new
14
14
  path, summary, tags, operation_id, required_request_params, raw_path_params, description, security =
15
15
  extract_request_attributes(request, example)
16
16
 
17
+ return if RSpec::OpenAPI.ignored_paths.any? { |ignored_path| path.match?(ignored_path) }
18
+
17
19
  request_headers, response_headers = extract_headers(request, response)
18
20
 
19
21
  RSpec::OpenAPI::Record.new(
@@ -48,7 +50,7 @@ class << RSpec::OpenAPI::RecordBuilder = Object.new
48
50
 
49
51
  def extract_headers(request, response)
50
52
  request_headers = RSpec::OpenAPI.request_headers.each_with_object([]) do |header, headers_arr|
51
- header_key = header.gsub(/-/, '_').upcase
53
+ header_key = header.gsub('-', '_').upcase
52
54
  header_value = request.get_header(['HTTP', header_key].join('_')) || request.get_header(header_key)
53
55
  headers_arr << [header, header_value] if header_value
54
56
  end
@@ -42,7 +42,8 @@ class << RSpec::OpenAPI::SchemaMerger = Object.new
42
42
  # parameters need to be merged as if `name` and `in` were the Hash keys.
43
43
  merge_arrays(base, key, value)
44
44
  else
45
- base[key] = value
45
+ # do not ADD `properties` or `required` fields if `additionalProperties` field is present
46
+ base[key] = value unless base.key?('additionalProperties') && %w[properties required].include?(key)
46
47
  end
47
48
  end
48
49
  base
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module OpenAPI
5
- VERSION = '0.12.0'
5
+ VERSION = '0.14.0'
6
6
  end
7
7
  end
data/lib/rspec/openapi.rb CHANGED
@@ -31,6 +31,7 @@ module RSpec::OpenAPI
31
31
  @response_headers = []
32
32
  @path_records = Hash.new { |h, k| h[k] = [] }
33
33
  @ignored_path_params = %i[controller action format]
34
+ @ignored_paths = []
34
35
 
35
36
  # This is the configuraion override file name we look for within each path.
36
37
  @config_filename = 'rspec_openapi.rb'
@@ -51,6 +52,7 @@ module RSpec::OpenAPI
51
52
  :example_types,
52
53
  :response_headers,
53
54
  :path_records,
55
+ :ignored_paths,
54
56
  :ignored_path_params
55
57
 
56
58
  attr_reader :config_filename
@@ -14,9 +14,12 @@ Gem::Specification.new do |spec|
14
14
  spec.license = 'MIT'
15
15
  spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
16
16
 
17
- spec.metadata['homepage_uri'] = spec.homepage
18
- spec.metadata['source_code_uri'] = spec.homepage
19
- spec.metadata['changelog_uri'] = File.join(spec.homepage, 'blob/master/CHANGELOG.md')
17
+ spec.metadata = {
18
+ 'homepage_uri' => 'https://github.com/exoego/rspec-openapi',
19
+ 'source_code_uri' => 'https://github.com/exoego/rspec-openapi',
20
+ 'changelog_uri' => "https://github.com/exoego/rspec-openapi/releases/tag/v#{RSpec::OpenAPI::VERSION}",
21
+ 'rubygems_mfa_required' => 'true',
22
+ }
20
23
 
21
24
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
25
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-openapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2024-02-17 00:00:00.000000000 Z
12
+ date: 2024-03-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -88,7 +88,7 @@ licenses:
88
88
  metadata:
89
89
  homepage_uri: https://github.com/exoego/rspec-openapi
90
90
  source_code_uri: https://github.com/exoego/rspec-openapi
91
- changelog_uri: https://github.com/exoego/rspec-openapi/blob/master/CHANGELOG.md
91
+ changelog_uri: https://github.com/exoego/rspec-openapi/releases/tag/v0.14.0
92
92
  rubygems_mfa_required: 'true'
93
93
  post_install_message:
94
94
  rdoc_options: []