You are here

public function OpenApiUiController::generate in OpenAPI 8

Same name and namespace in other branches
  1. 8.2 src/Controller/OpenApiUiController.php \Drupal\openapi\Controller\OpenApiUiController::generate()

Gets the OpenAPI output in JSON format.

Return value

\Symfony\Component\HttpFoundation\JsonResponse The JSON response.

1 string reference to 'OpenApiUiController::generate'
openapi.routing.yml in ./openapi.routing.yml
openapi.routing.yml

File

src/Controller/OpenApiUiController.php, line 41

Class

OpenApiUiController
API Specification controller base.

Namespace

Drupal\openapi\Controller

Code

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;
}