jsonapi_errors_handler 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/gem-push.yml +2 -2
- data/.github/workflows/gem-test.yml +2 -2
- data/.ruby-version +1 -1
- data/Gemfile.lock +1 -1
- data/README.md +13 -0
- data/lib/jsonapi_errors_handler/configuration.rb +3 -2
- data/lib/jsonapi_errors_handler/version.rb +1 -1
- data/lib/jsonapi_errors_handler.rb +5 -1
- data/package-lock.json +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31413f8cbc86bedcb155eb0574b6675ab75133b9ca4fec4721e7fc6b96bce447
|
4
|
+
data.tar.gz: 4d308a155c082df85e91b35d54f0b0c491e7db6905ef756f73493259223fc6b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87a8f68e263dbf1c1c7352ae1c5a9ce3294a4bdf4fe00bf1d60356ace9cea210ebf737047b003c183d22408a44f4e7edfa2bb3183f9df5da3c6d90d18a74f385
|
7
|
+
data.tar.gz: 25e5082f2cceb2f40c50c8ee3d572312b3f6803d3deb0eb7eccf06875451f74a8765e419ac72ce3175a7c95007014919ab47dccd7c399c0d7ead268833c4b2a7
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.7.
|
1
|
+
2.7.2
|
data/Gemfile.lock
CHANGED
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
|
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
|
@@ -49,7 +49,11 @@ module JsonapiErrorsHandler
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def render_error(error)
|
52
|
-
render
|
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.
|
381
|
-
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.
|
382
|
-
"integrity": "sha512-
|
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
|
+
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:
|
11
|
+
date: 2022-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|