OpenApiUiController.php in OpenAPI 8
File
src/Controller/OpenApiUiController.php
View source
<?php
namespace Drupal\openapi\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Url;
use Drupal\openapi\Plugin\openapi\OpenApiGeneratorInterface;
use Drupal\openapi_ui\Plugin\openapi_ui\OpenApiUiInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
class OpenApiUiController extends ControllerBase {
public function title(OpenApiUiInterface $openapi_ui, OpenApiGeneratorInterface $generator, Request $request) {
return $this
->t('%generator OpenApi Documentation', [
'%generator' => $generator
->getLabel(),
'%interface' => $openapi_ui
->getLabel(),
]);
}
public function generate(OpenApiUiInterface $openapi_ui, OpenApiGeneratorInterface $openapi_generator, Request $request) {
$options = $request
->get('options', []);
$build = [
'#type' => 'openapi_ui',
'#openapi_ui_plugin' => $openapi_ui,
'#openapi_schema' => $openapi_generator
->getSpecification(),
];
return $build;
}
}