<?php
declare(strict_types=1);
namespace App\Platform\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class ApiDocsController extends AbstractController
{
public function __construct(private UrlGeneratorInterface $urlGenerator)
{
}
#[Route(path: '/api-docs/swagger', name: 'api-docs.swagger')]
public function swagger(): Response
{
return $this->render('@base/api-docs/swagger.html.twig', [
'yamlUrl' => $this->generateUrl('api-docs.yaml', [
'major' => 0,
'minor' => 1,
'fix' => 0,
]),
]);
}
#[Route(path: '/api-docs/redoc', name: 'api-docs.redoc')]
public function redoc(): Response
{
return $this->render('@base/api-docs/redoc.html.twig', [
'yamlUrl' => $this->generateUrl('api-docs.yaml', [
'major' => 0,
'minor' => 1,
'fix' => 0,
]),
]);
}
#[Route(path: '/api-docs/elements', name: 'api-docs.elements')]
public function elements(): Response
{
return $this->render('@base/api-docs/elements.html.twig', [
'yamlUrl' => $this->generateUrl('api-docs.yaml', [
'major' => 0,
'minor' => 1,
'fix' => 0,
]),
]);
}
#[Route(path: '/api-docs/yaml/{major}/{minor}/{fix}', name: 'api-docs.yaml')]
public function yaml(int $major, int $minor, int $fix): Response
{
return $this->render(sprintf("@base/api-docs/yaml/v%s.%s.%s.openapi.yaml", $major, $minor, $fix), [
'baseUrl' => $this->urlGenerator->generate('index', [], 0) . 'api/v1',
]);
}
}