1. Go to this page and download the library: Download mouyong/laravel-doc library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace Tests;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use MouYong\LaravelDoc\Traits\YapiTrait; // here
abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
use YapiTrait; // here
}
namespace Tests\Feature\Tenant;
use App\Models\Tenant;
use Cblink\YApiDoc\YapiDTO;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\Feature\Tenant\Traits\AdminUserTrait;
use Tests\TestCase;
class OemTest extends TestCase
{
use AdminUserTrait;
/**
* Get tenant oem info.
*
* @return void
*/
public function test_get_tenant_oem_info()
{
$response = $this->getJson($this->tenantApi('/api/oem-info', false));
// 断言接口响应数据格式
$this->assertSuccess($response, [
'api',
'tenant_id',
'doctor_name',
'hospital_name',
'department_name',
'doctor_username',
'domains',
]);
// 生成 yapi 文档 与 openapi 2.0 文档
$this->yapi($response, new YapiDTO([
// 可以同时生成到多个 yapi 项目
'project' => ['default'],
// api 名称
'name' => '获取租户 oem 信息',
// api 分类
'category' => '系统',
'params' => [],
'desc' => '',
'request' =>[
// 这里是字段含义
'trans' => [
],
// 这里是非必填字段
'except' => [],
],
'response' =>[
// 这里是字段含义
'trans' => [
'api' => '租户 api 地址',
'tenant_id' => '租户 id',
'doctor_name' => '医生名',
'hospital_name' => '医院名',
'department_name' => '科室名',
'doctor_username' => '医生用户名',
'domains' => '租户域名',
],
// 这里是非必填字段
'except' => [],
],
]));
}
}