Example #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $version = $input->getArgument('version') ?: '*';
     $path = $input->getArgument('path');
     $doc = $this->resourceListing->getDocumentation($path);
     if ($doc instanceof DocumentationInterface) {
         if ($version == '*') {
             $version = $doc->getLatestVersion();
         }
         $resource = $doc->getResource($version);
         if (!$resource instanceof Resource) {
             throw new RuntimeException('Given version is not available');
         }
         $baseUri = $this->config['psx_url'] . '/' . $this->config['psx_dispatch'];
         $targetNamespace = $this->config['psx_json_namespace'];
         $generator = new Generator\Swagger($version, $baseUri, $targetNamespace);
         $output->write($generator->generate($resource));
     } else {
         throw new RuntimeException('Invalid resource');
     }
 }
 public function doDetail()
 {
     $version = $this->getUriFragment('version');
     $path = $this->getUriFragment('path');
     $doc = $this->resourceListing->getDocumentation($path);
     if ($doc instanceof DocumentationInterface) {
         if ($version == '*') {
             $version = $doc->getLatestVersion();
         }
         $resource = $doc->getResource($version);
         if (!$resource instanceof Resource) {
             throw new HttpException\NotFoundException('Given version is not available');
         }
         $baseUri = $this->config['psx_url'] . '/' . $this->config['psx_dispatch'];
         $targetNamespace = $this->config['psx_json_namespace'];
         $this->response->setHeader('Content-Type', 'application/json');
         $generator = new Generator\Swagger($version, $baseUri, $targetNamespace);
         $this->setBody($generator->generate($resource));
     } else {
         throw new HttpException\NotFoundException('Invalid resource');
     }
 }