sanger-jsonapi-resources 0.4.0 → 0.4.1
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/lib/jsonapi/error.rb +17 -2
- data/lib/jsonapi/exceptions.rb +2 -2
- data/lib/jsonapi/resources/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4f7b37198032c08ac3800b82abdb98dffdd1c5760a153bace28a712f326ce41e
|
|
4
|
+
data.tar.gz: e1b41e3bec53e30f7d4354318be0ef3fe0da8c2f67d7b3edb307ddc77a583f48
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 624d02550d83de48d6e704bcd9865a3ee08285eba28c803719976565ebe12bbb028f50bb65fed1eb0adb03fe9617b5d8a157ee582605577f87189b6607c817c9
|
|
7
|
+
data.tar.gz: 33d5cfafab15dd04fe18e567ce72f545789ae9be8d7c337ba9b901aa2ff34e786f0e2cc1fb456e8a65220316fcf7addadc2e77d0279f386653a8fbce68ece8d1
|
data/lib/jsonapi/error.rb
CHANGED
|
@@ -17,7 +17,7 @@ module JSONAPI
|
|
|
17
17
|
@source = options[:source]
|
|
18
18
|
@links = options[:links]
|
|
19
19
|
|
|
20
|
-
@status =
|
|
20
|
+
@status = status_code(options[:status]).to_s
|
|
21
21
|
@meta = options[:meta]
|
|
22
22
|
end
|
|
23
23
|
|
|
@@ -48,11 +48,26 @@ module JSONAPI
|
|
|
48
48
|
|
|
49
49
|
if error_object_overrides[:status]
|
|
50
50
|
# :nocov:
|
|
51
|
-
@status
|
|
51
|
+
@status = status_code(error_object_overrides[:status]).to_s
|
|
52
52
|
# :nocov:
|
|
53
53
|
end
|
|
54
54
|
@meta = error_object_overrides[:meta] || @meta
|
|
55
55
|
end
|
|
56
|
+
|
|
57
|
+
private
|
|
58
|
+
|
|
59
|
+
# Extracted from Rack 2
|
|
60
|
+
def status_code(status)
|
|
61
|
+
if status.nil?
|
|
62
|
+
raise ArgumentError, "Status code is required"
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
if status.is_a?(Symbol)
|
|
66
|
+
Rack::Utils::SYMBOL_TO_STATUS_CODE.fetch(status) { raise ArgumentError, "Unrecognized status code #{status.inspect}" }
|
|
67
|
+
else
|
|
68
|
+
status.to_i
|
|
69
|
+
end
|
|
70
|
+
end
|
|
56
71
|
end
|
|
57
72
|
|
|
58
73
|
class Warning
|
data/lib/jsonapi/exceptions.rb
CHANGED
|
@@ -498,7 +498,7 @@ module JSONAPI
|
|
|
498
498
|
|
|
499
499
|
def json_api_error(attr_key, message)
|
|
500
500
|
create_error_object(code: JSONAPI::VALIDATION_ERROR,
|
|
501
|
-
status: :
|
|
501
|
+
status: :unprocessable_content,
|
|
502
502
|
title: message,
|
|
503
503
|
detail: detail(attr_key, message),
|
|
504
504
|
source: { pointer: pointer(attr_key) },
|
|
@@ -532,7 +532,7 @@ module JSONAPI
|
|
|
532
532
|
class SaveFailed < Error
|
|
533
533
|
def errors
|
|
534
534
|
[create_error_object(code: JSONAPI::SAVE_FAILED,
|
|
535
|
-
status: :
|
|
535
|
+
status: :unprocessable_content,
|
|
536
536
|
title: I18n.translate('jsonapi-resources.exceptions.save_failed.title',
|
|
537
537
|
default: 'Save failed or was cancelled'),
|
|
538
538
|
detail: I18n.translate('jsonapi-resources.exceptions.save_failed.detail',
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sanger-jsonapi-resources
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- PSD Team - Wellcome Trust Sanger Institute
|
|
@@ -195,14 +195,14 @@ dependencies:
|
|
|
195
195
|
requirements:
|
|
196
196
|
- - "~>"
|
|
197
197
|
- !ruby/object:Gem::Version
|
|
198
|
-
version: '
|
|
198
|
+
version: '3.0'
|
|
199
199
|
type: :runtime
|
|
200
200
|
prerelease: false
|
|
201
201
|
version_requirements: !ruby/object:Gem::Requirement
|
|
202
202
|
requirements:
|
|
203
203
|
- - "~>"
|
|
204
204
|
- !ruby/object:Gem::Version
|
|
205
|
-
version: '
|
|
205
|
+
version: '3.0'
|
|
206
206
|
- !ruby/object:Gem::Dependency
|
|
207
207
|
name: concurrent-ruby
|
|
208
208
|
requirement: !ruby/object:Gem::Requirement
|