Skip to content

Allow 'links.self' as objects in the schema #1160

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

Merged
merged 2 commits into from
Jul 26, 2017

Conversation

tadast
Copy link
Contributor

@tadast tadast commented May 2, 2017

See #1159 for context.

This change allows the self link to be an object as well as a string as per spec.

A link MUST be represented as either:

  • a string containing the link’s URL.
  • an object (“link object”)

It also makes sure that each property in the links object is a definitions/link, as per spec.

The value of each links member MUST be an object (a “links object”).

It also separates a relationshipLinks definition that seems to carry
some relationship-specific descriptions. Although it could easily use the modified links definition as well with the same effect. If we don't care about these descriptions I can modify this PR for the relationship.links to use the new links definition.

Fixes #1159

The spec says that a link can be either a string or an
object: http://jsonapi.org/format/#document-links

However the schema enforces that `self` links must be
strings: https://github.com/json-api/json-api/blob/509ee949c621cee5683c959d4268386e1a592b83/schema#L158-L162

It is also a bit odd that the properties and descriptions in
`definitions/links` seems to be relationship-specific: https://github.com/json-api/json-api/blob/509ee949c621cee5683c959d4268386e1a592b83/schema#L154-L168 ,
but this definition is referenced from resource: https://github.com/json-api/json-api/blob/509ee949c621cee5683c959d4268386e1a592b83/schema#L144-L146
and top level: https://github.com/json-api/json-api/blob/509ee949c621cee5683c959d4268386e1a592b83/schema#L38-L43
link objects.

@steveklabnik has confirmed in GH issue json-api#1159 that the spec is the
source of truth and the schema might lag behind.

This change allows the self link to be an object as well as a string. It
also makes sure that each property in the `links` object is a
`definitions/link` (as per spec).
It also separates a relationshipLinks definition that seems to carry
some relationship-specific descriptions.

Fixes json-api#1159
@steveklabnik
Copy link
Contributor

Thank you!

@dgeb what do you think?

Copy link
Contributor

@jamesplease jamesplease left a comment

Choose a reason for hiding this comment

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

Looks good to me. Good catch @tadast

@dgeb dgeb merged commit 7e5cea0 into json-api:gh-pages Jul 26, 2017
@dgeb
Copy link
Member

dgeb commented Jul 26, 2017

@tadast thanks much! Apologies for taking so long to review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy