Skip to content

Commit 95e6f1f

Browse files
fix(hydra): hydra context stored in local
1 parent 4f1cdfb commit 95e6f1f

File tree

4 files changed

+798
-1
lines changed

4 files changed

+798
-1
lines changed

src/Hydra/Serializer/DocumentationNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ private function computeDoc(Documentation $object, array $classes, string $hydra
573573
private function getContext(string $hydraPrefix = ContextBuilder::HYDRA_PREFIX): array
574574
{
575575
return [
576-
ContextBuilderInterface::HYDRA_CONTEXT,
576+
'/bundles/apiplatform/hydra/context.jsonld',
577577
[
578578
'@vocab' => $this->urlGenerator->generate('api_doc', ['_format' => self::FORMAT], UrlGeneratorInterface::ABS_URL).'#',
579579
'hydra' => ContextBuilderInterface::HYDRA_NS,
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use ApiPlatform\Laravel\Test\ApiTestAssertionsTrait;
6+
use Illuminate\Contracts\Config\Repository;
7+
use Illuminate\Foundation\Application;
8+
use Illuminate\Foundation\Testing\RefreshDatabase;
9+
use Orchestra\Testbench\Concerns\WithWorkbench;
10+
use Orchestra\Testbench\TestCase;
11+
use Workbench\Database\Factories\AuthorFactory;
12+
use Workbench\Database\Factories\BookFactory;
13+
14+
class HeaderLinkTest extends TestCase
15+
{
16+
use ApiTestAssertionsTrait;
17+
use RefreshDatabase;
18+
use WithWorkbench;
19+
20+
/**
21+
* @param Application $app
22+
*/
23+
protected function defineEnvironment($app): void
24+
{
25+
tap($app['config'], function (Repository $config): void {
26+
$config->set('app.debug', true);
27+
$config->set('api-platform.formats', ['jsonapi' => ['application/vnd.api+json']]);
28+
$config->set('api-platform.docs_formats', ['jsonapi' => ['application/vnd.api+json']]);
29+
});
30+
}
31+
32+
public function testHeaderLinkDoesNotExistWithoutJsonld(): void {
33+
BookFactory::new()->has(AuthorFactory::new())->count(10)->create();
34+
$response = $this->get('/api/books', ['accept' => 'application/vnd.api+json']);
35+
$response->assertStatus(200);
36+
$response->assertHeaderMissing('link');
37+
//$response->assertHeader('link', '<http://localhost/api/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
38+
}
39+
}

0 commit comments

Comments
 (0)