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 +4 -4
- data/.rubocop.yml +1 -1
- data/.rubocop_todo.yml +5 -5
- data/Gemfile +9 -0
- data/lib/rspec/openapi/record.rb +1 -0
- data/lib/rspec/openapi/record_builder.rb +8 -3
- data/lib/rspec/openapi/schema_builder.rb +1 -0
- data/lib/rspec/openapi/schema_merger.rb +8 -1
- data/lib/rspec/openapi/version.rb +1 -1
- data/rspec-openapi.gemspec +1 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c69f9d896be2ad115cb158175dbcf2c1cba9b6d08a7214d23a107a67ec5fc529
|
4
|
+
data.tar.gz: a5af92611c4b47790f165ce6d861bfdedd1214f5dcd9c5641e618f272fe5a7ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e345e850fc539eb4e9fb018cdc48e7acadb47c774b47b438fcd1a95ebc680708999ae6d5440ee45f793bab47d27effd4e054fa3a08e25bf4e6956085effe9ea
|
7
|
+
data.tar.gz: b1f47ba0a95186141f38465ac4e6a89636185606c48b8a0a67b7f163934c18181ea59e4c7fe94e54291aa821f662ee726437f350f69f872399063b024f7cbfde
|
data/.rubocop.yml
CHANGED
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-
|
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:
|
12
|
+
Max: 49
|
13
13
|
|
14
14
|
# Offense count: 2
|
15
15
|
# Configuration parameters: CountComments, CountAsOne.
|
16
16
|
Metrics/ClassLength:
|
17
|
-
Max:
|
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:
|
27
|
+
Max: 36
|
28
28
|
|
29
|
-
# Offense count:
|
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
|
data/lib/rspec/openapi/record.rb
CHANGED
@@ -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
|
-
|
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
|
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)
|
data/rspec-openapi.gemspec
CHANGED
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.
|
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-
|
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.
|
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: []
|