ekanto/json-api-specifications
Pros:
links, meta, and included resources).belongsTo, hasMany).Cons:
Route::apiResource() and Eloquent models.Cache::remember) for serialized responses.FormRequest), but custom JSON:API validation rules may need extension.included resources or sparse fieldsets.json:api Artisan command to scaffold a compliant controller/resource.N+1 queries be handled for deeply nested relationships? (Bundle may need eager-loading tweaks.)meta) or modify resource shapes dynamically?/v1/, /v2/ endpoints.)ResourceController with JsonApiController (or extend BaseJsonApiController if provided).JsonApiSerializable) or use attributes (PHP 8+) for metadata.Route::jsonApiResource() (if supported) or manually define routes with JsonApiResource middleware.FormRequest to validate JSON:API payloads (e.g., data.attributes, data.relationships).JsonApiTestCase (if provided) or Laravel’s HttpTests with custom assertions for JSON:API compliance.Cache::tags('jsonapi')).posts) to JSON:API.X-Acccepted-Versions headers.Route::prefix('v1')->group(function () {
Route::jsonApiResource('posts', PostController::class);
});
included resources, sparse fieldsets).composer require ekanto/json-api-specifications.php artisan vendor:publish --tag=jaspecification-config.PostResource) extending JsonApiResource.config/jaspecification.php.JsonApiController trait.errors array with title, detail).included resources, sparse fieldsets).$app->pushMiddleware(function ($request, $next) {
if ($request->isJsonApi()) {
dd($request->jsonApiPayload());
}
return $next($request);
});
included resources. Optimize with:
fields[posts] parameter to limit attributes.include parameter to control nested resources.N+1 issues. Mitigate with:
with() or loadMissing().Cache::remember).data.id) cause 422 errors. Validate early with middleware.JsonApiSerializable::ignore() or depth limits.include=posts.comments.authors).Accept: application/vnd.api+json, application/json header to serve legacy responses.jsonapi.error rate (e.g., malformed requests).jsonapi.payload_size (identify bloated responses).jsonapi-to-openapi tools.POST /posts expects data.attributes.title).How can I help you explore Laravel packages today?