JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources

Related endpoints for STI resources do not yield proper types

Open
#772 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Type: Bug
Dominant language
Ruby
Stars
2.3k
Forks
546
PR merge metrics
No merged PRs in 30d

Description

Following up on #507

Given a model Animal with subclasses Cat and Dog, types get returned properly when querying directly for animals - e.g. hitting endpoint "api/animals" responds with types "cats" and "dogs" in the payload.

However, this behavior is not consistent when hitting the related endpoints of a resource - e.g. hitting "api/zoos/7/animals" responds with only type "animals" in the payload.

Currently, I am including "type" in the attributes object, which raises a warning and also breaks the JSON API specs. Is there a better workaround for this?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the STI behavior with Animal subclasses Cat and Dog by comparing api/animals with api/zoos/7/animals. Trace the related-resource endpoint handling first; done means the related response reports cats and dogs with valid JSON:API types without adding type to attributes or raising a warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.