rack-json_schema 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/rack/json_schema/request_validation.rb +16 -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: 2c02f8ffa259cdd0d9dc677025227bb679e904ec
|
4
|
+
data.tar.gz: 50f290b85d487fb9d46caaf928e14131712eb7b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61102d656d4c4550f9e2e0d73322ffe7192aed237083a117c1c5cfe21d8c64dfcb9b58d64b65e30791d9d9804f5495115df3837dd4977e8d72742ad51c28a3e0
|
7
|
+
data.tar.gz: 33aec895164221bbe5e58f0fa9d77509e5e273bc22578ab3b68ecfe36dfd99b5f4f7cc6e68b95e5c90b76476ffe9203e7bbe2c7a0820ebb7f049d34f130fd521
|
data/CHANGELOG.md
CHANGED
@@ -40,7 +40,7 @@ module Rack
|
|
40
40
|
raise InvalidContentType
|
41
41
|
when has_body? && !has_valid_json?
|
42
42
|
raise InvalidJson
|
43
|
-
when
|
43
|
+
when has_schema? && !has_valid_parameter?
|
44
44
|
raise InvalidParameter, "Invalid request.\n#{schema_validation_error_message}"
|
45
45
|
end
|
46
46
|
end
|
@@ -110,14 +110,23 @@ module Rack
|
|
110
110
|
# @return [Hash] Request parameters decoded from JSON
|
111
111
|
# @raise [JSON::JSONError]
|
112
112
|
def parameters
|
113
|
-
@parameters ||=
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
113
|
+
@parameters ||= parameters_from_query.merge(parameters_from_body)
|
114
|
+
end
|
115
|
+
|
116
|
+
# @return [Hash] Request parameters decoded from JSON
|
117
|
+
# @raise [JSON::JSONError]
|
118
|
+
def parameters_from_body
|
119
|
+
if has_body?
|
120
|
+
JSON.parse(body)
|
121
|
+
else
|
122
|
+
{}
|
119
123
|
end
|
120
124
|
end
|
125
|
+
|
126
|
+
# @return [Hash] Request parameters extracted from URI query
|
127
|
+
def parameters_from_query
|
128
|
+
request.GET
|
129
|
+
end
|
121
130
|
end
|
122
131
|
|
123
132
|
# Base error class for Rack::JsonSchema::RequestValidation
|