forked from api-platform/core
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(jsonschema): access related subschema on readableLink
fixes api-platform#5501 The locations relation inside BrokenDocs is a Resource (named Related) but its only operation is a NotExposed. Still, serializer groups are set, and therefore it is a "readableLink" so we actually want to compute the schema, even if it's not accessible directly, it is accessible through that relation.
- Loading branch information
Showing
5 changed files
with
84 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
tests/Fixtures/TestBundle/ApiResource/Issue5501/BrokenDocs.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?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 ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\Issue5501; | ||
|
||
use ApiPlatform\Metadata\ApiResource; | ||
use ApiPlatform\Metadata\Get; | ||
use Doctrine\Common\Collections\ArrayCollection; | ||
use Symfony\Component\Serializer\Annotation\Groups; | ||
|
||
#[ApiResource( | ||
operations: [ | ||
new Get( | ||
normalizationContext: ['groups' => ['location:read_collection']] | ||
), | ||
] | ||
)] | ||
class BrokenDocs | ||
{ | ||
public ?int $id = null; | ||
|
||
/** | ||
* @var ?ArrayCollection<Related> | ||
*/ | ||
#[Groups(['location:write', 'location:read_collection'])] | ||
public ?ArrayCollection $locations; | ||
} |
24 changes: 24 additions & 0 deletions
24
tests/Fixtures/TestBundle/ApiResource/Issue5501/Related.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?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 ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\Issue5501; | ||
|
||
use ApiPlatform\Metadata\ApiResource; | ||
use Symfony\Component\Serializer\Annotation\Groups; | ||
|
||
#[ApiResource(operations: [])] | ||
class Related | ||
{ | ||
#[Groups(['location:write', 'location:read_collection'])] | ||
public ?string $name = null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters