Skip to content

Commit

Permalink
Merge c31c9d9 into bcf2a46
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed Nov 26, 2020
2 parents bcf2a46 + c31c9d9 commit ec5ba1b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Documentation/Action/DocumentationAction.php
Expand Up @@ -85,7 +85,7 @@ public function __invoke(Request $request = null): DocumentationInterface
$this->formats = $this->formatsProvider->getFormatsFromAttributes($attributes ?? []);
}

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

Expand Down
4 changes: 4 additions & 0 deletions tests/Documentation/Action/DocumentationActionTest.php
Expand Up @@ -43,6 +43,7 @@ class DocumentationActionTest extends TestCase
public function testDocumentationAction(): void
{
$requestProphecy = $this->prophesize(Request::class);
$requestProphecy->getRequestFormat()->willReturn('json');
$attributesProphecy = $this->prophesize(ParameterBagInterface::class);
$queryProphecy = $this->prophesize(ParameterBag::class);
$resourceNameCollectionFactoryProphecy = $this->prophesize(ResourceNameCollectionFactoryInterface::class);
Expand All @@ -63,6 +64,7 @@ public function testDocumentationAction(): void
public function testLegacyDocumentationAction(): void
{
$requestProphecy = $this->prophesize(Request::class);
$requestProphecy->getRequestFormat()->willReturn('json');
$attributesProphecy = $this->prophesize(ParameterBagInterface::class);
$queryProphecy = $this->prophesize(ParameterBag::class);
$resourceNameCollectionFactoryProphecy = $this->prophesize(ResourceNameCollectionFactoryInterface::class);
Expand Down Expand Up @@ -97,6 +99,7 @@ public function testDocumentationActionV2(): void
{
$openApiFactoryProphecy = $this->prophesize(OpenApiFactoryInterface::class);
$requestProphecy = $this->prophesize(Request::class);
$requestProphecy->getRequestFormat()->willReturn('json');
$attributesProphecy = $this->prophesize(ParameterBagInterface::class);
$queryProphecy = $this->prophesize(ParameterBag::class);
$resourceNameCollectionFactoryProphecy = $this->prophesize(ResourceNameCollectionFactoryInterface::class);
Expand All @@ -120,6 +123,7 @@ public function testDocumentationActionV3(): void
$openApiFactoryProphecy = $this->prophesize(OpenApiFactoryInterface::class);
$openApiFactoryProphecy->__invoke(Argument::any())->shouldBeCalled()->willReturn($openApi);
$requestProphecy = $this->prophesize(Request::class);
$requestProphecy->getRequestFormat()->willReturn('json');
$attributesProphecy = $this->prophesize(ParameterBagInterface::class);
$queryProphecy = $this->prophesize(ParameterBag::class);
$resourceNameCollectionFactoryProphecy = $this->prophesize(ResourceNameCollectionFactoryInterface::class);
Expand Down

0 comments on commit ec5ba1b

Please sign in to comment.