/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $applicationName = $this->getParameter('application.name'); $routes = $this->routes->all(); $resources = $this->getResources($routes); $url = parse_url($this->getParameter('application.url')); $formatted = ['swagger' => '2.0', 'info' => ['title' => $applicationName, 'description' => sprintf('%s API', $applicationName), 'version' => '1.0.0'], 'consumes' => ['application/json'], 'produces' => ['application/json', 'text/html'], 'host' => $url['host'], 'schemes' => [$url['scheme']], 'securityDefinitions' => ['token' => ['type' => 'apiKey', 'description' => 'Given API Token', 'name' => 'Token', 'in' => 'Header']], 'security' => ['token' => ['all']], 'paths' => $resources]; $dumper = new Dumper(); $output->writeln($dumper->dump($formatted, 4)); }
/** * @param Request $request * @return Response|mixed */ private function handleRequest(Request $request) { // match route and set attributes in request object $attributes = $this->urlMatcher->match($request); $request->attributes->add($attributes); $routeName = $attributes['_route']; $route = $this->routes->get($routeName); foreach ($this->middlewares as $middleware) { $response = $middleware->processRequest($request, $route); if ($response) { // e.g. RedirectResponse or rendered error page return $response; } } /** @var callable $callable */ $callable = $this->resolver->getController($request); $arguments = $this->resolver->getArguments($request, $callable); return $callable(...$arguments); }