Skip to content

Commit 9663fda

Browse files
authored
Merge pull request #3846 from soyuka/fix/documentation
Fix #3844 open api shows with jsonld normalizer
2 parents bcf2a46 + c31c9d9 commit 9663fda

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/Documentation/Action/DocumentationAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function __invoke(Request $request = null): DocumentationInterface
8585
$this->formats = $this->formatsProvider->getFormatsFromAttributes($attributes ?? []);
8686
}
8787

88-
if (null !== $this->openApiFactory && isset($context) && 3 === $context['spec_version']) {
88+
if ('json' === $request->getRequestFormat() && null !== $this->openApiFactory && 3 === ($context['spec_version'] ?? null)) {
8989
return $this->openApiFactory->__invoke($context ?? []);
9090
}
9191

tests/Documentation/Action/DocumentationActionTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class DocumentationActionTest extends TestCase
4343
public function testDocumentationAction(): void
4444
{
4545
$requestProphecy = $this->prophesize(Request::class);
46+
$requestProphecy->getRequestFormat()->willReturn('json');
4647
$attributesProphecy = $this->prophesize(ParameterBagInterface::class);
4748
$queryProphecy = $this->prophesize(ParameterBag::class);
4849
$resourceNameCollectionFactoryProphecy = $this->prophesize(ResourceNameCollectionFactoryInterface::class);
@@ -63,6 +64,7 @@ public function testDocumentationAction(): void
6364
public function testLegacyDocumentationAction(): void
6465
{
6566
$requestProphecy = $this->prophesize(Request::class);
67+
$requestProphecy->getRequestFormat()->willReturn('json');
6668
$attributesProphecy = $this->prophesize(ParameterBagInterface::class);
6769
$queryProphecy = $this->prophesize(ParameterBag::class);
6870
$resourceNameCollectionFactoryProphecy = $this->prophesize(ResourceNameCollectionFactoryInterface::class);
@@ -97,6 +99,7 @@ public function testDocumentationActionV2(): void
9799
{
98100
$openApiFactoryProphecy = $this->prophesize(OpenApiFactoryInterface::class);
99101
$requestProphecy = $this->prophesize(Request::class);
102+
$requestProphecy->getRequestFormat()->willReturn('json');
100103
$attributesProphecy = $this->prophesize(ParameterBagInterface::class);
101104
$queryProphecy = $this->prophesize(ParameterBag::class);
102105
$resourceNameCollectionFactoryProphecy = $this->prophesize(ResourceNameCollectionFactoryInterface::class);
@@ -120,6 +123,7 @@ public function testDocumentationActionV3(): void
120123
$openApiFactoryProphecy = $this->prophesize(OpenApiFactoryInterface::class);
121124
$openApiFactoryProphecy->__invoke(Argument::any())->shouldBeCalled()->willReturn($openApi);
122125
$requestProphecy = $this->prophesize(Request::class);
126+
$requestProphecy->getRequestFormat()->willReturn('json');
123127
$attributesProphecy = $this->prophesize(ParameterBagInterface::class);
124128
$queryProphecy = $this->prophesize(ParameterBag::class);
125129
$resourceNameCollectionFactoryProphecy = $this->prophesize(ResourceNameCollectionFactoryInterface::class);

0 commit comments

Comments
 (0)