From df44425656c544adf6d3a5039ceb7ef3f44394ba Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Mon, 16 Dec 2024 06:48:12 +0100 Subject: [PATCH 1/2] Add "prev" field in Link attribute --- jsonapi.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jsonapi.go b/jsonapi.go index 83e1cab..924c4a4 100644 --- a/jsonapi.go +++ b/jsonapi.go @@ -75,7 +75,8 @@ type LinkObject struct { } // Link is the top-level links object as defined by https://jsonapi.org/format/1.0/#document-top-level. -// First|Last|Next|Previous are provided to support pagination as defined by https://jsonapi.org/format/1.0/#fetching-pagination. +// First|Last|Next|Prev are provided to support pagination as defined by https://jsonapi.org/format/1.0/#fetching-pagination. +// Previous is kept for backwards compatibility type Link struct { Self any `json:"self,omitempty"` Related any `json:"related,omitempty"` @@ -84,6 +85,7 @@ type Link struct { Last string `json:"last,omitempty"` Next string `json:"next,omitempty"` Previous string `json:"previous,omitempty"` + Prev string `json:"prev,omitempty"` } func checkLinkValue(linkValue any) (bool, *TypeError) { From c4e259eff4fbb25f392f6047aadac18c58796fa5 Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Tue, 17 Dec 2024 07:18:20 +0100 Subject: [PATCH 2/2] Update comment following Chris's comment --- jsonapi.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jsonapi.go b/jsonapi.go index 924c4a4..28240af 100644 --- a/jsonapi.go +++ b/jsonapi.go @@ -76,14 +76,14 @@ type LinkObject struct { // Link is the top-level links object as defined by https://jsonapi.org/format/1.0/#document-top-level. // First|Last|Next|Prev are provided to support pagination as defined by https://jsonapi.org/format/1.0/#fetching-pagination. -// Previous is kept for backwards compatibility type Link struct { Self any `json:"self,omitempty"` Related any `json:"related,omitempty"` - First string `json:"first,omitempty"` - Last string `json:"last,omitempty"` - Next string `json:"next,omitempty"` + First string `json:"first,omitempty"` + Last string `json:"last,omitempty"` + Next string `json:"next,omitempty"` + // Previous is deprecated and kept for backwards compatibility. Instead, use the Prev field. Previous string `json:"previous,omitempty"` Prev string `json:"prev,omitempty"` }