openapi_first 2.9.1 → 2.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +2 -0
- data/lib/openapi_first/router/find_response.rb +13 -9
- data/lib/openapi_first/test/coverage/terminal_formatter.rb +5 -2
- data/lib/openapi_first/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77ee23a7f40889116a6ae239e51711460c21c9f134f7e85bef5c2869d91d7d26
|
4
|
+
data.tar.gz: 5b541d1727e879c8e1ace187679bd6bc708054e2675d127dfca718fc963fb10b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68e0311f5a70192b54a4d3c3654e1910b39bdfc420db4c5abcce38ba4dc2d2f4e78a278ac35be8a9796c59ba42428c3b67912adb08c1aeb469ba5d08f8223800
|
7
|
+
data.tar.gz: e43db82ccea7aeca33f58fa705f16844080f672dc0b157f72f10aa1e5fdf7ca4a71d6146c93622b46b226811b6e9cd09c61fa72fec6fb16831edfc606668089b
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## 2.9.2
|
6
|
+
|
7
|
+
- OpenapiFirst::Test reports all non-covered requests now
|
8
|
+
- Response validation: Improve content type mismatch exception message
|
9
|
+
|
5
10
|
## 2.9.1
|
6
11
|
|
7
12
|
- Fix OpenapiFirst::Test's request validation to not always raise an error, but only for unknown requests
|
data/README.md
CHANGED
@@ -368,6 +368,8 @@ use OpenapiFirst::Middlewares::RequestValidation, oad
|
|
368
368
|
|
369
369
|
## Development
|
370
370
|
|
371
|
+
Run `git submodule update --init` to initialize the git submodules.
|
372
|
+
|
371
373
|
Run `bin/setup` to install dependencies.
|
372
374
|
|
373
375
|
See `bundle exec rake` to run the linter and the tests.
|
@@ -16,20 +16,24 @@ module OpenapiFirst
|
|
16
16
|
return Match.new(error: Failure.new(:response_not_found, message:), response: nil)
|
17
17
|
end
|
18
18
|
response = FindContent.call(contents, content_type)
|
19
|
-
|
20
|
-
message = "#{content_error(content_type, request_method:,
|
21
|
-
path:)} Content-Type should be #{contents.keys.join(' or ')}."
|
22
|
-
return Match.new(error: Failure.new(:response_not_found, message:), response: nil)
|
23
|
-
end
|
19
|
+
return response_not_found(content_type:, contents:, request_method:, path:) unless response
|
24
20
|
|
25
21
|
Match.new(response:, error: nil)
|
26
22
|
end
|
27
23
|
|
28
|
-
def self.
|
29
|
-
|
30
|
-
|
31
|
-
|
24
|
+
def self.response_not_found(content_type:, contents:, request_method:, path:)
|
25
|
+
empty_content = content_type.nil? || content_type.empty?
|
26
|
+
message =
|
27
|
+
"Content-Type should be #{contents.keys.join(' or ')}, " \
|
28
|
+
"but was #{empty_content ? 'empty' : content_type} for " \
|
29
|
+
"#{request_method.upcase} #{path}"
|
30
|
+
|
31
|
+
Match.new(
|
32
|
+
error: Failure.new(:response_not_found, message:),
|
33
|
+
response: nil
|
34
|
+
)
|
32
35
|
end
|
36
|
+
private_class_method :response_not_found
|
33
37
|
|
34
38
|
def self.find_status(responses, status)
|
35
39
|
# According to OAS status has to be a string,
|
@@ -33,14 +33,17 @@ module OpenapiFirst
|
|
33
33
|
@out.print(string)
|
34
34
|
end
|
35
35
|
|
36
|
-
def format_plan(plan)
|
36
|
+
def format_plan(plan) # rubocop:disable Metrics/PerceivedComplexity
|
37
37
|
puts ['', "API validation coverage for #{plan.api_identifier}: #{plan.coverage}%"]
|
38
38
|
return if plan.done? && !verbose
|
39
39
|
|
40
|
+
requested_routes_count = plan.routes.count { |route| route.requests.any?(&:requested?) }
|
41
|
+
focused_route = requested_routes_count <= 1 && focused
|
42
|
+
|
40
43
|
plan.routes.each do |route|
|
41
44
|
next if route.finished? && !verbose
|
42
45
|
|
43
|
-
next if route.requests.none?(&:requested?) &&
|
46
|
+
next if route.requests.none?(&:requested?) && focused_route
|
44
47
|
|
45
48
|
format_requests(route.requests)
|
46
49
|
|