rack-json_schema 1.5.1 → 1.5.2

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: e1bc0b3aeb691e9f03410743681b3aeb47636727
4
- data.tar.gz: 78f4809fbaa6d7732b5ba700f464be4187ad6263
3
+ metadata.gz: ea834b3142894728ead0af4795f018e28b76e49e
4
+ data.tar.gz: 4ad711b840ae6164ad75b97108b1c429a71fdec4
5
5
  SHA512:
6
- metadata.gz: 82933f6a328ccb1f7809880262f4f2119c19962c6830082ca188b768c995a55701f58f2e6f6d003c2522a3667d43f7eee91237bd844e4ccdc30da52733feb643
7
- data.tar.gz: 694562757728e378acf77e615247bc480f51048b9f649eb4ccc9b503889a1a545d39ad5af3ce860cb485e390186ddcce14853dd55c35a97ccceac606b21da49d
6
+ metadata.gz: 29d10eb928628fd8b5daef027e1a79e10ffd07d1ff80e2c08b35d7d043b2c676809ae61d25b5277a6cb33fba233ccd7d1e26f91471270b908e3906674b7ebb52
7
+ data.tar.gz: a18e18e1c587917e875514f6b626e7da6145969e3b8339bd1452658b17c0e1bfc41ca9a40a4dfa9be930d90e4aee04b26a409022cd1f8285bf2b1e0a3da14094
@@ -1,3 +1,6 @@
1
+ ## 1.5.2
2
+ - Fix bug on handling empty request body handling (e.g. GET)
3
+
1
4
  ## 1.5.1
2
5
  - Fix error when request body is an Array in JSON
3
6
 
@@ -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
- if has_hash_request_body?
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
- parsed_body.is_a?(Hash)
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
- parsed_body.is_a?(Hash) && schema_validation_result[0]
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
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  module JsonSchema
3
- VERSION = "1.5.1"
3
+ VERSION = "1.5.2"
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.5.1
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura