Skip to content
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 src/Laravel/ApiPlatformProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,7 @@ public function boot(ResourceNameCollectionFactoryInterface $resourceNameCollect
// _format is read by the middleware
$uriTemplate = $operation->getRoutePrefix().str_replace('{._format}', '{_format?}', $uriTemplate);
$route = (new Route([$operation->getMethod()], $uriTemplate, [ApiPlatformController::class, '__invoke']))
->where('_format', '^\.[a-zA-Z]+')
->name($operation->getName())
->setDefaults(['_api_operation_name' => $operation->getName(), '_api_resource_class' => $operation->getClass()]);

Expand Down
11 changes: 11 additions & 0 deletions src/Laravel/Tests/JsonLdTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ protected function defineEnvironment($app): void
{
tap($app['config'], function (Repository $config): void {
$config->set('app.debug', true);
$config->set('api-platform.resources', [app_path('Models'), app_path('ApiResource')]);
});
}

Expand Down Expand Up @@ -337,4 +338,14 @@ public function testRelationWithGroups(): void
$this->assertArrayHasKey('relation', $content);
$this->assertArrayHasKey('name', $content['relation']);
}

/**
* @see https://github.com/api-platform/core/issues/6779
*/
public function testSimilarRoutesWithFormat(): void
{
$response = $this->get('/api/staff_position_histories?page=1', ['accept' => 'application/ld+json']);
$response->assertStatus(200);
$this->assertSame('/api/staff_position_histories', $response->json()['@id']);
}
}
25 changes: 25 additions & 0 deletions src/Laravel/workbench/app/ApiResource/Staff.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

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

declare(strict_types=1);

namespace Workbench\App\ApiResource;

use ApiPlatform\Metadata\ApiResource;

#[ApiResource(provider: [self::class, 'provide'])]
class Staff
{
public static function provide()
{
return [];
}
}
25 changes: 25 additions & 0 deletions src/Laravel/workbench/app/ApiResource/StaffPositionHistory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

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

declare(strict_types=1);

namespace Workbench\App\ApiResource;

use ApiPlatform\Metadata\ApiResource;

#[ApiResource(provider: [self::class, 'provide'])]
class StaffPositionHistory
{
public static function provide()
{
return [];
}
}
Loading