serializeAndPush requires jsonapi.version, but spec does not
See original GitHub issueRight now the serializeAndPush checks the response for a { jsonapi: { version: * }
fragment, even though the JSON API spec says the following:
A JSON:API document MAY include information about its implementation under a top level jsonapi member. If present, the value of the jsonapi member MUST be an object (a “jsonapi object”). The jsonapi object MAY contain a version member whose value is a string indicating the highest JSON API version supported.
My interpretation of this is that serializeAndPush
is more strict than it should be, but I do understand this is probably included to inform users that this function is only compatible with a JSON API compliant API. An alternative would be to not return from this function, but just display the warning.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:5 (5 by maintainers)
Top GitHub Comments
@iezer that’s more generalized than I’m comfortable with. We need to auto-detect things that are definitely JSON:API documents without any false positives (i.e., this
serializeAndPush
feature should never get in the way, and should clearly announce that specific payload shapes are required if anything looks “off”).If I have a payload
I should get very clear feedback that this can’t be used with
serializeAndPush
.Maybe update
isJsonApi
to something likeWhat you’re looking for is
normalizeResponse
. Depending on therequestType
argument that it’s passed, it’ll look for the payload to contain a single record or array of records. https://github.com/emberjs/data/blob/3dc5976ed5565708ac0813e5c2beb46f31f4d44f/addon/serializers/json.js#L239-L262