初始化本地仓库
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
/config/installed.php
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\example;
|
||||
|
||||
use core\plugin\PluginInstall as BasePluginInstall;
|
||||
|
||||
/**
|
||||
* 插件安装类
|
||||
* 继承 PluginInstall 基类,自动处理:
|
||||
* - 数据库迁移 (resource/database/migrations/)
|
||||
* - 种子数据 (resource/database/seeds/)
|
||||
*
|
||||
* 菜单和模板需要按需导入,在 afterInstall/afterUninstall 中调用:
|
||||
* - $this->importPluginMenus() - 导入菜单
|
||||
* - $this->importTemplates() - 复制模板
|
||||
* - $this->uninstallPluginMenus() - 卸载菜单
|
||||
* - $this->deletePluginTemplates() - 删除模板
|
||||
*/
|
||||
class Install extends BasePluginInstall
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* 安装前回调
|
||||
*/
|
||||
protected function beforeInstall(string $version): void
|
||||
{
|
||||
echo " 🔄 Running beforeInstall...\n";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 安装后回调 - 按需导入菜单和模板
|
||||
*/
|
||||
protected function afterInstall(string $version): void
|
||||
{
|
||||
echo " 🔄 Running afterInstall...\n";
|
||||
|
||||
// 导入菜单
|
||||
$this->importPluginMenus();
|
||||
|
||||
// 复制模板资源
|
||||
$this->importTemplates();
|
||||
}
|
||||
|
||||
/**
|
||||
* 卸载前回调
|
||||
*/
|
||||
protected function beforeUninstall(string $version): void
|
||||
{
|
||||
echo " 🔄 Running beforeUninstall...\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* 卸载后回调 - 清理菜单和模板
|
||||
*/
|
||||
protected function afterUninstall(string $version): void
|
||||
{
|
||||
echo " 🔄 Running afterUninstall...\n";
|
||||
// 卸载菜单
|
||||
$this->uninstallPluginMenus();
|
||||
// 删除模板资源
|
||||
$this->deletePluginTemplates();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace plugin\example\app\controller\test;
|
||||
|
||||
|
||||
use madong\swagger\annotation\response\DataResponse;
|
||||
use madong\swagger\annotation\response\ListResponse;
|
||||
use madong\swagger\annotation\response\PageResponse;
|
||||
use madong\swagger\attribute\Permission;
|
||||
use OpenApi\Attributes as OA;
|
||||
use plugin\example\app\schema\response\AdminSchema;
|
||||
use plugin\example\app\schema\response\TestResponseDTO;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
|
||||
class InstanceResponseController
|
||||
{
|
||||
/**
|
||||
* DataResponse - 对象实例模式
|
||||
*/
|
||||
#[OA\Get(
|
||||
path: '/test/instance-data',
|
||||
description: '使用 DataResponse 注解并传入对象实例',
|
||||
summary: 'DataResponse - 对象实例模式',
|
||||
tags: ['Instance响应测试']
|
||||
)]
|
||||
#[DataResponse(
|
||||
schema: new TestResponseDTO(),
|
||||
description: '成功获取测试DTO数据'
|
||||
)]
|
||||
#[Permission(code: 'test:schema:data', operation: 'OR', description: 'DataResponse 实例模式测试权限')]
|
||||
public function testDataInstance(Request $request): Response
|
||||
{
|
||||
return json([
|
||||
'code' => 0,
|
||||
'message' => 'success',
|
||||
'data' => [
|
||||
'id' => '1',
|
||||
'username' => 'testuser1',
|
||||
'email' => 'test1@example.com',
|
||||
'status' => 1,
|
||||
'created_at' => '2024-01-01T00:00:00+08:00',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* PageResponse - 对象实例模式
|
||||
*/
|
||||
#[OA\Get(
|
||||
path: '/test/instance-page',
|
||||
description: '使用 PageResponse 注解并传入对象实例',
|
||||
summary: 'PageResponse - 对象实例模式',
|
||||
tags: ['Instance响应测试']
|
||||
)]
|
||||
#[PageResponse(
|
||||
schema: new AdminSchema(),
|
||||
description: '成功获取管理员分页列表',
|
||||
totalExample: 100,
|
||||
pageExample: 1,
|
||||
limitExample: 10
|
||||
)]
|
||||
#[Permission(code: 'test:schema:page', operation: 'OR', description: 'PageResponse 实例模式测试权限')]
|
||||
public function testPageInstance(Request $request): Response
|
||||
{
|
||||
return json([
|
||||
'code' => 0,
|
||||
'message' => 'success',
|
||||
'data' => [
|
||||
'total' => 100,
|
||||
'page' => 1,
|
||||
'limit' => 10,
|
||||
'items' => [
|
||||
[
|
||||
'id' => '1',
|
||||
'user_name' => 'admin1',
|
||||
'real_name' => '管理员1',
|
||||
'mobile_phone'=> '18888888881',
|
||||
'email' => 'admin1@example.com',
|
||||
'status' => 1,
|
||||
'dept_id' => 1,
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* ListResponse - 对象实例模式
|
||||
*/
|
||||
#[OA\Get(
|
||||
path: '/test/instance-list',
|
||||
description: '使用 ListResponse 注解并传入对象实例',
|
||||
summary: 'ListResponse - 对象实例模式',
|
||||
tags: ['Instance响应测试']
|
||||
)]
|
||||
#[ListResponse(
|
||||
schema: new AdminSchema(),
|
||||
description: '成功获取管理员列表'
|
||||
)]
|
||||
#[Permission(code: 'test:schema:list', operation: 'OR', description: 'ListResponse 实例模式测试权限')]
|
||||
public function testListInstance(Request $request): Response
|
||||
{
|
||||
return json([
|
||||
'code' => 0,
|
||||
'message' => 'success',
|
||||
'data' => [
|
||||
[
|
||||
'id' => '1',
|
||||
'user_name' => 'admin1',
|
||||
'real_name' => '管理员1',
|
||||
'email' => 'admin1@example.com',
|
||||
],
|
||||
[
|
||||
'id' => '2',
|
||||
'user_name' => 'admin2',
|
||||
'real_name' => '管理员2',
|
||||
'email' => 'admin2@example.com',
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 混合使用:对象实例 + 示例
|
||||
*/
|
||||
#[OA\Get(
|
||||
path: '/test/instance-with-example',
|
||||
description: '使用对象实例定义Schema,同时提供自定义示例',
|
||||
summary: '混合使用:对象实例 + 示例',
|
||||
tags: ['Instance响应测试']
|
||||
)]
|
||||
#[PageResponse(
|
||||
schema: new AdminSchema(),
|
||||
example: [
|
||||
[
|
||||
'id' => '999',
|
||||
'user_name' => 'custom_admin',
|
||||
'real_name' => '自定义管理员',
|
||||
'mobile_phone'=> '13999999999',
|
||||
'email' => 'custom@example.com',
|
||||
'status' => 1,
|
||||
'dept_id' => 99,
|
||||
]
|
||||
],
|
||||
description: '成功获取分页列表(带自定义示例)',
|
||||
totalExample: 50,
|
||||
pageExample: 2,
|
||||
limitExample: 20
|
||||
)]
|
||||
#[Permission(code: 'test:schema:mixed', operation: 'OR', description: '混合模式测试权限')]
|
||||
public function testMixed(Request $request): Response
|
||||
{
|
||||
return json([
|
||||
'code' => 0,
|
||||
'message' => 'success',
|
||||
'data' => [
|
||||
'total' => 50,
|
||||
'page' => 2,
|
||||
'limit' => 20,
|
||||
'items' => [
|
||||
[
|
||||
'id' => '21',
|
||||
'user_name' => 'admin21',
|
||||
'real_name' => '管理员21',
|
||||
'email' => 'admin21@example.com',
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
请求DTO
|
||||
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
/**
|
||||
*+------------------
|
||||
* madong
|
||||
*+------------------
|
||||
* Copyright (c) https://gitee.com/motion-code All rights reserved.
|
||||
*+------------------
|
||||
* Author: Mr. April (405784684@qq.com)
|
||||
*+------------------
|
||||
* Official Website: https://madong.tech
|
||||
*/
|
||||
|
||||
namespace plugin\example\app\schema\response;
|
||||
|
||||
use OpenApi\Attributes as OA;
|
||||
use WebmanTech\DTO\BaseResponseDTO;
|
||||
|
||||
#[OA\Schema(
|
||||
title: '管理员详情响应模型',
|
||||
description: '管理员详情接口的返回数据结构'
|
||||
)]
|
||||
class AdminSchema extends BaseResponseDTO
|
||||
{
|
||||
#[OA\Property(
|
||||
property: 'id',
|
||||
description: '管理员ID',
|
||||
type: 'string',
|
||||
example: '1'
|
||||
)]
|
||||
public string $id;
|
||||
|
||||
#[OA\Property(
|
||||
property: 'user_name',
|
||||
description: '用户名',
|
||||
type: 'string',
|
||||
example: 'admin'
|
||||
)]
|
||||
public string $user_name;
|
||||
|
||||
#[OA\Property(
|
||||
property: 'real_name',
|
||||
description: '真实姓名',
|
||||
type: 'string',
|
||||
example: '管理员'
|
||||
)]
|
||||
public string $real_name;
|
||||
|
||||
#[OA\Property(
|
||||
property: 'mobile_phone',
|
||||
description: '手机号码',
|
||||
type: 'string',
|
||||
example: '18888888888'
|
||||
)]
|
||||
public string $mobile_phone;
|
||||
|
||||
#[OA\Property(
|
||||
property: 'email',
|
||||
description: '邮箱',
|
||||
type: 'string',
|
||||
example: 'admin@example.com'
|
||||
)]
|
||||
public string $email;
|
||||
|
||||
#[OA\Property(
|
||||
property: 'status',
|
||||
description: '状态(0:禁用,1:启用)',
|
||||
type: 'integer',
|
||||
enum: [0, 1],
|
||||
example: 1,
|
||||
)]
|
||||
public int $status;
|
||||
|
||||
#[OA\Property(
|
||||
property: 'dept_id',
|
||||
description: '部门ID',
|
||||
type: 'integer',
|
||||
example: 1
|
||||
)]
|
||||
public int $dept_id;
|
||||
|
||||
#[OA\Property(
|
||||
property: 'avatar',
|
||||
description: '头像',
|
||||
type: 'string',
|
||||
example: '/upload/avatar.jpg'
|
||||
)]
|
||||
public string $avatar;
|
||||
|
||||
#[OA\Property(
|
||||
property: 'is_super',
|
||||
description: '是否超级管理员(0:否,1:是)',
|
||||
type: 'integer',
|
||||
example: 1,
|
||||
enum: [0, 1]
|
||||
)]
|
||||
public int $is_super;
|
||||
|
||||
#[OA\Property(
|
||||
property: 'is_tenant_admin',
|
||||
description: '是否租户管理员(0:否,1:是)',
|
||||
type: 'integer',
|
||||
example: 1,
|
||||
enum: [0, 1]
|
||||
)]
|
||||
public int $is_tenant_admin;
|
||||
|
||||
#[OA\Property(
|
||||
property: 'created_at',
|
||||
description: '创建时间',
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
example: '2025-10-10T16:28:51+08:00'
|
||||
)]
|
||||
public string $created_at;
|
||||
|
||||
#[OA\Property(
|
||||
property: 'updated_at',
|
||||
description: '更新时间',
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
example: '2025-10-10T16:28:51+08:00'
|
||||
)]
|
||||
public string $updated_at;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace plugin\example\app\schema\response;
|
||||
|
||||
use OpenApi\Attributes as OA;
|
||||
|
||||
#[OA\Schema(
|
||||
title: '部门树响应模型',
|
||||
description: '部门树形结构,支持无限层级'
|
||||
)]
|
||||
class DeptSchema
|
||||
{
|
||||
#[OA\Property(description: '部门ID', example: 1)]
|
||||
public int $id;
|
||||
|
||||
#[OA\Property(description: '部门名称', example: '技术部')]
|
||||
public string $name;
|
||||
|
||||
#[OA\Property(
|
||||
description: '子部门列表(树形结构)',
|
||||
type: 'array',
|
||||
items: new OA\Items(
|
||||
ref: '#/components/schemas/DeptSchema'
|
||||
)
|
||||
)]
|
||||
public array $children;
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
*+------------------
|
||||
* madong
|
||||
*+------------------
|
||||
* Copyright (c) https://gitee.com/motion-code All rights reserved.
|
||||
*+------------------
|
||||
* Author: Mr. April (405784684@qq.com)
|
||||
*+------------------
|
||||
* Official Website: http://www.madong.tech
|
||||
*/
|
||||
|
||||
namespace plugin\example\app\schema\response;
|
||||
|
||||
use madong\swagger\schema\BaseResponseDTO;
|
||||
use OpenApi\Attributes as OA;
|
||||
|
||||
/**
|
||||
* 测试响应 DTO
|
||||
*
|
||||
* 继承 BaseResponseDTO 可以通过 x 参数传递 schema
|
||||
* 使用方式:x: [SchemaConstants::X_SCHEMA_RESPONSE => TestResponseDTO::class]
|
||||
*/
|
||||
#[OA\Schema(
|
||||
title: '测试响应DTO',
|
||||
description: '测试响应DTO的数据结构'
|
||||
)]
|
||||
class TestResponseDTO extends BaseResponseDTO
|
||||
{
|
||||
#[OA\Property(
|
||||
property: 'id',
|
||||
description: 'ID',
|
||||
type: 'string',
|
||||
example: '1'
|
||||
)]
|
||||
public string $id;
|
||||
|
||||
#[OA\Property(
|
||||
property: 'username',
|
||||
description: '用户名',
|
||||
type: 'string',
|
||||
example: 'admin'
|
||||
)]
|
||||
public string $username;
|
||||
|
||||
#[OA\Property(
|
||||
property: 'email',
|
||||
description: '邮箱',
|
||||
type: 'string',
|
||||
example: 'admin@example.com'
|
||||
)]
|
||||
public string $email;
|
||||
|
||||
#[OA\Property(
|
||||
property: 'status',
|
||||
description: '状态',
|
||||
type: 'integer',
|
||||
example: 1
|
||||
)]
|
||||
public int $status;
|
||||
|
||||
#[OA\Property(
|
||||
property: 'created_at',
|
||||
description: '创建时间',
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
example: '2024-01-01T00:00:00+08:00'
|
||||
)]
|
||||
public string $created_at;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'enable' => true,
|
||||
'debug' => true,
|
||||
'controller_suffix' => 'Controller',
|
||||
'controller_reuse' => false,
|
||||
'version' => '1.0.0',
|
||||
'title' => 'Swagger示例插件',
|
||||
'description' => 'Swagger示例插件',
|
||||
'author' => 'Madong',
|
||||
'type' => 'madong',
|
||||
];
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 插件信息配置
|
||||
*/
|
||||
|
||||
return [
|
||||
'name' => 'example',
|
||||
'identifier' => 'example',
|
||||
'version' => '1.0.0',
|
||||
'description' => 'Swagger示例插件',
|
||||
'author' => 'Madong',
|
||||
'author_email' => 'support@madong.tech',
|
||||
'website' => 'https://www.madong.tech',
|
||||
'require' => [
|
||||
'composer' => [
|
||||
'ramsey/uuid' => '^4.7',
|
||||
],
|
||||
],
|
||||
'npm_require' => [
|
||||
'admin' => [
|
||||
'lodash' => '^4.17.21',
|
||||
],
|
||||
'web' => [
|
||||
'axios' => '^1.6.0',
|
||||
],
|
||||
],
|
||||
'uninstall' => [
|
||||
'undeletable' => true,
|
||||
'drop_tables' => false,
|
||||
'remove_dependencies' => false,
|
||||
],
|
||||
'type' => 'madong',
|
||||
];
|
||||
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
/**
|
||||
* 示例插件 - 审核配置示例
|
||||
*
|
||||
* 此文件展示如何为插件配置审核功能
|
||||
* 系统会自动扫描并合并此配置
|
||||
*/
|
||||
|
||||
return [
|
||||
// 插件信息
|
||||
'plugin' => [
|
||||
'name' => 'example',
|
||||
'display_name' => '示例插件',
|
||||
'version' => '1.0.0',
|
||||
],
|
||||
|
||||
// ==================== 审核类型配置示例 ====================
|
||||
|
||||
// 示例1:简单配置(仅使用默认映射)
|
||||
'example_simple' => [
|
||||
'morph_alias' => 'example_simple', // 对应 morph_map.php 中的别名
|
||||
'display_name' => '简单示例审核',
|
||||
'priority' => 5,
|
||||
|
||||
// 字段映射(如果为空,使用系统默认映射)
|
||||
'fields' => [
|
||||
'title' => [
|
||||
'type' => 'attribute',
|
||||
'source' => 'title', // 模型中的字段名
|
||||
'label' => '标题',
|
||||
'fallback' => '默认标题',
|
||||
],
|
||||
'content' => [
|
||||
'type' => 'attribute',
|
||||
'source' => 'description', // 可能字段名不同
|
||||
'label' => '内容',
|
||||
'fallback' => '无内容',
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
// 示例2:复杂配置(使用关联和回调)
|
||||
'example_complex' => [
|
||||
'morph_alias' => 'example_complex',
|
||||
'display_name' => '复杂示例审核',
|
||||
'priority' => 10,
|
||||
|
||||
'fields' => [
|
||||
'title' => [
|
||||
'type' => 'callback',
|
||||
'callback' => function($model) {
|
||||
// 自定义标题生成逻辑
|
||||
return $model->name . ' (ID: ' . $model->id . ')';
|
||||
},
|
||||
'label' => '标题',
|
||||
'fallback' => '未命名',
|
||||
],
|
||||
'content' => [
|
||||
'type' => 'attribute',
|
||||
'source' => 'description',
|
||||
'label' => '描述',
|
||||
'format' => 'html_to_text', // 应用格式化函数
|
||||
'fallback' => '无描述',
|
||||
],
|
||||
'applicant' => [
|
||||
'type' => 'relation',
|
||||
'source' => 'creator', // 关联关系名
|
||||
'attribute' => 'username', // 关联模型的字段
|
||||
'label' => '创建人',
|
||||
'fallback' => '未知用户',
|
||||
],
|
||||
'category' => [
|
||||
'type' => 'relation',
|
||||
'source' => 'category', // 关联关系
|
||||
'attribute' => 'name', // 关联模型的字段
|
||||
'label' => '分类',
|
||||
'fallback' => '未分类',
|
||||
],
|
||||
'tags' => [
|
||||
'type' => 'relation',
|
||||
'source' => 'tags', // 多对多关联
|
||||
'attribute' => 'name', // 关联模型的字段
|
||||
'label' => '标签',
|
||||
'multiple' => true, // 多值字段
|
||||
'format' => 'implode:、', // 多个值用顿号连接
|
||||
'fallback' => '无标签',
|
||||
],
|
||||
],
|
||||
|
||||
// 审核回调(可选)
|
||||
'callbacks' => [
|
||||
'approved' => 'plugin\example\app\service\ExampleReviewService@onApproved',
|
||||
'rejected' => 'plugin\example\app\service\ExampleReviewService@onRejected',
|
||||
],
|
||||
|
||||
// 额外信息(用于前端显示)
|
||||
'extra' => [
|
||||
'icon' => 'ant-design:experiment-outlined',
|
||||
'color' => '#722ed1',
|
||||
'route' => '/example/detail/{id}', // 详情页路由
|
||||
],
|
||||
],
|
||||
|
||||
// ==================== 字段格式化函数示例 ====================
|
||||
|
||||
'formatters' => [
|
||||
'my_custom_formatter' => function($value) {
|
||||
// 自定义格式化函数
|
||||
return strtoupper($value);
|
||||
},
|
||||
'currency' => function($amount, $currency = '¥') {
|
||||
// 货币格式化
|
||||
return $currency . number_format($amount, 2);
|
||||
},
|
||||
'short_date' => function($timestamp) {
|
||||
// 短日期格式
|
||||
return date('Y-m-d', $timestamp);
|
||||
},
|
||||
],
|
||||
|
||||
// ==================== 插件级默认字段 ====================
|
||||
|
||||
'default_fields' => [
|
||||
'created_time' => [
|
||||
'type' => 'attribute',
|
||||
'source' => 'created_at',
|
||||
'label' => '创建时间',
|
||||
'format' => 'datetime:Y年m月d日 H:i:s',
|
||||
],
|
||||
'status_text' => [
|
||||
'type' => 'callback',
|
||||
'callback' => function($model) {
|
||||
$statusMap = [0 => '待处理', 1 => '进行中', 2 => '已完成'];
|
||||
return $statusMap[$model->status] ?? '未知';
|
||||
},
|
||||
'label' => '状态',
|
||||
],
|
||||
],
|
||||
|
||||
// ==================== 使用说明 ====================
|
||||
|
||||
'_notes' => [
|
||||
'1. 确保在 morph_map.php 中配置了模型别名映射',
|
||||
'2. priority 数字越大,排序越靠前',
|
||||
'3. 字段映射优先级:插件特定配置 > 插件默认配置 > 系统默认配置',
|
||||
'4. 可以自定义格式化函数,然后在 format 中使用',
|
||||
],
|
||||
];
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of webman.
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the MIT-LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @author walkor<walkor@workerman.net>
|
||||
* @copyright walkor<walkor@workerman.net>
|
||||
* @link http://www.workerman.net/
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
use Webman\Route;
|
||||
use WebmanTech\Swagger\Swagger;
|
||||
use OpenApi\Annotations as OA;
|
||||
|
||||
|
||||
/**
|
||||
* 注册example APP路由
|
||||
*/
|
||||
Route::group('/example', function () {
|
||||
|
||||
// Swagger 文档路由配置
|
||||
Swagger::create()->registerRoute([
|
||||
'route_prefix' => '/openapi',
|
||||
'register_route' => true,
|
||||
'openapi_doc' => [
|
||||
'scan_path' => [
|
||||
base_path('plugin/example'),
|
||||
],
|
||||
'exclude' => [
|
||||
// 排除非控制器文件和目录
|
||||
],
|
||||
'processors' => [
|
||||
// 添加自定义处理器来过滤基类
|
||||
],
|
||||
'modify' => function (OA\OpenApi $openapi) {
|
||||
$openapi->info->title = config('app.name') . ' API';
|
||||
$openapi->info->version = '1.0.0';
|
||||
$openapi->servers = [
|
||||
new OA\Server(
|
||||
[
|
||||
'url' => '/example',
|
||||
'description' => request()->host(),
|
||||
]
|
||||
),
|
||||
];
|
||||
/** @phpstan-ignore-next-line */
|
||||
if (!$openapi->components instanceof OA\Components) {
|
||||
$openapi->components = new OA\Components([]);
|
||||
}
|
||||
$openapi->components->securitySchemes = [
|
||||
new OA\SecurityScheme([
|
||||
'securityScheme' => 'api_key',
|
||||
'type' => 'apiKey',
|
||||
'name' => config('core.jwt.app.token_name', 'Authorization'),
|
||||
'in' => 'header',
|
||||
]),
|
||||
];
|
||||
|
||||
// 过滤掉不应该出现在文档中的路径
|
||||
// foreach ($openapi->paths as $path => $pathItem) {
|
||||
// // 过滤掉测试路径
|
||||
// if (str_contains($path, '/test/')) {
|
||||
// unset($openapi->paths[$path]);
|
||||
// }
|
||||
// }
|
||||
},
|
||||
|
||||
],
|
||||
]);
|
||||
|
||||
// 注意:ResponseTestController 的路由已通过 Swagger 注解自动生成
|
||||
// 无需在此手动定义路由
|
||||
// Swagger 会根据 @OA\Get 注解自动注册路由到 /adminapi/test/response/*
|
||||
});
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1023 B |
Binary file not shown.
|
After Width: | Height: | Size: 303 B |
Reference in New Issue
Block a user