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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7c359a173c8a15742899c048066568b9ba4e9dcc
4
- data.tar.gz: 868a647466e9df56fd41302f74f4f768fbdccddd
3
+ metadata.gz: 2c02f8ffa259cdd0d9dc677025227bb679e904ec
4
+ data.tar.gz: 50f290b85d487fb9d46caaf928e14131712eb7b2
5
5
  SHA512:
6
- metadata.gz: 31755c67da66e679a28434d7bc2fae80d1532dd56404f9a9419410e83dfd2047181c5b444dce1449d465bf24a9d74d1633df767df3b4ee078fa81cb2e582e252
7
- data.tar.gz: 5220e8a448947182e56bf153969181ba0aa9fe81bee99b6abb943c5b13064a31d2292a9410100e6b62b3ea7949a98c0bb668fb5173ce518f14a8d63549909ea3
6
+ metadata.gz: 61102d656d4c4550f9e2e0d73322ffe7192aed237083a117c1c5cfe21d8c64dfcb9b58d64b65e30791d9d9804f5495115df3837dd4977e8d72742ad51c28a3e0
7
+ data.tar.gz: 33aec895164221bbe5e58f0fa9d77509e5e273bc22578ab3b68ecfe36dfd99b5f4f7cc6e68b95e5c90b76476ffe9203e7bbe2c7a0820ebb7f049d34f130fd521
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 1.1.3
2
+ * Validate request parameters in URI query too
3
+
1
4
  ## 1.1.2
2
5
  * Support an empty array response at response validation
3
6
 
@@ -40,7 +40,7 @@ module Rack
40
40
  raise InvalidContentType
41
41
  when has_body? && !has_valid_json?
42
42
  raise InvalidJson
43
- when has_body? && has_schema? && !has_valid_parameter?
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 ||= begin
114
- if has_body?
115
- JSON.parse(body)
116
- else
117
- {}
118
- end
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
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  module JsonSchema
3
- VERSION = "1.1.2"
3
+ VERSION = "1.1.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-json_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura