Open octomad opened 2 years ago
Personally I vote to keep our convention of @id
the problem that i had with @id
is that it represents the current document being returned. In this case, it isn't referring to the current doc but rather a ref to the resource that was created.
@id isn't solely for representing the current resource, it's used as a reference in other places (like Collections). It's our version of hypertext navigation.
Hyperion spec makes no mention of what type of response a 201 should be sending back. In order to reach some type consistency across all Hyperion compliant APIs there should be a standard in place for this.
According to the HTTP spec:
According to Mozilla's dev site
Both of those references have similarities but also some differences -- most notably the mention of what the body/payload should include. We should lean towards what former HTTP spec mentions however it does leave some room for interpretation using words like "typically describes" and not a MUST. The
Location
header is common and should be part of the headers.Given this, I see three possible avenues that an API can take. Return a
Location
header along with:LinkValue
to the new resource - While redundant with the HTTP specification, this appears to be the most Hyperion-esque. Not only do APIs benefit from not having to re-query, the response provides useful information about where the new resource is located.An example header + payload response for option 3 could be: