rack-json_schema 1.5.1 → 1.5.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 +3 -0
- data/lib/rack/json_schema/request_validation.rb +5 -7
- data/lib/rack/json_schema/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea834b3142894728ead0af4795f018e28b76e49e
|
4
|
+
data.tar.gz: 4ad711b840ae6164ad75b97108b1c429a71fdec4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29d10eb928628fd8b5daef027e1a79e10ffd07d1ff80e2c08b35d7d043b2c676809ae61d25b5277a6cb33fba233ccd7d1e26f91471270b908e3906674b7ebb52
|
7
|
+
data.tar.gz: a18e18e1c587917e875514f6b626e7da6145969e3b8339bd1452658b17c0e1bfc41ca9a40a4dfa9be930d90e4aee04b26a409022cd1f8285bf2b1e0a3da14094
|
data/CHANGELOG.md
CHANGED
@@ -55,12 +55,10 @@ module Rack
|
|
55
55
|
case
|
56
56
|
when content_type_json? && has_body? && !has_valid_json?
|
57
57
|
raise InvalidJson
|
58
|
+
when content_type_json? && has_schema? && !has_hash_request_body?
|
59
|
+
raise InvalidParameter, "Invalid request. Request body must be an Object in JSON."
|
58
60
|
when content_type_json? && has_schema? && !has_valid_parameter?
|
59
|
-
|
60
|
-
raise InvalidParameter, "Invalid request.\n#{schema_validation_error_message}"
|
61
|
-
else
|
62
|
-
raise InvalidParameter, "Invalid request. Request body must be an Object in JSON."
|
63
|
-
end
|
61
|
+
raise InvalidParameter, "Invalid request.\n#{schema_validation_error_message}"
|
64
62
|
end
|
65
63
|
end
|
66
64
|
elsif !ignore_missing_path?
|
@@ -71,7 +69,7 @@ module Rack
|
|
71
69
|
private
|
72
70
|
|
73
71
|
def has_hash_request_body?
|
74
|
-
|
72
|
+
parameters_from_body.is_a?(Hash)
|
75
73
|
end
|
76
74
|
|
77
75
|
def has_valid_json?
|
@@ -83,7 +81,7 @@ module Rack
|
|
83
81
|
|
84
82
|
# @return [true, false] True if request parameters are all valid
|
85
83
|
def has_valid_parameter?
|
86
|
-
|
84
|
+
!!schema_validation_result[0]
|
87
85
|
end
|
88
86
|
|
89
87
|
# @return [true, false] True if any schema is defined for the current action
|