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