jsonapi.rb 1.1.1 → 1.1.2
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/Gemfile.lock +1 -1
- data/lib/jsonapi/pagination.rb +4 -2
- data/lib/jsonapi/rails.rb +5 -3
- data/lib/jsonapi/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34da5d6dcd9a125571ba22e88bf08962369e6a78d849f250e756694b1c32dc1b
|
4
|
+
data.tar.gz: 27cd59c2e576c6ae7ab98ef397e6dca446231c9b61ed97568c63e9a2f1fe8034
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a89e3160b394aa072a3cefa1c64f6e4f2ab94fdee53242ab97e48a7fc2d38145aada482d0956c8a17278f7b14f07828721e4e00de1be2eff918b81153ef113c5
|
7
|
+
data.tar.gz: 649b9fd8157a09153ef06d23178fc946453cc6d3d65264fb5d979b4c4ceb9adb8fde26c4ca1bbb6343c8651832ec97f66dcfd22be4539458538b74895bf0dc1e
|
data/Gemfile.lock
CHANGED
data/lib/jsonapi/pagination.rb
CHANGED
@@ -39,7 +39,9 @@ module JSONAPI
|
|
39
39
|
|
40
40
|
pagination.each do |page_name, number|
|
41
41
|
original_params[:page][:number] = number
|
42
|
-
links[page_name] = original_url + CGI.unescape(
|
42
|
+
links[page_name] = original_url + CGI.unescape(
|
43
|
+
original_params.to_query
|
44
|
+
)
|
43
45
|
end
|
44
46
|
|
45
47
|
links
|
@@ -47,7 +49,7 @@ module JSONAPI
|
|
47
49
|
|
48
50
|
# Generates pagination numbers
|
49
51
|
#
|
50
|
-
# @return [Hash] with the first, previous, next, current
|
52
|
+
# @return [Hash] with the first, previous, next, current, last page numbers
|
51
53
|
def jsonapi_pagination_meta(resources)
|
52
54
|
return {} unless JSONAPI::Rails.is_collection?(resources)
|
53
55
|
|
data/lib/jsonapi/rails.rb
CHANGED
@@ -13,7 +13,7 @@ module JSONAPI
|
|
13
13
|
Mime::Type.register JSONAPI::MEDIA_TYPE, :jsonapi
|
14
14
|
|
15
15
|
# Map the JSON parser to the JSONAPI mime type requests.
|
16
|
-
if Rails::VERSION::MAJOR >= 5
|
16
|
+
if ::Rails::VERSION::MAJOR >= 5
|
17
17
|
parser = ActionDispatch::Request.parameter_parsers[:json]
|
18
18
|
ActionDispatch::Request.parameter_parsers[:jsonapi] = parser
|
19
19
|
else
|
@@ -63,14 +63,16 @@ module JSONAPI
|
|
63
63
|
options[:meta] ||= (
|
64
64
|
jsonapi_meta(resource) if respond_to?(:jsonapi_meta, true))
|
65
65
|
options[:links] ||= (
|
66
|
-
jsonapi_pagination(resource) if respond_to?(:jsonapi_pagination, true)
|
66
|
+
jsonapi_pagination(resource) if respond_to?(:jsonapi_pagination, true)
|
67
|
+
)
|
67
68
|
|
68
69
|
# If it's an empty collection, return it directly.
|
69
70
|
if JSONAPI::Rails.is_collection?(resource) && !resource.any?
|
70
71
|
return options.slice(:meta, :links).merge(data: []).to_json
|
71
72
|
end
|
72
73
|
|
73
|
-
options[:fields] ||=
|
74
|
+
options[:fields] ||= (
|
75
|
+
jsonapi_fields if respond_to?(:jsonapi_fields, true))
|
74
76
|
options[:include] ||= (
|
75
77
|
jsonapi_include if respond_to?(:jsonapi_include, true))
|
76
78
|
|
data/lib/jsonapi/version.rb
CHANGED