Skip to content

The Server: configuring an API

Server\Server is the configuration root for one API version. You build it fluently — a base URI, the PSR-17 factories, a default paginator, the recognised profiles, your registered types, the middleware chain, and the inner handler — and you get back a value you can hand to a framework or call directly. This page covers how that value is assembled, how it resolves a type's serializer and hydrator, and the two ways to drive it.

If this is your first server, read getting started first — it walks the whole wiring in context. (See the index for installation.)

An immutable configuration root

Server::make() returns an empty server, and every with…() / register…() call returns a new instance — the underlying registries are cloned before they are touched, so a configured server is a shareable value and a derived server never leaks back into its parent. You can keep a base server around and specialise it per request, per test, or per version without surprise mutation.

At a glance, the common path is three steps: register your types, set the middleware list and inner handler, then drive the server — handle() for an HTTP request or dispatch() for a programmatic call. The example app's bootstrap.php is the single source of truth for a full assembly. It builds the configuration root, then derives the runnable server from it:

use haddowg\JsonApi\Server\Server;
use Nyholm\Psr7\Factory\Psr17Factory;

$psr17 = new Psr17Factory();

$base = Server::make()
    ->withBaseUri('https://music.example')
    ->withPsr17($psr17, $psr17)
    ->withDefaultPaginator(PagePaginator::make()->withDefaultPerPage(10))
    ->withProfile(new TimestampProfile())
    ->withProfile(new CursorPaginationProfile())
    ->register(ArtistResource::class)
    ->register(AlbumResource::class)
    ->register(TrackResource::class, serializer: TrackSerializer::class)
    ->register(PlaylistResource::class, hydrator: PlaylistHydrator::class)
    ->register(UserResource::class)
    ->register(FavoriteResource::class)
    ->register(LibraryResource::class)
    ->registerSerializerHydrator('charts', serializer: ChartSerializer::class);

$server = $base
    ->withMiddleware([
        new ErrorHandlerMiddleware($base, $debug),
        new ContentNegotiationMiddleware(),
        new RequestBodyParsingMiddleware(),
        new PathPrefixRouter($base),
    ])
    ->withHandler(new MusicCatalogHandler($repository));

Server implements Server\ResolvingServerInterface, which extends the minimal Server\ServerInterface render contract (the surface the response value objects read) with the type-keyed serializer/hydrator resolution an operation handler needs. It is also a PSR-15 RequestHandlerInterface, so handling a request is one handle() call.

The configurator surface

Each with…() replaces a single setting; register, registerSerializerHydrator, and withProfile add to a registry. All of them return a new server.

Method Sets
withBaseUri(string) The base URI prepended to generated links (default ''). Empty ⇒ links resolve to the request origin; a non-empty value pins a fixed canonical host.
withVersion(string) The jsonapi.version member (default 1.1).
withDefaultMeta(array) The default jsonapi.meta object.
withEncodeOptions(int) Flags passed to json_encode() when rendering (e.g. \JSON_PRETTY_PRINT), on top of \JSON_THROW_ON_ERROR and \JSON_PRESERVE_ZERO_FRACTION, which always apply.
withDefaultPaginator(?PaginatorInterface) The fallback paginator for collections.
withMaxIncludeDepth(?int) The default maximum include depth (hops from the primary resource). null (the default) or <= 0 means unlimited; a resource can override it.
withOutputTimezone(?string) The zone every DateTime attribute renders in unless the field sets its own (default null, no conversion).
withStrictQueryParameters(bool) Whether to reject an unrecognized query-parameter family with a 400 (default true). false ignores unknown families.
withCustomQueryParameter(string ...$names) Registers host custom query-parameter families the server recognizes (so strict mode does not reject them).
withPsr17(ResponseFactoryInterface, StreamFactoryInterface) The PSR-17 factories used to emit the PSR-7 response.
withContainer(ContainerInterface\|callable) The lazy instantiation factory used to build registered classes.
withRelationshipLoadState(?RelationshipLoadStateInterface) The load-state predicate a lazy relation consults.
withLinkObjects(bool) Whether the links the server builds render as link objects (default true) or bare strings.
withReadOnlyAttributesRejected(bool) Whether a write body that sends an attribute the client cannot write is rejected with a 403 (default false, such attributes are ignored).
withDescribedByResolver(?DescribedByResolverInterface) The resolver that gives each built link, and each document, a describedby into the served OpenAPI document (default null, none).
register(string $resource, ?string $serializer, ?string $hydrator) Registers a Resource class for its declared $type, with optional serializer/hydrator overrides.
registerSerializerHydrator(string $type, ?string $serializer, ?string $hydrator) Registers a bare serializer + hydrator pair under an explicit $type, no Resource.
withProfile(ProfileInterface) Registers a profile.
withMiddleware(list<MiddlewareInterface>) Replaces the ordered middleware list.
withHandler(OperationHandlerInterface\|RequestHandlerInterface) Sets the inner handler.
withServing(\Closure) Appends a serving handler fired once before each operation; it may throw to abort.

The matching accessors read the configuration back:

Accessor Returns
baseUri() The configured base URI.
jsonApiVersion() The jsonapi.version member.
defaultMeta() The default jsonapi.meta array.
encodeOptions() The json_encode() flags.
defaultPaginator() The fallback paginator, or null.
profiles() The ProfileRegistry.
responseFactory() / streamFactory() The PSR-17 factories — each throws a \LogicException if withPsr17() was never called.
serializerFor(string) / hasSerializerFor(string) The serializer for a type (resolving an override ahead of the Resource), or whether one exists.
hydratorFor(string) / hasHydratorFor(string) The hydrator for a type, or whether one exists.
resourceFor(string) / hasResourceFor(string) The AbstractResource for a type, or whether one exists.
relationshipLoadState() The injected load-state predicate, or null.
rendersLinkObjects() / describedByResolver() The link form, and the describedby resolver or null (the ConfiguresLinksInterface contract a custom ServerInterface can implement too).
outputTimezone() The default output zone, or null.
rejectsReadOnlyAttributes() Whether read-only attributes in a write body are rejected.
serving() The registered serving handlers, in registration order.

serializerFor() / hydratorFor() are the resolution surface your handler uses. The music-catalog handler narrows the context's server to the concrete Server and reads them per type:

$server = $this->server($operation->context());
$type = $operation->target()->type;
$serializer = $server->serializerFor($type);
// …
$entity = $server->hydratorFor($type)->hydrate(/* … */);

A handler that only needs resolution (not resourceFor() / defaultPaginator()) can type-hint the ResolvingServerInterface and skip the downcast — see operations.

Base URI and the request origin

withBaseUri() controls the base every generated link is prefixed with, and it has two modes:

  • Empty (the default). Links resolve to the request origin — <scheme>://<authority> of the request that produced the document (the authority is the host, with port and userinfo when present). So with no base_uri configured, a request to https://music.example/albums/1 renders links.self as https://music.example/albums/1 — an absolute URL — and a deployment that serves several hosts emits the correct absolute links for each with no configuration. The request URI is whatever your PSR-7 stack produced (already proxy/forwarded-host aware upstream).

  • Non-empty. The configured value pins a fixed canonical host, used for every link regardless of the request's own host — set this when links must always address one canonical origin. The value is trailing-slash tolerant: https://music.example/ and /api/ are trimmed before prepending, so a link never double-slashes.

A configured base URI's path is the server's mount. Resource links append a server-relative path (/albums/1) to the base, while document links (links.self and the pagination links) are built from the request path, which already carries the mount when your routes are imported under a prefix. So the mount is removed from the front of the request path before the base is prepended, and appears once:

base_uri Request path Document self
/api/v5 /api/v5/albums /api/v5/albums
https://music.example/api/v5 /api/v5/albums https://music.example/api/v5/albums
/api/v5 /albums (prefix stripped by a proxy) /api/v5/albums
/api/v5 /api/v50/albums /api/v5/api/v50/albums (only a whole segment is a mount)
empty any the request origin plus the path

A request with no resolvable origin — a relative or path-only request URI (no authority, or an authority with no scheme) — falls back to a host-relative link (/albums/1) rather than emitting a broken prefix. To force host-relative output, leave base_uri empty and serve over such a request, or configure a path-only base_uri (e.g. /api).

Output timezone

withOutputTimezone() converts every DateTime attribute into one zone before it is formatted. Use it when your storage keeps local times but the API should always answer in UTC:

$server = Server::make()->withOutputTimezone('UTC');

It applies wherever a resource renders its attributes: primary data, included, attributes flattened from a related model with on(), and DateTime children of a Map, Obj or OneOf. A field that sets its own outputTimezone() keeps it.

Date and Time fields are left alone. Converting a calendar date can move it to another day, and a time of day has no date to convert against, so those convert only when the field asks. A hand-written serializer formats its own values and is not affected. An unknown zone name throws an \InvalidArgumentException from withOutputTimezone() itself.

The default is read when a resource renders, through the resolver the server injects. A custom SerializerResolverInterface that wraps the server's resolver should also implement ProvidesOutputTimezoneInterface and delegate it, or the resources it serves render without the default.

Registering types

register() and registerSerializerHydrator() are the two ways a type enters the server, and they are the seam that decouples a type from AbstractResource:

  • register(ResourceClass::class, serializer:, hydrator:) — a full field-driven Resource, keyed by its declared $type. The optional serializer: / hydrator: arguments override one concern while the Resource still supplies the other — in bootstrap.php, tracks overrides the serializer (a request-aware TrackSerializer wins for reads) and playlists overrides the hydrator (PlaylistHydrator wins for writes).
  • registerSerializerHydrator('type', serializer:, hydrator:) — a bare pair under an explicit type-string, with no Resource (at least one of the two is required). The standalone read-only charts type registers only a serializer:
->registerSerializerHydrator('charts', serializer: ChartSerializer::class);

charts therefore has a serializer but no hydrator and no Resource, so hasHydratorFor('charts') is false and resourceFor('charts') throws NoResourceRegistered. It serves GET /charts end-to-end (the ChartReadTest proves it) and the router exposes only GET for it.

Composing a type from independent capabilities is the full story — read-only vs write-only types, override resolution order, and the NoResourceRegistered boundary.

Handling a request

Server::handle() folds the configured middleware list over the inner handler — each middleware wraps the next, outermost first — and dispatches the PSR-7 request through the resulting chain:

$response = $server->handle($request); // PSR-7 ResponseInterface

The inner handler is whatever you passed to withHandler(). There are two accepted shapes:

  • An OperationHandlerInterface (the recommended surface). The server wraps it in Psr7ToOperationHandlerAdapter automatically — the adapter turns the request into an operation, calls your handler, and encodes the returned response value object to PSR-7.
  • A bare PSR-15 RequestHandlerInterface, accepted directly when you want to own the request/response framing yourself.

Calling handle() with no handler configured throws a \LogicException.

dispatch(): the no-PSR-7 path

Server::dispatch(JsonApiOperationInterface) invokes the configured OperationHandlerInterface directly, bypassing the middleware chain. It returns the response value object unrendered, which makes it the natural entry point for programmatic calls, integration tests, and framework integrations that own their own request lifecycle (the Symfony bundle dispatches this way):

$response = $server->dispatch($operation); // a response value object, not PSR-7

dispatch() requires the inner handler to be an OperationHandlerInterface (a bare PSR-15 handler throws a \LogicException). The same handler serves both paths: the music-catalog handler reaches the originating request through context()->httpRequest(), which returns null under dispatch(), so it falls back to a minimal request when there is no HTTP message. Build operations for dispatch() with the JsonApiOperationBuilder test utility:

$operation = JsonApiOperationBuilder::create('albums', $server)
    ->withAttribute('title', 'In Rainbows')
    ->build();

See operations for the operation model, the Target/router seam, and the handler contract.

serving: a pre-operation hook

withServing(\Closure) registers a request-scoped handler that dispatch() fires once, before the operation handler runs — the seam for cross-cutting, request-wide concerns (an authorization gate, request-wide setup, an imperative-validation escape hatch) that every operation shares. The wither is immutable and appends, so handlers fire in registration order:

$server = Server::make()
    ->withHandler($handler)
    ->withServing(static function (JsonApiRequestInterface $request): void {
        // Authorize the request, set up request-wide state, etc.
        if (!authorized($request)) {
            throw new Forbidden(); // any JsonApiExceptionInterface
        }
    });

The hook fires on the dispatch() path only — so a framework integration that dispatches operations directly gets it, but the bare PSR-15 handle() path (the operations adapter calls the inner handler directly, never through dispatch()) does not.

The handler is a \Closure(JsonApiRequestInterface): void. The request is resolved from the operation's context (context()->httpRequest()); a programmatic dispatch() with no HTTP message has no request to gate, so firing is skipped. A handler aborts the request by throwing any JsonApiExceptionInterface — the throw propagates out of dispatch() unchanged (the operation handler never runs), and the caller maps it to an error document the same way it maps any other JSON:API exception (a 403 gate, a 422 validation failure, a 409 conflict). serving() reads the registered handlers back, in order.

This is the core seam the Symfony bundle builds its per-operation lifecycle hooks on — core has no CRUD lifecycle of its own to fire finer-grained before/after hooks in, so those belong in the integration layer, built over serving.

Lazy instantiation and containers

register() takes class-strings and the registry reads the resource's static $type to key the entry without constructing the class. Instances are built lazily on first lookup and cached, so registering a server is cheap and a resource whose constructor has dependencies (or side effects) is not built until it is actually used.

By default the registry builds each class with plain new $class(), which needs a no-argument constructor. To build resources, serializers, and hydrators with dependencies, give the server a factory through withContainer(). It accepts either a PSR-11 \Psr\Container\ContainerInterface or any callable(class-string): object; both are normalised internally to a single closure:

// PSR-11 container — the registry calls $container->get(ArtistResource::class).
$server = Server::make()
    ->withContainer($container)
    ->register(ArtistResource::class);

// Or any callable that maps a class-string to an instance.
$server = Server::make()
    ->withContainer(fn(string $class) => $factory->make($class))
    ->register(ArtistResource::class);

withContainer() is order-independent — calling it before or after register() is equivalent, because lookups are lazy and the factory lives on the registry. Like every other configurator it clones, so it never leaks into a parent server.

The factory must return an instance of the requested concern (AbstractResource / SerializerInterface / HydratorInterface); a wrong-type return is a wiring fault and throws a \LogicException on lookup. A PSR-11 container that returns a non-object is caught the same way. Prefer a factory that hands out fresh instances: the registry injects itself as the relationship serializer-resolver when it first builds (and caches) an instance, so a shared singleton handed to two servers would have its resolver overwritten by whichever server's registry built it last.

Relationship load state

withRelationshipLoadState() injects the storage-aware predicate a lazy relation consults (RelationInterface::emitsDataOnlyWhenLoaded() — the per-type default) — it decides whether a relation's linkage is already loaded and so cheap to emit, letting a lazy to-many render links-only without forcing a fetch. Passing null (the default) restores the standalone behaviour: every relation is treated as loaded and its linkage data is emitted. See relations for the policy and the predicate contract.

Supplying to-many members

linkageForRelationship() on the same seam supplies a to-many relation's members for a parent, for a HasMany, BelongsToMany and MorphToMany alike. Return a RelationshipLinkage holding the members to render, or null to read the parent as usual. The supplied members are the relationship's data and what it adds to included, so a host can render a narrowed set, such as the rows a scoped provider admits for each member type of a polymorphic relation, without writing it onto the parent.

A host supplies a paginated to-many's first page here, as pagination requires wherever its linkage renders, and injects the matching page with withRelationshipPagination(). A RelationshipPaginationInterface returns, per parent and relation, the RelationshipPagination built by RelationshipPagination::firstPage() from the windowed read: core renders its first, prev, next and last links in the relationship object, and a counted page's total as a countable relation's meta.total. RelationshipPagination::firstPageRequest() is the request that read is made with, and Server::linkagePaginator() the paginator it is cut to.

Supplying to-one targets

By default a to-one relation renders whatever the parent model holds. An adapter that loads related rows through its own path, such as a scoped query or a custom provider, can hand core the target to render instead, without writing it onto the parent. Implement ToOneRelationshipLinkageInterface and inject it with withRelationshipLinkage():

use haddowg\JsonApi\Request\JsonApiRequestInterface;
use haddowg\JsonApi\Resource\Field\RelationInterface;
use haddowg\JsonApi\Schema\Relationship\RelationshipLinkage;
use haddowg\JsonApi\Schema\Relationship\ToOneRelationshipLinkage;
use haddowg\JsonApi\Serializer\ToOneRelationshipLinkageInterface;

final class ScopedLinkage implements ToOneRelationshipLinkageInterface
{
    public function toOneLinkageForRelationship(mixed $model, RelationInterface $relation, JsonApiRequestInterface $request): ?ToOneRelationshipLinkage
    {
        if (!$this->scopes($relation)) {
            return null; // read the parent as usual
        }

        $target = $this->loadScoped($model, $relation);

        return $target === null ? ToOneRelationshipLinkage::none() : ToOneRelationshipLinkage::to($target);
    }

    public function linkageForRelationship(mixed $model, RelationInterface $relation, JsonApiRequestInterface $request): ?RelationshipLinkage
    {
        return null; // nothing to supply for to-many relations
    }
}

$server = $server->withRelationshipLinkage(new ScopedLinkage(/* … */));

Core asks it for every BelongsTo, HasOne and MorphTo, hidden ones included, and uses the answer for the relationship's data, for included, for the /relationships/{name} document and for each hop of an on() attribute. The three answers mean:

Return Renders
null What the parent holds, exactly as without the seam.
ToOneRelationshipLinkage::to($target) $target. A MorphTo serializes it by its own type; a target of no declared type renders as none.
ToOneRelationshipLinkage::none() An empty relation, even when the parent holds an object: data: null, nothing in included, and null for an attribute flattened through it. Writing such an attribute fails with RELATED_ATTRIBUTE_OWNER_MISSING, as it does for a null hop.

A relation the load-state predicate defers still defers, and the seam is asked only when its data renders. Core does not serve the related endpoint (GET /articles/1/author): your handler reads the related object there, so read it through the same scoped path.

Authorizing relation data

A host guards a relation's own endpoints itself, but core also reaches relation data on its own: the linkage and included resources of every rendered relationship, and the related model an on() attribute writes onto. withRelationAuthorizer() lets the host decide those too. Implement RelationAuthorizerInterface:

use haddowg\JsonApi\Request\JsonApiRequestInterface;
use haddowg\JsonApi\Resource\Field\FieldInterface;
use haddowg\JsonApi\Resource\Field\RelationInterface;
use haddowg\JsonApi\Resource\RelationAuthorizerInterface;

final class RelationGate implements RelationAuthorizerInterface
{
    public function canReadRelationship(mixed $model, RelationInterface $relation, JsonApiRequestInterface $request): bool
    {
        $rule = $relation->securityRead();

        return !\is_string($rule) || $this->allows($rule, $model, $request);
    }

    public function canWriteRelatedAttribute(mixed $owner, RelationInterface $relation, FieldInterface $field, mixed $model, JsonApiRequestInterface $request): bool
    {
        return $this->mayUpdate($relation->relatedTypes()[0], $owner, $request);
    }
}

$server = $server->withRelationAuthorizer(new RelationGate(/* … */));

canReadRelationship() is asked once per rendered relationship, on primary and included resources alike, with the parent model. When it answers false the relationship keeps its links and renders nothing else: no data, no meta such as the ?withCount total, and nothing in included, so an include path through it is pruned for that parent rather than refused. A relationship with no links to render is left out. The relation's own endpoints are still the host's to refuse.

canWriteRelatedAttribute() is asked before each flattened write, with the related model, the last relation of the chain and the resource being hydrated. A false answer fails the write with 403 ACCESS_DENIED.

With no authorizer, the default, core renders and writes without asking. A resolver that decorates the server's should implement ProvidesRelationAuthorizerInterface and delegate, or the relationships it builds skip the authorizer.

Casting values for storage

Core assigns each attribute it hydrates to the model's member through a setter or the property. When the data layer stores a member in another PHP type than the field hydrates, such as a decimal column a mapper reads as a string, withStorageCast() lets the host convert the value just before the assignment. Implement StorageCastInterface:

use haddowg\JsonApi\Resource\Field\FieldInterface;
use haddowg\JsonApi\Resource\StorageCastInterface;

final class DecimalColumns implements StorageCastInterface
{
    public function forStorage(object $model, string $member, mixed $value, FieldInterface $field): mixed
    {
        $scale = $this->decimalScale($model::class, $member);

        return $scale !== null && \is_float($value) ? \number_format($value, $scale, '.', '') : $value;
    }
}

$server = $server->withStorageCast(new DecimalColumns(/* … */));

forStorage() gets the model, the member about to be written, the hydrated value and the field. Whatever it returns is assigned. It runs for each attribute core writes, including a flattened on() attribute, which it gets with the related model. A fillUsing() hook writes its own value, and a composite such as an Obj writes its whole value, so neither is cast. With no cast, the default, each value is assigned as its field hydrated it. A resolver that decorates the server's should implement ProvidesStorageCastInterface and delegate.

Rejecting read-only attributes

A create or update body can send an attribute the client cannot write in that request: one declared readOnly(), a computed one, or one read-only on that verb or by its readOnly(when:) predicate. The spec lets a server either ignore such a member or reject the request, and core ignores it by default. withReadOnlyAttributesRejected() switches the server to rejecting:

$server = $server->withReadOnlyAttributesRejected();

AbstractResource then checks the body before it hydrates anything and throws AttributeWriteProhibited, a 403 ATTRIBUTE_WRITE_PROHIBITED carrying one error per offending attribute, each pointing at /data/attributes/<name>. Hidden attributes, undeclared ones and relationships are outside the check: the first two are ignored as before, and a read-only relation in a resource body is still dropped.

The check reads the setting off the resource's resolver through RejectsReadOnlyAttributesInterface, which the server and its registry implement. A resolver that decorates the server's should implement it and delegate. To catalogue the code in a generated document, have the server's OpenAPI metadata implement OpenApi\Metadata\DeclaresReadOnlyAttributeRejection; without it the document stays as it was.

Some types serve no endpoint of their own. They're reached only as another type's related or included resources, or as the request document of a custom action. Mark them with withRelatedOnlyTypes():

$server = $server->withRelatedOnlyTypes('labels', 'credits');

Their resources render no by-convention self link, and their relationship objects render no self, related or page links, since none of those endpoints exist. A relationship object left with no links carries its linkage data instead. Everything else renders as before, and a self returned from getLinks() still wins. The server doesn't route, so leaving the type's own endpoints out of your routing is the adapter's job.

The transformer reads the set through Resource\DeclaresRelatedOnlyTypesInterface, which the server and its registry implement. It asks the resource's own resolver, then the server a response renders against, so a serializer that decorates or overrides the type's resource, with no resolver of its own, still renders it related-only. A resolver that decorates the server's should implement it and delegate. For the generated document, have the type's OpenAPI metadata implement OpenApi\Metadata\DeclaresRelatedOnly (see OpenAPI).

Singleton types

A singleton type serves the caller's one resource at /{uriType}. The server says which registered types are singletons and resolves the caller's id for one:

$server->isSingleton('inboxes');                                   // true
$server->resolveSingletonId('inboxes', new SingletonContext('inboxes', $request)); // '42', or null

Resolve the id once per request and carry it on a Target::singleton() target. The OperationFactory does that for a singleton target that arrives without an id, passing the request it builds the operation from; an adapter with more to hand, such as its authenticated user, builds the SingletonContext itself, with that as an attribute, and passes the resolved id on the target. A null id answers 404. dispatch() builds no operation, so a singleton target passed to it must already carry the resolved id.

The transformer renders a singleton's resource self link as {baseUri}/{uriType} and its relationship self and related links under it, on a relationship endpoint too. A type is a singleton when its serializer declares itself one through SingletonResourceInterface, or when the resource's resolver or the server a response renders against says so through Resource\DeclaresSingletonTypesInterface, which the server and its registry implement. So a serializer that decorates or overrides a singleton resource class, without declaring the singleton itself, still links it at /{uriType}. A resolver that decorates the server's should implement it and delegate. For the generated document, have the type's OpenAPI metadata implement OpenApi\Metadata\DeclaresSingleton (see OpenAPI).

The server doesn't route, so serving /{uriType} in place of the collection and /{uriType}/{id}, and refusing the operations a singleton can't serve, is the adapter's job. Resource\SingletonMisdeclared::assertExclusive() refuses a collection fetch, a create, a delete or a collection-scope action with the message the adapters raise.

Wiring faults are exceptions, not error documents

A misconfigured server is a programming error, so the registry throws a \LogicException rather than producing a JSON:API error document. The faults you might hit:

Fault When
Duplicate type Registering two Resource classes (or two bare pairs) for the same $type.
Empty $type A Resource whose static $type is empty, or a bare pair under an empty type-string.
Empty bare pair registerSerializerHydrator() with neither a serializer nor a hydrator.
Unresolved singleton A Resource declaring $singleton = true that doesn't override resolveSingletonId().
Duplicate profile URI Registering two profiles with the same URI.
Wrong-type factory return A withContainer() factory returning the wrong concern (or a non-object).
Missing PSR-17 responseFactory() / streamFactory() read before withPsr17().
Missing handler handle() or dispatch() with no withHandler().
dispatch() on a PSR-15 handler dispatch() when the inner handler is a bare RequestHandlerInterface.

These are distinct from request-time JSON:API errors — those are rendered as documents through the error handler.

Multiple servers / API versioning

One Server describes one API version. To serve several side by side, configure one server per version and pick between them upstream — that selection is routing, and (as with target resolution) it lives outside core. A tiny path-prefix dispatcher, with no framework involved:

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;

final readonly class VersionDispatcher implements RequestHandlerInterface
{
    /** @param array<string, RequestHandlerInterface> $servers prefix => server */
    public function __construct(private array $servers) {}

    public function handle(ServerRequestInterface $request): ResponseInterface
    {
        $path = \trim($request->getUri()->getPath(), '/');

        foreach ($this->servers as $prefix => $server) {
            if ($path === $prefix || \str_starts_with($path, $prefix . '/')) {
                return $server->handle($request);
            }
        }

        throw new \RuntimeException('No API version matched the request path.');
    }
}

$dispatcher = new VersionDispatcher([
    'v1' => $serverV1,
    'v2' => $serverV2,
]);

Each Server keeps its own registry, defaults, and middleware list, so versions evolve independently — a type registered (or a default changed) on v2 never affects v1. Because every configurator clones, v2 can be derived from v1 ($v1->withVersion('2.0')->register(NewResource::class)) and the shared base is never mutated.

Next / See also