hgthecode / apidoc-php Goto Github PK
View Code? Open in Web Editor NEW基于PHP的注解生成API文档,兼容Laravel、ThinkPHP、Hyperf、Webman等框架;在线调试、Markdown文档、多应用/多版本、Mock数据、授权访问、接口生成器、代码生成器等众多实用功能,快来体验吧!
Home Page: https://docs.apidoc.icu
License: MIT License
基于PHP的注解生成API文档,兼容Laravel、ThinkPHP、Hyperf、Webman等框架;在线调试、Markdown文档、多应用/多版本、Mock数据、授权访问、接口生成器、代码生成器等众多实用功能,快来体验吧!
Home Page: https://docs.apidoc.icu
License: MIT License
Fatal error: Cannot override final method Doctrine\Common\Annotations\Annotation::__construct() in \vendor\hg\apidoc\src\annotation\Field.php on line 20
访问/apidoc页面空白,F12发现加载的资源文件都没有apidoc前缀,需要配置什么吗
在TP6的config/apidoc.php文件配置了数据库的选配信息,但是并没有生效,实际用的还是config/database.php的内容
另外模板语法麻烦加上ucfirst的支持,不想直接改vendor的代码
Next Illuminate\Database\QueryException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'call' at line 1 (SQL: SHOW FULL COLUMNS FROM call) in D:\www\xzzh\xzzh_manages\vendor\illuminate\database\Connection.php:712
Stack trace:
#0 D:\www\xzzh\xzzh_manages\vendor\illuminate\database\Connection.php(672): Illuminate\Database\Connection->runQueryCallback('SHOW FULL COLUM...', Array, Object(Closure))
#1 D:\www\xzzh\xzzh_manages\vendor\illuminate\database\Connection.php(376): Illuminate\Database\Connection->run('SHOW FULL COLUM...', Array, Object(Closure))
#2 D:\www\xzzh\xzzh_manages\vendor\illuminate\database\Capsule\Manager.php(200): Illuminate\Database\Connection->select('SHOW FULL COLUM...')
#3 D:\www\xzzh\xzzh_manages\vendor\hg\apidoc\src\middleware\WebmanMiddleware.php(46): Illuminate\Database\Capsule\Manager::__callStatic('select', Array)
#4 D:\www\xzzh\xzzh_manages\vendor\hg\apidoc\src\providers\BaseService.php(111): hg\apidoc\middleware\WebmanMiddleware::databaseQuery('SHOW FULL COLUM...')
#5 D:\www\xzzh\xzzh_manages\vendor\hg\apidoc\src\parses\ParseModel.php(196): hg\apidoc\middleware\WebmanMiddleware->hg\apidoc\providers{closure}('SHOW FULL COLUM...')
#6 D:\www\xzzh\xzzh_manages\vendor\hg\apidoc\src\parses\ParseModel.php(69): hg\apidoc\parses\ParseModel::getTableDocument(Object(app\common\model\Call), Array)
#7 D:\www\xzzh\xzzh_manages\vendor\hg\apidoc\src\parses\ParseModel.php(37): hg\apidoc\parses\ParseModel::parseModelTable(Object(app\common\model\Call), 'app\common\mode...', '')
#8 D:\www\xzzh\xzzh_manages\vendor\hg\apidoc\src\parses\ParseApiDetail.php(452): hg\apidoc\parses\ParseModel->renderModel('app\common\mode...')
#9 D:\www\xzzh\xzzh_manages\vendor\hg\apidoc\src\parses\ParseApiDetail.php(747): hg\apidoc\parses\ParseApiDetail->renderRef('app\common\mode...', true)
#10 D:\www\xzzh\xzzh_manages\vendor\hg\apidoc\src\parses\ParseApiDetail.php(597): hg\apidoc\parses\ParseApiDetail->handleParamAndReturned(Array, Object(hg\apidoc\annotation\Returned), 'returned', true, 'controller')
#11 D:\www\xzzh\xzzh_manages\vendor\hg\apidoc\src\parses\ParseApiDetail.php(254): hg\apidoc\parses\ParseApiDetail->parseAnnotation(Object(ReflectionMethod), true, 'controller')
#12 D:\www\xzzh\xzzh_manages\vendor\hg\apidoc\src\parses\ParseApiDetail.php(84): hg\apidoc\parses\ParseApiDetail->parseApiMethod(Object(ReflectionClass), Object(ReflectionMethod))
#13 D:\www\xzzh\xzzh_manages\vendor\hg\apidoc\src\Controller.php(158): hg\apidoc\parses\ParseApiDetail->renderApiDetail('api', 'app\api\v3\cont...', 'lists')
#14 D:\www\xzzh\xzzh_manages\vendor\workerman\webman-framework\src\App.php(304): hg\apidoc\Controller->getApiDetail(Object(support\Request))
#15 D:\www\xzzh\xzzh_manages\vendor\hg\apidoc\src\middleware\WebmanMiddleware.php(25): Webman\App::Webman{closure}(Object(support\Request))
#16 D:\www\xzzh\xzzh_manages\vendor\workerman\webman-framework\src\App.php(299): hg\apidoc\middleware\WebmanMiddleware->process(Object(support\Request), Object(Closure))
#17 D:\www\xzzh\xzzh_manages\vendor\webman\log\src\Middleware.php(58): Webman\App::Webman{closure}(Object(support\Request))
#18 D:\www\xzzh\xzzh_manages\vendor\workerman\webman-framework\src\App.php(299): Webman\Log\Middleware->process(Object(support\Request), Object(Closure))
#19 D:\www\xzzh\xzzh_manages\vendor\webman\cors\src\CORS.php(12): Webman\App::Webman{closure}(Object(support\Request))
#20 D:\www\xzzh\xzzh_manages\vendor\workerman\webman-framework\src\App.php(299): Webman\Cors\CORS->process(Object(support\Request), Object(Closure))
#21 D:\www\xzzh\xzzh_manages\app\common\middleware\AccessControl.php(32): Webman\App::Webman{closure}(Object(support\Request))
#22 D:\www\xzzh\xzzh_manages\vendor\workerman\webman-framework\src\App.php(299): app\common\middleware\AccessControl->process(Object(support\Request), Object(Closure))
#23 D:\www\xzzh\xzzh_manages\app\common\middleware\ApiDocServiceProvider.php(39): Webman\App::Webman{closure}(Object(support\Request))
#24 D:\www\xzzh\xzzh_manages\vendor\workerman\webman-framework\src\App.php(299): app\common\middleware\ApiDocServiceProvider->process(Object(support\Request), Object(Closure))
#25 D:\www\xzzh\xzzh_manages\vendor\workerman\webman-framework\src\App.php(515): Webman\App::Webman{closure}(Object(support\Request))
#26 D:\www\xzzh\xzzh_manages\vendor\workerman\webman-framework\src\App.php(128): Webman\App::findRoute(Object(Workerman\Connection\TcpConnection), '/apidoc/apiDeta...', 'POST/apidoc/api...', Object(support\Request))
#27 D:\www\xzzh\xzzh_manages\vendor\workerman\workerman\Connection\TcpConnection.php(638): Webman\App->onMessage(Object(Workerman\Connection\TcpConnection), Object(support\Request))
#28 D:\www\xzzh\xzzh_manages\vendor\workerman\workerman\Events\Select.php(311): Workerman\Connection\TcpConnection->baseRead(Resource id #320)
#29 D:\www\xzzh\xzzh_manages\vendor\workerman\workerman\Worker.php(2457): Workerman\Events\Select->loop()
#30 D:\www\xzzh\xzzh_manages\vendor\workerman\workerman\Worker.php(1443): Workerman\Worker->run()
#31 D:\www\xzzh\xzzh_manages\vendor\workerman\workerman\Worker.php(1386): Workerman\Worker::forkWorkersForWindows()
#32 D:\www\xzzh\xzzh_manages\vendor\workerman\workerman\Worker.php(559): Workerman\Worker::forkWorkers()
#33 D:\www\xzzh\xzzh_manages\vendor\workerman\webman-framework\src\support\App.php(124): Workerman\Worker::runAll()
#34 D:\www\xzzh\xzzh_manages\start.php(4): support\App::run()
#35 {main}
src/Controller.php
第:230行-234行
$pathArr = explode("@", urldecode($item['menuKey']));
$classPath = $pathArr[0];
$method = $pathArr[1];
$apiDetail = (new ParseApiDetail($config))->renderApiDetail($appKey,$classPath,$method);
应改为:
$apiDetail = (new ParseApiDetail($config))->renderApiDetail($appKey,urldecode($item['menuKey']));
// (选配)接口分享功能
'share'=>[
// 是否开启接口分享功能
'enable'=>true,
// (选配)自定义接口分享操作,每个配置为一个按钮操作
'actions'=>[
[
// 操作名称
'name'=>'下载json',
// 点击时触发的方法
'click'=>function($shareData,$apiData){
// 这里面自定义实现你要的功能,此处仅简单的保存一个json文件并下载
$path = "test.json";
$jsonFile = fopen(public_path().$path, "w") or die("Unable to open file!");
$txt = json_encode($apiData);
fwrite($jsonFile, $txt);
fclose($jsonFile);
// 返回js给前端执行,内置了downloadFile方法来执行文件下载
return 'downloadFile("/'.$path.'","'.$shareData['name'].'");';
}
]
]
],
开启后控制写法
<?php
namespace app\controller;
class UserController
{
public function login()
{
return 'login';
}
}
'responses' => [
// 成功响应体
'success' => [
['name' => 'code', 'desc' => '业务代码', 'type' => 'int', 'require' => 1],
['name' => 'message', 'desc' => '业务信息', 'type' => 'string', 'require' => 1],
//参数同上 headers;main=true来指定接口Returned参数挂载节点
['name' => 'data', 'desc' => '业务数据', 'main' => true, 'type' => 'object', 'require' => 1],
],
Apidoc\Returned这个name参数可以不填,反正要table直接放在data上,而不是data.data来获取到table
#[
Apidoc\Title("详情"),
Apidoc\Method("GET"),
Apidoc\Tag("已完成"),
Apidoc\Param(name: "id", type: "integer", require: true, default: "", desc: "详情id"),
Apidoc\Returned("",type:"array",table:"line_material",desc:"详情", replaceGlobal: true),
]
如题,建议可以弄一个参数缓存,方便刷新页面后填写的参数还在
浏览器标题能否做成配置项?
一直在使用yapi,但越发觉得很多局限性,一直想参考swagger做个便捷的文档系统(好像Java的knife),作者实现了,支持
求教 laravel 10如何不降级doctrine安装APIDOC
只支持本地接口的URL吗?
可以增加远程URL接口支持吗?
如果开启了thinkphp的 配置:
配置说明
// 开启控制器后缀
'controller_suffix' => true,
对应文件 /app/api/controller/IndexController 自动适配的地址就变成了 /api/indexController
而不是 /api/index
所以希望可以通过实时读取配置,或者在配置文件中主动配置的方式来兼容这种后缀模式。
replaceGlobal 不生效,文档及演示站点也是这样,并未生效
我是直接粘贴的手册中的配置
// (选配)接口分享功能
'share'=>[
// 是否开启接口分享功能
'enable'=>true,
// (选配)自定义接口分享操作,每个配置为一个按钮操作
'actions'=>[
[
// 操作名称
'name'=>'下载json',
// 点击时触发的方法
'click'=>function($shareData,$apiData){
// 这里面自定义实现你要的功能,此处仅简单的保存一个json文件并下载
$path = "test.json";
$jsonFile = fopen(public_path().$path, "w") or die("Unable to open file!");
$txt = json_encode($apiData);
fwrite($jsonFile, $txt);
fclose($jsonFile);
// 返回js给前端执行,内置了downloadFile方法来执行文件下载
return 'downloadFile("/'.$path.'","'.$shareData['name'].'");';
}
]
]
],
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.