mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-09 02:59:27 +03:00
Merge pull request #1172 from nelmio/api-platform
Fix Api-Platform support
This commit is contained in:
commit
447f44e5a1
@ -14,32 +14,15 @@ namespace Nelmio\ApiDocBundle\Describer;
|
||||
use ApiPlatform\Core\Documentation\Documentation;
|
||||
use ApiPlatform\Core\Swagger\Serializer\DocumentationNormalizer;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
final class ApiPlatformDescriber extends ExternalDocDescriber
|
||||
{
|
||||
public function __construct(Documentation $documentation, DocumentationNormalizer $normalizer, UrlGeneratorInterface $urlGenerator)
|
||||
{
|
||||
parent::__construct(function () use ($documentation, $normalizer, $urlGenerator) {
|
||||
$paths = [];
|
||||
$baseContext = $urlGenerator->getContext();
|
||||
$urlGenerator->setContext(new RequestContext());
|
||||
|
||||
try {
|
||||
$basePath = $urlGenerator->generate('api_entrypoint');
|
||||
} finally {
|
||||
$urlGenerator->setContext($baseContext);
|
||||
}
|
||||
|
||||
$documentation = (array) $normalizer->normalize($documentation);
|
||||
unset($documentation['basePath']);
|
||||
|
||||
foreach ($documentation['paths'] as $path => $value) {
|
||||
$paths['/'.ltrim($basePath.'/'.ltrim($path, '/'), '/')] = $value;
|
||||
}
|
||||
|
||||
$documentation['paths'] = $paths;
|
||||
|
||||
return $documentation;
|
||||
});
|
||||
}
|
||||
|
@ -37,9 +37,10 @@
|
||||
"symfony/stopwatch": "^3.4|^4.0",
|
||||
"sensio/framework-extra-bundle": "^3.0",
|
||||
"doctrine/annotations": "^1.2",
|
||||
"doctrine/common": "^2.4",
|
||||
|
||||
"phpdocumentor/reflection-docblock": "^3.1",
|
||||
"api-platform/core": "^2.0.3",
|
||||
"api-platform/core": "^2.1.0",
|
||||
"friendsofsymfony/rest-bundle": "^2.0",
|
||||
"jms/serializer-bundle": "^2.0"
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user