-
Notifications
You must be signed in to change notification settings - Fork 351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Single items returned inside arrays #95
Comments
You can create a new class which extends current serializer and use it for transformation: class JsonApiSerializer extends \League\Fractal\Serializer\JsonApiSerializer {
/**
* Serialize an item resource
*
* @param string $resourceKey
* @param array $data
*
* @return array
*/
public function item($resourceKey, array $data)
{
return array($resourceKey ?: 'data' => $data);
}
} |
I was thrown off by this too. |
This is #93 right? |
Yes, sorry. Didn't realise that. It will definitely BC when you change this (and change the tests) so keep that in mind. You can close this in favour of 93 if you want. |
Cheers. I bumped the issue and will merge when I get it, then release 0.10.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I know the tests are made up to expect this specific format but I cannot understand the reasoning behind it, nor can I find it back on the jsonapi.org website why it's made like this.
For example, in this test, you expect the following response:
Why is it like this? I would expect it to return the following when using
Item
:The text was updated successfully, but these errors were encountered: