jsonapi_compliable 0.11.30 → 0.11.31

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: 6fa03551f19ae09cd9075762f59437eeb13d334f
4
- data.tar.gz: 39ba214c311ac1e28d7ba3cc23e990da77a88c51
3
+ metadata.gz: 76109d783e52c411bd1ed7583bd94f50478f7605
4
+ data.tar.gz: f3d5581fbbda759b055219c454d8a2060dc879b0
5
5
  SHA512:
6
- metadata.gz: 1bf91e4f4d66d489e00479d07f45f4203faea85fb1025ee17979b90993a7642fac1d0e4a2f0ac6240643bdd8cd227513628cf36a8dee549b4357f5329459547f
7
- data.tar.gz: b5bebf8a56a6da6152d7614ad97b3d0a1d4d5d8b65291b61e20d586ffa2b7aa8b7b8bffceeddfbacbeb7d3d326a0445b8f43fc84e7bc04947ce530c3ebb39996
6
+ metadata.gz: fed2ef49d65ba39ba4255a599886e93255afb03d654efa45ca820f561399fff83eed54cc0e536da49d0335f7a6b7d4b4832452bdaed1ab76e511442cec769e0d
7
+ data.tar.gz: 0f95a5e83ea0a23b570dcf84b44f552b8d1536826e3331815ebec4d28da307fb2c32331527ab7451ae5fcc0675f9f5c2511c4c65c438d3668c1db64036e35741
@@ -345,7 +345,7 @@ module JsonapiCompliable
345
345
  end
346
346
 
347
347
  def force_includes?
348
- not deserialized_params.data.nil?
348
+ not (deserialized_params.data.nil? || deserialized_params.data.empty?)
349
349
  end
350
350
 
351
351
  def perform_render_jsonapi(opts)
@@ -48,14 +48,23 @@ class JsonapiCompliable::Deserializer
48
48
  # @param payload [Hash] The incoming payload with symbolized keys
49
49
  # @param env [Hash] the Rack env (e.g. +request.env+).
50
50
  def initialize(payload, env)
51
- @payload = payload
51
+ @payload = payload || {}
52
52
  @payload = @payload[:_jsonapi] if @payload.has_key?(:_jsonapi)
53
53
  @env = env
54
+ validate_content_type
55
+ end
56
+
57
+ # checks Content-Type header and prints a warning if it doesn't seem correct
58
+ def validate_content_type
59
+ content_type = @env['CONTENT_TYPE'] || ""
60
+ if !(content_type.include?("application/json") || content_type.include?("application/vnd.api+json"))
61
+ print("WARNING - JSONAPI Compliable :: Content-Type header appears to be set to an invalid value: #{content_type}\n")
62
+ end
54
63
  end
55
64
 
56
65
  # @return [Hash] the raw :data value of the payload
57
66
  def data
58
- @payload[:data]
67
+ @payload[:data] || {}
59
68
  end
60
69
 
61
70
  # @return [String] the raw :id value of the payload
@@ -1,3 +1,3 @@
1
1
  module JsonapiCompliable
2
- VERSION = "0.11.30"
2
+ VERSION = "0.11.31"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi_compliable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.30
4
+ version: 0.11.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Richmond
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-09-04 00:00:00.000000000 Z
12
+ date: 2018-09-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jsonapi-serializable