rspec-openapi 0.16.0 → 0.16.1

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: 61aad8140991defb871eca3436054e43a6e933d6062ac813c987faf93aa767b5
4
- data.tar.gz: 8c3d02cf5be2e31131c1d855528f597b0bd604d306dba79e91c782448ae111a3
3
+ metadata.gz: c69f9d896be2ad115cb158175dbcf2c1cba9b6d08a7214d23a107a67ec5fc529
4
+ data.tar.gz: a5af92611c4b47790f165ce6d861bfdedd1214f5dcd9c5641e618f272fe5a7ca
5
5
  SHA512:
6
- metadata.gz: 2b879c9733c1704b94c2f5649de5a3200df3bbdac2b5cb76d668e94da32a45262bf40301d74359f30a86af7622851131243c8e95e3ffcfbc716bbd1d6765b47f
7
- data.tar.gz: 16f048fae7721a7986de3dc0a293a29f1986085c55cb6fc793d596826e3fedff0540de4ab94dca2a3363a3c233c58f7d2f63fdcf8ec66793eed4ae72fe237a48
6
+ metadata.gz: 8e345e850fc539eb4e9fb018cdc48e7acadb47c774b47b438fcd1a95ebc680708999ae6d5440ee45f793bab47d27effd4e054fa3a08e25bf4e6956085effe9ea
7
+ data.tar.gz: b1f47ba0a95186141f38465ac4e6a89636185606c48b8a0a67b7f163934c18181ea59e4c7fe94e54291aa821f662ee726437f350f69f872399063b024f7cbfde
data/.rubocop.yml CHANGED
@@ -5,7 +5,7 @@ AllCops:
5
5
  SuggestExtensions: false
6
6
  TargetRubyVersion: 2.7
7
7
  Exclude:
8
- - 'spec/rails/**/*'
8
+ - 'spec/apps/**/*'
9
9
  - 'vendor/**/*'
10
10
 
11
11
  Style/TrailingCommaInHashLiteral:
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2024-03-25 05:35:37 UTC using RuboCop version 1.62.1.
3
+ # on 2024-04-01 14:13:50 UTC using RuboCop version 1.62.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -9,12 +9,12 @@
9
9
  # Offense count: 11
10
10
  # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
11
11
  Metrics/AbcSize:
12
- Max: 48
12
+ Max: 49
13
13
 
14
14
  # Offense count: 2
15
15
  # Configuration parameters: CountComments, CountAsOne.
16
16
  Metrics/ClassLength:
17
- Max: 207
17
+ Max: 195
18
18
 
19
19
  # Offense count: 8
20
20
  # Configuration parameters: AllowedMethods, AllowedPatterns.
@@ -24,9 +24,9 @@ Metrics/CyclomaticComplexity:
24
24
  # Offense count: 19
25
25
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
26
26
  Metrics/MethodLength:
27
- Max: 34
27
+ Max: 36
28
28
 
29
- # Offense count: 3
29
+ # Offense count: 4
30
30
  # Configuration parameters: AllowedMethods, AllowedPatterns.
31
31
  Metrics/PerceivedComplexity:
32
32
  Max: 13
data/Gemfile CHANGED
@@ -6,7 +6,16 @@ source 'https://rubygems.org'
6
6
  gemspec
7
7
 
8
8
  gem 'rails', ENV['RAILS_VERSION'] || '6.0.3.7'
9
+
10
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0')
11
+ gem 'hanami', ENV['HANAMI_VERSION'] || '2.1.0'
12
+ gem 'hanami-controller', ENV['HANAMI_VERSION'] || '2.1.0'
13
+ gem 'hanami-router', ENV['HANAMI_VERSION'] || '2.1.0'
14
+ end
15
+
9
16
  gem 'roda'
17
+
18
+ gem 'rails-dom-testing', '~> 2.2'
10
19
  gem 'rspec-rails'
11
20
 
12
21
  group :test do
@@ -14,6 +14,7 @@ RSpec::OpenAPI::Record = Struct.new(
14
14
  :operation_id, # @param [String] - "request-1234"
15
15
  :description, # @param [String] - "returns a status"
16
16
  :security, # @param [Array] - [{securityScheme1: []}]
17
+ :deprecated, # @param [Boolean] - true
17
18
  :status, # @param [Integer] - 200
18
19
  :response_body, # @param [Object] - {"status" => "ok"}
19
20
  :response_headers, # @param [Array] - [["header_key1", "header_value1"], ["header_key2", "header_value2"]]
@@ -11,7 +11,7 @@ class << RSpec::OpenAPI::RecordBuilder = Object.new
11
11
  request, response = extract_request_response(context)
12
12
  return if request.nil?
13
13
 
14
- path, summary, tags, operation_id, required_request_params, raw_path_params, description, security =
14
+ path, summary, tags, operation_id, required_request_params, raw_path_params, description, security, deprecated =
15
15
  extract_request_attributes(request, example)
16
16
 
17
17
  return if RSpec::OpenAPI.ignored_paths.any? { |ignored_path| path.match?(ignored_path) }
@@ -32,6 +32,7 @@ class << RSpec::OpenAPI::RecordBuilder = Object.new
32
32
  operation_id: operation_id,
33
33
  description: description,
34
34
  security: security,
35
+ deprecated: deprecated,
35
36
  status: response.status,
36
37
  response_body: safe_parse_body(response, response.media_type),
37
38
  response_headers: response_headers,
@@ -54,7 +55,10 @@ class << RSpec::OpenAPI::RecordBuilder = Object.new
54
55
  def extract_headers(request, response)
55
56
  request_headers = RSpec::OpenAPI.request_headers.each_with_object([]) do |header, headers_arr|
56
57
  header_key = header.gsub('-', '_').upcase.to_sym
57
- header_value = request.get_header(['HTTP', header_key].join('_')) || request.get_header(header_key)
58
+
59
+ header_value = request.get_header(['HTTP', header_key].join('_')) ||
60
+ request.get_header(header_key) ||
61
+ request.get_header(header_key.to_s)
58
62
  headers_arr << [header, header_value] if header_value
59
63
  end
60
64
  response_headers = RSpec::OpenAPI.response_headers.each_with_object([]) do |header, headers_arr|
@@ -73,6 +77,7 @@ class << RSpec::OpenAPI::RecordBuilder = Object.new
73
77
  required_request_params = metadata[:required_request_params] || []
74
78
  security = metadata[:security]
75
79
  description = metadata[:description] || RSpec::OpenAPI.description_builder.call(example)
80
+ deprecated = metadata[:deprecated]
76
81
  raw_path_params = request.path_parameters
77
82
  path = request.path
78
83
  if rails?
@@ -91,7 +96,7 @@ class << RSpec::OpenAPI::RecordBuilder = Object.new
91
96
  raw_path_params = raw_path_params.slice(*(raw_path_params.keys - RSpec::OpenAPI.ignored_path_params))
92
97
  end
93
98
  summary ||= "#{request.method} #{path}"
94
- [path, summary, tags, operation_id, required_request_params, raw_path_params, description, security]
99
+ [path, summary, tags, operation_id, required_request_params, raw_path_params, description, security, deprecated]
95
100
  end
96
101
 
97
102
  def extract_request_response(context)
@@ -34,6 +34,7 @@ class << RSpec::OpenAPI::SchemaBuilder = Object.new
34
34
  tags: record.tags,
35
35
  operationId: record.operation_id,
36
36
  security: record.security,
37
+ deprecated: record.deprecated ? true : nil,
37
38
  parameters: build_parameters(record),
38
39
  requestBody: http_method == 'get' ? nil : build_request_body(record),
39
40
  responses: {
@@ -53,7 +53,8 @@ class << RSpec::OpenAPI::SchemaMerger = Object.new
53
53
  def merge_parameters(base, key, value)
54
54
  all_parameters = value | base[key]
55
55
 
56
- unique_base_parameters = base[key].index_by { |parameter| [parameter[:name], parameter[:in]] }
56
+ unique_base_parameters = build_unique_params(base, key)
57
+
57
58
  all_parameters = all_parameters.map do |parameter|
58
59
  base_parameter = unique_base_parameters[[parameter[:name], parameter[:in]]] || {}
59
60
  base_parameter ? base_parameter.merge(parameter) : parameter
@@ -63,6 +64,12 @@ class << RSpec::OpenAPI::SchemaMerger = Object.new
63
64
  base[key] = all_parameters
64
65
  end
65
66
 
67
+ def build_unique_params(base, key)
68
+ base[key].each_with_object({}) do |parameter, hash|
69
+ hash[[parameter[:name], parameter[:in]]] = parameter
70
+ end
71
+ end
72
+
66
73
  SIMILARITY_THRESHOLD = 0.5
67
74
 
68
75
  def merge_closest_match!(options, spec)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module OpenAPI
5
- VERSION = '0.16.0'
5
+ VERSION = '0.16.1'
6
6
  end
7
7
  end
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.require_paths = ['lib']
30
30
 
31
31
  spec.add_dependency 'actionpack', '>= 5.2.0'
32
+ spec.add_dependency 'rails-dom-testing'
32
33
  spec.add_dependency 'rspec-core'
33
34
  spec.metadata['rubygems_mfa_required'] = 'true'
34
35
  end
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.16.0
4
+ version: 0.16.1
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-03-28 00:00:00.000000000 Z
12
+ date: 2024-04-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -25,6 +25,20 @@ dependencies:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: 5.2.0
28
+ - !ruby/object:Gem::Dependency
29
+ name: rails-dom-testing
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
28
42
  - !ruby/object:Gem::Dependency
29
43
  name: rspec-core
30
44
  requirement: !ruby/object:Gem::Requirement
@@ -89,7 +103,7 @@ licenses:
89
103
  metadata:
90
104
  homepage_uri: https://github.com/exoego/rspec-openapi
91
105
  source_code_uri: https://github.com/exoego/rspec-openapi
92
- changelog_uri: https://github.com/exoego/rspec-openapi/releases/tag/v0.16.0
106
+ changelog_uri: https://github.com/exoego/rspec-openapi/releases/tag/v0.16.1
93
107
  rubygems_mfa_required: 'true'
94
108
  post_install_message:
95
109
  rdoc_options: []