Thinkphp apidoc 最近项目配置 mark一下子

生活 · 2022-07-08

最近项目最新配置 mark一下子
官网地址

<?php
return [
    // 文档标题
    'title'              => 'API接口文档',
    // 文档描述
    'desc'               => '',
    // 版权申明
    'copyright'          => 'Powered By hg-code',
    // 默认作者
    'default_author'=>'',
    // 默认请求类型
    'default_method'=>'GET',
    // 设置应用/版本(必须设置)
    'apps'           => [
        [
            'title' => 'admin',
            'path' => 'app\admin\controller',
            'folder' => 'admin',
            'groups'             => [
                ['title'=>'基础模块','name'=>'admin'],
                ['title'=>'业务模块','name'=>'business'],
            ],

        ]
    ],
    // 控制器分组
    'groups'             => [
        ['title' => 'admin', 'name' => 'admin'],
        ['title' => 'index', 'name' => 'index'],
    ],
    // 指定公共注释定义的文件地址
    'definitions'        => "app\common\controller\ApiDocDefinitions",
    //指定生成文档的控制器
    'controllers'        => [
    ],
    // 过滤,不解析的控制器
    'filter_controllers' => [
        // 'app\admin\controller\SettingWechat',
    ],
    // 缓存配置
    'cache'              => [
        // 是否开启缓存
        'enable' => false,
        // 缓存文件路径
        'path'   =>  '../runtime/apidoc/',
        // 是否显示更新缓存按钮
        'reload' => true,
        // 最大缓存文件数
        'max'    => 5,  //最大缓存数量
    ],
    // 权限认证配置
    'auth'               => [
        // 是否启用密码验证
        'enable'     => false,
        // 验证密码
        'password'   => "123456",
        // 密码加密盐
        'secret_key' => "apidoc#hg_code",
        'expire' => 24*60*60,
    ],
    // 统一的请求Header
    'headers'=>[],
    // 统一的请求参数Parameters
    'parameters'=>[],
    // 统一的请求响应体,仅显示在文档提示中
    'responses'=>[
        // ['name'=>'code','desc'=>'状态码','type'=>'int'],
        // ['name'=>'message','desc'=>'操作描述','type'=>'string'],
        // ['name'=>'data','desc'=>'业务数据','main'=>true,'type'=>'object'],
    ],
    // md文档
    'docs'              => [],
    'curd'=>[
        // 生成控制器配置
        'controller' => [
            'path' => 'app\${app[0].folder}\controller',
            'template' => '../private/apidoc/controller',
            'file_name' => '${controller.class_name}',
        ],

        // 生成验证器配置
        'validate' => [
            'path' => 'app\common\validate',
            'template' => '../private/apidoc/validate',
            'file_name' => '${validate.class_name}Validate',
            'rules' => [
                ['name' => '必填', 'rule' => 'require', 'message' => '${field} must'],
                ['name' => '1是0否', 'rule' => 'require|in:0,1', 'message' => ['${field}.require' => '${field} must', '${field}.in' => '${field} 1是0否']]
            ]
        ],

        // 生成业务逻辑配置
        'service' => [
            'path' => 'app\common\service',
            'template' => '../private/apidoc/service',
            'file_name' => '${service.class_name}Service',
        ],

        // 生成缓存配置
        'cache' => [
            'path' => 'app\common\cache',
            'template' => '../private/apidoc/cache',
            'file_name' => '${cache.class_name}Cache',
        ],

        // 生成模型配置
        'model' => [
            'path' => 'app\common\model',
            'template' => '../private/apidoc/model',
            'file_name' => '${model.class_name}Model',
            'default_fields' => [
                [
                    'field' => 'id',
                    'desc' => 'id',
                    'type' => 'int',
                    'length' => 11,
                    'default' => '',
                    'not_null' => true,
                    'main_key' => true,
                    'incremental' => true,
                    'validate' => '',
                    'query' => false,
                    'where' => '=',
                    'list' => true,
                    'detail' => true,
                    'add' => false,
                    'edit' => true,
                    'delete' => true
                ],
                [
                    'field' => 'is_delete',
                    'desc' => '是否删除1是0否',
                    'type' => 'tinyint',
                    'length' => 1,
                    'default' => 0,
                    'not_null' => false,
                    'main_key' => false,
                    'incremental' => false,
                    'validate' => '',
                    'query' => false,
                    'where' => '=',
                    'list' => false,
                    'detail' => false,
                    'add' => false,
                    'edit' => false,
                    'delete' => false
                ],
                [
                    'field' => 'create_time',
                    'desc' => '添加时间',
                    'type' => 'int', // 'datetime'
                    'length' => 11, // 0
                    'default' => 0, // NULL
                    'not_null' => false,
                    'main_key' => false,
                    'incremental' => false,
                    'validate' => '',
                    'query' => false,
                    'where' => '=',
                    'list' => true,
                    'detail' => true,
                    'add' => false,
                    'edit' => true,
                    'delete' => false
                ],
                [
                    'field' => 'update_time',
                    'desc' => '修改时间',
                    'type' => 'int',
                    'length' => 11,
                    'default' => 0,
                    'not_null' => false,
                    'main_key' => false,
                    'incremental' => false,
                    'validate' => '',
                    'query' => false,
                    'where' => '=',
                    'list' => true,
                    'detail' => true,
                    'add' => false,
                    'edit' => true,
                    'delete' => false
                ],
                [
                    'field' => 'delete_time',
                    'desc' => '删除时间',
                    'type' => 'int',
                    'length' => 11,
                    'default' => 0,
                    'not_null' => false,
                    'main_key' => false,
                    'incremental' => false,
                    'validate' => '',
                    'query' => false,
                    'where' => '=',
                    'list' => false,
                    'detail' => false,
                    'add' => false,
                    'edit' => false,
                    'delete' => false
                ],
                [
                    'field' => 'is_disable',
                    'desc' => '是否禁用',
                    'type' => 'tinyint',
                    'length' => 1,
                    'default' => 0,
                    'not_null' => false,
                    'main_key' => false,
                    'incremental' => false,
                    'validate' => '',
                    'query' => false,
                    'where' => '=',
                    'list' => false,
                    'detail' => false,
                    'add' => false,
                    'edit' => false,
                    'delete' => false
                ],
                [
                    'field' => 'sort',
                    'desc' => '排序',
                    'type' => 'int',
                    'length' => 11,
                    'default' => 999,
                    'not_null' => false,
                    'main_key' => false,
                    'incremental' => false,
                    'validate' => '',
                    'query' => false,
                    'where' => '=',
                    'list' => false,
                    'detail' => false,
                    'add' => false,
                    'edit' => false,
                    'delete' => false
                ],
                [
                    'field' => 'title',
                    'desc' => '标题',
                    'type' => 'varchar',
                    'length' => 255,
                    'default' => '',
                    'not_null' => true,
                    'main_key' => false,
                    'incremental' => false,
                    'validate' => '',
                    'query' => false,
                    'where' => 'LIKE',
                    'list' => true,
                    'detail' => true,
                    'add' => true,
                    'edit' => true,
                    'delete' => false
                ],
                [
                    'field' => 'creator_id',
                    'desc' => '创建人',
                    'type' => 'int',
                    'length' => 11,
                    'default' => 0,
                    'not_null' => false,
                    'main_key' => false,
                    'incremental' => false,
                    'validate' => '',
                    'query' => false,
                    'where' => '=',
                    'list' => false,
                    'detail' => false,
                    'add' => false,
                    'edit' => false,
                    'delete' => false
                ],
            ],
            'fields_types' => [
                'int',
                'varchar',
                'datetime',
                'tinyint',
                'char',
                'text',
                'float',
                'decimal',
            ],
            'fields_wheres' => [
                'LIKE',
                '=',
                'IN',
                'EXP',
            ]
        ]
    ]

];
php thinkphp apidoc apidoc配置
Theme Jasmine by Kent Liao