2017-06-17 00:19:42 +00:00
|
|
|
<?php
|
2020-10-14 22:19:31 +00:00
|
|
|
|
2021-07-19 05:53:45 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2018-08-04 22:05:14 +00:00
|
|
|
namespace App\Console\Command;
|
2017-06-17 00:19:42 +00:00
|
|
|
|
2020-12-03 04:18:06 +00:00
|
|
|
use App\Environment;
|
2018-11-26 20:54:49 +00:00
|
|
|
use App\Version;
|
2021-06-08 06:40:49 +00:00
|
|
|
use OpenApi\Generator;
|
|
|
|
use OpenApi\Util;
|
2019-09-10 23:10:57 +00:00
|
|
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
2020-10-14 22:19:31 +00:00
|
|
|
|
2019-09-10 23:10:57 +00:00
|
|
|
class GenerateApiDocsCommand extends CommandAbstract
|
2017-06-17 00:19:42 +00:00
|
|
|
{
|
2019-09-10 23:10:57 +00:00
|
|
|
public function __invoke(
|
|
|
|
SymfonyStyle $io,
|
2020-12-03 04:18:06 +00:00
|
|
|
Environment $environment
|
2020-10-14 22:19:31 +00:00
|
|
|
): int {
|
2018-12-24 08:47:45 +00:00
|
|
|
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',
|
|
|
|
],
|
|
|
|
[
|
2017-06-17 00:19:42 +00:00
|
|
|
'bootstrap',
|
|
|
|
'locale',
|
2019-09-04 18:00:51 +00:00
|
|
|
'templates',
|
2021-06-08 06:40:49 +00:00
|
|
|
]
|
|
|
|
);
|
2017-06-17 00:19:42 +00:00
|
|
|
|
2020-12-03 04:18:06 +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);
|
2017-06-17 00:19:42 +00:00
|
|
|
|
2019-09-10 23:10:57 +00:00
|
|
|
$io->writeln('API documentation updated!');
|
2018-05-07 01:57:06 +00:00
|
|
|
return 0;
|
2017-06-17 00:19:42 +00:00
|
|
|
}
|
|
|
|
}
|