I created a route which serializes an entity to a JSON:API argument. This worked great until I installed JSON:API Schema.
This is due to the route generation to try and create the describedby link
else {
$resource_type_name = explode('.', $this->currentRouteMatch->getRouteName())[1];
$schema_route_name = "jsonapi_schema.{$resource_type_name}." . static::$schemaRouteType;
}
In my case the route was called mymodule_jsonapi.json_view. This returned the rendered JSON in a modal.
The code in JSON:API Schema caused this route to fail as it tried to look up a route called jsonapi_schema.json_view.item, which is not a valid route. All JSON:API routes should have resource_type in their route per
// Add the resource type as a parameter to every resource route.
foreach ($routes as $route) {
static::addRouteParameter($route, static::RESOURCE_TYPE_KEY, ['type' => ResourceTypeConverter::PARAM_TYPE_ID]);
$route->addDefaults([static::RESOURCE_TYPE_KEY => $resource_type->getTypeName()]);
}
So maybe we could fetch that from the route if it exists versus magically grabbing it from the route name.

Comments
Comment #2
mglamanHere is a patch which supports normalization off of the main route, but the resulting JSON still has the describedby links
Comment #3
mglamanThis is a blocker for Commerce API and prevents the module from installing.
Comment #4
gabesulliceThanks for the detailed issue description and patch, that made this easy to review! The problem makes sense, the fix makes sense. LGTM.
Comment #6
gabesullice