Skip to content

Commit 8ee4284

Browse files
committed
Make the self link URL compliant with the spec.
1 parent 5ecc724 commit 8ee4284

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

lib/jsonapi-serializers/serializer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def self_link
6969
end
7070

7171
def relationship_self_link(attribute_name)
72-
"#{self_link}/links/#{format_name(attribute_name)}"
72+
"#{self_link}/relationships/#{format_name(attribute_name)}"
7373
end
7474

7575
def relationship_related_link(attribute_name)

spec/serializer_spec.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ def serialize_primary(object, options = {})
4343
'relationships' => {
4444
'user' => {
4545
'links' => {
46-
'self' => '/long-comments/1/links/user',
46+
'self' => '/long-comments/1/relationships/user',
4747
'related' => '/long-comments/1/user',
4848
},
4949
},
5050
'post' => {
5151
'links' => {
52-
'self' => '/long-comments/1/links/post',
52+
'self' => '/long-comments/1/relationships/post',
5353
'related' => '/long-comments/1/post',
5454
},
5555
},
@@ -96,13 +96,13 @@ def serialize_primary(object, options = {})
9696
# Both to-one and to-many links are present, but neither include linkage:
9797
'author' => {
9898
'links' => {
99-
'self' => '/posts/1/links/author',
99+
'self' => '/posts/1/relationships/author',
100100
'related' => '/posts/1/author',
101101
},
102102
},
103103
'long-comments' => {
104104
'links' => {
105-
'self' => '/posts/1/links/long-comments',
105+
'self' => '/posts/1/relationships/long-comments',
106106
'related' => '/posts/1/long-comments',
107107
},
108108
},
@@ -131,7 +131,7 @@ def serialize_primary(object, options = {})
131131
'relationships' => {
132132
'author' => {
133133
'links' => {
134-
'self' => '/posts/1/links/author',
134+
'self' => '/posts/1/relationships/author',
135135
'related' => '/posts/1/author',
136136
},
137137
# Spec: Resource linkage MUST be represented as one of the following:
@@ -141,7 +141,7 @@ def serialize_primary(object, options = {})
141141
},
142142
'long-comments' => {
143143
'links' => {
144-
'self' => '/posts/1/links/long-comments',
144+
'self' => '/posts/1/relationships/long-comments',
145145
'related' => '/posts/1/long-comments',
146146
},
147147
'data' => [],
@@ -169,7 +169,7 @@ def serialize_primary(object, options = {})
169169
'relationships' => {
170170
'author' => {
171171
'links' => {
172-
'self' => '/posts/1/links/author',
172+
'self' => '/posts/1/relationships/author',
173173
'related' => '/posts/1/author',
174174
},
175175
# Spec: Resource linkage MUST be represented as one of the following:
@@ -182,7 +182,7 @@ def serialize_primary(object, options = {})
182182
},
183183
'long-comments' => {
184184
'links' => {
185-
'self' => '/posts/1/links/long-comments',
185+
'self' => '/posts/1/relationships/long-comments',
186186
'related' => '/posts/1/long-comments',
187187
},
188188
'data' => [],
@@ -210,14 +210,14 @@ def serialize_primary(object, options = {})
210210
'relationships' => {
211211
'author' => {
212212
'links' => {
213-
'self' => '/posts/1/links/author',
213+
'self' => '/posts/1/relationships/author',
214214
'related' => '/posts/1/author',
215215
},
216216
'data' => nil,
217217
},
218218
'long-comments' => {
219219
'links' => {
220-
'self' => '/posts/1/links/long-comments',
220+
'self' => '/posts/1/relationships/long-comments',
221221
'related' => '/posts/1/long-comments',
222222
},
223223
# Spec: Resource linkage MUST be represented as one of the following:
@@ -249,14 +249,14 @@ def serialize_primary(object, options = {})
249249
'relationships' => {
250250
'author' => {
251251
'links' => {
252-
'self' => '/posts/1/links/author',
252+
'self' => '/posts/1/relationships/author',
253253
'related' => '/posts/1/author',
254254
},
255255
'data' => nil,
256256
},
257257
'long-comments' => {
258258
'links' => {
259-
'self' => '/posts/1/links/long-comments',
259+
'self' => '/posts/1/relationships/long-comments',
260260
'related' => '/posts/1/long-comments',
261261
},
262262
# Spec: Resource linkage MUST be represented as one of the following:

0 commit comments

Comments
 (0)