get:
responses:
200:
$inc: /components/description.yml
$inc: /components/response/notfound.yml
summary: Included file
get:
responses:
200:
description: This description in folder, include with
404:
$inc: /components/description.yml
summary: Included file
get:
responses:
200:
description: This description in folder, include with
404:
description: This description in folder, include with
summary: Included file
public function parseYamlFile($file_path): array
{
$yaml_array = Yaml::parseFile($file_path);
return $this->buildArray($yaml_array);
}
public function buildArray(array $yaml_array): array
{
$result_array = [];
foreach ($yaml_array as $key => $value) {
if ($key == '$inc') {
$base_folder = dirname($this->file_path) . $value;
$result_array[$key] = $this->parseYamlFile($base_folder);
}
if (is_array($yaml_array[$key])) {
$result_array[$key] = $this->buildArray($yaml_array[$key]);
} else {
$result_array[$key] = $value;
}
}
return $result_array;
}
$rs_arr = $ymlBuilder->parseYamlFile($file); // В $file путь до файла
return Yaml::dump($rs_arr);