webman/config/plugin/hg/apidoc/app.php

102 lines
4.1 KiB
PHP
Raw Normal View History

2025-02-15 12:13:10 +08:00
<?php
return [
'enable' => true,
'apidoc' => [
// (选配)文档标题,显示在左上角与首页
'title' => 'Apidoc',
// (选配)文档描述,显示在首页
'desc' => '',
// (必须)设置文档的应用/版本
'apps' => [
[
// (必须)标题
2025-02-19 20:42:25 +08:00
'title' => 'Api接口',
2025-02-15 12:13:10 +08:00
// (必须)控制器目录地址
2025-02-19 20:42:25 +08:00
'path' => 'app\controller',
2025-02-15 12:13:10 +08:00
// 必须唯一的key
2025-02-19 20:42:25 +08:00
'key' => 'api',
'groups' => [
['title' => '基础模块', 'name' => 'base'],
['title' => '管理员', 'name' => 'admin']
]
2025-02-15 12:13:10 +08:00
]
],
// (必须)指定通用注释定义的文件地址
'definitions' => "app\common\controller\Definitions",
// 必须自动生成url规则当接口不添加@Apidoc\Url ("xxx")注解时,使用以下规则自动生成
'auto_url' => [
// 字母规则lcfirst=首字母小写ucfirst=首字母大写;
'letter_rule' => "lcfirst",
// url前缀
2025-02-19 20:42:25 +08:00
'prefix' => "",
2025-02-15 12:13:10 +08:00
],
// (选配)是否自动注册路由
2025-02-19 20:42:25 +08:00
'auto_register_routes' => false,
2025-02-15 12:13:10 +08:00
// (必须)缓存配置
'cache' => [
// 是否开启缓存
'enable' => false,
],
// (必须)权限认证配置
'auth' => [
// 是否启用密码验证
'enable' => false,
// 全局访问密码
'password' => "123456",
// 密码加密盐
'secret_key' => "apidoc#hg_code",
// 授权访问后的有效期
2025-02-19 20:42:25 +08:00
'expire' => 24 * 60 * 60
2025-02-15 12:13:10 +08:00
],
// 全局参数
2025-02-19 20:42:25 +08:00
'params' => [
2025-02-15 12:13:10 +08:00
// 选配全局的请求Header
2025-02-19 20:42:25 +08:00
'header' => [
2025-02-15 12:13:10 +08:00
// name=字段名type=字段类型require=是否必须default=默认值desc=字段描述
2025-02-19 20:42:25 +08:00
['name' => 'Authorization', 'type' => 'string', 'require' => true, 'desc' => '身份令牌Token'],
2025-02-15 12:13:10 +08:00
],
// 选配全局的请求Query
2025-02-19 20:42:25 +08:00
'query' => [
2025-02-15 12:13:10 +08:00
// 同上 header
],
// 选配全局的请求Body
2025-02-19 20:42:25 +08:00
'body' => [
2025-02-15 12:13:10 +08:00
// 同上 header
],
],
// 全局响应体
2025-02-19 20:42:25 +08:00
'responses' => [
2025-02-15 12:13:10 +08:00
// 成功响应体
2025-02-19 20:42:25 +08:00
'success' => [
['name' => 'code', 'desc' => '业务代码', 'type' => 'int', 'require' => 1],
['name' => 'message', 'desc' => '业务信息', 'type' => 'string', 'require' => 1],
2025-02-15 12:13:10 +08:00
//参数同上 headersmain=true来指定接口Returned参数挂载节点
2025-02-19 20:42:25 +08:00
['name' => 'data', 'desc' => '业务数据', 'main' => true, 'type' => 'object', 'require' => 1],
2025-02-15 12:13:10 +08:00
],
// 异常响应体
2025-02-19 20:42:25 +08:00
'error' => [
['name' => 'code', 'desc' => '业务代码', 'type' => 'int', 'require' => 1, 'md' => '/docs/HttpError.md'],
['name' => 'message', 'desc' => '业务信息', 'type' => 'string', 'require' => 1],
2025-02-15 12:13:10 +08:00
]
],
//(选配)默认作者
2025-02-19 20:42:25 +08:00
'default_author' => '',
2025-02-15 12:13:10 +08:00
//(选配)默认请求类型
2025-02-19 20:42:25 +08:00
'default_method' => 'GET',
2025-02-15 12:13:10 +08:00
//选配Apidoc允许跨域访问
2025-02-19 20:42:25 +08:00
'allowCrossDomain' => false,
2025-02-15 12:13:10 +08:00
/**
* (选配)解析时忽略带@注解的关键词,当注解中存在带@字符并且非Apidoc注解 @key test此时Apidoc页面报类似以下错误时:
* [Semantical Error] The annotation "@key" in method xxx() was never imported. Did you maybe forget to add a "use" statement for this annotation?
*/
2025-02-19 20:42:25 +08:00
'ignored_annitation' => [],
2025-02-15 12:13:10 +08:00
// (选配)数据库配置
2025-02-19 20:42:25 +08:00
'database' => [],
2025-02-15 12:13:10 +08:00
// 选配Markdown文档
'docs' => [],
// (选配)接口生成器配置 注意:是一个二维数组
2025-02-19 20:42:25 +08:00
'generator' => []
2025-02-15 12:13:10 +08:00
]
2025-02-19 20:42:25 +08:00
];