You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
452 B
23 lines
452 B
<?php
|
|
declare (strict_types=1);
|
|
|
|
namespace app\api\controller;
|
|
|
|
use function OpenApi\scan;
|
|
|
|
class Swagger
|
|
{
|
|
/**
|
|
* 生成json/yamf文件
|
|
*/
|
|
public function createFile()
|
|
{
|
|
|
|
$openapi = @scan(dirname(__DIR__));
|
|
$spec = json_encode($openapi, JSON_PRETTY_PRINT);
|
|
if (file_put_contents('openapi.json', $spec)) {
|
|
echo 'http://' . \request()->server()['HTTP_HOST'] . '/openapi.json';
|
|
}
|
|
}
|
|
|
|
}
|
|
|