Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(laravel): only enable JSON-LD by default #6528

Merged
merged 3 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
->in(__DIR__)
->exclude([
'src/Core/Bridge/Symfony/Maker/Resources/skeleton',
'src/Laravel/config',
'tests/Fixtures/app/var',
'docs/guides',
'docs/var',
Expand Down
12 changes: 12 additions & 0 deletions src/Laravel/Tests/JsonApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
namespace ApiPlatform\Laravel\Tests;

use ApiPlatform\Laravel\Test\ApiTestAssertionsTrait;
use Illuminate\Contracts\Config\Repository;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Orchestra\Testbench\Concerns\WithWorkbench;
use Orchestra\Testbench\TestCase;
Expand All @@ -26,6 +28,16 @@
use RefreshDatabase;
use WithWorkbench;

/**
* @param Application $app
*/
protected function defineEnvironment($app): void

Check warning on line 34 in src/Laravel/Tests/JsonApiTest.php

View check run for this annotation

Codecov / codecov/patch

src/Laravel/Tests/JsonApiTest.php#L34

Added line #L34 was not covered by tests
{
tap($app['config'], function (Repository $config): void {
$config->set('api-platform.formats', ['jsonapi' => ['application/vnd.api+json']]);
});

Check warning on line 38 in src/Laravel/Tests/JsonApiTest.php

View check run for this annotation

Codecov / codecov/patch

src/Laravel/Tests/JsonApiTest.php#L36-L38

Added lines #L36 - L38 were not covered by tests
}

public function testGetCollection(): void
{
$response = $this->get('/api/books', ['accept' => ['application/vnd.api+json']]);
Expand Down
17 changes: 3 additions & 14 deletions src/Laravel/config/api-platform.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
<?php

/*
* This file is part of the API Platform project.
*
* (c) Kévin Dunglas <dunglas@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

return [
'title' => 'API Platform',
'description' => 'My awesome API',
Expand All @@ -31,17 +20,17 @@

'formats' => [
'jsonld' => ['application/ld+json'],
'jsonapi' => ['application/vnd.api+json'],
//'jsonapi' => ['application/vnd.api+json'],

Check warning on line 23 in src/Laravel/config/api-platform.php

View check run for this annotation

Codecov / codecov/patch

src/Laravel/config/api-platform.php#L23

Added line #L23 was not covered by tests
],

'patch_formats' => [
'json' => ['application/merge-patch+json'],
],

'docs_formats' => [
'jsonopenapi' => ['application/vnd.openapi+json'],
'json' => ['application/json'],
'jsonld' => ['application/ld+json'],
//'jsonapi' => ['application/vnd.api+json'],
'jsonopenapi' => ['application/vnd.openapi+json'],

Check warning on line 33 in src/Laravel/config/api-platform.php

View check run for this annotation

Codecov / codecov/patch

src/Laravel/config/api-platform.php#L33

Added line #L33 was not covered by tests
'html' => ['text/html'],
],

Expand Down
Loading