Reference

Diagnostics

The findings of jsonapi:check and ResourceAssertions, and how to fix them.

Found when a definition is compiled or by the check of ark4ne/laravel-api-revisions (whose own codes, such as conversion-missing, are documented there). An error fails the check; a warning fails it with --strict / strict: true.

CodeLevelCause and fix
definition-errorerrorThe values cannot be compiled: a plain value or a member without name in a hook, a hook throwing on the probe (an if on the model, a call on a relation), a relationship to a class that is not a resource, an invalid history. Rendering throws a DefinitionException
hook-failureerrortoLinks() threw on the probe, or holds a descriptor
invalid-resourceerrorThe class is not a resource, its type cannot be read, or it exists at no revision
jsonapi-reserved-nameerrorAn attribute or a relationship named id or type at the revision
jsonapi-name-collisionerrorAn attribute and a relationship with one name at the revision: bound them with until() / since()
jsonapi-absent-resourceerrorA relationship reaches, at the revision, a resource absent from it (#[JsonApiSince] without was() for older revisions)
missing-routeerrorThe self route of #[JsonApiRoutes] does not exist
load-conflictwarningTwo relationships load the same relation with different withLoad() constraints
filter-on-unloadedwarning->filters() on a relation that is not loaded, read resource by resource: let it load

load-conflict and filter-on-unloaded are found while rendering too, in debug only, in the diagnostics of the JsonApiContext.

When the document is wrong

SymptomCause and fix
A member is missingLeft out by fields[type], by its condition, or empty (attributes, meta… are left out when empty)
fields / include rejected for a member that existsIt is added under an if: use ->when() or applyWhen()
data missing on a relationshiprelationship.linkage is included or loaded, or the relationship has ->whenIncluded() / ->whenLoaded()
One query per resourceThe relationship is read by a closure: use $this->many(PostResource::class), or ->withLoad('posts')
A value has the wrong typeUse the matching descriptor (integer(), datetime(), decimal(), enum()…)
A date lost its timedate() is a date without time: use datetime()
RenderingExceptionThe identifier is neither an integer nor a string, or the resource does not exist at the revision
The error body is Laravel'sJsonApi::renderErrors() is not called, or the request does not expect JSON