jsonapi-realizer 6.1.0 → 6.1.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
  SHA256:
3
- metadata.gz: 11437da4f610341f2ae128255d1e07320935d5cac5fc4eea6e6a17ff16b32750
4
- data.tar.gz: fc07e3bebde79b8f09050f603941c1b7d1730290ad3d000868e166eeed324c00
3
+ metadata.gz: fec0b16787e2f4f35009538074a18f77b18e9c50206a2fca4999ff0bcc64587c
4
+ data.tar.gz: b687b0a05cac646131f602c16efbfd3e409034d9ed63facd8a44bba01d01a471
5
5
  SHA512:
6
- metadata.gz: 1da40502c9f56fc9acd1b2ac4aaa3d0d9dff8429c2eef5caf6752307343daf5bced3120f02c66219bba607a131c4788591aa8020ce6d8e9a0e9cfd8cb4b11aa0
7
- data.tar.gz: 42c7ffdc5dd6cb89bcaa5a0ecac553bcec9df5f953befb5d8ff46359fc800e563ca4edcc874edd292c91c350997c123e1518245d24ce02cad7ba4bfd865bb4aa
6
+ metadata.gz: df2a33d07219d19037ed213ea43ae1a1ff830ed88e1b90ea1909f6cf326ad098deb22a277a3d6a51926f5c7dd96d8751b324bc762e346cefb1141432143f7941
7
+ data.tar.gz: bb7a5ccd8a64f9c388ae8e6b2c46fd4eeed28758d4074eeec12839f700b6e7435d35af277b0c7295752d3884ac19e5a294d9bcd0490193d796e6ba04e5d3d077
@@ -8,9 +8,13 @@ module JSONAPI
8
8
  attr_accessor(:default_origin)
9
9
  attr_accessor(:default_identifier)
10
10
  attr_accessor(:adapter_mappings)
11
+ attr_accessor(:default_missing_accept_type_exception)
12
+ attr_accessor(:default_invalid_accept_type_exception)
11
13
  attr_accessor(:default_missing_content_type_exception)
12
14
  attr_accessor(:default_invalid_content_type_exception)
13
15
 
16
+ validates_presence_of(:default_missing_accept_type_exception)
17
+ validates_presence_of(:default_invalid_accept_type_exception)
14
18
  validates_presence_of(:default_missing_content_type_exception)
15
19
  validates_presence_of(:default_invalid_content_type_exception)
16
20
 
@@ -4,7 +4,7 @@ module JSONAPI
4
4
  module Realizer
5
5
  module Controller
6
6
  private def reject_missing_accept_type_header
7
- return if request.body.empty?
7
+ return if request.body.read.empty?
8
8
  return if request.headers.key?("HTTP_ACCEPT")
9
9
 
10
10
  raise(JSONAPI::Realizer.configuration.default_missing_accept_type_exception)
@@ -19,7 +19,7 @@ module JSONAPI
19
19
  end
20
20
 
21
21
  private def reject_missing_content_type_header
22
- return if request.body.empty?
22
+ return if request.body.read.empty?
23
23
  return if request.headers.key?("Content-Type")
24
24
 
25
25
  raise(JSONAPI::Realizer.configuration.default_missing_content_type_exception)
@@ -32,41 +32,6 @@ module JSONAPI
32
32
 
33
33
  raise(JSONAPI::Realizer.configuration.default_invalid_content_type_exception)
34
34
  end
35
-
36
- private def reject_missing_root_property
37
- return if request.parameters.key?("body")
38
- return if request.parameters.key?("errors")
39
- return if request.parameters.key?("meta")
40
-
41
- raise(Error::MissingRootProperty)
42
- end
43
-
44
- private def reject_invalid_root_property
45
- reject_missing_root_property
46
-
47
- return unless request.parameters.key?("data") && (request.parameters.fetch("data").is_a?(Hash) || request.parameters.fetch("data").is_a?(Array))
48
- return unless request.parameters.key?("errors") && request.parameters.fetch("errors").is_a?(Array)
49
-
50
- raise(Error::InvalidRootProperty)
51
- end
52
-
53
- private def reject_missing_type_property
54
- reject_invalid_root_property
55
-
56
- return if request.parameters.fetch("data").is_a?(Hash) && request.parameters.fetch("data").key?("type")
57
- return if request.parameters.fetch("data").is_a?(Array) && request.parameters.fetch("data").all? { |data| data.key?("type") }
58
-
59
- raise(Error::MissingDataTypeProperty)
60
- end
61
-
62
- private def reject_invalid_type_property
63
- reject_missing_type_property
64
-
65
- return if request.parameters.fetch("data").is_a?(Hash) && request.parameters.fetch("data").fetch("type").is_a?(String) && request.parameters.fetch("data").fetch("type").present?
66
- return if request.parameters.fetch("data").is_a?(Array) && request.parameters.fetch("data").map { |data| data.fetch("type") }.all? { |type| type.is_a?(String) && type.present? }
67
-
68
- raise(Error::InvalidDataTypeProperty)
69
- end
70
35
  end
71
36
  end
72
37
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module JSONAPI
4
4
  module Realizer
5
- VERSION = "6.1.0"
5
+ VERSION = "6.1.2"
6
6
  end
7
7
  end
@@ -18,6 +18,8 @@ module JSONAPI
18
18
  require_relative("realizer/controller")
19
19
 
20
20
  @configuration ||= Configuration.new(
21
+ default_invalid_accept_type_exception: JSONAPI::Realizer::Error::InvalidAcceptTypeHeader,
22
+ default_missing_accept_type_exception: JSONAPI::Realizer::Error::MissingAcceptTypeHeader,
21
23
  default_invalid_content_type_exception: JSONAPI::Realizer::Error::InvalidContentTypeHeader,
22
24
  default_missing_content_type_exception: JSONAPI::Realizer::Error::MissingContentTypeHeader,
23
25
  default_identifier: :id,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi-realizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.1.0
4
+ version: 6.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kurtis Rainbolt-Greene
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-18 00:00:00.000000000 Z
11
+ date: 2023-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport