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(jsonld): anonymous context hydra_prefix value
fixes api-platform#6810
- Loading branch information
Showing
6 changed files
with
95 additions
and
19 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
30 changes: 30 additions & 0 deletions
30
tests/Fixtures/TestBundle/ApiResource/Issue6810/JsonLdContextOutput.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,30 @@ | ||
<?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\Issue6810; | ||
|
||
use ApiPlatform\Metadata\Get; | ||
use ApiPlatform\Metadata\Operation; | ||
|
||
#[Get('/json_ld_context_output', provider: [self::class, 'getData'], output: Output::class, normalizationContext: ['hydra_prefix' => false])] | ||
class JsonLdContextOutput | ||
{ | ||
public function __construct(public string $id) | ||
{ | ||
} | ||
|
||
public static function getData(Operation $operation, array $uriVariables = [], array $context = []): Output | ||
{ | ||
return new Output(); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
tests/Fixtures/TestBundle/ApiResource/Issue6810/Output.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,19 @@ | ||
<?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\Issue6810; | ||
|
||
class Output | ||
{ | ||
public string $foo = 'bar'; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,8 +35,6 @@ | |
use Prophecy\Prophecy\ObjectProphecy; | ||
use Symfony\Component\PropertyInfo\Type; | ||
|
||
use const ApiPlatform\JsonLd\HYDRA_CONTEXT; | ||
|
||
/** | ||
* @author Markus Mächler <[email protected]> | ||
*/ | ||
|
@@ -293,12 +291,9 @@ public function testResourceContextWithoutHydraPrefix(): void | |
$contextBuilder = new ContextBuilder($this->resourceNameCollectionFactoryProphecy->reveal(), $this->resourceMetadataCollectionFactoryProphecy->reveal(), $this->propertyNameCollectionFactoryProphecy->reveal(), $this->propertyMetadataFactoryProphecy->reveal(), $this->urlGeneratorProphecy->reveal(), null, null, [ContextBuilder::HYDRA_CONTEXT_HAS_PREFIX => false]); | ||
|
||
$expected = [ | ||
HYDRA_CONTEXT, | ||
[ | ||
'@vocab' => '#', | ||
'hydra' => 'http://www.w3.org/ns/hydra/core#', | ||
'dummyPropertyA' => 'DummyEntity/dummyPropertyA', | ||
], | ||
'@vocab' => '#', | ||
'hydra' => 'http://www.w3.org/ns/hydra/core#', | ||
'dummyPropertyA' => 'DummyEntity/dummyPropertyA', | ||
]; | ||
|
||
$this->assertEquals($expected, $contextBuilder->getResourceContext($this->entityClass)); | ||
|