Skip to content

Commit 90c9fb3

Browse files
authored
fix(symfony): register api_error route (#6281)
closes #6269
1 parent d061c38 commit 90c9fb3

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

src/Symfony/Bundle/Resources/config/routing/api.xml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,4 @@
1313

1414
<requirement key="index">index</requirement>
1515
</route>
16-
17-
<route id="api_errors" path="/errors/{status}">
18-
<default key="_controller">api_platform.action.not_exposed</default>
19-
<default key="status">500</default>
20-
21-
<requirement key="status">\d+</requirement>
22-
</route>
23-
24-
<route id="api_validation_errors" path="/validation_errors/{id}">
25-
<default key="_controller">api_platform.action.not_exposed</default>
26-
</route>
27-
2816
</routes>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
3+
<routes xmlns="http://symfony.com/schema/routing"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://symfony.com/schema/routing
6+
http://symfony.com/schema/routing/routing-1.0.xsd">
7+
8+
<route id="api_errors" path="/errors/{status}">
9+
<default key="_controller">api_platform.action.not_exposed</default>
10+
<default key="status">500</default>
11+
12+
<requirement key="status">\d+</requirement>
13+
</route>
14+
15+
<route id="api_validation_errors" path="/validation_errors/{id}">
16+
<default key="_controller">api_platform.action.not_exposed</default>
17+
</route>
18+
</routes>

src/Symfony/Routing/ApiLoader.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ public function supports(mixed $resource, ?string $type = null): bool
125125
private function loadExternalFiles(RouteCollection $routeCollection): void
126126
{
127127
$routeCollection->addCollection($this->fileLoader->load('genid.xml'));
128+
$routeCollection->addCollection($this->fileLoader->load('errors.xml'));
128129

129130
if ($this->entrypointEnabled) {
130131
$routeCollection->addCollection($this->fileLoader->load('api.xml'));

tests/Symfony/Routing/ApiLoaderTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ public function testApiLoaderWithPrefix(): void
213213

214214
$prefixedPath = $prefix.$path;
215215

216+
$this->assertNotNull($routeCollection->get('api_errors'));
216217
$this->assertEquals(
217218
$this->getRoute(
218219
$prefixedPath,

0 commit comments

Comments
 (0)