jsonapi_errors_handler 0.4.0 → 0.5.0

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: ae6d9355a82a2ff27bf1681dba4d37579d5018da3fd6f219305b5169b18541d1
4
- data.tar.gz: 8e06b88766e7c18ebf9f9a12f145edbee8cf60e357d5c464f7df4dac45f75b3a
3
+ metadata.gz: 31413f8cbc86bedcb155eb0574b6675ab75133b9ca4fec4721e7fc6b96bce447
4
+ data.tar.gz: 4d308a155c082df85e91b35d54f0b0c491e7db6905ef756f73493259223fc6b7
5
5
  SHA512:
6
- metadata.gz: 5f47b8542ca61fd1f331c010f5aa7e9d94e9105d2808a97c5464ae49d3152add962da1126bd1b74cf8d88ecc67747319b458d6fa3f3781128194a788d7ec3b10
7
- data.tar.gz: f67a3b5ab34dca5177797ccbf0eeab38319e4cea39e6937eafce62cba21aebe1b4b7aaccf2b0d90c3bd8123bd04512fa7ac538d4a15d2b797079cf62c6bb5014
6
+ metadata.gz: 87a8f68e263dbf1c1c7352ae1c5a9ce3294a4bdf4fe00bf1d60356ace9cea210ebf737047b003c183d22408a44f4e7edfa2bb3183f9df5da3c6d90d18a74f385
7
+ data.tar.gz: 25e5082f2cceb2f40c50c8ee3d572312b3f6803d3deb0eb7eccf06875451f74a8765e419ac72ce3175a7c95007014919ab47dccd7c399c0d7ead268833c4b2a7
@@ -11,10 +11,10 @@ jobs:
11
11
 
12
12
  steps:
13
13
  - uses: actions/checkout@v2
14
- - name: Set up Ruby 2.7.1
14
+ - name: Set up Ruby 2.7.2
15
15
  uses: actions/setup-ruby@v1
16
16
  with:
17
- ruby-version: 2.7.1
17
+ ruby-version: 2.7.2
18
18
  - name: Run tests
19
19
  run: |
20
20
  bundle install
@@ -13,10 +13,10 @@ jobs:
13
13
 
14
14
  steps:
15
15
  - uses: actions/checkout@v2
16
- - name: Set up Ruby 2.7.1
16
+ - name: Set up Ruby 2.7.2
17
17
  uses: actions/setup-ruby@v1
18
18
  with:
19
- ruby-version: 2.7.1
19
+ ruby-version: 2.7.2
20
20
  - name: Run tests
21
21
  run: |
22
22
  bundle install
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.1
1
+ 2.7.2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jsonapi_errors_handler (0.4.0)
4
+ jsonapi_errors_handler (0.5.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -57,6 +57,19 @@ JsonapiErrorsHandler.configure do |config|
57
57
  end
58
58
  ```
59
59
 
60
+
61
+ ### Response Content-Type
62
+
63
+ If you want to change the response content type you can do it through the configuration setting `content_type` by default it is `application/vnd.api+json`
64
+
65
+ ```ruby
66
+ require 'jsonapi_errors_handler'
67
+
68
+ JsonapiErrorsHandler.configure do |config|
69
+ config.content_type = 'application/json'
70
+ end
71
+ ```
72
+
60
73
  ### Custom errors mapping
61
74
 
62
75
  If you want your custom errors being handled by default, just add them to the mapper
@@ -9,9 +9,9 @@ module JsonapiErrorsHandler
9
9
  include Singleton
10
10
 
11
11
  attr_writer :handle_unexpected
12
-
12
+ attr_accessor :content_type
13
13
  # Allows to override the configuration options
14
- # @param [Block] - list of options to be overwriten
14
+ # @param [Block] - list of options to be overwritten
15
15
  #
16
16
  def configure
17
17
  yield(self) if block_given?
@@ -28,6 +28,7 @@ module JsonapiErrorsHandler
28
28
 
29
29
  def initialize
30
30
  @handle_unexpected = false
31
+ @content_type = 'application/vnd.api+json'
31
32
  end
32
33
  end
33
34
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JsonapiErrorsHandler
4
- VERSION = '0.4.0'
4
+ VERSION = '0.5.0'
5
5
  end
@@ -49,7 +49,11 @@ module JsonapiErrorsHandler
49
49
  end
50
50
 
51
51
  def render_error(error)
52
- render json: ::JsonapiErrorsHandler::ErrorSerializer.new(error), status: error.status
52
+ render(
53
+ json: ::JsonapiErrorsHandler::ErrorSerializer.new(error),
54
+ status: error.status,
55
+ content_type: Configuration.instance.content_type
56
+ )
53
57
  end
54
58
 
55
59
  def self.configure(&block)
data/package-lock.json CHANGED
@@ -377,9 +377,9 @@
377
377
  "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
378
378
  },
379
379
  "ini": {
380
- "version": "1.3.5",
381
- "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz",
382
- "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw=="
380
+ "version": "1.3.7",
381
+ "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.7.tgz",
382
+ "integrity": "sha512-iKpRpXP+CrP2jyrxvg1kMUpXDyRUFDWurxbnVT1vQPx+Wz9uCYsMIqYuSBLV+PAaZG/d7kRLKRFc9oDMsH+mFQ=="
383
383
  },
384
384
  "is-alphabetical": {
385
385
  "version": "1.0.4",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi_errors_handler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Wilgosz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-18 00:00:00.000000000 Z
11
+ date: 2022-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler