AzuraCast/src/Console/Command/GenerateApiDocsCommand.php

45 lines
1.2 KiB
PHP
Raw Normal View History

<?php
2021-07-19 05:53:45 +00:00
declare(strict_types=1);
namespace App\Console\Command;
use App\Environment;
use App\Version;
2021-06-08 06:40:49 +00:00
use OpenApi\Generator;
use OpenApi\Util;
use Symfony\Component\Console\Style\SymfonyStyle;
class GenerateApiDocsCommand extends CommandAbstract
{
public function __invoke(
SymfonyStyle $io,
Environment $environment
): int {
define('AZURACAST_API_URL', 'https://demo.azuracast.com/api');
define('AZURACAST_API_NAME', 'AzuraCast Public Demo Server');
define('AZURACAST_VERSION', Version::FALLBACK_VERSION);
2021-06-08 06:40:49 +00:00
$finder = Util::finder(
[
$environment->getBaseDirectory() . '/util/openapi.php',
$environment->getBaseDirectory() . '/src/Entity',
$environment->getBaseDirectory() . '/src/Controller/Api',
],
[
'bootstrap',
'locale',
2019-09-04 18:00:51 +00:00
'templates',
2021-06-08 06:40:49 +00:00
]
);
$yaml_path = $environment->getBaseDirectory() . '/web/static/api/openapi.yml';
2021-06-08 06:40:49 +00:00
$yaml = (Generator::scan($finder))->toYaml();
2018-09-18 14:09:48 +00:00
file_put_contents($yaml_path, $yaml);
$io->writeln('API documentation updated!');
2018-05-07 01:57:06 +00:00
return 0;
}
}