Exemplo n.º 1
0
 private function fetchSchema($bundleName, $path) : JSONSchema
 {
     $bundle = $this->bundleService->getBundleByName($bundleName);
     if (!$bundle->hasAPIDocsDir()) {
         throw new NoAPIDocsAvailableException(sprintf('No API docs available for bundle `%s`', $bundle->getName()));
     }
     $apiFile = "{$bundle->getAPIDocsDir()}/{$path}";
     if (!file_exists($apiFile)) {
         throw new SchemaFileNotExists(sprintf('Schema file `%s` not found', $apiFile));
     }
     $yaml = Yaml::parse(file_get_contents($apiFile));
     $yaml = array_pop($yaml);
     $yaml = json_decode(json_encode($yaml));
     return new JSONSchema($yaml);
 }