function RestJsonApiUnsupported::testApiJsonNotSupportedInRest
Deploying a REST resource using api_json format results in 400 responses.
See also
\Drupal\jsonapi\EventSubscriber\JsonApiRequestValidator::validateQueryParams()
File
- 
              core/modules/ jsonapi/ tests/ src/ Functional/ RestJsonApiUnsupported.php, line 91 
Class
- RestJsonApiUnsupported
- Ensures that the 'api_json' format is not supported by the REST module.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
public function testApiJsonNotSupportedInRest() : void {
  $this->assertSame([
    'json',
    'xml',
  ], $this->container
    ->getParameter('serializer.formats'));
  $this->provisionResource([
    'api_json',
  ], []);
  $this->setUpAuthorization('GET');
  $url = Node::load(1)->toUrl()
    ->setOption('query', [
    '_format' => 'api_json',
  ]);
  $request_options = [];
  $response = $this->request('GET', $url, $request_options);
  $this->assertResourceErrorResponse(400, FALSE, $response, [
    '4xx-response',
    'config:system.logging',
    'config:user.role.anonymous',
    'http_response',
    'node:1',
  ], [
    'url.query_args',
    'url.site',
    'user.permissions',
  ], 'MISS', 'MISS');
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
