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.
21 lines
487 B
21 lines
487 B
<?php
|
|
declare (strict_types=1);
|
|
|
|
namespace app\api\controller;
|
|
|
|
class Swagger
|
|
{
|
|
/**
|
|
* 生成json/yamf文件
|
|
*/
|
|
public function createFile()
|
|
{
|
|
// echo dirname(__DIR__);exit;
|
|
$openapi = \OpenApi\Generator::scan([dirname(__DIR__)]);
|
|
header('Content-Type: application/json');
|
|
if (file_put_contents('openapi.json', $openapi->toJson())) {
|
|
echo 'http://' . \request()->server()['HTTP_HOST'] . '/openapi.json';
|
|
}
|
|
}
|
|
|
|
}
|
|
|