Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "prev" field in Link attribute #60

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions jsonapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,17 @@ 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.
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"`
Copy link
Collaborator

@chrismclennon chrismclennon Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: I'd recommend placing the comment as close to the field as possible, I believe it will be more readable this way.

Suggested change
Previous string `json:"previous,omitempty"`
// Previous is deprecated and kept for backwards compatibility. Instead, use the Prev field.
Previous string `json:"previous,omitempty"`

or perhaps,

Suggested change
Previous string `json:"previous,omitempty"`
// DEPRECATED: Use the Prev field.
Previous string `json:"previous,omitempty"`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the comment !

Prev string `json:"prev,omitempty"`
}

func checkLinkValue(linkValue any) (bool, *TypeError) {
Expand Down
Loading