jsonapi
jsonapi copied to clipboard
Support for multiple type in the same relationship
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.