isApiEnabled) { throw new NotFoundException(); } $type = $request->getAttribute('type'); if ($type == 'specs') { $json = json_decode(file_get_contents($this->rootDir . '/docs/openapi.json')); $uri = $request->getUri(); $uri = $uri->withPath('/api'); $json->servers[0] = (object) [ 'url' => (string) $uri, 'description' => 'Production server' ]; return new JsonResponse($json); } return new ViewResponse( '/templates/app/api.twig', [ 'specs' => '/app/api-specs' ] ); } }