mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-03-12 10:36:09 +03:00
Merge pull request #1015 from nelmio/fosrest
Fix docs when using FOSRestBundle format listener
This commit is contained in:
commit
6776d7880e
@ -27,6 +27,10 @@ final class SwaggerUiController
|
||||
|
||||
public function __invoke()
|
||||
{
|
||||
return new Response($this->twig->render('@NelmioApiDoc/SwaggerUi/index.html.twig', ['swagger_data' => ['spec' => $this->apiDocGenerator->generate()->toArray()]]));
|
||||
return new Response(
|
||||
$this->twig->render('@NelmioApiDoc/SwaggerUi/index.html.twig', ['swagger_data' => ['spec' => $this->apiDocGenerator->generate()->toArray()]]),
|
||||
Response::HTTP_OK,
|
||||
['Content-Type' => 'text/html']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ class SwaggerUiTest extends WebTestCase
|
||||
|
||||
$response = $client->getResponse();
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertEquals('text/html; charset=UTF-8', $response->headers->get('Content-Type'));
|
||||
|
||||
$swaggerUiSpec = json_decode($crawler->filterXPath('//script[@id="swagger-data"]')->text(), true);
|
||||
$appSpec = $client->getContainer()->get('nelmio_api_doc.generator')->generate()->toArray();
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Nelmio\ApiDocBundle\Tests\Functional;
|
||||
|
||||
use ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle;
|
||||
use FOS\RestBundle\FOSRestBundle;
|
||||
use Nelmio\ApiDocBundle\NelmioApiDocBundle;
|
||||
use Nelmio\ApiDocBundle\Tests\Functional\TestBundle;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle;
|
||||
@ -38,6 +39,7 @@ class TestKernel extends Kernel
|
||||
new SensioFrameworkExtraBundle(),
|
||||
new ApiPlatformBundle(),
|
||||
new NelmioApiDocBundle(),
|
||||
new FOSRestBundle(),
|
||||
new TestBundle(),
|
||||
];
|
||||
}
|
||||
@ -67,6 +69,17 @@ class TestKernel extends Kernel
|
||||
'serializer' => ['enable_annotations' => true],
|
||||
]);
|
||||
|
||||
$c->loadFromExtension('fos_rest', [
|
||||
'format_listener' => [
|
||||
'rules' => [
|
||||
[
|
||||
'path' => '^/',
|
||||
'fallback_format' => 'json',
|
||||
]
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
// Filter routes
|
||||
$c->loadFromExtension('nelmio_api_doc', [
|
||||
'documentation' => [
|
||||
|
Loading…
x
Reference in New Issue
Block a user