JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources

How to override type?

Open
#618 12 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

We have a model in the backend that we refer to as a different name in our public API. We need to override the type returned but haven't found a way to do this yet.

I tried adding def self._type (as I noticed that's where it was grabbing type from) to my base model class as well as the resource serializer but that didn't change the response.

Any help would be appreciated.

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

Start by tracing the base model's def self._type and the resource serializer, which the issue identifies as possible sources of the returned type. Confirm how the public API derives that type and whether an override point is supported; done means the API returns the model's requested public name and the behavior is covered by an appropriate test.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby
Domain
api, backend-api-design
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.