This commit is contained in:
lisida 2019-02-14 17:41:52 +08:00
parent c27fac903f
commit e9ba9fae73
2 changed files with 19 additions and 1 deletions

View File

@ -4,6 +4,7 @@ namespace JsonRpc\Server;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\View\Factory; use Illuminate\View\Factory;
use itxq\apidoc\BootstrapApiDoc;
use JsonRpc\Exception\RpcServerException; use JsonRpc\Exception\RpcServerException;
use Monolog\Logger; use Monolog\Logger;
@ -50,8 +51,21 @@ class JsonRpcTool
); );
} }
} }
$methods = [];
foreach ($this->config['map'] as $key => $item) {
if (!in_array($item[0], $methods)) {
$methods[] = $item[0];
}
}
$config = [
'class' => $methods,
'filter_method' => [],
];
$api = new BootstrapApiDoc($config);
$data = $api->getApiDocTmp();
$methods = $this->getMethods(); $methods = $this->getMethods();
$view->share('method', $method); $view->share('data',json_encode($data));
$view->share('endpoint', $this->getEndpoint()); $view->share('endpoint', $this->getEndpoint());
$view->share('methods', $methods); $view->share('methods', $methods);
$view->share('params', json_encode($params, JSON_PRETTY_PRINT)); $view->share('params', json_encode($params, JSON_PRETTY_PRINT));

View File

@ -102,5 +102,9 @@
<script src="https://cdn.bootcss.com/highlight.js/9.13.1/highlight.min.js"></script> <script src="https://cdn.bootcss.com/highlight.js/9.13.1/highlight.min.js"></script>
<script src="https://cdn.bootcss.com/highlight.js/9.13.1/languages/json.min.js"></script> <script src="https://cdn.bootcss.com/highlight.js/9.13.1/languages/json.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script> <script>hljs.initHighlightingOnLoad();</script>
<script>
var data = <?php echo $data; ?>;
console.log(data)
</script>
</body> </body>
</html> </html>