mattpolzin / mattpolzin/JSONAPI
Handle unexpected relationships in json?
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 81
- Forks
- 21
- PR merge metrics
- No merged PRs in 30d
Description
We have run into situations where the API gets a bit ahead of our application and the endpoint returns a relationship that hasn't been defined in the application's object model yet.
For example, a JSONAPI ResourceObjectDescription might include a relationship for 'person' and 'address'. The API returns /included data for 'person', 'address' and 'email'.
In this case, the decoding fails and returns a message along the lines of:
Out of the 3 includes in the document, the 1st one failed to parse: Found JSON:API type ‘email’ but expected one of ‘person’, ‘address’
The API team is trying to avoid strict API versioning, so I have been asked if there is a way to circumvent this error in the event that unexpected data is found in the json.
Thoughts?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No file, test, or entry point is named. Begin by locating the JSON:API included-resource decoding path and reproduce the reported failure with an unexpected email relationship. Done should be defined as an agreed behavior for unknown relationships, with coverage for the person/address plus unexpected email case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100