Scalr\Tests\Functional\Api\V2\SpecSchema\SpecManager::getPathTemplates PHP Method

getPathTemplates() public method

The list of endpoints in Api specifications
public getPathTemplates ( string $method = null ) : string[]
$method string HTTP method
return string[]
    public function getPathTemplates($method = null)
    {
        if (!is_null($method)) {
            $method = strtolower($method);
            $paths = array_filter($this->specification['paths'], function ($v) use($method) {
                return array_key_exists($method, $v) && array_key_exists(200, $v[$method]['responses']);
            });
        } else {
            $paths = $this->specification['paths'];
        }
        return array_keys($paths);
    }

Usage Example

Esempio n. 1
0
 /**
  * Data provider for testGetEndpoint()
  *
  * @return array[]
  */
 public function dataGetEndpointProvider()
 {
     $basePaths = static::$userSpec->getPathTemplates(Request::METHOD_GET);
     $farmRoles = array_filter($basePaths, function ($v) {
         return preg_match('#^/{envId}/farm-roles#', $v);
     });
     foreach ($farmRoles as $i => $farmRole) {
         unset($basePaths[$i]);
     }
     array_push($basePaths, ...$farmRoles);
     $data = [];
     foreach ($basePaths as $basePath) {
         $data[$basePath] = [$basePath, 'user'];
     }
     $basePaths = static::$accountSpec->getPathTemplates(Request::METHOD_GET);
     foreach ($basePaths as $basePath) {
         $data[$basePath] = [$basePath, 'account'];
     }
     if (file_exists($ignoreFile = $this->getFixturesDirectory() . '/ignorePath.yaml')) {
         $ignorePaths = yaml_parse_file($ignoreFile);
         if (!empty($ignorePaths = $ignorePaths['paths'])) {
             $data = array_filter($data, function ($k) use($ignorePaths) {
                 foreach ($ignorePaths as $path) {
                     if (preg_match("#{$path}#", $k)) {
                         return false;
                     }
                 }
                 return true;
             }, ARRAY_FILTER_USE_KEY);
         }
     }
     return $data;
 }
All Usage Examples Of Scalr\Tests\Functional\Api\V2\SpecSchema\SpecManager::getPathTemplates