All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning and this changelog format.
- #203 JSON API container now checks whether there is a Laravel container binding for a class name. This allows schemas, adapters etc to be bound into the container rather than having to exist as actual classes.
- #202 When appending the schema and host on a request, the base URL is now also appended. This caters for Laravel applications that are served from host sub-directories.
- Errors that occur before a route is processed by a JSON API are now sent to the client as JSON API
error responses if the client wants a JSON API response. This is determined using the
Acceptheader and means that exceptions such as the maintenance mode exception are correctly returned as JSON API errors if that is what the client wants. - Can now override the default API name via the JSON API facade.
- Field guarding that was previously available on the Eloquent adapter is now also available on the generic adapter.
- Extracted the logic for an Eloquent
hasManyThroughrelation into its own relationship adapter (was previously in thehas-manyadapter). - Moved the
FindsManyResourcestrait from theStorenamespace toAdapter\Concerns. - The
hydrateRelationshipsmethod on theAbstractResourceAdapteris no longer abstract as it now contains the implementation that was previously on the Eloquent adapter. - The test exception handler has been moved from the dummy app to the
Testingnamespace. This means it can now be used when testing JSON API packages. - Merged the two resolvers provided by this package into a single class.
- #176
When using not-by-resource resolution, the type of the class is now appended to the class name. E.g.
App\JsonApi\Adapters\PostAdapteris now expected instead ofApp\JsonApi\Adapters\Post. The previous behaviour can be maintained by setting theby-resourceconfig option to the stringfalse-0.x. - The constructor dependencies for the
Repositories\ErrorRepositoryhave been simplified.
- Resolver was not correctly classifying the resource type when resolution was not by resource.
- #176 Do not import model class in Eloquent adapter stub to avoid collisions with class name when using the legacy not-by-resource behaviour.
- An exception is no longer triggered when create JSON API responses when there is no booted JSON API handling the request.
- #181 Send a
419error response with an error object for aTokenMismatchException. - #182 Send a
422error response with JSON API error objects when aValidationExceptionis thrown outside of JSON API validation.
- The
reportmethod on the JSON API service/facade will be removed by1.0.0.
- New authorizer interface and an abstract class that better integrates with Laravel's authentication and authorization style. See the new Security chapter for details.
- Can now generate authorizers using the
make:json-api:authorizercommand, or the--authflag when generating a resource withmake:json-api:resource. - The JSON API controller now has the following additional hooks:
searchingfor an index action.readingfor a read action.
- #163 Added relationship hooks to the JSON API controller.
- Generating an Eloquent schema will now generate a class that extends
SchemaProvider, i.e. the generic schema. - Existing JSON API controller hooks now receive the whole validated JSON API request rather than just the resource object submitted by the client.
- The previous authorizer implementation has been removed in favour of the new one. The following were deleted:
Contract\Authorizer\AuthorizerInterfaceAuthorizer\AbstractAuthorizerAuthorizer\ReadOnlyAuthorizerExceptions\AuthorizationException
- Eloquent schemas are now deprecated in favour of using generic schemas. This is because of the amount of
processing involved without any benefit, as generic schemas are straight-forward to construct. The following
classes/traits are deprecated:
Eloquent\AbstractSchemaEloquent\SerializesModelsSchema\CreatesLinksSchema\EloquentSchema(was deprecated in1.0.0-alpha.1).
As we are now only developing JSON API within Laravel applications, we have deprecated our framework agnostic
cloudcreativity/json-api package. All the classes from that package have been merged into this package and
renamed to the CloudCreativity\LaravelJsonApi namespace. This will allow us to more rapidly develop this
Laravel package and simplify the code in subsequent releases.
- New Eloquent relationship adapters allows full support for relationship endpoints.
- Message bags can now have their keys mapped and/or dasherized when converting them to JSON API errors
in the
ErrorBagclass. - JSON API resource paths are now automatically converted to model relationship paths for eager loading in the Eloquent adapter.
- The Eloquent adapter now applies eager loading when reading or updating a specific resource.
- Eloquent adapters can now guard JSON API fields via their
$guardedand$fillableproperties. These are used when filling attributes and relationships. - Added standard serialization of relationships within Eloquent schemas. This always serializes
selfandrelatedlinks for listed model relationships, and only adds the relationshipdataif the relationship is being included in a compound document.
- By default resources no longer need to have a controller as the generic JSON API controller will now
handle any resource. If resources have controllers, the
controllerrouting option can be set to a string controller name, ortrueto use a controller with the same name as the resource. - Split adapter into resource and relationship adapter, and created classes to specifically deal with Eloquent relationships.
- Adapters now handle both reading and modifying domain records.
- Moved Eloquent JSON API classes into a single namespace.
- Moved logic from Eloquent controller into the JSON API controller as the logic is no longer specific to handling resources that related to Eloquent models.
- Filter, sort and page query parameters are no longer allowed for requests on primary resources (create, read update and delete) because these query parameters do not apply to these requests.
- When serializing Eloquent models, if no attributes are specified for serialization (a
nullvalue), onlyModel::getVisible()will now be used to work out what attributes must be serialized. Previously ifgetVisiblereturned an empty array,getFillablewould be used instead.
- Delete Eloquent hydrator class as all hydration is now handled by adapters instead.
- The utility
Fqnclass has been removed as namespace resolution is now done by resolvers. - The deprecated
Strutility class has been removed. UseCloudCreativity\JsonApi\Utils\Strinstead.
- The Eloquent controller is deprecated in favour using the JSON API controller directly.
- The
Schema\EloquentSchemais deprecated in favour of using theEloquent\AbstractSchema. - The
Store\EloquentAdapteris deprecated in favour of using theEloquent\AbstractAdapter. - The
Testing\InteractsWithModelstrait is deprecated in favour of Laravel database assertion helpers. - The
ErrorBag::toArraymethod is deprecated in favour ofErrorBag::all. - The
Schema\CreatesEloquentIdentitiestrait is deprecated.
- #128 Filter, sort and page parameters validation rules are excluded for resource requests for which those parameters do not apply (create, read, update and delete).
- #92 Last page link is now excluded if there are pages, rather than linking to page zero.
- #67 Pagination meta will no longer leak into error response if error occurs when encoding data.
- #111 Sending an invalid content type header now returns a JSON API error object.
- #146 Return a 404 JSON API error object and allow this to be overridden.
- #155 Return a JSON API error when the request content cannot be JSON decoded.
- #169
Generating a resource when the
by-resourceoption was set tofalsehad the wrong class name in the generated file.