renderOpenApi = $renderOpenApi; } public function __invoke(Request $request, $area = 'default') { try { $response = new Response( $this->renderOpenApi->render(RenderOpenApi::HTML, $area, [ 'server_url' => '' !== $request->getBaseUrl() ? $request->getSchemeAndHttpHost().$request->getBaseUrl() : null, ]), Response::HTTP_OK, ['Content-Type' => 'text/html'] ); return $response->setCharset('UTF-8'); } catch (InvalidArgumentException $e) { $advice = ''; if (false !== strpos($area, '.json')) { $advice = ' Since the area provided contains `.json`, the issue is likely caused by route priorities. Try switching the Swagger UI / the json documentation routes order.'; } throw new BadRequestHttpException(sprintf('Area "%s" is not supported as it isn\'t defined in config.%s', $area, $advice)); } } }