- Apiato Response
- Default Apiato Responses Payload
- Change the default Response payload
- Resource Keys
- Error Responses formats
- Building a Responses from the Controller
In Apiato you can define your own response payload or use one of the supported serializers.
Currently, the supported serializers are (
JsonApiSerializer). As provided
By default, Apiato uses
DataArraySerializer. Below is an example of the response payload.
DataArraySerializer response payload looks like this:
When data is paginated the response payload will contain a
meta description about the pagination.
Informs the User about what relationships can be included in the response. Example:
For more details read the
Relationships section in the Query Parameters page.
The default response format (specification) is the
DataArray Fractal Serializer (
To change the default Fractal Serializer open the
app/Ship/Configs/fractal.php file and change the
The Supported Serializers are
In case of returning JSON Data (
JsonApiSerializer), you may wish to check some JSON response standards:
The transformer allows appending a
ResourceKey to the transformed resource. You can set the
ResourceKey in your
response payload in 2 ways:
- Manually set it via the respective parameter in the
$this->transform()call. Note that this will only set the
top levelresource key and does not affect the resource keys from
- Specify it on the respective
Model. By overriding $resourceKey, (
protected $resourceKey = 'FooBar';). If no
$resourceKeyis defined at the
ShortClassNameis used as key. For example, the
Visit each feature, e.g. the Authentication and there you will see how an unauthenticated response looks like, same for Authorization, Validation and so on.
Checkout the Controller response builder helper functions.