Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support for multiple type in the same relationship #54

Open
daniel-m-dd opened this issue Mar 26, 2024 · 0 comments
Open

Support for multiple type in the same relationship #54

daniel-m-dd opened this issue Mar 26, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@daniel-m-dd
Copy link

Is your feature request related to a problem? Please describe.

When fetching a resource (say an article) I can get either

{
  "data": {
    "id": "1",
    "type": "articles",
    "attributes": { "title": "A" },
    "relationships": { "author": { "data": { "id": "1", "type": "human" } } }
  }
}

or

{
  "data": {
    "id": "1",
    "type": "articles",
    "attributes": { "title": "A" },
    "relationships": { "author": { "data": { "id": "xorg", "type": "bot" } } }
  }
}

Describe the solution you'd like

I would like to be able to Marshal/Unmarshal such a json api structure.

Describe alternatives you've considered

Tried to find a smart way to use StringIdentifier but not working.
I also tried to define twice the relationship field in my golang struct with the same json author key

type Article struct {
...
HumanAuthor        HumanAuthor `jsonapi:"relationship" json:"author"`
BotAuthor              BotAuthor `jsonapi:"relationship" json:"author"`
}

but the same json field cannot co-exist.

Additional context
Add any other context or screenshots about the feature request here.

@daniel-m-dd daniel-m-dd added the enhancement New feature or request label Mar 26, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant